Moved robots to separate folders and a dedicated robotlist in the UI

This commit is contained in:
=
2026-04-29 14:08:02 +02:00
parent 17057487d6
commit 832fb47ec0
15 changed files with 176 additions and 47 deletions
+27
View File
@@ -0,0 +1,27 @@
using System.Threading.Tasks;
using Godot;
public partial class Robot : Node3D
{
public ProgramInterpreter interpreter;
public override void _Ready()
{
}
public override void _Process(double delta)
{
}
public void Move()
{
}
public void OnClicked()
{
GetNode<UIHandler>("/root/Main/CanvasLayer/UIHandler").ShowNamingPopup(this);
}
}
+1
View File
@@ -0,0 +1 @@
uid://e0pgy7jya41y
+23
View File
@@ -0,0 +1,23 @@
using Godot;
public partial class RobotDisplay : PanelContainer
{
[Export] public RichTextLabel listItem;
[Signal]
public delegate void OnRobotJumpToEventHandler(Robot robot);
public Robot robot;
public override void _Ready()
{
}
public override void _Process(double delta)
{
}
public void OnJumpToClicked()
{
EmitSignal(SignalName.OnRobotJumpTo, robot);
}
}
+1
View File
@@ -0,0 +1 @@
uid://dcxom1paffp0p
+47
View File
@@ -0,0 +1,47 @@
using Godot;
using System;
public partial class RobotList : PanelContainer
{
[Export] VBoxContainer robotList;
[Signal]
public delegate void OnRobotJumpToEventHandler(Robot robot);
public PackedScene robotDisplayPrefab;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
robotDisplayPrefab = ResourceLoader.LoadRobotDisplay();
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
if (Input.IsActionJustPressed("robot_list"))
{
Visible = !Visible;
if (Visible) ReloadRobots();
}
}
public void ReloadRobots()
{
foreach (Node node in robotList.GetChildren())
{
robotList.RemoveChild(node);
node.QueueFree();
}
RobotDisplay display;
foreach (Robot robotObject in GameData.robots)
{
display = robotDisplayPrefab.Instantiate<RobotDisplay>();
display.robot = robotObject;
display.listItem.Text = robotObject.Name;
display.OnRobotJumpTo += (robot) =>
{
EmitSignal(SignalName.OnRobotJumpTo, robot);
};
robotList.AddChild(display);
}
}
}
+1
View File
@@ -0,0 +1 @@
uid://k6vlo7ulvtep