Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DebugCameraCore.c
Go to the documentation of this file.
1 
4 [BaseContainerProps(configRoot: true)]
5 class SCR_DebugCameraCore : SCR_GameCoreBase
6 {
7  [Attribute("", UIWidgets.ResourceNamePicker, "SCR_ManualCamera prefab", "et")]
8  private ResourceName m_CameraPrefab;
9 
10  private CameraManager m_CameraManager;
11  private IEntity m_Camera;
12 
13  //------------------------------------------------------------------------------------------------
15  void ToggleCamera()
16  {
17  if (m_Camera)
18  DeleteCamera();
19  else
20  CreateCamera();
21  }
22 
23  //------------------------------------------------------------------------------------------------
26  void CreateCamera(vector transform[4])
27  {
28  if (m_Camera)
29  return;
30 
31  EntitySpawnParams spawnParams = new EntitySpawnParams;
32  spawnParams.Transform = transform;
33  m_Camera = GetGame().SpawnEntityPrefab(Resource.Load(m_CameraPrefab), GetGame().GetWorld(), spawnParams);
34 
35  DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 1);
36  }
37 
38  //------------------------------------------------------------------------------------------------
40  void CreateCamera()
41  {
42  BaseWorld world = GetGame().GetWorld();
43  if (!world)
44  return;
45 
46  vector transform[4];
47  world.GetCurrentCamera(transform);
48  CreateCamera(transform);
49  }
50 
51  //------------------------------------------------------------------------------------------------
53  void DeleteCamera()
54  {
55  if (!m_Camera)
56  return;
57 
58  delete m_Camera;
59 
60  DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 0);
61  }
62 
63  //------------------------------------------------------------------------------------------------
66  IEntity GetCamera()
67  {
68  return m_Camera;
69  }
70 
71  //------------------------------------------------------------------------------------------------
74  static IEntity GetCameraInstance()
75  {
77  if (core)
78  return core.GetCamera();
79 
80  return null;
81  }
82 
83  //------------------------------------------------------------------------------------------------
84  override bool CanCreate()
85  {
86  if (m_CameraPrefab.IsEmpty())
87  {
88  Print("Cannot initialize SCR_DebugCameraCore, m_CameraPrefab is empty!", LogLevel.ERROR);
89  return false;
90  }
91  typename type = SCR_BaseContainerTools.GetContainerClassName(m_CameraPrefab).ToType();
92  if (!type.IsInherited(SCR_ManualCamera))
93  {
94  Print(string.Format("Cannot initialize SCR_DebugCameraCore, prefab '%1' is %2, not SCR_ManualCamera!", m_CameraPrefab.GetPath(), type), LogLevel.ERROR);
95  return false;
96  }
97  return true;
98  }
99 
100  //------------------------------------------------------------------------------------------------
101  override void OnUpdate(float timeSlice)
102  {
103  if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE))
104  {
105  //--- Check if in-game editor is opened
106  if (SCR_EditorManagerEntity.IsOpenedInstance())
107  {
108  DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 0);
109  Print("Attempting to start debug camera when the editor is opened. There is no need for that.", LogLevel.NORMAL);
110  return;
111  }
112 
113  //--- Create new camera
114  CreateCamera();
115 
116  //--- Set camera as current if some other camera stole focus
117  if (m_CameraManager && m_CameraManager.CurrentCamera() != m_Camera)
118  {
119  m_CameraManager.SetCamera(CameraBase.Cast(m_Camera));
120  }
121  }
122  else
123  {
124  DeleteCamera();
125  }
126  }
127 
128  //------------------------------------------------------------------------------------------------
129  override void OnGameStart()
130  {
131  DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, "lctrl+lalt+c", "Debug manual camera", "Cheats");
132  DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 0);
133 
134  m_CameraManager = GetGame().GetCameraManager();
135 
136 #ifdef PLATFORM_WINDOWS
137  //--- Delete obsolete settings file. ToDo: Remove
138  FileIO.DeleteFile("$profile:.EditorSettings.conf");
139 #endif
140  }
141 
142  //------------------------------------------------------------------------------------------------
143  override void OnGameEnd()
144  {
145  DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 0);
146  delete m_Camera;
147  }
148 }
SCR_ManualCamera
Definition: SCR_ManualCamera.c:16
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_Camera
protected SCR_ManualCamera m_Camera
Definition: SCR_BaseManualCameraComponent.c:14
SCR_DebugCameraCore
Debug manual camera.
Definition: SCR_DebugCameraCore.c:5
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_BaseContainerTools
Definition: SCR_BaseContainerTools.c:3
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26