Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_PressureTriggerComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/ScriptWizard", description: "")]
3 {
4 }
5 
6 class SCR_PressureTriggerComponent : SCR_BaseTriggerComponent
7 {
8  protected const float MIN_DELAY = 125; //time between explosion tries in ms
9  protected float m_fLastTryTime = 0;
10 
11  [Attribute("10", desc: "Min. weight that can set off this trigger when applied to it. [kg]")]
12  protected float m_fMinWeight;
13 
14  //------------------------------------------------------------------------------------------------
15  override void EOnContact(IEntity owner, IEntity other, Contact contact)
16  {
17  if (GetGame().GetWorld().GetWorldTime() - m_fLastTryTime < MIN_DELAY)
18  return;
19 
20  Physics otherPhysics = other.GetPhysics();
21  if (!otherPhysics)
22  return;
23 
24  float otherMass = otherPhysics.GetMass();
25 
27  {
28  VehicleWheeledSimulation vehicleSimulation = VehicleWheeledSimulation.Cast(other.FindComponent(VehicleWheeledSimulation));
29  if (vehicleSimulation)
30  otherMass /= vehicleSimulation.WheelCount(); // assume it's a vehicle and assume min. weight it lays on the trigger is weight / wheels count
31  }
32  else
33  {
34  VehicleWheeledSimulation_SA vehicleSimulation = VehicleWheeledSimulation_SA.Cast(other.FindComponent(VehicleWheeledSimulation_SA));
35  if (vehicleSimulation)
36  otherMass /= vehicleSimulation.WheelCount(); // assume it's a vehicle and assume min. weight it lays on the trigger is weight / wheels count
37  }
38 
39  m_fLastTryTime = GetGame().GetWorld().GetWorldTime();
40 
41  if (otherMass < m_fMinWeight)
42  return; // Too light, won't set the trigger off
43 
44  BaseTriggerComponent baseTriggerComponent = BaseTriggerComponent.Cast(GetOwner().FindComponent(BaseTriggerComponent));
45  if (!baseTriggerComponent)
46  return;
47 
48  GetGame().GetCallqueue().CallLater(RPC_DoTrigger); // Delay it to next frame, cannot delete entity in EOnContact
49  Rpc(RPC_DoTrigger);
50  }
51 
52  //------------------------------------------------------------------------------------------------
55  {
56  //~ Delay it to next frame, cannot trigger entity at the same time as Rpc
57  GetGame().GetCallqueue().CallLater(RPC_DoTrigger);
58  Rpc(RPC_DoTrigger);
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  // Only call this on the server
63  override void ActivateTrigger()
64  {
65  super.ActivateTrigger();
66 
67  GenericEntity owner = GenericEntity.Cast(GetOwner());
68  RplComponent rplComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
69  if (!rplComponent || rplComponent.IsProxy())
70  return;
71 
72  SetEventMask(owner, EntityEvent.CONTACT);
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  override event protected void EOnInit(IEntity owner)
77  {
78  if (m_bLive)
79  ActivateTrigger(); // Using call later to avoid accessing uninitialized components
80  }
81 }
BaseTriggerComponent
Definition: BaseTriggerComponent.c:12
EOnContact
override void EOnContact(IEntity owner, IEntity other, Contact contact)
Definition: SCR_PressureTriggerComponent.c:15
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
m_fLastTryTime
protected float m_fLastTryTime
Definition: SCR_PressureTriggerComponent.c:9
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
RPC_DoTrigger
void RPC_DoTrigger()
Definition: SCR_BaseTriggerComponent.c:78
SCR_PressureTriggerComponentClass
Definition: SCR_PressureTriggerComponent.c:2
GetIsClientAuthority
override bool GetIsClientAuthority()
Definition: game.c:268
Attribute
typedef Attribute
Post-process effect of scripted camera.
ActivateTrigger
override void ActivateTrigger()
Definition: SCR_PressureTriggerComponent.c:63
SCR_BaseTriggerComponent
void SCR_BaseTriggerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_BaseTriggerComponent.c:99
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
TriggerManuallyServer
void TriggerManuallyServer()
Manually trigger the entity (Server Only)
Definition: SCR_PressureTriggerComponent.c:54
SCR_BaseTriggerComponentClass
Definition: SCR_BaseTriggerComponent.c:2
EOnInit
override event protected void EOnInit(IEntity owner)
Initialise this component with data from FactionsManager.
Definition: SCR_PressureTriggerComponent.c:76
m_fMinWeight
protected float m_fMinWeight
Definition: SCR_PressureTriggerComponent.c:12
MIN_DELAY
SCR_PressureTriggerComponentClass MIN_DELAY
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180