cylindertrigger.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //! Trigger with cylinder shape
  2. class CylinderTrigger : Trigger
  3. {
  4. override void EOnInit(IEntity other, int extra)
  5. {
  6. SetCollisionCylinderTwoWay(1, -0.25, 0.25);
  7. }
  8. #ifdef DIAG_DEVELOPER
  9. override void DebugSendDmgTrigger()
  10. {
  11. vector minmax[2];
  12. GetCollisionBox(minmax);
  13. DebugTriggerInfo data = new DebugTriggerInfo(vector.Zero, vector.Zero, vector.Zero, vector.Zero, 0, "", null);
  14. data.param1 = GetPosition();
  15. data.param2 = GetOrientation();
  16. data.param3 = minmax[0];
  17. data.param4 = minmax[1];
  18. data.param5 = GetCollisionRadius();
  19. data.param6 = m_DebugAreaType;
  20. data.param7 = m_insiders;
  21. if (GetGame().IsMultiplayer() && GetGame().IsServer())
  22. PluginDiagMenuServer.SendDataToSubscribersServer(this, ESubscriberSystems.TRIGGERS, ERPCs.DIAG_TRIGGER_DEBUG, data, false);
  23. else if (!GetGame().IsMultiplayer() || m_Local)
  24. DebugDmgTrigger(data.param1, data.param2, data.param3, data.param4, data.param5, data.param6, data.param7);
  25. }
  26. override protected Shape DrawDebugShape(vector pos, vector min, vector max, float radius, int color)
  27. {
  28. //! min/max taken from bbox (which goes from center to top of the cylinder only; min is always negative)
  29. float triggerHeight = (max[1] - min[1]);
  30. Shape dbgShape = Debug.DrawCylinder(pos, radius, triggerHeight, color, ShapeFlags.TRANSP|ShapeFlags.NOZWRITE|ShapeFlags.DOUBLESIDE);
  31. dbgShape.SetPosition(pos);
  32. dbgTargets.Insert(dbgShape);
  33. return dbgShape;
  34. }
  35. #endif
  36. }