3 [
ComponentEditorProps(
category:
"GameScripted/Editor", description:
"Debug editor component. Works only with SCR_EditorBaseEntity!", icon:
"WBData/ComponentEditorProps/componentEditor.png")]
17 private int m_LayerID;
26 private static int m_iFakePlayerIndex = 0;
30 ref set<SCR_EditableEntityComponent> m_LOL =
new set<SCR_EditableEntityComponent>;
33 static string GetFakePlayerName(
int playerID)
35 array<string> debugNames = {
"",
"Hedrik",
"Ton",
"Roach",
"Natasha"};
36 return debugNames[-playerID % debugNames.Count()];
38 static string GetFakePlayerName()
40 return GetFakePlayerName(m_iFakePlayerIndex);
43 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
44 protected void CreateFakePlayerServer()
46 array<SCR_SpawnPoint> spawnPoints =
SCR_SpawnPoint.GetSpawnPointsForFaction(
"USSR");
47 if (!spawnPoints.IsEmpty())
49 ResourceName prefab =
"{DCB41B3746FDD1BE}Prefabs/Characters/OPFOR/USSR_Army/Character_USSR_Rifleman.et";
50 EntitySpawnParams spawnParams =
new EntitySpawnParams();
51 spawnParams.Transform[3] = spawnPoints[0].GetOrigin();
52 IEntity fakePlayer =
GetGame().SpawnEntityPrefab(Resource.Load(prefab),
GetGame().GetWorld(), spawnParams);
54 prefab =
"{69B7035099CEE1FC}Prefabs/AI/Groups/ChimeraGroupNonEditable.et";
55 AIGroup group = AIGroup.Cast(
GetGame().SpawnEntityPrefab(Resource.Load(prefab),
GetGame().GetWorld(), spawnParams));
57 AIControlComponent aiControl = AIControlComponent.Cast(fakePlayer.FindComponent(AIControlComponent));
58 aiControl.ActivateAI();
59 AIAgent agent = aiControl.GetAIAgent();
61 prefab =
"{FFF9518F73279473}PrefabsEditable/Auto/AI/Waypoints/E_AIWaypoint_Move.et";
64 vector cursorWorldPos;
65 cursorComponent.GetCursorWorldPos(cursorWorldPos);
66 spawnParams.Transform[3] = cursorWorldPos;
67 AIWaypoint wp = AIWaypoint.Cast(
GetGame().SpawnEntityPrefab(Resource.Load(prefab),
GetGame().GetWorld(), spawnParams));
69 group.AddAgent(agent);
70 group.AddWaypoint(wp);
76 gameMode.GetOnPlayerSpawned().Invoke(m_iFakePlayerIndex, fakePlayer);
80 protected void PingFakePlayer()
84 pingManager.CallEvents(GetManager(),
true, -1,
false,
false, vector.Zero, m_FakePlayer);
87 override void EOnFrame(IEntity owner,
float timeSlice)
109 if (Debug.KeyState(KeyCode.KC_U))
111 Debug.ClearKey(KeyCode.KC_U);
113 Rpc(CreateFakePlayerServer);
115 if (Debug.KeyState(KeyCode.KC_K))
117 Debug.ClearKey(KeyCode.KC_K);
126 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_ACCESS_KEY_TOGGLE))
128 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_ACCESS_KEY_TOGGLE,
false);
129 SCR_AccessKeysEditorComponent accessKeyComponent = SCR_AccessKeysEditorComponent.Cast(SCR_AccessKeysEditorComponent.GetInstance(SCR_AccessKeysEditorComponent));
130 if (!accessKeyComponent)
return;
134 keysType.GetVariableValue(
null, DiagMenu.GetRangeValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_ACCESS_KEY), keyValue);
135 if (!m_TestComponent.HasAccessSelf(keyValue))
137 accessKeyComponent.AddEntityAccessKey(m_TestComponent, keyValue);
141 accessKeyComponent.RemoveEntityAccessKey(m_TestComponent, keyValue);
143 m_TestComponent.LogAccessKey();
145 bool show = DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_SHOW);
146 if (show != m_TestComponent.GetVisibleSelf())
148 m_TestComponent.SetVisible(show);
150 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_SELECT))
152 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_SELECT,
false);
156 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_FOCUS))
158 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_FOCUS,
false);
159 if (m_FocusedManager) m_FocusedManager.Toggle(m_TestComponent);
282 override void EOnEditorDebug(array<string> debugTexts)
288 string entityName =
"N/A";
291 if (entityUnderCursor) entityName = entityUnderCursor.GetDisplayName();
292 debugTexts.Insert(
"Under Cursor: " + entityName +
" / " + isDelegate.ToString());
296 debugTexts.Insert(
"\nTestEntity: " + m_TestComponent.GetDisplayName());
300 debugTexts.Insert(
"Parent: " + parent.GetDisplayName());
302 debugTexts.Insert(
"Parent: N/A");
305 int enumCount = enumType.GetVariableCount();
306 for (
int i = 0; i < enumCount; i++)
309 if (enumType.GetVariableType(i) ==
int && enumType.GetVariableValue(
null, i, val))
311 debugTexts.Insert(
string.Format(
"%1: %2", enumType.GetVariableName(i), m_TestComponent.HasEntityState(val) > 0));
315 debugTexts.Insert(
"\n");
319 override void EOnEditorPostActivate()
329 override void EOnEditorActivate()
332 m_iFakePlayerIndex = 0;
333 SetEventMask(
GetOwner(), EntityEvent.FRAME);
337 SetEventMask(
GetOwner(), EntityEvent.FRAME);
340 if (!testEntity)
return;
343 if (!m_TestComponent)
return;
345 m_LayerOrig = m_TestComponent.GetParentEntity();
348 int keysCount = keysType.GetVariableCount();
350 DiagMenu.RegisterRange(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_ACCESS_KEY,
"",
"TestEntity: Access Key",
"Editable Entities",
string.Format(
"0, %1, 0, 1", keysCount - 1));
351 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_ACCESS_KEY_TOGGLE,
"",
"TestEntity: Access Key: Toggle",
"Editable Entities");
352 DiagMenu.RegisterRange(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_LAYER,
"",
"TestEntity: Layer",
"Editable Entities",
"0, 2, 0, 1");
353 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_SELECT,
"",
"TestEntity: Toggle Selection",
"Editable Entities");
354 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_FOCUS,
"",
"TestEntity: Toggle Focus",
"Editable Entities");
355 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_SHOW,
"",
"TestEntity: Show",
"Editable Entities");
357 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_LAYER, 0);
358 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_SHOW,
true);
362 override protected void EOnEditorDeactivate()
364 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_ACCESS_KEY);
365 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_ACCESS_KEY_TOGGLE);
366 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_LAYER);
367 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_SELECT);
368 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_FOCUS);
369 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_TEST_ENTITY_SHOW);