Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BuildingDestructionManagerComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Destruction", description: "Building destruction manager, stores data for destroyed buildings.")]
2 class SCR_BuildingDestructionManagerComponentClass : ScriptComponentClass
3 {
4 }
5 
6 class SCR_BuildingDestructionData
7 {
8  int m_iNextFreeIndex = -1;
11  vector m_vStartMatrix[4];
20  float m_fSpeedMultiplier = 1;
21  ref RandomGenerator m_RandomGenerator = new RandomGenerator();
22  ref array<IEntity> m_aQueriedEntities;
24  ref array<IEntity> m_aExcludeList;
25  ref array<ref Tuple2<vector, vector>> m_aNavmeshAreas;
26  ref array<bool> m_aRedoRoads;
27  ref SCR_BuildingDestructionCameraShakeProgress m_CameraShake = new SCR_BuildingDestructionCameraShakeProgress();
31 
32  //------------------------------------------------------------------------------------------------
34  void Reset()
35  {
36  m_vTargetOrigin = vector.Zero;
37  m_vStartAngles = vector.Zero;
38  Math3D.MatrixIdentity4(m_vStartMatrix);
39  m_vTargetAngles = vector.Zero;
40  m_iRotatedTimes = 0;
41  m_iRotationTime = 0;
44  m_iPauseTime = 0;
46  m_iRotationStart = 0;
48  m_RandomGenerator = new RandomGenerator();
49  m_aQueriedEntities = null;
51  m_aExcludeList = null;
52  m_aNavmeshAreas = null;
53  m_aRedoRoads = null;
54  m_CameraShake = new SCR_BuildingDestructionCameraShakeProgress();
55  m_AudioSource = null;
57  }
58 }
59 
61 {
62  [Attribute()]
63  protected ref SCR_BuildingDestructionConfig m_BuildingDestructionConfig;
64 
65  private int m_iFirstFreeData = -1;
66  private ref array<ref SCR_BuildingDestructionData> m_aBuildingDestructionData = {};
67 
68  protected ref array<SCR_DestructibleBuildingComponent> m_aDestroyedBuildings = {};
69  protected static int s_iHighestId;
70  protected static ref map<int, SCR_DestructibleBuildingComponent> s_mBuildingIds = new map<int, SCR_DestructibleBuildingComponent>();
71 
72  //------------------------------------------------------------------------------------------------
75  notnull SCR_BuildingDestructionData GetData(inout int index)
76  {
77  if (index == -1)
78  index = AllocateData();
79 
80  return m_aBuildingDestructionData[index];
81  }
82 
83  //------------------------------------------------------------------------------------------------
86  private int AllocateData()
87  {
88  if (m_iFirstFreeData == -1)
89  return m_aBuildingDestructionData.Insert(new SCR_BuildingDestructionData());
90 
91  int returnIndex = m_iFirstFreeData;
92  SCR_BuildingDestructionData data = m_aBuildingDestructionData[returnIndex];
93  m_iFirstFreeData = data.m_iNextFreeIndex;
94  data.m_iNextFreeIndex = -1;
95  return returnIndex;
96  }
97 
98  //------------------------------------------------------------------------------------------------
101  void FreeData(int index)
102  {
103  // If you got a VME here, please report it only if you didn't touch the array/index
104  // Otherwise no guarantees
105  m_aBuildingDestructionData[index].Reset();
106  m_aBuildingDestructionData[index].m_iNextFreeIndex = m_iFirstFreeData;
107  m_iFirstFreeData = index;
108  }
109 
110  //------------------------------------------------------------------------------------------------
112  array<string> GetExcludedQueryTypes()
113  {
114  array<string> outArray = {};
115  if (!m_BuildingDestructionConfig)
116  return outArray;
117  else
118  outArray.Copy(m_BuildingDestructionConfig.m_aExcludedEntityQueryTypes);
119  return outArray;
120  }
121 
122  //------------------------------------------------------------------------------------------------
127  static bool IsIdTaken(int id, SCR_DestructibleBuildingComponent building)
128  {
129  SCR_DestructibleBuildingComponent idBuilding = s_mBuildingIds.Get(id);
130  return idBuilding && building != idBuilding;
131  }
132 
133  //------------------------------------------------------------------------------------------------
135  static int GetNewId()
136  {
137  s_iHighestId++;
138  return s_iHighestId;
139  }
140 
141  //------------------------------------------------------------------------------------------------
144  static SCR_DestructibleBuildingComponent GetDestructibleBuilding(int id)
145  {
146  return s_mBuildingIds.Get(id);
147  }
148 
149  //------------------------------------------------------------------------------------------------
152  static void UnregisterBuildingId(notnull SCR_DestructibleBuildingComponent component)
153  {
154  int id = s_mBuildingIds.GetKeyByValue(component);
155  if (id <= 0 || id > s_iHighestId)
156  return;
157 
158  s_mBuildingIds.Remove(id);
159 
160  if (id == s_iHighestId)
161  {
162  while (!s_mBuildingIds.Contains(s_iHighestId) && s_iHighestId > 0)
163  {
164  s_iHighestId--;
165  }
166  }
167  }
168 
169  //------------------------------------------------------------------------------------------------
173  static void RegisterBuildingId(notnull SCR_DestructibleBuildingComponent component, int id)
174  {
175  if (s_mBuildingIds.Contains(id))
176  {
177  Print("Id taken!", LogLevel.WARNING);
178  return;
179  }
180 
181  if (id >= s_iHighestId)
182  s_iHighestId = id;
183 
184  s_mBuildingIds.Insert(id, component);
185  }
186 
187  //------------------------------------------------------------------------------------------------
190  int GetDestroyedBuildings(notnull array<SCR_DestructibleBuildingComponent> destroyedBuildings)
191  {
192  return destroyedBuildings.Copy(m_aDestroyedBuildings);
193  }
194 
195  //------------------------------------------------------------------------------------------------
198  void RegisterDestroyedBuilding(SCR_DestructibleBuildingComponent building)
199  {
200  if (m_aDestroyedBuildings.Contains(building))
201  return;
202 
203  m_aDestroyedBuildings.Insert(building);
204  }
205 
206  //------------------------------------------------------------------------------------------------
207  // constructor
211  void SCR_BuildingDestructionManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
212  {
213  GetGame().RegisterBuildingDestructionManager(this);
214  }
215 
216  //------------------------------------------------------------------------------------------------
217  // destructor
219  {
220  GetGame().UnregisterBuildingDestructionManager(this);
221  }
222 }
SCR_AudioSource
Definition: SCR_AudioSource.c:1
m_vTargetOrigin
vector m_vTargetOrigin
Definition: SCR_BuildingDestructionManagerComponent.c:9
m_fSizeMultiplier
float m_fSizeMultiplier
Definition: SCR_BuildingDestructionManagerComponent.c:30
m_aQueriedEntities
ref array< IEntity > m_aQueriedEntities
Definition: SCR_BuildingDestructionManagerComponent.c:22
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
m_iRotatedTimes
int m_iRotatedTimes
Definition: SCR_BuildingDestructionManagerComponent.c:13
m_AudioSource
SCR_AudioSource m_AudioSource
Definition: SCR_BuildingDestructionManagerComponent.c:28
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_vTargetAngles
vector m_vTargetAngles
Definition: SCR_BuildingDestructionManagerComponent.c:12
m_vStartAngles
vector m_vStartAngles
Definition: SCR_BuildingDestructionManagerComponent.c:10
m_fRotationSpeedMultiplier
float m_fRotationSpeedMultiplier
Definition: SCR_BuildingDestructionManagerComponent.c:18
m_iRotationTime
int m_iRotationTime
Definition: SCR_BuildingDestructionManagerComponent.c:14
m_fBuildingVolume
float m_fBuildingVolume
Definition: SCR_BuildingDestructionManagerComponent.c:29
m_aNavmeshAreas
ref array< ref Tuple2< vector, vector > > m_aNavmeshAreas
Definition: SCR_BuildingDestructionManagerComponent.c:25
m_CameraShake
ref SCR_BuildingDestructionCameraShakeProgress m_CameraShake
Definition: SCR_BuildingDestructionManagerComponent.c:27
SCR_BuildingDestructionManagerComponentClass
Definition: SCR_BuildingDestructionManagerComponent.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_iPauseTime
int m_iPauseTime
Definition: SCR_BuildingDestructionManagerComponent.c:17
m_aExecutedEffectIndices
ref set< int > m_aExecutedEffectIndices
Definition: SCR_BuildingDestructionManagerComponent.c:23
m_iRotationStart
int m_iRotationStart
Definition: SCR_BuildingDestructionManagerComponent.c:19
m_aExcludeList
ref array< IEntity > m_aExcludeList
Definition: SCR_BuildingDestructionManagerComponent.c:24
SCR_BuildingDestructionConfig
Definition: SCR_BuildingDestructionConfig.c:2
m_iRotationMultiplier
int m_iRotationMultiplier
Definition: SCR_BuildingDestructionManagerComponent.c:15
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
m_iChecksThisFrame
int m_iChecksThisFrame
Definition: SCR_BuildingDestructionManagerComponent.c:16
SCR_BuildingDestructionManagerComponent
Definition: SCR_BuildingDestructionManagerComponent.c:60
m_aRedoRoads
ref array< bool > m_aRedoRoads
Definition: SCR_BuildingDestructionManagerComponent.c:26
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
m_RandomGenerator
ref RandomGenerator m_RandomGenerator
Definition: SCR_BuildingDestructionManagerComponent.c:21
Reset
void Reset()
Sets variables to default values when freed to be reused by another object on demand.
Definition: SCR_BuildingDestructionManagerComponent.c:34
m_fSpeedMultiplier
float m_fSpeedMultiplier
Definition: SCR_BuildingDestructionManagerComponent.c:20
m_vStartMatrix
vector m_vStartMatrix[4]
Definition: SCR_BuildingDestructionManagerComponent.c:11
m_iNextFreeIndex
SCR_BuildingDestructionManagerComponentClass m_iNextFreeIndex
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180