Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DebugCameraCore.c
Go to the documentation of this file.
1
2
4[BaseContainerProps(configRoot: true)]
5class 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
21 }
22
23 //------------------------------------------------------------------------------------------------
26 void CreateCamera(vector transform[4])
27 {
28 if (m_Camera)
29 return;
30
31#ifdef ENABLE_DIAG
32 #ifndef WORKBENCH
33 //~ Send notification to all players if player teleported and Diag is enabled
34 SCR_NotificationsComponent.SendToEveryone(ENotification.PLAYER_ENTERED_DEBUG_CAMERA, SCR_PlayerController.GetLocalPlayerId());
35 #endif
36#endif
37
38 EntitySpawnParams spawnParams = new EntitySpawnParams;
39 spawnParams.Transform = transform;
40 m_Camera = GetGame().SpawnEntityPrefab(Resource.Load(m_CameraPrefab), GetGame().GetWorld(), spawnParams);
41
42 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 1);
43
44
45 }
46
47 //------------------------------------------------------------------------------------------------
49 void CreateCamera()
50 {
51 BaseWorld world = GetGame().GetWorld();
52 if (!world)
53 return;
54
55 vector transform[4];
56 world.GetCurrentCamera(transform);
57 CreateCamera(transform);
58 }
59
60 //------------------------------------------------------------------------------------------------
62 void DeleteCamera()
63 {
64 if (!m_Camera)
65 return;
66
67 delete m_Camera;
68
69 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 0);
70 }
71
72 //------------------------------------------------------------------------------------------------
75 IEntity GetCamera()
76 {
77 return m_Camera;
78 }
79
80 //------------------------------------------------------------------------------------------------
83 static IEntity GetCameraInstance()
84 {
86 if (core)
87 return core.GetCamera();
88
89 return null;
90 }
91
92 //------------------------------------------------------------------------------------------------
93 override bool CanCreate()
94 {
95 if (m_CameraPrefab.IsEmpty())
96 {
97 Print("Cannot initialize SCR_DebugCameraCore, m_CameraPrefab is empty!", LogLevel.ERROR);
98 return false;
99 }
100 typename type = SCR_BaseContainerTools.GetContainerClassName(m_CameraPrefab).ToType();
101 if (!type.IsInherited(SCR_ManualCamera))
102 {
103 Print(string.Format("Cannot initialize SCR_DebugCameraCore, prefab '%1' is %2, not SCR_ManualCamera!", m_CameraPrefab.GetPath(), type), LogLevel.ERROR);
104 return false;
105 }
106 return true;
107 }
108
109 //------------------------------------------------------------------------------------------------
110 override void OnUpdate(float timeSlice)
111 {
112 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE))
113 {
114 //--- Check if in-game editor is opened
115 if (SCR_EditorManagerEntity.IsOpenedInstance())
116 {
117 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 0);
118 Print("Attempting to start debug camera when the editor is opened. There is no need for that.", LogLevel.NORMAL);
119 return;
120 }
121
122 //--- Create new camera
123 CreateCamera();
124
125 //--- Set camera as current if some other camera stole focus
126 if (m_CameraManager && m_CameraManager.CurrentCamera() != m_Camera)
127 {
128 m_CameraManager.SetCamera(CameraBase.Cast(m_Camera));
129 }
130 }
131 else
132 {
133 DeleteCamera();
134 }
135 }
136
137 //------------------------------------------------------------------------------------------------
138 override void OnGameStart()
139 {
140 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, "lctrl+lalt+c", "Debug manual camera", "Cheats");
141 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 0);
142
143 m_CameraManager = GetGame().GetCameraManager();
144
145#ifdef PLATFORM_WINDOWS
146 //--- Delete obsolete settings file. ToDo: Remove
147 FileIO.DeleteFile("$profile:.EditorSettings.conf");
148#endif
149 }
150
151 //------------------------------------------------------------------------------------------------
152 override void OnGameEnd()
153 {
154 DiagMenu.SetValue(SCR_DebugMenuID.DEBUGUI_MANUAL_CAMERA_FREE, 0);
155 delete m_Camera;
156 }
157}
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
override void OnGameEnd()
Called on all machines when the world ends.
EDamageType type
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
override void OnUpdate()
Diagnostic and developer menu system.
Definition DiagMenu.c:18
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
Debug manual camera.
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
void EntitySpawnParams()
Definition gameLib.c:130
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
override bool OnGameStart()
Gets called after world is initialized but before first ticks.
Definition game.c:561