Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
game.c
Go to the documentation of this file.
1 #ifdef BREAK_COMPILATION
2  THIS DEFINE BREAKS GAME SCRIPT MODULE COMPILATION
3  DO NOT REMOVE IT, IT IS NEEDED FOR VARIOUS TESTS
4 #endif
5 
14 
17 {
20  SpawnAI = 4,
21  Last = 4
22 }
23 
25 enum EDiagMenuGame : EDiagMenuGameLib
26 {
27 }
28 
31 class ArmaReforgerScripted : ChimeraGame
32 {
33  const string CONFIG_CORES_PATH = "Configs/Core/";
34 
35  const ResourceName CONFIG_DIALOGS_ERROR = "{D3BFEE28E7D5B6A1}Configs/ServerBrowser/KickDialogs.conf";
36 
39  protected bool m_bAreGameFlagsObtained;
40  protected ref ScriptInvoker Event_OnObtainedGameFlags = new ScriptInvoker();
48  protected SCR_SpawnerAIGroupManagerComponent m_SpawnerAIGroupManager;
49  protected bool m_bHasKeyboard;
50 
53 
55  protected SCR_DataCollectorComponent m_DataCollectorComponent;
56 
59 
60  ref ScriptInvoker m_OnMissionSetInvoker = new ScriptInvoker();
62 
63  bool m_bIsMainMenuOpen = false;
64  private bool m_bGameStarted = false;
65 
67  protected ref SCR_Stack<SCR_GameErrorMessage> m_aErrorStack = new SCR_Stack<SCR_GameErrorMessage>();
68 
69  protected ref ScriptInvoker m_OnChangeUserSettingsInvoker = new ScriptInvoker();
70  protected ref ScriptInvoker m_OnInputDeviceUserChangedInvoker = new ScriptInvoker();
71  protected ref ScriptInvoker m_OnInputDeviceIsGamepadInvoker = new ScriptInvoker();
72  protected ref ScriptInvoker m_OnWorldSimulatePhysicsInvoker = new ScriptInvoker();
73  protected ref ScriptInvoker<int, int, bool> m_OnWindowResizeInvoker = new ScriptInvoker();
74  protected ref ScriptCallQueue m_Callqueue = new ScriptCallQueue();
75 
76  //ref SCR_RCONCommander m_dsCommander;
77 
80 
81  //------------------------------------------------------------------------------------------------
82  // destructor
84  {
85  g_ARGame = null;
86  }
87 
88  //------------------------------------------------------------------------------------------------
90  SCR_DataCollectorComponent GetDataCollector()
91  {
93  }
94 
95  //------------------------------------------------------------------------------------------------
98  {
99  if (!m_ResourceGrid)
101 
102  return m_ResourceGrid;
103  }
104 
105  //------------------------------------------------------------------------------------------------
108  {
111 
113  }
114 
115  //------------------------------------------------------------------------------------------------
118  void RegisterDataCollector(SCR_DataCollectorComponent instance)
119  {
121  {
122  Print("Trying to register a SCR_DataCollectorComponent, but one is already registered!", LogLevel.ERROR);
123  return;
124  }
125 
126  m_DataCollectorComponent = instance;
127  }
128 
129  //------------------------------------------------------------------------------------------------
133  {
134  // Only set to null if it's the passed one
135  if (m_BuildingDestructionManager == manager)
137  }
138 
139  //------------------------------------------------------------------------------------------------
143  {
145  {
146  Print("Trying to register a SCR_BuildingDestructionManagerComponent, but one is already registered!", LogLevel.ERROR);
147  return;
148  }
149 
151  }
152 
153  //------------------------------------------------------------------------------------------------
156  {
158  }
159 
160  //------------------------------------------------------------------------------------------------
164  {
165  return m_pLoadoutManager;
166  }
167 
168  //------------------------------------------------------------------------------------------------
172  {
174  {
175  Print("Trying to register a SCR_SoundManagerEntity, but one is already registered!", LogLevel.ERROR);
176  return;
177  }
178 
179  m_SoundManagerEntity = instance;
180  }
181 
182  //------------------------------------------------------------------------------------------------
185  {
186  return m_SoundManagerEntity;
187  }
188 
189  //------------------------------------------------------------------------------------------------
192  {
193  if (!m_SettingsManager)
195 
196  return m_SettingsManager;
197  }
198 
199  //------------------------------------------------------------------------------------------------
202  {
203  if (!m_ProfanityFilter)
205 
206  return m_ProfanityFilter;
207  }
208 
209  //------------------------------------------------------------------------------------------------
212  {
213  return m_SaveManagerCore;
214  }
215 
216  //------------------------------------------------------------------------------------------------
219  {
220  return m_bHasKeyboard;
221  }
222 
223  //------------------------------------------------------------------------------------------------
225  ScriptCallQueue GetCallqueue()
226  {
227  return m_Callqueue;
228  }
229 
230  //------------------------------------------------------------------------------------------------
233  {
235  }
236 
237  //------------------------------------------------------------------------------------------------
240  {
242  }
243 
244  //------------------------------------------------------------------------------------------------
247  {
249  }
250 
251  //------------------------------------------------------------------------------------------------
254  {
256  }
257 
258  //------------------------------------------------------------------------------------------------
260  ScriptInvoker OnWindowResizeInvoker()
261  {
263  }
264 
265  //------------------------------------------------------------------------------------------------
268  override bool GetIsClientAuthority()
269  {
270  return false;
271  }
272 
273  //------------------------------------------------------------------------------------------------
274  override protected void OnMissionSet(MissionHeader mission)
275  {
276  m_OnMissionSetInvoker.Invoke(mission);
277 
278  SCR_MissionHeader pHeader = SCR_MissionHeader.Cast(mission);
279  if (pHeader)
280  SetGameFlags(pHeader.m_eDefaultGameFlags, false);
281 
282  GameSessionStorage.s_Data["m_iRejoinAttempt"] = "0";
283  }
284 
285  //------------------------------------------------------------------------------------------------
286  override void OnCinematicStart()
287  {
288  Print("Cinematic start");
289  }
290 
291  //------------------------------------------------------------------------------------------------
292  override void OnCinematicEnd()
293  {
294  Print("Cinematic end");
295  }
296 
297  //------------------------------------------------------------------------------------------------
298  override void OnCinematicBlending(float blendFactor, vector cameraPosition)
299  {
300  // This makes the player head dissolve nicely when we are transitioning from/to cinematic
301  auto playerEntity = SCR_PlayerController.GetLocalControlledEntity();
302  if (playerEntity)
303  {
304  SCR_CharacterCameraHandlerComponent camHandlerComp = SCR_CharacterCameraHandlerComponent.Cast(playerEntity.FindComponent(SCR_CharacterCameraHandlerComponent));
305  if (camHandlerComp)
306  {
307  camHandlerComp.UpdateHeadVisibility(cameraPosition);
308  }
309  }
310  }
311 
312  //------------------------------------------------------------------------------------------------
314  override protected void OnKickedFromGame(KickCauseCode kickCode)
315  {
316  KickCauseGroup2 groupInt;
317  int reasonInt;
318  string group, reason;
319 
320  //~ Get the kick reason ID
321  GetFullKickReason(kickCode, groupInt, reasonInt, group, reason);
322 
323  // Detail
324  string format = "Kick cause code: group=%1 '%2', reason=%3 '%4'";
325  string strDetail = string.Format(format , groupInt, group, reasonInt, reason);
326  Print(string.Format(format, groupInt, group, reasonInt, reason), LogLevel.NORMAL);
327 
328  // Set dialog tag
329  string dialogTag = group + "_" + reason;
330 
331  // Default error
332  if (group == "<unknown>")
333  dialogTag = "DEFAULT_ERROR";
334  else
335  {
336  // No specific reason in group
337  if (reason == "<unknown>")
338  {
339  dialogTag = group;
340  }
341  }
342 
343  // Set msg
344  SCR_KickDialogs.CreateKickErrorDialog(dialogTag, group, strDetail);
345 
346  // Add rejoin attempt
348  }
349 
350  //------------------------------------------------------------------------------------------------
358  bool GetFullKickReason(KickCauseCode kickCode, out KickCauseGroup2 groupInt, out int reasonInt, out string group, out string reason)
359  {
360  groupInt = KickCauseCodeAPI.GetGroup(kickCode);
361  reasonInt = KickCauseCodeAPI.GetReason(kickCode);
362 
363  group = "<unknown>";
364  reason = "<unknown>";
365  switch(groupInt)
366  {
367  case RplKickCauseGroup.REPLICATION:
368  group = "REPLICATION";
369  switch(reasonInt)
370  {
371  case RplError.SYSTEM_FAILURE: reason = "SYSTEM_FAILURE"; return true;
372  case RplError.DISCONNECTION: reason = "DISCONNECTION"; return true;
373  case RplError.CONNECTION_FAILURE: reason = "CONNECTION_FAILURE"; return true;
374  case RplError.TIMEOUT: reason = "TIMEOUT"; return true;
375  case RplError.FLOODED: reason = "FLOODED"; return true;
376  case RplError.STALLED: reason = "STALLED"; return true;
377  case RplError.SERVICE_FAILURE: reason = "SERVICE_FAILURE"; return true;
378  case RplError.JIP_ERROR: reason = "JIP_ERROR"; return true;
379  case RplError.SHUTDOWN: reason = "SHUTDOWN"; return true;
380  case RplError.CREATION_FAILURE: reason = "CREATION_FAILURE"; return true;
381  }
382  break;
383 
384  case KickCauseGroup.BATTLEYE_INIT:
385  group = "BATTLEYE_INIT";
386  switch(reasonInt)
387  {
388  case BattlEyeInitError.LOAD_ERROR: reason = "LOAD_ERROR"; return true;
389  case BattlEyeInitError.UNSUPPORTED_VERSION: reason = "UNSUPPORTED_VERSION"; return true;
390  case BattlEyeInitError.OTHER_ERROR: reason = "OTHER_ERROR"; return true;
391  }
392  break;
393 
394  case KickCauseGroup.BATTLEYE:
395  group = "BATTLEYE";
396  switch(reasonInt)
397  {
398  case BattlEyeKickReason.CLIENT_NOT_RESPONDING: reason = "CLIENT_NOT_RESPONDING"; return true;
399  case BattlEyeKickReason.QUERY_TIMEOUT: reason = "QUERY_TIMEOUT"; return true;
400  case BattlEyeKickReason.GAME_RESTART_REQUIRED: reason = "GAME_RESTART_REQUIRED"; return true;
401  case BattlEyeKickReason.BAD_SERVICE_VERSION: reason = "BAD_SERVICE_VERSION"; return true;
402  case BattlEyeKickReason.DISALLOWED_PROGRAM: reason = "DISALLOWED_PROGRAM"; return true;
403  case BattlEyeKickReason.CORRUPTED_MEMORY: reason = "CORRUPTED_MEMORY"; return true;
404  case BattlEyeKickReason.CORRUPTED_DATA: reason = "CORRUPTED_DATA"; return true;
405  case BattlEyeKickReason.WINAPI_FAILURE: reason = "WINAPI_FAILURE"; return true;
406  case BattlEyeKickReason.GLOBAL_BAN: reason = "GLOBAL_BAN"; return true;
407  case BattlEyeKickReason.ADMIN_BAN: reason = "ADMIN_BAN"; return true;
408  case BattlEyeKickReason.ADMIN_KICK: reason = "ADMIN_KICK"; return true;
409  case BattlEyeKickReason.INVALID_SERVER_CONFIG: reason = "INVALID_SERVER_CONFIG"; return true;
410  }
411  break;
412 
413  case KickCauseGroup.DATA:
414  group = "DATA";
415  switch(reasonInt)
416  {
417  case DataError.VERSION_MISMATCH: reason = "VERSION_MISMATCH"; return true;
418  case DataError.RDB_MISMATCH: reason = "RDB_MISMATCH"; return true;
419  case DataError.SCRIPT_MISMATCH: reason = "SCRIPT_MISMATCH"; return true;
420  case DataError.WORLD_LOAD_ERROR: reason = "WORLD_LOAD_ERROR"; return true;
421  case DataError.WORLD_LOAD_INCONSISTENCY: reason = "WORLD_LOAD_INCONSISTENCY"; return true;
422  case DataError.ADDON_LOAD_ERROR: reason = "ADDON_LOAD_ERROR"; return true;
423  }
424  break;
425 
426  case KickCauseGroup2.PLATFORM:
427  group = "PLATFORM";
428  switch(reasonInt)
429  {
430  case PlatformKickReason.ACTIVE_USER_LOST: reason = "ACTIVE_USER_LOST"; return true;
431  case PlatformKickReason.NO_MP_PRIVILEGE: reason = "NO_MP_PRIVILEGE"; return true;
432  case PlatformKickReason.NO_CROSSPLAY_PRIVILEGE: reason = "NO_CROSSPLAY_PRIVILEGE"; return true;
433  }
434  break;
435 
436  case KickCauseGroup2.PLAYER_MANAGER:
437  group = "PLAYER_MANAGER";
438  switch (reasonInt)
439  {
440  case PlayerManagerKickReason.KICK: reason = "KICK"; return true;
441  case PlayerManagerKickReason.KICK_VOTED: reason = "KICK_VOTED"; return true;
442  case PlayerManagerKickReason.DUPLICATE_PLAYER_IDENTITY: reason = "DUPLICATE_PLAYER_IDENTITY"; return true;
443  case PlayerManagerKickReason.BAN: reason = "BAN"; return true;
444  case PlayerManagerKickReason.TEMP_BAN: reason = "TEMP_BAN"; return true;
445  case SCR_PlayerManagerKickReason.KICKED_BY_GM: reason = "KICKED_BY_GM"; return true;
446  case SCR_PlayerManagerKickReason.BANNED_BY_GM: reason = "BANNED_BY_GM"; return true;
447  case SCR_PlayerManagerKickReason.FRIENDLY_FIRE: reason = "FRIENDLY_FIRE"; return true;
448  case SCR_PlayerManagerKickReason.DISRUPTIVE_BEHAVIOUR: reason = "DISRUPTIVE_BEHAVIOUR"; return true;
449  }
450  break;
451  }
452 
453  return false;
454  }
455 
456  //------------------------------------------------------------------------------------------------
457  protected void AddRejoinAttempt()
458  {
459  // Get count
460  string strAttempt = GameSessionStorage.s_Data["m_iRejoinAttempt"];
461  int attempt = 0;
462 
463  // Setup number
464  if (strAttempt.IsEmpty())
465  {
466  GameSessionStorage.s_Data["m_iRejoinAttempt"] = "0";
467  }
468  else
469  {
470  attempt = strAttempt.ToInt();
471  }
472 
473  // Add
474  attempt++;
475  GameSessionStorage.s_Data["m_iRejoinAttempt"] = attempt.ToString();
476  }
477 
478  //------------------------------------------------------------------------------------------------
479  protected override void OnWorldPostProcess(World world)
480  {
481  if (m_CoresManager)
482  m_CoresManager.OnWorldPostProcess(world);
483 
484  if (GetGameMode())
485  GetGameMode().OnWorldPostProcess(world);
486  }
487 
488  //------------------------------------------------------------------------------------------------
491  protected override void ShowErrorMessage(string msg)
492  {
493  m_aErrorStack.Push(new SCR_GameErrorMessage(msg, "Error"));
494  }
495 
496  //------------------------------------------------------------------------------------------------
499  protected void ShowNextErrorDialog()
500  {
501  MenuManager menuManager = GetMenuManager();
502  if (!menuManager) // No menu manager, we have no means of displaying the error atm
503  return;
504 
505  DialogUI currentDialog = DialogUI.Cast(menuManager.FindMenuByPreset(ChimeraMenuPreset.ErrorDialog));
506  if (currentDialog != null) // There is already an error dialog displayed, do not display next one
507  return;
508 
509  SCR_GameErrorMessage errorMessage = m_aErrorStack.Pop();
510  if (!errorMessage)
511  return; // Should not occur as we're checking for whether the stack is empty
512 
513  // Display the error message using DialogUI menu dialogue
514  if (errorMessage)
515  {
516  DialogUI dialog = DialogUI.Cast(menuManager.OpenDialog(ChimeraMenuPreset.ErrorDialog));
517  if (dialog)
518  {
519  dialog.SetTitle(errorMessage.GetTitle());
520  dialog.SetMessage(errorMessage.GetMessage());
521  }
522  }
523  }
524 
525  //------------------------------------------------------------------------------------------------
528  {
529  return m_bGameStarted;
530  }
531 
532  //------------------------------------------------------------------------------------------------
535  {
536  return m_eGameFlags;
537  }
538 
539  //------------------------------------------------------------------------------------------------
542  void SetGameFlags(EGameFlags newGameFlags, bool shouldInvoke)
543  {
545  m_eGameFlags = newGameFlags;
546 
547  if (shouldInvoke)
548  {
549  InvokeGameFlags();
550  }
551  }
552 
553  //------------------------------------------------------------------------------------------------
559  {
561  }
562 
563  //------------------------------------------------------------------------------------------------
567  bool AreGameFlagsSet(EGameFlags checkGameFlags)
568  {
569  return (m_eGameFlags & checkGameFlags) != 0;
570  }
571 
572  //------------------------------------------------------------------------------------------------
575  {
577  }
578 
579  //------------------------------------------------------------------------------------------------
580  protected void InvokeGameFlags()
581  {
582  Event_OnObtainedGameFlags.Invoke();
583  }
584 
585  //------------------------------------------------------------------------------------------------
588  override typename GetMenuPreset()
589  {
590  return ChimeraMenuPreset;
591  }
592 
593  //------------------------------------------------------------------------------------------------
594  override LoadingAnim CreateLoadingAnim(WorkspaceWidget workspaceWidget)
595  {
596  return new ArmaReforgerLoadingAnim(workspaceWidget);
597  }
598 
599  //------------------------------------------------------------------------------------------------
602  override void OnAfterInit(BaseWorld world)
603  {
604  //required for DS registration with -dserver param
605  if (System.IsConsoleApp())
606  {
607  DSSession session = GetGame().GetBackendApi().GetDSSession();
608  if (session)
609  {
610  /*m_dsCommander = new SCR_RCONCommander();
611  session.SetRCONCommander(m_dsCommander);*/
612  }
613  }
614  m_CoresManager = SCR_GameCoresManager.CreateCoresManager();
616 
617  WidgetManager.SetCursor(0);
618  }
619 
620  //------------------------------------------------------------------------------------------------
621  override bool OnGameStart()
622  {
623  m_bGameStarted = true;
624 
625  #ifdef ENABLE_DIAG
626  if (RplSession.Mode() != RplMode.Client)
627  {
628  DiagMenu.RegisterMenu(SCR_DebugMenuID.DEBUGUI_DEPLOYABLE_SPAWNPOINTS, "Deployable SpawnPoints", "Game");
629  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_DEPLOYABLE_SPAWNPOINTS_ENABLE_DIAG, "", "Show Exclusion Zones", "Deployable SpawnPoints");
630  }
631 
632  DiagMenu.RegisterItem(SCR_DebugMenuID.DEBUGUI_INPUT_MANAGER, "", "Show input manager", "GameCode", "disabled,active,all");
633 
634  // Game
635  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_GAME_BOUNDS_OVERLAP_PREFAB, "", "Show bounds overlap target info", "Game");
636  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_GAME_CURSOR_TARGET_PREFAB, "", "Show cursor target info", "Game");
637  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_GAME_COPY_ENF_VIEW_LINK, "lctrl+lshift+l", "Copy view link", "Game");
638 
639  // UI
640  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_UI_CLOSE_ALL_MENUS, "", "Close All Menus", "UI");
641  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_UI_OPEN_MAIN_MENU, "", "Open Main Menu", "UI");
642  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_UI_LOG_UNDER_CURSOR, "", "Log widgets under cursor", "UI");
643  #endif
644 
645  if (!GetWorldEntity() || RplSession.Mode() != RplMode.Client)
646  {
648  InvokeGameFlags();
649  }
650 
652 
653  if (m_CoresManager)
654  m_CoresManager.OnGameStart();
655 
657 
658 #ifndef PLATFORM_CONSOLE
659  if (System.IsCLIParam("listScenarios"))
660  SCR_GameLogHelper.LogScenariosConfPaths();
661 
662  m_bHasKeyboard = true;
663 #endif
664 
665 #ifdef PLATFORM_CONSOLE
666  SCR_SettingsManager settingsManager = GetSettingsManager();
667  //by default we do not expect console to have keyboard
668  m_bHasKeyboard = false;
669 
670  //setup default quality settings for series S and series X xbox
671  if (settingsManager)
672  {
673  SCR_SettingsManagerVideoModule settingsVideoModule = SCR_SettingsManagerVideoModule.Cast(settingsManager.GetModule(ESettingManagerModuleType.SETTINGS_MANAGER_VIDEO));
674 
675  //by default we do not expect console to have keyboard
676  m_bHasKeyboard = false;
677 
678  //setup default quality settings for series S and series X xbox
679  if (settingsVideoModule)
680  {
681  int lastUsedPresetID = -1;
682  BaseContainer videoSettings = GetGame().GetGameUserSettings().GetModule("SCR_VideoSettings");
683  if (videoSettings)
684  {
685  videoSettings.Get("m_iLastUsedPreset", lastUsedPresetID);
686  if (lastUsedPresetID == -1 && System.GetPlatform() == EPlatform.XBOX_SERIES_S)
687  settingsVideoModule.SetConsolePreset(EVideoQualityPreset.SERIES_S_PRESET_QUALITY);
688  else if (lastUsedPresetID == -1 && System.GetPlatform() == EPlatform.XBOX_SERIES_X)
689  settingsVideoModule.SetConsolePreset(EVideoQualityPreset.SERIES_X_PRESET_QUALITY);
690 
691  if (lastUsedPresetID != -1)
692  settingsVideoModule.SetConsolePreset(lastUsedPresetID);
693  }
694  }
695  }
696 #endif
697 
698  return true;
699  }
700 
701  //------------------------------------------------------------------------------------------------
702  protected static void OnMenuOpen()
703  {
704  MenuManager menuManager = GetGame().GetMenuManager();
705  if (!menuManager || menuManager.IsAnyMenuOpen() || menuManager.IsAnyDialogOpen())
706  return;
707 
708  OpenPauseMenu();
709  }
710 
711  //------------------------------------------------------------------------------------------------
713  static void OnShowPlayerList()
714  {
715  MenuManager manager = GetGame().GetMenuManager();
716  if (manager.IsAnyMenuOpen() || manager.IsAnyDialogOpen())
717  return;
718 
719  OpenPlayerList();
720  }
721 
722  //------------------------------------------------------------------------------------------------
724  static void OnShowGroupMenu()
725  {
726  OpenGroupMenu();
727  }
728 
729  //------------------------------------------------------------------------------------------------
733  static void OpenPauseMenu(bool hideParentMenu = true, bool fadeBackground = false)
734  {
735  MenuBase menu = GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.PauseMenu, 0, true, hideParentMenu);
736  if (!fadeBackground)
737  return;
738 
739  PauseMenuUI pauseMenu = PauseMenuUI.Cast(menu);
740  if (pauseMenu)
741  pauseMenu.FadeBackground(true, true);
742  }
743 
744  //------------------------------------------------------------------------------------------------
747  static SCR_PlayerListMenu OpenPlayerList()
748  {
749  MenuManager menuManager = GetGame().GetMenuManager();
750  if (menuManager.IsAnyDialogOpen())
751  return null; // We don't want to open this menu behind any dialogs.
752 
753  MenuBase menu = menuManager.FindMenuByPreset(ChimeraMenuPreset.PlayerListMenu);
754  if (!menu)
755  menu = menuManager.OpenMenu(ChimeraMenuPreset.PlayerListMenu);
756 
757  return SCR_PlayerListMenu.Cast(menu);
758  }
759 
760  //------------------------------------------------------------------------------------------------
764  {
765  SCR_Faction playerFaction;
766  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
767  if (factionManager)
768  playerFaction = SCR_Faction.Cast(factionManager.GetLocalPlayerFaction());
769 
770  if (!playerFaction)
771  return null;
772 
773  MenuManager menuManager = GetGame().GetMenuManager();
774  if (menuManager.IsAnyDialogOpen())
775  return null; // We don't want to open this menu behind any dialogs.
776 
777  MenuBase menu = MenuBase.Cast(menuManager.FindMenuByPreset(ChimeraMenuPreset.GroupMenu));
778  MenuBase playerMenu = MenuBase.Cast(menuManager.FindMenuByPreset(ChimeraMenuPreset.PlayerListMenu));
779  if (playerMenu)
780  return null;
781 
782  if (!menu)
783  GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.GroupMenu, 0, false, false);
784  else
785  GetGame().GetMenuManager().CloseMenu(menu);
786 
787  return SCR_GroupMenu.Cast(menu);
788  }
789 
790  //------------------------------------------------------------------------------------------------
791  override void OnGameEnd()
792  {
793  m_bAreGameFlagsObtained = false;
795  GetGame().GetMenuManager().CloseAllMenus();
796 
798 
799  SCR_BaseGameMode gameMode = SCR_BaseGameMode.Cast(GetGameMode());
800  if (gameMode)
801  gameMode.OnGameEnd();
802 
803  ShutdownBackend();
804 
805  if (m_CoresManager)
806  m_CoresManager.OnGameEnd();
807  }
808 
809  //------------------------------------------------------------------------------------------------
811  {
813  }
814 
815  //------------------------------------------------------------------------------------------------
819  override void OnInputDeviceUserChangedEvent(EInputDeviceType oldDevice, EInputDeviceType newDevice)
820  {
821  m_OnInputDeviceUserChangedInvoker.Invoke(oldDevice, newDevice);
822  }
823 
824  //------------------------------------------------------------------------------------------------
825  override void OnInputDeviceIsGamepadEvent(bool isGamepad)
826  {
827  m_OnInputDeviceIsGamepadInvoker.Invoke(isGamepad);
828  if (!isGamepad && !m_bHasKeyboard)
829  m_bHasKeyboard = true;
830  }
831 
832  //------------------------------------------------------------------------------------------------
833  override void OnWorldSimulatePhysics(float timeSlice)
834  {
835  m_OnWorldSimulatePhysicsInvoker.Invoke(timeSlice);
836  }
837 
838  //------------------------------------------------------------------------------------------------
839  override event void OnWindowResize(int w, int h, bool windowed)
840  {
841  m_OnWindowResizeInvoker.Invoke(w, h, windowed);
842  }
843 
844  //------------------------------------------------------------------------------------------------
847  {
848  InputManager inputManager = GetInputManager();
849  inputManager.AddActionListener("ShowScoreboard", EActionTrigger.DOWN, OnShowPlayerList);
850  inputManager.AddActionListener("ShowGroupMenu", EActionTrigger.DOWN, OnShowGroupMenu);
851  inputManager.AddActionListener("MenuOpen", EActionTrigger.DOWN, OnMenuOpen);
852 
853  #ifdef WORKBENCH
854  inputManager.AddActionListener("MenuOpenWB", EActionTrigger.DOWN, OnMenuOpen);
855  #endif
856  }
857 
858  //------------------------------------------------------------------------------------------------
861  {
862  InputManager inputManager = GetInputManager();
863  inputManager.RemoveActionListener("ShowScoreboard", EActionTrigger.DOWN, OnShowPlayerList);
864  inputManager.RemoveActionListener("ShowGroupMenu", EActionTrigger.DOWN, OnShowGroupMenu);
865  inputManager.RemoveActionListener("MenuOpen", EActionTrigger.DOWN, OnMenuOpen);
866 
867  #ifdef WORKBENCH
868  inputManager.RemoveActionListener("MenuOpenWB", EActionTrigger.DOWN, OnMenuOpen);
869  #endif
870  }
871 
872  #ifdef ENABLE_DIAG
873  private ref QueryTargetDiag m_pQueryTargetDiag = new QueryTargetDiag();
874 
875  //------------------------------------------------------------------------------------------------
876  private bool GetQueryTargetInfo(IEntity ent, out string name, out string tree)
877  {
878  if (!ent)
879  return false;
880 
881  EntityPrefabData prefabData = ent.GetPrefabData();
882  if (!prefabData)
883  return false;
884 
885  name = prefabData.GetPrefabName();
886  tree = "";
887 
888  BaseContainer cont = prefabData.GetPrefab();
889  while (cont)
890  {
891  string contName = cont.GetName();
892  if (!contName.IsEmpty())
893  {
894  tree += contName;
895  if (!tree.IsEmpty())
896  tree += "\n";
897 
898  if (name.IsEmpty())
899  name = contName;
900  }
901 
902  cont = cont.GetAncestor();
903  }
904 
905  return true;
906  }
907  #endif
908 
909  //------------------------------------------------------------------------------------------------
910  override void OnUpdate(BaseWorld world, float timeslice)
911  {
912  super.OnUpdate(world, timeslice);
913 
914  m_Callqueue.Tick(timeslice);
915 
916  // Setup in-game context
917  if (!GetMenuManager().IsAnyMenuOpen())
918  {
919  GetInputManager().ActivateContext("IngameContext", 1);
920  }
921 
922  // If we're in the main menu and there are errors on the error stack
923  // process them one by one
924  if (m_bIsMainMenuOpen)
925  {
926  if (!m_aErrorStack.IsEmpty())
927  {
929  }
930  }
931 
932  GetInputManager().SetDebug(DiagMenu.GetValue(SCR_DebugMenuID.DEBUGUI_INPUT_MANAGER));
933 
934  // Check clipboard link diag
935  #ifdef ENABLE_DIAG
936  bool bGetEnfLinkToClipboard = DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_GAME_COPY_ENF_VIEW_LINK);
937  if (bGetEnfLinkToClipboard)
938  {
939  // Out to clip
940  vector cameraTransform[4];
941  world.GetCurrentCamera(cameraTransform);
942  System.ExportToClipboard(GetWorldEditorLink(cameraTransform));
943  // Reset
944  DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_GAME_COPY_ENF_VIEW_LINK, 0);
945  }
946 
947  if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_GAME_CURSOR_TARGET_PREFAB))
948  {
949  CameraManager cameraManager = GetGame().GetCameraManager();
950  if (cameraManager)
951  {
952  CameraBase current = cameraManager.CurrentCamera();
953  if (current)
954  {
955  DbgUI.Begin("Cursor target info");
956  IEntity ent = current.GetCursorTarget();
957  if (ent)
958  {
959  // Position
960  vector pos = ent.GetOrigin();
961 
962  // Name
963  string name = ent.GetName();
964  string pname;
965  if( name.IsEmpty() )
966  pname = "Unnamed entity";
967  else
968  pname = "Name: " + name;
969 
970  // Draw text
971  DbgUI.Text(pname);
972 
973  string prfab;
974  string ptree;
975  string pepos;
976  if (GetQueryTargetInfo(ent, prfab, ptree))
977  {
978  pepos = "Position: <" + pos[0] + ", " + pos[1] + ", " + pos[2] + ">";
979 
980  Physics phys = ent.GetPhysics();
981  if( phys && phys.GetVelocity().Length() > 0 )
982  {
983  string pevel = "Velocity: " + phys.GetVelocity().Length();
984  pepos += ", ";
985  pepos += pevel;
986  }
987  DbgUI.Text(pepos);
988 
989  DbgUI.Text("Prefab: " + prfab);
990  DbgUI.Text("Prefab Inheritance Tree: " + ptree);
991  }
992  DbgUI.Spacer(32);
993  string infoText = string.Format("%1\n%2\nPrefab: \"%3\"\nPrefab Inheritance Tree: \"%4\"", pname, pepos, prfab, ptree);
994 
995  if (DbgUI.Button("Copy to clipboard"))
996  {
997  System.ExportToClipboard(infoText);
998  }
999 
1000  // Draw ddbox
1001  vector mins, maxs;
1002  ent.GetWorldBounds(mins, maxs);
1003  Shape boundingFill = Shape.Create(ShapeType.BBOX, ARGB(5, 0, 255, 0), ShapeFlags.ONCE | ShapeFlags.NOZBUFFER | ShapeFlags.TRANSP, mins, maxs);
1004  Shape boundingWire = Shape.Create(ShapeType.BBOX, ARGB(200, 0, 255, 255), ShapeFlags.ONCE | ShapeFlags.NOZBUFFER | ShapeFlags.WIREFRAME | ShapeFlags.TRANSP, mins, maxs);
1005 
1006  DebugTextWorldSpace.Create(current.GetWorld(), infoText, DebugTextFlags.FACE_CAMERA | DebugTextFlags.CENTER | DebugTextFlags.ONCE, pos[0], maxs[1] + 0.5, pos[2], 8, ARGB(255, 0, 255, 255), ARGB(64, 0, 0, 0));
1007  }
1008  DbgUI.End();
1009  }
1010  }
1011  }
1012 
1013  if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_GAME_BOUNDS_OVERLAP_PREFAB))
1014  {
1015  CameraManager cameraManager = GetGame().GetCameraManager();
1016  if (cameraManager)
1017  {
1018  CameraBase current = cameraManager.CurrentCamera();
1019  if (current)
1020  {
1021  DbgUI.Begin("Bounds overlap target info");
1022  vector cameraMat[4];
1023  current.GetWorldTransform(cameraMat);
1024 
1025  m_pQueryTargetDiag.Prepare();
1026  m_pQueryTargetDiag.DoQuery(current.GetWorld(), cameraMat[3], cameraMat[3] + 3.0 * cameraMat[2]);
1027  IEntity ent = m_pQueryTargetDiag.GetClosestEntity(cameraMat[3]);
1028  if (ent)
1029  {
1030  // Position
1031  vector pos = ent.GetOrigin();
1032 
1033  // Name
1034  string name = ent.GetName();
1035  string pname;
1036  if( name.IsEmpty() )
1037  pname = "Unnamed entity";
1038  else
1039  pname = "Name: " + name;
1040 
1041  // Draw text
1042  DbgUI.Text(pname);
1043 
1044  string prfab;
1045  string ptree;
1046  string pepos;
1047  if (GetQueryTargetInfo(ent, prfab, ptree))
1048  {
1049  pepos = "Position: <" + pos[0] + ", " + pos[1] + ", " + pos[2] + ">";
1050 
1051  Physics phys = ent.GetPhysics();
1052  if( phys && phys.GetVelocity().Length() > 0 )
1053  {
1054  string pevel = "Velocity: " + phys.GetVelocity().Length();
1055  pepos += ", ";
1056  pepos += pevel;
1057  }
1058  DbgUI.Text(pepos);
1059 
1060  DbgUI.Text("Prefab: " + prfab);
1061  DbgUI.Text("Prefab Inheritance Tree: " + ptree);
1062  }
1063  DbgUI.Spacer(32);
1064  string infoText = string.Format("%1\n%2\nPrefab: \"%3\"\nPrefab Inheritance Tree: \"%4\"", pname, pepos, prfab, ptree);
1065  if (DbgUI.Button("Copy to clipboard"))
1066  {
1067  System.ExportToClipboard(infoText);
1068  }
1069 
1070  // Draw ddbox
1071  vector mins, maxs;
1072  ent.GetWorldBounds(mins, maxs);
1073  Shape boundingFill = Shape.Create(ShapeType.BBOX, ARGB(5, 0, 255, 0), ShapeFlags.ONCE | ShapeFlags.NOZBUFFER | ShapeFlags.TRANSP, mins, maxs);
1074  Shape boundingWire = Shape.Create(ShapeType.BBOX, ARGB(200, 0, 255, 255), ShapeFlags.ONCE | ShapeFlags.NOZBUFFER | ShapeFlags.WIREFRAME | ShapeFlags.TRANSP, mins, maxs);
1075 
1076  DebugTextWorldSpace.Create(current.GetWorld(), infoText, DebugTextFlags.FACE_CAMERA | DebugTextFlags.CENTER | DebugTextFlags.ONCE, pos[0], maxs[1] + 0.5, pos[2], 8, ARGB(255, 0, 255, 255), ARGB(64, 0, 0, 0));
1077  }
1078  DbgUI.End();
1079  }
1080  }
1081  }
1082 
1083  // Close all menus
1084  if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_UI_CLOSE_ALL_MENUS))
1085  {
1086  DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_UI_CLOSE_ALL_MENUS, 0);
1087  GetGame().GetMenuManager().CloseAllMenus();
1088  }
1089 
1090  // Open main menu
1091  if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_UI_OPEN_MAIN_MENU))
1092  {
1093  DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_UI_OPEN_MAIN_MENU, 0);
1094  GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.MainMenu);
1095  }
1096 
1097  if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_UI_LOG_UNDER_CURSOR))
1098  {
1099  DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_UI_LOG_UNDER_CURSOR, 0);
1100 
1101  array<Widget> widgets = {};
1102  int mouseX, mouseY;
1103  WidgetManager.GetMousePos(mouseX, mouseY);
1104  WidgetManager.TraceWidgets(mouseX, mouseY, GetGame().GetWorkspace(), widgets);
1105  int count = widgets.Count();
1106  Print(string.Format("Widgets under cursor (x = %1, y = %2): %3", mouseX, mouseY, count), LogLevel.NORMAL);
1107  for (int i; i < count; i++)
1108  {
1109  Print(" " + SCR_WidgetTools.GetHierarchyLog(widgets[i]), LogLevel.NORMAL);
1110  }
1111  }
1112 
1113  #endif
1114 
1115  if (m_CoresManager)
1116  m_CoresManager.OnUpdate(timeslice);
1117  }
1118 
1119  //------------------------------------------------------------------------------------------------
1121  // called by OnGameEnd
1123  {
1124 // BackendApi backendApi = GetBackendApi();
1125 // if (backendApi.IsAuthenticated())
1126 // backendApi.Shutdown();
1127  }
1128 
1129  //------------------------------------------------------------------------------------------------
1132  {
1133  m_HUDManager = hud;
1134  }
1135 
1136  //------------------------------------------------------------------------------------------------
1139  void LoadSave(string fileName)
1140  {
1141  //--- Remove .json extension
1142  string ext;
1143  string fileNameFiltered = FilePath.StripExtension(fileName, ext);
1144  if (ext == "json")
1145  fileName = fileNameFiltered;
1146 
1147  GetSaveManager().RestartAndLoad(fileName);
1148  }
1149 
1150  //------------------------------------------------------------------------------------------------
1155  {
1156  if (m_pLoadoutManager)
1157  {
1158  Print("Trying to register a SCR_LoadoutManager, but one is already registered!", LogLevel.ERROR);
1159  return;
1160  }
1161 
1162  m_pLoadoutManager = instance;
1163  }
1164 
1165  //------------------------------------------------------------------------------------------------
1170  {
1171  if (!m_pLoadoutManager)
1172  {
1173  Print("Trying to unregister a SCR_LoadoutManager, but none is registered!", LogLevel.ERROR);
1174  return;
1175  }
1176 
1177  if (!instance)
1178  {
1179  Print("Trying to unregister an invalid SCR_LoadoutManager!", LogLevel.ERROR);
1180  return;
1181  }
1182 
1183  if (m_pLoadoutManager != instance)
1184  {
1185  Print("Trying to unregister a SCR_LoadoutManager, but different one is registered!", LogLevel.ERROR);
1186  return;
1187  }
1188 
1189  Print("SCR_LoadoutManager unregistered successfully, released instance: " + instance, LogLevel.VERBOSE);
1190  // Release reference
1191  m_pLoadoutManager = null;
1192  }
1193 
1194  //------------------------------------------------------------------------------------------------
1197  {
1198  return m_HUDManager;
1199  }
1200 
1201  #ifdef ENABLE_DIAG
1202  //------------------------------------------------------------------------------------------------
1205  static string GetWorldEditorLink(vector transformation[4])
1206  {
1207  // Fetch position
1208  vector position = transformation[3];
1209 
1210  // Fetch angles
1211  vector angles = Math3D.MatrixToAngles(transformation);
1212 
1213  // We want to substring only /worlds/...
1214  // to prevent exposing local folders, etc.
1215  string fullLink = GetGame().GetWorldFile();
1216  string fullLinkLower = fullLink;
1217  fullLinkLower.ToLower(); // In case another casing of the folder is used
1218  int begin = fullLinkLower.IndexOf("worlds/");
1219  string worldPath = fullLink.Substring(begin, fullLink.Length() - begin);
1220 
1221  // Create link
1222  string link = string.Format(
1223  "enfusion://WorldEditor/%1;%2,%3,%4;%5,%6,%7",
1224  worldPath,
1225  position[0],
1226  position[1],
1227  position[2],
1228  angles[1],
1229  angles[0],
1230  angles[2]);
1231 
1232  // Print it to console
1233  return link;
1234  }
1235  #endif
1236 
1237  //------------------------------------------------------------------------------------------------
1238  override protected ref Managed GetPlayerDataStats(int playerID)
1239  {
1241  return m_DataCollectorComponent.GetPlayerDataStats(playerID);
1242 
1243  return null;
1244  }
1245 
1246  //------------------------------------------------------------------------------------------------
1247  override string GetMissionName()
1248  {
1249  SCR_MissionHeader header = SCR_MissionHeader.Cast(GetMissionHeader());
1250  if (header)
1251  return header.m_sName;
1252  else
1253  return "";
1254  }
1255 
1256  //------------------------------------------------------------------------------------------------
1257  override void PlayGameConfig(ResourceName sResource, string addonsList)
1258  {
1259  Print(string.Format("PlayGameConfig {Resource: %1; Addons: %2}", sResource, addonsList), LogLevel.NORMAL);
1260 
1261  if (sResource.Empty)
1262  {
1263  Print(string.Format("PlayGameConfig: Empty resource passed!"), LogLevel.NORMAL);
1264  return;
1265  }
1266 
1267  if (GameStateTransitions.RequestScenarioChangeTransition(sResource, addonsList))
1268  GetGame().GetMenuManager().CloseAllMenus();
1269  else
1270  Print(string.Format("Failed to start scenario."), LogLevel.ERROR);
1271  }
1272 
1273  //------------------------------------------------------------------------------------------------
1274  override void HostGameConfig()
1275  {
1276  bool success = GameStateTransitions.RequestPublicServerTransition(null);
1277 
1278  if (success)
1279  GetGame().GetMenuManager().CloseAllMenus();
1280  else
1281  Print("Failed to host config", LogLevel.ERROR);
1282  }
1283 
1284  //------------------------------------------------------------------------------------------------
1287  override Managed ReadGameConfig(string sResource)
1288  {
1289  return MissionHeader.ReadMissionHeader(sResource);
1290  }
1291 
1292  //------------------------------------------------------------------------------------------------
1295  override array<ResourceName> GetDefaultGameConfigs()
1296  {
1297  ResourceName config = "{CB4130E7FBE99D74}Configs/Workshop/DefaultScenarios.conf";
1298  Resource resource = BaseContainerTools.LoadContainer(config);
1299  if (!resource)
1300  return null;
1301 
1302  BaseContainer entries = resource.GetResource().ToBaseContainer();
1303  if (!entries)
1304  return null;
1305 
1306  array<ResourceName> resources = {};
1307 
1308  entries.Get("m_aDefaultScenarios", resources);
1309 
1310  return resources;
1311  }
1312 
1313  //------------------------------------------------------------------------------------------------
1317  protected void InsertNewScenario(ResourceName scenario, inout array<ResourceName> resources)
1318  {
1319  foreach (ResourceName r : resources)
1320  {
1321  if (scenario == r)
1322  return;
1323  }
1324 
1325  resources.Insert(scenario);
1326  }
1327 
1328  //------------------------------------------------------------------------------------------------
1331  protected static bool CheckMissionHeader(MissionWorkshopItem mission)
1332  {
1333  SCR_MissionHeader header = SCR_MissionHeader.Cast(mission.GetHeader());
1334 
1335  if (!header)
1336  {
1337  Print(string.Format("Mission header doesn't exist or is not of SCR_MissionHeader class: %1", mission.Name()), LogLevel.ERROR);
1338  return false;
1339  }
1340 
1341  string worldPath = header.GetWorldPath();
1342  if (worldPath.IsEmpty())
1343  {
1344  Print(string.Format("Mission world path is incorrect: %1", mission.Name()), LogLevel.ERROR);
1345  return false;
1346  }
1347 
1348  return true;
1349  }
1350 
1351  //------------------------------------------------------------------------------------------------
1353  static SCR_2DPIPSightsComponent GetCurrentPIPSights()
1354  {
1355  IEntity controlledEntity = SCR_PlayerController.GetLocalControlledEntity();
1356  if (!controlledEntity)
1357  return null;
1358 
1359  ChimeraCharacter character = ChimeraCharacter.Cast(controlledEntity);
1360  if (!character)
1361  return null;
1362 
1363  BaseWeaponManagerComponent weaponManager = character.GetCharacterController().GetWeaponManagerComponent();
1364  if (!weaponManager)
1365  return null;
1366 
1367  BaseSightsComponent currentSights = weaponManager.GetCurrentSights();
1368  if (!currentSights)
1369  return null;
1370 
1371  SCR_2DPIPSightsComponent pip = SCR_2DPIPSightsComponent.Cast(currentSights);
1372  if (!pip)
1373  return null;
1374 
1375  return pip;
1376  }
1377 
1378  //------------------------------------------------------------------------------------------------
1383  static bool IsScreenPointInPIPSights(vector screenPosition, SCR_2DPIPSightsComponent sightsComponent)
1384  {
1385  if (!sightsComponent)
1386  return false;
1387 
1388  return sightsComponent.IsScreenPositionInSights(screenPosition);
1389  }
1390 
1391  //-------------------------------------------------------------------------------------------
1394  {
1395  #ifdef PLATFORM_CONSOLE
1396  return true;
1397  #else
1398  return false;
1399  #endif
1400  }
1401 
1402  //-------------------------------------------------------------------------------------------
1405  override void OnGamepadConnectionStatus(bool isConnected)
1406  {
1407  #ifndef AUTOTEST
1408  if (!isConnected && IsPlatformGameConsole())
1409  SCR_GamepadRemovalUI.OpenGamepadRemovalDialog();
1410  #endif
1411  }
1412 }
1413 
1414 ArmaReforgerScripted g_ARGame;
1415 
1416 //------------------------------------------------------------------------------------------------
1418 {
1419  g_ARGame = new ArmaReforgerScripted;
1420  return g_ARGame;
1421 }
1422 
1423 //------------------------------------------------------------------------------------------------
1424 ArmaReforgerScripted GetGame()
1425 {
1426  return g_ARGame;
1427 }
1428 
1429 #ifdef ENABLE_DIAG
1430 class QueryTargetDiag
1431 {
1432  private ref array<IEntity> m_aQueriedTargetEntities = {};
1433 
1434  //------------------------------------------------------------------------------------------------
1436  // Prepares for collection
1437  void Prepare()
1438  {
1439  m_aQueriedTargetEntities.Clear();
1440  }
1441 
1442  //------------------------------------------------------------------------------------------------
1447  // Collects nearby entities
1448  void DoQuery(BaseWorld world, vector from, vector to)
1449  {
1450  world.QueryEntitiesByLine(from, to, QueryTargetEntity);
1451  }
1452 
1453  // Internal query callback
1454  private bool QueryTargetEntity(IEntity ent)
1455  {
1456  if (CameraBase.Cast(ent))
1457  return true;
1458 
1459  m_aQueriedTargetEntities.Insert(ent);
1460  return true;
1461  }
1462 
1464  IEntity GetFirstEntity()
1465  {
1466  if (m_aQueriedTargetEntities.Count() > 0)
1467  return m_aQueriedTargetEntities[0];
1468 
1469  return null;
1470  }
1471 
1472  //------------------------------------------------------------------------------------------------
1475  // Returns closest entity relative to point
1476  IEntity GetClosestEntity(vector relativeTo)
1477  {
1478  IEntity closest = null;
1479  float sqDistance = float.MAX;
1480  foreach (IEntity ent : m_aQueriedTargetEntities)
1481  {
1482  float currentSqDist = vector.DistanceSq(ent.GetOrigin(), relativeTo);
1483  if (currentSqDist < sqDistance)
1484  {
1485  closest = ent;
1486  sqDistance = currentSqDist;
1487  }
1488  }
1489 
1490  return closest;
1491  }
1492 }
1493 #endif
OnMissionSet
override protected void OnMissionSet(MissionHeader mission)
Definition: game.c:274
OnCinematicBlending
override void OnCinematicBlending(float blendFactor, vector cameraPosition)
Definition: game.c:298
m_SessionErrorHandler
ref RplSessionErrorHandler m_SessionErrorHandler
Definition: game.c:61
OnUserSettingsChangedEvent
override void OnUserSettingsChangedEvent()
Definition: game.c:810
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
SCR_HUDManagerComponent
Definition: SCR_HUDManagerComponent.c:23
RplSessionErrorHandler
Definition: RplSessionErrorHandler.c:2
GetResourceSystemSubscriptionManager
SCR_ResourceSystemSubscriptionManager GetResourceSystemSubscriptionManager()
Definition: game.c:107
SCR_ResourceGrid
void SCR_ResourceGrid()
Definition: SCR_ResourceGrid.c:785
m_ResourceGrid
protected ref SCR_ResourceGrid m_ResourceGrid
Definition: game.c:78
m_bIsMainMenuOpen
bool m_bIsMainMenuOpen
Definition: game.c:63
Event_OnObtainedGameFlags
protected ref ScriptInvoker Event_OnObtainedGameFlags
Definition: game.c:40
ScriptedChatEntity
Definition: ScriptedChatEntity.c:9
Metabolism
@ Metabolism
Definition: game.c:18
AreGameFlagsObtained
bool AreGameFlagsObtained()
Definition: game.c:558
SCR_WidgetTools
Definition: SCR_WidgetTools.c:1
SCR_PlayerController
Definition: SCR_PlayerController.c:31
m_OnInputDeviceUserChangedInvoker
protected ref ScriptInvoker m_OnInputDeviceUserChangedInvoker
Definition: game.c:70
m_ChatEntity
protected ScriptedChatEntity m_ChatEntity
Definition: game.c:42
m_SaveManagerCore
protected SCR_SaveManagerCore m_SaveManagerCore
Definition: game.c:46
RegisterBuildingDestructionManager
void RegisterBuildingDestructionManager(notnull SCR_BuildingDestructionManagerComponent manager)
Definition: game.c:142
KickCauseGroup2
KickCauseGroup2
Extends KickCauseGroup by adding game-specific groups.
Definition: KickCauseGroup2.c:13
RegisterSoundManagerEntity
void RegisterSoundManagerEntity(SCR_SoundManagerEntity instance)
Definition: game.c:171
AddActionListeners
void AddActionListeners()
Definition: game.c:846
GetCallqueue
ScriptCallQueue GetCallqueue()
Definition: game.c:225
SCR_GamepadRemovalUI
Dialog displayed when the gamepad is removed.
Definition: SCR_GamepadRemovalUI.c:3
m_OnMissionSetInvoker
ref ScriptInvoker m_OnMissionSetInvoker
Definition: game.c:60
GetMissionName
override string GetMissionName()
Definition: game.c:1247
m_aErrorStack
protected ref SCR_Stack< SCR_GameErrorMessage > m_aErrorStack
Stack of queued error messages. All messages are popped one by one as user closes them and only in th...
Definition: game.c:67
SpawnVehicles
@ SpawnVehicles
Definition: game.c:19
Last
@ Last
Definition: game.c:21
OnInputDeviceUserChangedEvent
override void OnInputDeviceUserChangedEvent(EInputDeviceType oldDevice, EInputDeviceType newDevice)
Definition: game.c:819
m_BuildingDestructionManager
protected SCR_BuildingDestructionManagerComponent m_BuildingDestructionManager
Definition: game.c:47
SCR_KickDialogs
Definition: SCR_KickDialogs.c:1
m_HUDManager
protected SCR_HUDManagerComponent m_HUDManager
Definition: game.c:41
m_SoundManagerEntity
protected SCR_SoundManagerEntity m_SoundManagerEntity
Object responsible for managing sounds trigged in script.
Definition: game.c:58
OnGamepadConnectionStatus
override void OnGamepadConnectionStatus(bool isConnected)
Definition: game.c:1405
m_ResourceSystemSubscriptionManager
protected ref SCR_ResourceSystemSubscriptionManager m_ResourceSystemSubscriptionManager
Definition: game.c:79
SCR_PlayerListMenu
Definition: SCR_PlayerListMenu.c:33
GetGameStarted
bool GetGameStarted()
Definition: game.c:527
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
CreateLoadingAnim
override LoadingAnim CreateLoadingAnim(WorkspaceWidget workspaceWidget)
Definition: game.c:594
PauseMenuUI
Definition: SCR_PauseMenuUI.c:2
MissionHeader
Definition: MissionHeader.c:32
KickCauseCodeAPI
Definition: KickCauseCodeAPI.c:12
OnWorldSimulatePhysics
override void OnWorldSimulatePhysics(float timeSlice)
Definition: game.c:833
AreGameFlagsSet
bool AreGameFlagsSet(EGameFlags checkGameFlags)
Definition: game.c:567
EGameFlags
EGameFlags
GameMode Game Flags represented by bit mask.
Definition: game.c:16
OnUserSettingsChangedInvoker
ScriptInvoker OnUserSettingsChangedInvoker()
Definition: game.c:232
GetDefaultGameConfigs
override array< ResourceName > GetDefaultGameConfigs()
Definition: game.c:1295
m_OnWorldSimulatePhysicsInvoker
protected ref ScriptInvoker m_OnWorldSimulatePhysicsInvoker
Definition: game.c:72
OpenGroupMenu
protected void OpenGroupMenu()
Definition: SCR_DeployMenuBase.c:839
GetHasKeyboard
bool GetHasKeyboard()
Definition: game.c:218
OnInputDeviceUserChangedInvoker
ScriptInvoker OnInputDeviceUserChangedInvoker()
Definition: game.c:239
IsPlatformGameConsole
bool IsPlatformGameConsole()
Definition: game.c:1393
GetBuildingDestructionManager
SCR_BuildingDestructionManagerComponent GetBuildingDestructionManager()
Definition: game.c:155
SCR_GameCoresManager
Definition: SCR_GameCoresManager.c:8
SpawnAI
@ SpawnAI
Definition: game.c:20
SCR_LoadoutManager
void SCR_LoadoutManager(IEntitySource src, IEntity parent)
Definition: SCR_LoadoutManager.c:500
GetGameFlags
EGameFlags GetGameFlags()
Definition: game.c:534
PlatformKickReason
PlatformKickReason
Definition: PlatformKickReason.c:12
ChimeraGame
Definition: ChimeraGame.c:7
SCR_SoundManagerEntity
Definition: SCR_SoundManagerEntity.c:17
HostGameConfig
override void HostGameConfig()
Definition: game.c:1274
OnUpdate
override void OnUpdate(BaseWorld world, float timeslice)
Definition: game.c:910
SCR_ResourceSystemSubscriptionManager
Definition: SCR_ResourceSystemSubscriptionManager.c:1
KickCauseCode
KickCauseCode
Definition: KickCauseCode.c:19
SCR_GroupMenu
Definition: SCR_GroupMenu.c:1
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
UnregisterLoadoutManager
void UnregisterLoadoutManager(SCR_LoadoutManager instance)
Definition: game.c:1169
SCR_GameLogHelper
Definition: SCR_GameLogHelper.c:1
CONFIG_DIALOGS_ERROR
const ResourceName CONFIG_DIALOGS_ERROR
Definition: game.c:35
GetIsClientAuthority
override bool GetIsClientAuthority()
Definition: game.c:268
OnAfterInit
override void OnAfterInit(BaseWorld world)
Definition: game.c:602
m_Callqueue
protected ref ScriptCallQueue m_Callqueue
Definition: game.c:74
~ArmaReforgerScripted
void ~ArmaReforgerScripted()
Definition: game.c:83
OnMenuOpen
MenuRootComponent OnMenuOpen
GameStateTransitions
Definition: GameStateTransitions.c:12
OnCinematicStart
override void OnCinematicStart()
Definition: game.c:286
OnInputDeviceIsGamepadEvent
override void OnInputDeviceIsGamepadEvent(bool isGamepad)
Definition: game.c:825
InvokeGameFlags
protected void InvokeGameFlags()
Definition: game.c:580
RegisterLoadoutManager
void RegisterLoadoutManager(SCR_LoadoutManager instance)
Definition: game.c:1154
SCR_GameErrorMessage
Wrapper for error messages.
Definition: SCR_GameErrorMessage.c:3
OnCinematicEnd
override void OnCinematicEnd()
Definition: game.c:292
OnWorldSimulatePhysicsInvoker
ScriptInvoker OnWorldSimulatePhysicsInvoker()
Definition: game.c:253
GetProfanityFilter
SCR_ProfaneFilter GetProfanityFilter()
Definition: game.c:201
PlayerManagerKickReason
PlayerManagerKickReason
Definition: PlayerManagerKickReason.c:12
GetPlayerDataStats
override protected ref Managed GetPlayerDataStats(int playerID)
Definition: game.c:1238
SCR_SettingsManagerVideoModule
Definition: SCR_SettingsManagerVideoModule.c:2
OnWindowResize
override event void OnWindowResize(int w, int h, bool windowed)
Definition: game.c:839
m_pLoadoutManager
protected SCR_LoadoutManager m_pLoadoutManager
Object responsible for managing and providing game modes with list of available loadouts.
Definition: game.c:52
SCR_SaveManagerCore
Definition: SCR_SaveManagerCore.c:9
m_OnChangeUserSettingsInvoker
protected ref ScriptInvoker m_OnChangeUserSettingsInvoker
Definition: game.c:69
PlayGameConfig
override void PlayGameConfig(ResourceName sResource, string addonsList)
Definition: game.c:1257
DialogUI
Definition: DialogUI.c:1
UnregisterBuildingDestructionManager
void UnregisterBuildingDestructionManager(notnull SCR_BuildingDestructionManagerComponent manager)
Definition: game.c:132
CONFIG_CORES_PATH
enum EGameFlags CONFIG_CORES_PATH
Enum of DiagMenu id values, generated by Game.
OnGameStart
override bool OnGameStart()
Gets called after world is initialized but before first ticks.
Definition: game.c:621
m_eGameFlags
protected EGameFlags m_eGameFlags
Game Flags specific for current game mode, or for the game mode which is going to be played when it i...
Definition: game.c:38
m_SettingsManager
protected ref SCR_SettingsManager m_SettingsManager
Definition: game.c:44
OnWindowResizeInvoker
ScriptInvoker OnWindowResizeInvoker()
Definition: game.c:260
GetSoundManagerEntity
SCR_SoundManagerEntity GetSoundManagerEntity()
Definition: game.c:184
OnKickedFromGame
override protected void OnKickedFromGame(KickCauseCode kickCode)
Called after player was kicked from game back to main menu, providing reason for the kick.
Definition: game.c:314
RemoveActionListeners
void RemoveActionListeners()
Definition: game.c:860
AddRejoinAttempt
protected void AddRejoinAttempt()
Definition: game.c:457
m_CoresManager
protected ref SCR_GameCoresManager m_CoresManager
Definition: game.c:43
m_bAreGameFlagsObtained
protected bool m_bAreGameFlagsObtained
Definition: game.c:39
GetMenuPreset
override GetMenuPreset()
Definition: game.c:588
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
ReadGameConfig
override Managed ReadGameConfig(string sResource)
Definition: game.c:1287
GetHUDManager
SCR_HUDManagerComponent GetHUDManager()
Definition: game.c:1196
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
m_bGameStarted
private bool m_bGameStarted
Definition: game.c:64
m_DataCollectorComponent
protected SCR_DataCollectorComponent m_DataCollectorComponent
Object responsible for tracking and connecting to the database for Career Profile.
Definition: game.c:55
OnWorldPostProcess
protected override void OnWorldPostProcess(World world)
Definition: game.c:479
SCR_BuildingDestructionManagerComponent
Definition: SCR_BuildingDestructionManagerComponent.c:60
RegisterDataCollector
void RegisterDataCollector(SCR_DataCollectorComponent instance)
Definition: game.c:118
ShowErrorMessage
protected override void ShowErrorMessage(string msg)
Definition: game.c:491
SCR_SettingsManager
Definition: SCR_SettingsManager.c:10
CreateGame
Game CreateGame()
Definition: game.c:1417
SetHUDManager
void SetHUDManager(SCR_HUDManagerComponent hud)
Definition: game.c:1131
GetDataCollector
SCR_DataCollectorComponent GetDataCollector()
Definition: game.c:90
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
InsertNewScenario
protected void InsertNewScenario(ResourceName scenario, inout array< ResourceName > resources)
Definition: game.c:1317
g_ARGame
ArmaReforgerScripted g_ARGame
Definition: game.c:1414
LoadSave
void LoadSave(string fileName)
Definition: game.c:1139
GAME
@ GAME
Definition: SCR_EGameModeState.c:16
GetSettingsManager
SCR_SettingsManager GetSettingsManager()
Definition: game.c:191
SetGameFlags
void SetGameFlags(EGameFlags newGameFlags, bool shouldInvoke)
Definition: game.c:542
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
GetSaveManager
SCR_SaveManagerCore GetSaveManager()
Definition: game.c:211
m_SpawnerAIGroupManager
protected SCR_SpawnerAIGroupManagerComponent m_SpawnerAIGroupManager
Definition: game.c:48
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
SCRIPT
@ SCRIPT
Set by script.
Definition: EEditorCanClose.c:7
m_ProfanityFilter
protected ref SCR_ProfaneFilter m_ProfanityFilter
Definition: game.c:45
GetLoadoutManager
SCR_LoadoutManager GetLoadoutManager()
Definition: game.c:163
OnInputDeviceIsGamepadInvoker
ScriptInvoker OnInputDeviceIsGamepadInvoker()
Definition: game.c:246
SCR_ProfaneFilter
Handles filtering profanities in texts.
Definition: SCR_ProfaneFilter.c:2
SCR_Faction
Definition: SCR_Faction.c:6
SCR_MissionHeader
Definition: SCR_MissionHeader.c:1
ShowNextErrorDialog
protected void ShowNextErrorDialog()
Definition: game.c:499
GetOnObtainedGameFlagsInvoker
ScriptInvoker GetOnObtainedGameFlagsInvoker()
Definition: game.c:574
m_bHasKeyboard
protected bool m_bHasKeyboard
Definition: game.c:49
ShutdownBackend
void ShutdownBackend()
Definition: game.c:1122
ArmaReforgerLoadingAnim
Definition: LoadingScreen.c:3
OnGameEnd
override void OnGameEnd()
Called on all machines when the world ends.
Definition: game.c:791
m_OnInputDeviceIsGamepadInvoker
protected ref ScriptInvoker m_OnInputDeviceIsGamepadInvoker
Definition: game.c:71
GetResourceGrid
SCR_ResourceGrid GetResourceGrid()
Definition: game.c:97
m_OnWindowResizeInvoker
protected ref ScriptInvoker< int, int, bool > m_OnWindowResizeInvoker
Definition: game.c:73
ESettingManagerModuleType
ESettingManagerModuleType
Definition: SCR_SettingsManager.c:2
GetFullKickReason
bool GetFullKickReason(KickCauseCode kickCode, out KickCauseGroup2 groupInt, out int reasonInt, out string group, out string reason)
Definition: game.c:358