blob: 814d2ac81fe16c761d79f12c60d0a737abf4c31c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
using Godot;
using System;
public partial class Details : CanvasLayer
{
private static readonly LabelSettings lblSettings = GD.Load<LabelSettings>("res://assets/definitions/message_label_settings.tres");
private Map map;
private VBoxContainer entityNames;
private Godot.Collections.Array<Entity> entities = [];
private Godot.Collections.Array<Label> actorsLabel = [];
public override void _Ready()
{
base._Ready();
map = GetParent<Map>();
entityNames = GetNode<VBoxContainer>("HBoxContainer/PanelContainer/ScrollContainer/Entities");
SignalBus.Instance.InspectorMoved += OnInspectorWalk;
SignalBus.Instance.EnterInspectionMode += () => Visible = true;
SignalBus.Instance.ExitInspectionMode += () => Visible = false;
}
public void OnInspectorWalk(Vector2I pos) {
MapData mapData = map.Map_Data;
entities = mapData.GetEntitiesAtPosition(pos);
UpdateLabels();
}
private void UpdateLabels() {
foreach(Label label in actorsLabel) {
label.QueueFree();
}
actorsLabel.Clear();
foreach (Entity entity in entities) {
Label label = new()
{
Text = entity.DisplayName,
LabelSettings = lblSettings
};
actorsLabel.Add(label);
entityNames.AddChild(label);
}
}
}
|