Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PhysicsObserverSystem.c
Go to the documentation of this file.
2{
3 protected ref array<ref Tuple3<IEntity, bool, SCR_PhysicsObserverAttribute>> m_aObservedEntities;
4
5 //------------------------------------------------------------------------------------------------
6 override bool ShouldBePaused()
7 {
8 return true;
9 }
10
11 //------------------------------------------------------------------------------------------------
12 override static void InitInfo(WorldSystemInfo outInfo)
13 {
14 outInfo.SetAbstract(false);
15 outInfo.SetLocation(WorldSystemLocation.Both);
16 outInfo.AddPoint(WorldSystemPoint.Frame);
17 }
18
19 //------------------------------------------------------------------------------------------------
22 {
23 World world = GetGame().GetWorld();
25 return system;
26 }
27
28 //------------------------------------------------------------------------------------------------
32 void RegisterEntity(notnull IEntity ent, InventoryItemComponent iic = null)
33 {
34 Physics phys = ent.GetPhysics();
35 if (!phys)
36 return;
37
40
42 {
43 if (entry && entry.param1 == ent)
44 return;
45 }
46
47 if (!iic)
48 {
49 iic = InventoryItemComponent.Cast(ent.FindComponent(InventoryItemComponent));
50 if (!iic)
51 return;
52 }
53
55 if (!attribute)
56 return;
57
58 m_aObservedEntities.Insert(new Tuple3<IEntity, bool, SCR_PhysicsObserverAttribute>(ent, phys.IsActive(), attribute));
59 if (!IsEnabled())
60 Enable(true);
61 }
62
63 //------------------------------------------------------------------------------------------------
66 void UnregisterEntity(notnull IEntity ent)
67 {
69 return;
70
72 {
73 if (!entry || entry.param1 != ent)
74 continue;
75
76 //Only null the entry to ensure that someone wont try to delete an entry mid update loop
77 m_aObservedEntities[i] = null;
78 return;
79 }
80 }
81
82 //------------------------------------------------------------------------------------------------
83 override protected void OnUpdatePoint(WorldUpdatePointArgs args)
84 {
86 {
87 Enable(false);
88 return;
89 }
90
91 Physics phys;
94 {
95 if (!entry)
96 continue;
97
98 if (!entry.param1)
99 {
100 m_aObservedEntities[i] = null;
101 continue;
102 }
103
104 phys = entry.param1.GetPhysics();
105 if (phys.IsActive() == entry.param2)
106 continue;
107
108 entry.param2 = !entry.param2;
109 attribute = entry.param3;
110 if (attribute)
111 attribute.OnPhysicsStateChanged(entry.param1, entry.param2);
112 else
113 m_aObservedEntities[i] = null;
114 }
115
116 // When update finished looping through then remove null entries
117 m_aObservedEntities.RemoveItem(null);
118 }
119}
ArmaReforgerScripted GetGame()
Definition game.c:1398
static override void InitInfo(WorldSystemInfo outInfo)
static SCR_PhysicsObserverSystem GetInstance()
void UnregisterEntity(notnull IEntity ent)
void OnUpdatePoint(WorldUpdatePointArgs args)
void RegisterEntity(notnull IEntity ent, InventoryItemComponent iic=null)
ref array< ref Tuple3< IEntity, bool, SCR_PhysicsObserverAttribute > > m_aObservedEntities
Definition World.c:16
Structure holding world system meta-information required by the engine.
Structure holding extra data of WorldSystem update point.
int IsEnabled()
Returns true if the light is enabled.
void Tuple3(T1 p1, T2 p2, T3 p3)
Definition tuple.c:95
WorldSystemPoint
WorldSystemLocation