DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ EOnPostSimulate()

override void EOnPostSimulate ( IEntity other,
float timeSlice )
protected

In case where one of the valves is already running

  • snapshot values; stop animation of that valve and continue with newly requested

will force that valve to start deanimation of gauge

water level course and animation

stay on the same level

pressure course and animation

stay on the same level

end of deanimation - overlapped activation of valves

См. определение в файле Land_Underground_WaterReservoir.c строка 166

167 {
168 #ifndef SERVER
171 #endif
172
173 if (!GetGame().IsServer())
174 {
175 return;
176 }
177
178 int valve;
179 float waterHeight, pressureLevel;
180 WaterLevelSettings wlStageSettings, wlStageSettingsPrev;
181 PressureLevelSettings plStageSettings, plStageSettingsPrev;
182
185 for (valve = 0; valve < VALVES_COUNT; ++valve)
186 {
187 if (m_LastActiveValve != INDEX_NOT_FOUND && m_LastActiveValve != valve && m_ValveStates[valve] == true)
188 {
189 wlStageSettings = ActualWaterLevelStageSettings(valve);
192 m_WaterLevelSnapshot.RemainingDuration = Math.Clamp(wlStageSettings.Duration - m_WaterLevelTimesAccumulated[valve], 0, wlStageSettings.Duration);
193 m_ValveStates[valve] = false;
194 m_PressureDeanimationRequests[valve] = true;
195 break;
196 }
197 }
198
200 for (valve = 0; valve < VALVES_COUNT; ++valve)
201 {
202 if (m_ValveStates[valve] == true)
203 {
204 wlStageSettingsPrev = PreviousWaterLevelStageSettings(valve);
205 wlStageSettings = ActualWaterLevelStageSettings(valve);
206
208 if (wlStageSettings.Duration == -1.0)
209 {
210 m_ValveStates[valve] = false;
214 return;
215 }
216
217 float adjustedWaterHeight = WaterLevelToHeight(wlStageSettingsPrev.WaterLevel);
218 float adjustedDuration = wlStageSettings.Duration;
220 {
221 adjustedWaterHeight = m_WaterLevelSnapshot.WaterHeight;
222 adjustedDuration = wlStageSettings.Duration + m_WaterLevelSnapshot.RemainingDuration;
223 }
224
225 if (m_WaterLevelTimesAccumulated[valve] <= adjustedDuration)
226 {
227 float start = adjustedWaterHeight;
228 float target = WaterLevelToHeight(wlStageSettings.WaterLevel);
229 waterHeight = Math.Lerp(start, target, Easing.EaseInOutSine(m_WaterLevelTimesAccumulated[valve] / adjustedDuration));
230 SetWaterLevelHeight(waterHeight);
231 }
232 else
233 {
237 SetSynchDirty();
238 }
239
241 }
242 else
243 {
246 }
247 }
248
249 int allValvesStates = 0;
250
252 for (valve = 0; valve < VALVES_COUNT; ++valve)
253 {
254 if (m_PressureAnimationRequests[valve] == true)
255 {
256 bool hasToBeDeanimated = m_PressureAnimationRequests[valve] == m_PressureDeanimationRequests[valve];
257 plStageSettingsPrev = PreviousPressureLevelStageSettings(valve, hasToBeDeanimated);
258 plStageSettings = ActualPressureLevelStageSettings(valve, hasToBeDeanimated);
259
261 if (plStageSettings.Duration == -1.0)
262 {
264 m_PressureAnimationRequests[valve] = false;
266 return;
267 }
268
269 if (m_PressureTimesAccumulated[valve] <= plStageSettings.Duration)
270 {
271 float plStart = PressureLevelToValue(plStageSettingsPrev.PressureLevel);
272 float plTarget = PressureLevelToValue(plStageSettings.PressureLevel);
273 pressureLevel = Math.Lerp(plStart, plTarget, m_PressureTimesAccumulated[valve] / plStageSettings.Duration);
274 SetValvePressureLevelGauge(valve, pressureLevel);
275 }
276 else
277 {
280 if (hasToBeDeanimated && IsValvePressureLevelGaugeAtBase(valve))
281 {
282 m_PressureDeanimationRequests[valve] = false;
284 }
285 else
286 {
288 SetSynchDirty();
289 }
290 }
291
293 }
294 else
295 {
297 }
298
299
300 allValvesStates += m_PressureAnimationRequests[valve];
301 if (allValvesStates == false)
302 {
304 }
305 }
306 }
float m_WaterLevelHeightActual
void SetDefaultPressureLevelStageSettings(int pValveIndex)
bool IsValvePressureLevelGaugeAtBase(int pValveIndex)
PressureLevelSettings ActualPressureLevelStageSettings(int pValveIndex, bool pDeanimationRequest=false)
ref array< bool > m_PressureDeanimationRequests
WaterLevelSettings ActualWaterLevelStageSettings(int pValveIndex)
const int VALVES_COUNT
void AdvanceToNextPressureLevelStageSettings(int pValveIndex)
PressureLevelSettings PreviousPressureLevelStageSettings(int pValveIndex, bool pDeanimationRequest=false)
void SetWaterLevelHeight(float pHeight)
ref array< bool > m_ValveStates
void SetValvePressureLevelGauge(int pValveIndex, float pValue)
float WaterLevelToHeight(int pWaterLevel)
ref array< float > m_PressureTimesAccumulated
WaterLevelSettings PreviousWaterLevelStageSettings(int pValveIndex)
void AdvanceToNextWaterLevelStageSettings(int pValveIndex)
void HandleSoundEffects()
float PressureLevelToValue(int pPressureLevel)
ref WaterLevelSnapshot m_WaterLevelSnapshot
for deanimation purposes
float AdjustTime(float originalTime)
void SyncValveVariables()
ref array< float > m_WaterLevelTimesAccumulated
ref array< bool > m_PressureAnimationRequests
int m_LastActiveValve
void PressureLevelSettings(int pPressureLevel, float pDuration)
void HandleVisualEffects()
static float EaseInOutSine(float t)
Определения Easing.c:14
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Определения Easing.c:3
Определения EnMath.c:7
const int INDEX_NOT_FOUND
Определения gameplay.c:13
proto native CGame GetGame()
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

Перекрестные ссылки ActualPressureLevelStageSettings(), ActualWaterLevelStageSettings(), AdjustTime(), AdvanceToNextPressureLevelStageSettings(), AdvanceToNextWaterLevelStageSettings(), Math::Clamp(), WaterLevelSettings::Duration, Easing::EaseInOutSine(), GetGame(), HandleSoundEffects(), HandleVisualEffects(), INDEX_NOT_FOUND, IsValvePressureLevelGaugeAtBase(), Math::Lerp(), m_LastActiveValve, m_PressureAnimationRequests, m_PressureDeanimationRequests, m_PressureTimesAccumulated, m_ValveStates, m_WaterLevelHeightActual, m_WaterLevelSnapshot, m_WaterLevelTimesAccumulated, PressureLevelSettings(), PressureLevelToValue(), PreviousPressureLevelStageSettings(), PreviousWaterLevelStageSettings(), SetDefaultPressureLevelStageSettings(), SetValvePressureLevelGauge(), SetWaterLevelHeight(), SyncValveVariables(), VALVES_COUNT, WaterLevelSettings::WaterLevel и WaterLevelToHeight().