Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ManagedDamageEffectsContainer.c
Go to the documentation of this file.
2{
4 protected ref set<SCR_PersistentDamageEffect> m_EffectsSet;
5
6 //------------------------------------------------------------------------------------------------
10 bool AddEffect(notnull SCR_PersistentDamageEffect dmgEffect)
11 {
12 if (!m_EffectsSet)
13 m_EffectsSet = new set<SCR_PersistentDamageEffect>();
14
15 return m_EffectsSet.Insert(dmgEffect);
16 }
17
18 //------------------------------------------------------------------------------------------------
23 {
24 if (!m_EffectsSet)
25 return 0;
26
27 m_EffectsSet.RemoveItem(dmgEffect);
28 return m_EffectsSet.Count();
29 }
30
31 //------------------------------------------------------------------------------------------------
35 {
37 return null;
38
39 return m_mBatchedEffects.Get(t);
40 }
41
42 //------------------------------------------------------------------------------------------------
47 bool BatchData(notnull inout map<typename, ref SCR_BatchedDamageEffects> newBatchedData, const float avgTimeSlice, SCR_ExtendedDamageManagerComponent dmgMgr)
48 {
49 if (dmgMgr.GetState() == EDamageState.DESTROYED)
50 return false;
51
52 newBatchedData.Clear();
53 if (!m_EffectsSet || m_EffectsSet.IsEmpty())
54 return false;
55
56 typename effectType;
57 SCR_DotDamageEffect dotEffect;
58 SCR_BatchedDamageEffects batchContainer;
59 SCR_PersistentDamageEffect dmgEffectVirtualInstance;
61 {
62 dotEffect = SCR_DotDamageEffect.Cast(effect);
63 if (dotEffect)
64 dotEffect.RecalculateDPS(avgTimeSlice, dmgMgr);
65
66 if (effect.UseBatchProcessing())
67 {
68 effectType = effect.Type();
69 dmgEffectVirtualInstance = SCR_DamageSufferingSystem.GetVirtualInstanceOfDamageEffect(effectType);
70 if (!dmgEffectVirtualInstance)
71 continue;
72
73 batchContainer = newBatchedData.Get(effectType);
74 if (batchContainer)
75 {
76 dmgEffectVirtualInstance.BatchData(batchContainer, effect);
77 }
78 else
79 {
80 dmgEffectVirtualInstance.BatchData(batchContainer, effect);
81 if (!batchContainer) // if it failed to create a batch container then ignore it - but it is sus (O_O")
82 {
83 Debug.Error("SCR_DamageSufferingSystem.OnUpdatePoint: " + effectType.ToString() + ".BatchData() failed to create an instance of the batched data container!");
84 continue;
85 }
86
87 newBatchedData.Insert(effectType, batchContainer);
88 }
89 }
90 else
91 {
92 effect.IndividualProcessing(dmgMgr);
93 }
94 }
95
96 return true;
97 }
98
99 //------------------------------------------------------------------------------------------------
103 {
104 if (m_mBatchedEffects && (!newBatchedData || newBatchedData.IsEmpty()))
105 {
106 m_mBatchedEffects.Clear();
107 return;
108 }
109
112
113 // simple lookup table of what is now in the batch to allow us later to discard no longer valid data
114 const set<typename> batchedTypes = new set<typename>();
115 bool needsCleanup = newBatchedData.Count() < m_mBatchedEffects.Count();
116
117 // transfer information from new to the old set
118 SCR_BatchedDamageEffects oldBatchContainer;
119 foreach (typename effectType, ref SCR_BatchedDamageEffects batchContainer : newBatchedData)
120 {
121 batchedTypes.Insert(effectType);
122 oldBatchContainer = m_mBatchedEffects.Get(effectType);
123 if (!oldBatchContainer)
124 {
125 needsCleanup = true;
126 m_mBatchedEffects.Insert(effectType, batchContainer);
127 }
128 else
129 {
130 oldBatchContainer.CopyBatchedData(batchContainer);
131 }
132 }
133
134 if (!needsCleanup)
135 return;
136
137 // now cleanup old elements which are no longer being batched
138 const set<typename> garbageTypes = new set<typename>();
139 foreach (typename effectType, ref SCR_BatchedDamageEffects batchContainer : m_mBatchedEffects)
140 {
141 if (batchedTypes.Contains(effectType))
142 continue;
143
144 garbageTypes.Insert(effectType);
145 }
146
147 foreach (typename garbageKey : garbageTypes)
148 {
149 m_mBatchedEffects.Remove(garbageKey);
150 }
151 }
152
153 //------------------------------------------------------------------------------------------------
157 void ProcessBatchedData(notnull SCR_ExtendedDamageManagerComponent dmgMgr, bool isAuthority)
158 {
160 return;
161
162 SCR_PersistentDamageEffect dmgEffectVirtualInstance;
163 foreach (typename effectType, ref SCR_BatchedDamageEffects container : m_mBatchedEffects)
164 {
165 dmgEffectVirtualInstance = SCR_DamageSufferingSystem.GetVirtualInstanceOfDamageEffect(effectType);
166 if (!dmgEffectVirtualInstance)
167 continue;
168
169 dmgEffectVirtualInstance.BatchProcessing(dmgMgr, container, isAuthority);
170 }
171 }
172
173 //------------------------------------------------------------------------------------------------
174 // constructor
177 void SCR_ManagedDamageEffectsContainer(set<SCR_PersistentDamageEffect> effectsSet = null, map<typename, ref SCR_BatchedDamageEffects> batchedEffects = null)
178 {
179 m_EffectsSet = effectsSet;
180 m_mBatchedEffects = batchedEffects;
181 }
182}
Definition Debug.c:13
void RecalculateDPS(float timeSlice, notnull SCR_ExtendedDamageManagerComponent dmgManager)
void ProcessBatchedData(notnull SCR_ExtendedDamageManagerComponent dmgMgr, bool isAuthority)
ref map< typename, ref SCR_BatchedDamageEffects > m_mBatchedEffects
void SCR_ManagedDamageEffectsContainer(set< SCR_PersistentDamageEffect > effectsSet=null, map< typename, ref SCR_BatchedDamageEffects > batchedEffects=null)
int RemoveEffect(notnull SCR_PersistentDamageEffect dmgEffect)
ref set< SCR_PersistentDamageEffect > m_EffectsSet
bool AddEffect(notnull SCR_PersistentDamageEffect dmgEffect)
SCR_BatchedDamageEffects GetBatchedDataOfType(typename t)
void UpdateBachedData(map< typename, ref SCR_BatchedDamageEffects > newBatchedData)
bool BatchData(notnull inout map< typename, ref SCR_BatchedDamageEffects > newBatchedData, const float avgTimeSlice, SCR_ExtendedDamageManagerComponent dmgMgr)
void BatchProcessing(notnull SCR_ExtendedDamageManagerComponent dmgManager, notnull SCR_BatchedDamageEffects batchedDataContainer, bool isAuthority)
void BatchData(inout SCR_BatchedDamageEffects batchedDataContainer, notnull SCR_PersistentDamageEffect effect)
Definition Types.c:486
EDamageState