Test for calling method of Node.

This commit is contained in:
gdz
2025-08-26 18:22:25 +02:00
parent 50cea7f096
commit ffaee18654
3 changed files with 27 additions and 127 deletions

View File

@@ -1,10 +0,0 @@
<component name="libraryTable">
<library name="GdSdk Master" type="GdScript">
<properties path="$USER_HOME$/.cache/JetBrains/Rider2025.1/projects/.idea.ecosystem.daf914ba/sdk/GdSdk Master" version="Master" date="2024-06-01T15:14:16.000+02:00" />
<CLASSES />
<JAVADOC />
<SOURCES>
<root url="file://$USER_HOME$/.cache/JetBrains/Rider2025.1/projects/.idea.ecosystem.daf914ba/sdk/GdSdk Master" />
</SOURCES>
</library>
</component>

View File

@@ -13,15 +13,18 @@ public partial class Main : Node
screenSize = GetViewport().GetVisibleRect().Size; screenSize = GetViewport().GetVisibleRect().Size;
camera = GetNode<Camera2D>("GlobalCamera"); camera = GetNode<Camera2D>("GlobalCamera");
spawner = GetNode("World/Spawner"); spawner = GetNode("World/Spawner");
Node2D grid = GetNode<Node2D>("World/Grid");
GetNode<Node2D>("Grid").Call("generateGrid");
camera.Position = new Vector2(screenSize.X / 2, screenSize.Y / 2); camera.Position = new Vector2(screenSize.X / 2, screenSize.Y / 2);
var flyPosition = camera.Position; var flyPosition = camera.Position;
spawner.Call("spawn_fly", flyPosition); spawner.Call("spawn_fly", flyPosition);
Node2D fly = (Node2D)spawner.GetChild(0);
GD.Print(grid.Call("worldToGrid", fly.Position));
GetNode<MarginContainer>("HUD").Call("buildInfoPanel", (Node)fly);
GetNode<MarginContainer>("HUD").Call("ShowInfoPanel");
} }
} }

View File

