35 typedef Param7<vector, vector, vector, vector, float, string, array<ref TriggerInsider>> DebugTriggerInfo;
42 const int TIMEOUT = 1000;
48 string m_DebugAreaType;
65 CleanupDebugShapes(dbgTargets);
73 override void EOnInit(
IEntity other,
int extra)
76 SetExtents(
"-2 -4 -2",
"2 4 2");
88 override void EOnFrame(
IEntity other,
float timeSlice)
90 UpdateInsiders(TIMEOUT);
94 override void EOnEnter(
IEntity other,
int extra)
97 if (
Class.CastTo(obj, other) && CanAddObjectAsInsider(obj))
102 override void EOnLeave(
IEntity other,
int extra)
105 if (
Class.CastTo(obj, other))
106 RemoveInsiderByObject(obj);
124 return GetCollisionRadius();
138 for (
int n = 0; n < m_insiders.Count(); ++n )
141 if (ins.GetObject() ==
object)
149 int GetInsiderIndexForObject(
Object object)
153 for (
int n = 0; n < m_insiders.Count(); ++n )
156 if (ins.GetObject() ==
object)
172 OnEnter(insider.GetObject());
178 OnLeave(insider.GetObject());
187 void OnEnter(
Object obj) {}
189 void OnLeave(
Object obj) {}
197 protected bool CanAddObjectAsInsider(
Object object)
228 protected void AddInsider(
Object obj)
234 if ( GetInsiderForObject( obj ) )
242 insider.timeStamp =
g_Game.GetTime();
243 insider.timeEntered =
g_Game.GetTickTime();
244 insider.lastUpdated = insider.timeEntered;
247 if ( ShouldRemoveInsider(insider) || ShouldRemoveInsiderNoLeave(insider) )
251 int index = m_insiders.Insert(insider);
255 obj.OnEnterTrigger(
this);
257 #ifdef TRIGGER_DEBUG_NORMAL
263 protected void RemoveInsider(
TriggerInsider insider,
int index = -1)
266 insider.GetObject().OnLeaveTrigger(
this);
268 #ifdef TRIGGER_DEBUG_NORMAL
269 Debug.TriggerLog(
string.Format(
"%1: removing at index %2",
GetDebugName(insider.GetObject()), index),
"Trigger",
"",
"RemoveInsider",
GetDebugName(
this));
273 m_insiders.Remove(index);
275 m_insiders.RemoveItemUnOrdered(insider);
279 protected void RemoveInsiderByObject(
Object object)
282 for (
int n = 0; n < m_insiders.Count(); ++n )
285 if (ins.GetObject() ==
object)
287 RemoveInsider(ins, n);
297 protected void UpdateInsiders(
int timeout)
299 #ifdef DIAG_DEVELOPER
300 DebugSendDmgTrigger();
304 if ( m_insiders.Count() == 0 )
308 StayStart(m_insiders.Count());
311 for (
int n = m_insiders.Count() - 1; n >= 0 ; --n)
314 Object obj = insider.GetObject();
317 if ( !obj || ShouldRemoveInsiderNoLeave(insider) )
319 #ifdef TRIGGER_DEBUG_BASIC
323 m_insiders.Remove(n);
328 if ( ShouldRemoveInsider(insider) )
330 RemoveInsider(insider, n);
336 float currentTime =
g_Game.GetTickTime();
337 Stay(insider, currentTime - insider.lastUpdated);
338 insider.lastUpdated = currentTime;
352 super.OnRPC(sender, rpc_type, ctx);
354 #ifdef DIAG_DEVELOPER
357 case ERPCs.DIAG_TRIGGER_DEBUG:
361 DebugDmgTrigger(data.param1, data.param2, data.param3, data.param4, data.param5, data.param6, data.param7);
367 #ifdef DIAG_DEVELOPER
368 void DebugSendDmgTrigger()
371 GetCollisionBox(minmax);
374 data.param1 = GetWorldPosition();
376 data.param3 = minmax[0];
377 data.param4 = minmax[1];
378 data.param5 = GetCollisionRadius();
379 data.param6 = m_DebugAreaType;
380 data.param7 = m_insiders;
383 PluginDiagMenuServer.SendDataToSubscribersServer(
this, ESubscriberSystems.TRIGGERS,
ERPCs.DIAG_TRIGGER_DEBUG, data,
false);
384 else if (!
GetGame().IsMultiplayer() || m_Local)
385 DebugDmgTrigger(data.param1, data.param2, data.param3, data.param4, data.param5, data.param6, data.param7);
392 CleanupDebugShapes(dbgTargets);
402 vector w_pos, w_pos_sphr, w_pos_lend;
411 m_DebugAreaType = dmgType;
414 switch ( m_DebugAreaType )
420 case "BarbedWireHit":
430 m_dbgInsiders = insiders;
432 if (m_dbgInsiders.Count() > 0)
437 for (
int i = 0; i < m_dbgInsiders.Count(); i++)
442 vector insiderPos = insider_EAI.GetWorldPosition() +
"0 0.1 0";
443 dbgTargets.Insert(
Debug.DrawArrow(w_pos, insiderPos));
461 dbgShape.CreateMatrix(mat);
462 dbgShape.SetMatrix(mat);
475 dbgTargets.Insert(dbgShape);
482 foreach (
Shape shape : shapes)
484 Debug.RemoveShape(shape);