2019-10-18 17:26:34 -07:00
|
|
|
/**
|
|
|
|
|
* This class manages the developer overlay which displays the state of the first selected entity.
|
|
|
|
|
*/
|
|
|
|
|
class DeveloperOverlayEntityState
|
|
|
|
|
{
|
|
|
|
|
constructor(selection)
|
|
|
|
|
{
|
|
|
|
|
this.developerOverlayEntityState = Engine.GetGUIObjectByName("developerOverlayEntityState");
|
|
|
|
|
this.selection = selection;
|
|
|
|
|
this.updater = this.update.bind(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setEnabled(enabled)
|
|
|
|
|
{
|
|
|
|
|
this.developerOverlayEntityState.hidden = !enabled;
|
|
|
|
|
|
|
|
|
|
if (enabled)
|
|
|
|
|
{
|
|
|
|
|
registerSimulationUpdateHandler(this.updater);
|
|
|
|
|
registerEntitySelectionChangeHandler(this.updater);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unregisterSimulationUpdateHandler(this.updater);
|
|
|
|
|
unregisterEntitySelectionChangeHandler(this.updater);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update()
|
|
|
|
|
{
|
2025-05-10 07:50:42 -07:00
|
|
|
const simState = clone(g_SimState);
|
2019-10-18 17:26:34 -07:00
|
|
|
simState.players = "<<<omitted>>>";
|
|
|
|
|
let text = "simulation: " + uneval(simState);
|
|
|
|
|
|
2025-05-10 07:50:42 -07:00
|
|
|
const selection = this.selection.toList();
|
2019-10-18 17:26:34 -07:00
|
|
|
if (selection.length)
|
|
|
|
|
{
|
2025-05-10 07:50:42 -07:00
|
|
|
const entState = GetEntityState(selection[0]);
|
2019-10-18 17:26:34 -07:00
|
|
|
if (entState)
|
|
|
|
|
{
|
2025-05-10 07:50:42 -07:00
|
|
|
const template = GetTemplateData(entState.template);
|
2019-10-18 17:26:34 -07:00
|
|
|
text += "\n\nentity: {\n";
|
2025-05-10 07:50:42 -07:00
|
|
|
for (const k in entState)
|
2019-10-18 17:26:34 -07:00
|
|
|
text += " " + k + ":" + uneval(entState[k]) + "\n";
|
|
|
|
|
text += "}\n\ntemplate: " + uneval(template);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.developerOverlayEntityState.caption = text.replace(/\[/g, "\\[");
|
|
|
|
|
}
|
|
|
|
|
}
|