@@ -1,34 +1,26 @@
[gd_scene load_steps=8 format=3 uid="uid://bkw0abirq18mt"] [gd_scene load_steps=7 format=3 uid="uid://bkw0abirq18mt"]
[ext_resource type="Script" uid="uid://dte8xibis5wf7" path="res://scenes/main/Main.cs" id="1_6q06x"] [ext_resource type="Script" uid="uid://dte8xibis5wf7" path="res://scenes/main/Main.cs" id="1_6q06x"]
[ext_resource type="PackedScene" uid="uid://brbhyuelsuxyx" path="res://scenes/world/world.tscn" id="1_o5qli"] [ext_resource type="PackedScene" uid="uid://brbhyuelsuxyx" path="res://scenes/world/world.tscn" id="1_o5qli"]
[ext_resource type="Script" uid="uid://cqrt5x30j5vm6" path="res://scenes/main/grid.gd" id="3_hujxm"]
[ext_resource type="Script" uid="uid://csmrhb44u00j" path="res://scenes/main/GobalCamera.cs" id="3_ow5a4"] [ext_resource type="Script" uid="uid://csmrhb44u00j" path="res://scenes/main/GobalCamera.cs" id="3_ow5a4"]
[ext_resource type="Script" uid="uid://8vkyddmxqfaf" path="res://scenes/HUD/menu_bar.gd" id="4_tbgi4"] [ext_resource type="PackedScene" uid="uid://djgeio24bm6i4" path="res://scenes/HUD/hud.tscn" id="4_ow5a4"]
[ext_resource type="Script" uid="uid://cmoqidhmxlccq" path="res://scenes/HUD/options_menu.gd" id="5_tefeu"] [ext_resource type="Script" uid="uid://cm0m3up5ufny2" path="res://scenes/HUD/information_panel.gd" id="5_hujxm"]
[ext_resource type="Script" uid="uid://dskaddldr1q0x" path="res://scenes/main/EntityManager.cs" id="6_ow5a4"] [ext_resource type="Script" uid="uid://dskaddldr1q0x" path="res://scenes/main/EntityManager.cs" id="6_ow5a4"]
[node name="Main" type="Node"] [node name="Main" type="Node"]
script = ExtResource("1_6q06x") script = ExtResource("1_6q06x")
[node name="World" parent="." instance=ExtResource("1_o5qli")] [node name="World" parent="." instance=ExtResource("1_o5qli")]
NoiseSeed = 5 Algorithm = 2
NoiseFrequency = 0.32 NoiseType = 3
NoiseOffset = Vector3(0.04, 0, 0) NoiseSeed = 521632
NoiseFrequency = 0.03
NoiseFractalType = 2 NoiseFractalType = 2
NoiseFractalOctaves = 10
NoiseFractalLacunarity = 0.395
NoiseFractalGain = 0.26
NoiseFractalWeightedStrength = 0.355
[node name="Spawner" parent="World" index="1"] [node name="Grid" parent="World" index="3"]
position = Vector2(482.81, 501.18) show_debug = false
show_grid = false
[node name="Grid" type="Node2D" parent="."] show_label = false
script = ExtResource("3_hujxm")
show_debug = true
[node name="Debug" type="Node2D" parent="Grid"]
[node name="GlobalCamera" type="Camera2D" parent="."] [node name="GlobalCamera" type="Camera2D" parent="."]
drag_left_margin = 0.5 drag_left_margin = 0.5
@@ -36,108 +28,23 @@ drag_top_margin = 0.5
drag_right_margin = 0.5 drag_right_margin = 0.5
drag_bottom_margin = 0.5 drag_bottom_margin = 0.5
script = ExtResource("3_ow5a4") script = ExtResource("3_ow5a4")
cameraStepSize = 200.0
[node name="HUD" type="CanvasLayer" parent="."] [node name="HUD" parent="." instance=ExtResource("4_ow5a4")]
[node name="MenuBar" type="MenuBar" parent="HUD"] [node name="Info" parent="HUD/MenuBar" index="3"]
anchors_preset = 10 item_count = 3
anchor_right = 1.0 item_2/text = "Close"
grow_horizontal = 2 item_2/id = 2
script = ExtResource("4_tbgi4")
[node name="Entity" type="PopupMenu" parent="HUD/MenuBar"] [node name="InformationPanel" parent="HUD" index="4"]
auto_translate_mode = 1 custom_minimum_size = Vector2(100, 0)
size = Vector2i(109, 100) script = ExtResource("5_hujxm")
[node name="Spawn" type="PopupMenu" parent="HUD/MenuBar"]
size = Vector2i(109, 100)
item_count = 2
item_0/text = "Fly"
item_0/id = 0
item_1/text = "Bumblebee"
item_1/id = 1
[node name="Options" type="PopupMenu" parent="HUD/MenuBar"]
item_count = 2
item_0/text = "Camera"
item_0/id = 0
item_1/text = "World"
item_1/id = 1
script = ExtResource("5_tefeu")
[node name="Camera" type="PopupMenu" parent="HUD/MenuBar/Options"]
item_count = 2
item_0/text = "Speed"
item_0/id = 0
item_1/text = "Position"
item_1/id = 1
[node name="World" type="PopupMenu" parent="HUD/MenuBar/Options"]
auto_translate_mode = 1
item_count = 1
item_0/text = "Generate"
item_0/id = 0
[node name="SpawnMenuButton" type="MenuButton" parent="HUD"]
visible = false
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -31.0
offset_right = 60.0
grow_vertical = 0
text = "Spawn"
item_count = 2
popup/item_0/text = "Fly"
popup/item_0/id = 0
popup/item_1/text = "Bumblebee"
popup/item_1/id = 1
[node name="Button" type="Button" parent="HUD"]
visible = false
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -42.5
offset_top = -31.0
offset_right = 42.5
grow_horizontal = 2
grow_vertical = 0
text = "Spawn Fly"
[node name="GenerateWorldButton" type="Button" parent="HUD"]
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -131.0
offset_top = -31.0
grow_horizontal = 0
grow_vertical = 0
text = "Regenerate World"
[node name="InformationMarginContainer" type="MarginContainer" parent="HUD"]
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 0
[node name="HBoxContainer" type="HBoxContainer" parent="HUD/InformationMarginContainer"]
layout_mode = 2
[node name="EntityInformationContainer" type="VBoxContainer" parent="HUD/InformationMarginContainer/HBoxContainer"]
layout_mode = 2
[node name="EntityManager" type="Node" parent="."] [node name="EntityManager" type="Node" parent="."]
script = ExtResource("6_ow5a4") script = ExtResource("6_ow5a4")
[connection signal="index_pressed" from="HUD/MenuBar/Options" to="HUD/MenuBar" method="options_index_pressed"] [connection signal="index_pressed" from="HUD/MenuBar/Info" to="HUD/MenuBar" method="info_index_pressed"]
[connection signal="pressed" from="HUD/Button" to="." method="spawn_fly"]
[connection signal="pressed" from="HUD/GenerateWorldButton" to="World" method="GenerateWorld"]
[editable path="World"] [editable path="World"]
[editable path="HUD"]