Skip to content

Commit e03eee0

Browse files
committed
Update debugger tab and messages for enhanced system management and relationship handling
1 parent 4ddf147 commit e03eee0

File tree

6 files changed

+392
-41
lines changed

6 files changed

+392
-41
lines changed

‎addons/gecs/debug/gecs_editor_debugger.gd‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ extends EditorDebuggerPlugin
44
## The Debugger session for the current game
55
var session: EditorDebuggerSession
66
## The tab that will be added to the debugger window
7-
var debugger_tab = (
8-
preload("res://addons/gecs/debug/gecs_editor_debugger_tab.tscn").instantiate()
9-
as GECSEditorDebuggerTab
10-
)
7+
var debugger_tab: GECSEditorDebuggerTab = preload("res://addons/gecs/debug/gecs_editor_debugger_tab.tscn").instantiate()
8+
119
## The debugger messages that will be sent to the editor debugger
12-
var Msg = GECSEditorDebuggerMessages.Msg
10+
var Msg := GECSEditorDebuggerMessages.Msg
1311
## Reference to editor interface for selecting nodes
1412
var editor_interface: EditorInterface = null
1513

@@ -89,8 +87,8 @@ func _capture(message: String, data: Array, session_id: int) -> bool:
8987
debugger_tab.entity_component_removed(data[0], data[1])
9088
return true
9189
elif message == Msg.ENTITY_RELATIONSHIP_ADDED:
92-
# data: [Entity, Relationship]
93-
debugger_tab.entity_relationship_added(data[0], data[1])
90+
# data: [ent_id, rel_id, rel_data]
91+
debugger_tab.entity_relationship_added(data[0], data[1], data[2])
9492
return true
9593
elif message == Msg.ENTITY_RELATIONSHIP_REMOVED:
9694
# data: [Entity, Relationship]

‎addons/gecs/debug/gecs_editor_debugger_messages.gd‎

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ static func can_send_message() -> bool:
3131

3232
static func world_init(world: World) -> bool:
3333
if can_send_message():
34-
EngineDebugger.send_message(Msg.WORLD_INIT, [world.get_instance_id(), world.get_path()])
34+
EngineDebugger.send_message(Msg.WORLD_INIT,[world.get_instance_id(),
35+
world.get_path()
36+
])
3537
return true
3638

3739
static func system_metric(system: System, time: float) -> bool:
3840
if can_send_message():
3941
EngineDebugger.send_message(
40-
Msg.SYSTEM_METRIC, [system.get_instance_id(), system.name, time]
42+
Msg.SYSTEM_METRIC,[system.get_instance_id(),
43+
system.name,
44+
time
45+
]
4146
)
4247
return true
4348

@@ -57,7 +62,10 @@ static func system_last_run_data(system: System, last_run_data: Dictionary) -> b
5762
static func set_world(world: World) -> bool:
5863
if can_send_message():
5964
EngineDebugger.send_message(
60-
Msg.SET_WORLD, [world.get_instance_id(), world.get_path()] if world else []
65+
Msg.SET_WORLD,[world.get_instance_id(),
66+
world.get_path()
67+
] if world else[
68+
]
6169
)
6270
return true
6371

@@ -118,7 +126,13 @@ static func _get_type_name_for_debugger(obj) -> String:
118126
if obj is Resource or obj is Node:
119127
var script = obj.get_script()
120128
if script:
121-
return script.get_class()
129+
# Try to get class_name first
130+
var type_name = script.get_class()
131+
if type_name and type_name != "GDScript":
132+
return type_name
133+
# Otherwise use the resource path (e.g., "res://components/C_Health.gd")
134+
if script.resource_path:
135+
return script.resource_path # Returns "C_Health"
122136
return obj.get_class()
123137
elif obj is Object:
124138
return obj.get_class()
@@ -141,7 +155,9 @@ static func entity_component_added(ent: Entity, comp: Resource) -> bool:
141155
static func entity_component_removed(ent: Entity, comp: Resource) -> bool:
142156
if can_send_message():
143157
EngineDebugger.send_message(
144-
Msg.ENTITY_COMPONENT_REMOVED, [ent.get_instance_id(), comp.get_instance_id()]
158+
Msg.ENTITY_COMPONENT_REMOVED,[ent.get_instance_id(),
159+
comp.get_instance_id()
160+
]
145161
)
146162
return true
147163

@@ -151,20 +167,60 @@ static func entity_component_property_changed(
151167
if can_send_message():
152168
EngineDebugger.send_message(
153169
Msg.COMPONENT_PROPERTY_CHANGED,
154-
[ent.get_instance_id(), comp.get_instance_id(), property_name, old_value, new_value]
170+
[ent.get_instance_id(),
171+
comp.get_instance_id(),
172+
property_name,
173+
old_value,
174+
new_value
175+
]
155176
)
156177
return true
157178

158179
static func entity_relationship_added(ent: Entity, rel: Relationship) -> bool:
159180
if can_send_message():
181+
# Serialize relationship data for debugger display
182+
var rel_data = {
183+
"relation_type": _get_type_name_for_debugger(rel.relation) if rel.relation else "null",
184+
"relation_data": rel.relation.serialize() if rel.relation else {},
185+
"target_type": "",
186+
"target_data": {}
187+
}
188+
189+
# Format target based on type
190+
if rel.target == null:
191+
rel_data["target_type"] = "null"
192+
elif rel.target is Entity:
193+
rel_data["target_type"] = "Entity"
194+
rel_data["target_data"] = {
195+
"id": rel.target.get_instance_id(),
196+
"path": str(rel.target.get_path())
197+
}
198+
elif rel.target is Component:
199+
rel_data["target_type"] = "Component"
200+
rel_data["target_data"] = {
201+
"type": _get_type_name_for_debugger(rel.target),
202+
"data": rel.target.serialize()
203+
}
204+
elif rel.target is Script:
205+
rel_data["target_type"] = "Archetype"
206+
rel_data["target_data"] = {
207+
"script_path": rel.target.resource_path
208+
}
209+
160210
EngineDebugger.send_message(
161-
Msg.ENTITY_RELATIONSHIP_ADDED, [ent.get_instance_id(), rel.get_instance_id()]
211+
Msg.ENTITY_RELATIONSHIP_ADDED,
212+
[ent.get_instance_id(),
213+
rel.get_instance_id(),
214+
rel_data
215+
]
162216
)
163217
return true
164218

165219
static func entity_relationship_removed(ent: Entity, rel: Relationship) -> bool:
166220
if can_send_message():
167221
EngineDebugger.send_message(
168-
Msg.ENTITY_RELATIONSHIP_REMOVED, [ent.get_instance_id(), rel.get_instance_id()]
222+
Msg.ENTITY_RELATIONSHIP_REMOVED,[ent.get_instance_id(),
223+
rel.get_instance_id()
224+
]
169225
)
170226
return true

0 commit comments

Comments
 (0)