Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PressureTriggerComponent.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/ScriptWizard", description: "")]
3{
4 [Attribute("10", desc: "Min. weight that can set off this trigger when applied to it. [kg]")]
5 protected float m_fMinWeight;
6
7 //------------------------------------------------------------------------------------------------
9 {
10 return m_fMinWeight;
11 }
12}
13
14class SCR_PressureTriggerComponent : SCR_BaseTriggerComponent
15{
16 protected const float MIN_DELAY = 125; //time between explosion tries in ms
17 protected float m_fLastTryTime = 0;
18
19 //------------------------------------------------------------------------------------------------
20 override void EOnContact(IEntity owner, IEntity other, Contact contact)
21 {
22 if (GetGame().GetWorld().GetWorldTime() - m_fLastTryTime < MIN_DELAY)
23 return;
24
25 Physics otherPhysics = other.GetPhysics();
26 if (!otherPhysics)
27 return;
28
29 float otherMass = otherPhysics.GetMass();
30
31 Vehicle vehicle = Vehicle.Cast(other);
32 if (vehicle)
33 {
34 VehicleWheeledSimulation vehicleSimulation = VehicleWheeledSimulation.Cast(vehicle.FindComponent(VehicleWheeledSimulation));
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
42 if (!data)
43 return;
44
45 if (otherMass < data.GetMinWeight())
46 return; // Too light, won't set the trigger off
47
48 BaseTriggerComponent baseTriggerComponent = BaseTriggerComponent.Cast(GetOwner().FindComponent(BaseTriggerComponent));
49 if (!baseTriggerComponent)
50 return;
51
52 GetGame().GetCallqueue().CallLater(RPC_DoTrigger); // Delay it to next frame, cannot delete entity in EOnContact
53 Rpc(RPC_DoTrigger);
54 }
55
56 //------------------------------------------------------------------------------------------------
59 {
60 //~ Delay it to next frame, cannot trigger entity at the same time as Rpc
61 GetGame().GetCallqueue().CallLater(RPC_DoTrigger);
62 Rpc(RPC_DoTrigger);
63 }
64
65 //------------------------------------------------------------------------------------------------
67 override void ActivateTrigger()
68 {
69 super.ActivateTrigger();
70
71 IEntity owner = GetOwner();
72 RplComponent rplComponent = SCR_EntityHelper.GetEntityRplComponent(owner);
73 if (!rplComponent || rplComponent.IsProxy())
74 return;
75
76 const float armingDelay = GetArmingTime() * 1000.0; //in ms
77 if (armingDelay != 0)
78 m_fLastTryTime = GetGame().GetWorld().GetWorldTime() + armingDelay;
79
80 SetEventMask(owner, EntityEvent.CONTACT);
81 }
82
83 //------------------------------------------------------------------------------------------------
87 {
89 }
90
91 //------------------------------------------------------------------------------------------------
93 override void DisarmTrigger()
94 {
95 HideFuse();
96 GetInstigator().SetInstigator(null);
97
98 IEntity owner = GetOwner();
99 RplComponent rplComponent = SCR_EntityHelper.GetEntityRplComponent(owner);
100 if (!rplComponent || rplComponent.IsProxy())
101 return;
102
103 ClearEventMask(owner, EntityEvent.CONTACT);
104 super.DisarmTrigger();
105 }
106
107 //------------------------------------------------------------------------------------------------
109 override void OnActivatedChanged()
110 {
111 super.OnActivatedChanged();
112
114 if (!data)
115 return;
116
117 if (!m_bActivated)
118 HideFuse();
119 }
120
121 //------------------------------------------------------------------------------------------------
123 void HideFuse()
124 {
125 IEntity owner = GetOwner();
126 int meshIndex = GameAnimationUtils.FindMeshIndex(owner, m_sFuzeMeshName);
127 if (meshIndex == -1)
128 return;
129
130 GameAnimationUtils.ShowMesh(owner, meshIndex, false);
131 }
132
133 //------------------------------------------------------------------------------------------------
134 override protected void EOnInit(IEntity owner)
135 {
136 if (m_bLive)
138 }
139}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void ActivateTrigger()
void RPC_DoTrigger()
void DisarmTrigger()
void OnActivatedChanged()
Method called on the clients, the item should be outside inventory already.
void SCR_BaseTriggerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_CharacterSoundComponentClass GetComponentData()
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Get all prefabs that have the spawner data
override void EOnContact(IEntity owner, IEntity other, Contact contact)
SCR_PressureTriggerComponentClass MIN_DELAY
void TriggerManuallyServer()
Manually trigger the entity (Server Only).
void ResetTimeout()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Physics GetPhysics()
static RplComponent GetEntityRplComponent(notnull IEntity entity)
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
BaseProjectileComponentClass GameComponentClass GetInstigator()