Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_PhysicsObserverSystem.c
Go to the documentation of this file.
1
class
SCR_PhysicsObserverSystem
:
GameSystem
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
//------------------------------------------------------------------------------------------------
21
static
SCR_PhysicsObserverSystem
GetInstance
()
22
{
23
World
world =
GetGame
().GetWorld();
24
SCR_PhysicsObserverSystem
system =
SCR_PhysicsObserverSystem
.Cast(world.FindSystem(
SCR_PhysicsObserverSystem
));
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
38
if
(!
m_aObservedEntities
)
39
m_aObservedEntities
= {};
40
41
foreach
(
Tuple3<IEntity, bool, SCR_PhysicsObserverAttribute>
entry :
m_aObservedEntities
)
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
54
SCR_PhysicsObserverAttribute
attribute =
SCR_PhysicsObserverAttribute
.Cast(iic.FindAttribute(
SCR_PhysicsObserverAttribute
));
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
{
68
if
(!
m_aObservedEntities
||
m_aObservedEntities
.IsEmpty())
69
return
;
70
71
foreach
(
int
i,
Tuple3<IEntity, bool, SCR_PhysicsObserverAttribute>
entry :
m_aObservedEntities
)
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
{
85
if
(!
m_aObservedEntities
||
m_aObservedEntities
.IsEmpty())
86
{
87
Enable(
false
);
88
return
;
89
}
90
91
Physics
phys;
92
SCR_PhysicsObserverAttribute
attribute;
93
foreach
(
int
i,
Tuple3<IEntity, bool, SCR_PhysicsObserverAttribute>
entry :
m_aObservedEntities
)
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
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GameSystem
Definition
GameSystem.c:16
IEntity
Definition
IEntity.c:13
InventoryItemComponent
Definition
InventoryItemComponent.c:13
Physics
Definition
Physics.c:22
SCR_PhysicsObserverAttribute
Definition
SCR_PhysicsObserverAttribute.c:2
SCR_PhysicsObserverSystem
Definition
SCR_PhysicsObserverSystem.c:2
SCR_PhysicsObserverSystem::InitInfo
static override void InitInfo(WorldSystemInfo outInfo)
Definition
SCR_PhysicsObserverSystem.c:12
SCR_PhysicsObserverSystem::GetInstance
static SCR_PhysicsObserverSystem GetInstance()
Definition
SCR_PhysicsObserverSystem.c:21
SCR_PhysicsObserverSystem::UnregisterEntity
void UnregisterEntity(notnull IEntity ent)
Definition
SCR_PhysicsObserverSystem.c:66
SCR_PhysicsObserverSystem::OnUpdatePoint
void OnUpdatePoint(WorldUpdatePointArgs args)
Definition
SCR_PhysicsObserverSystem.c:83
SCR_PhysicsObserverSystem::RegisterEntity
void RegisterEntity(notnull IEntity ent, InventoryItemComponent iic=null)
Definition
SCR_PhysicsObserverSystem.c:32
SCR_PhysicsObserverSystem::ShouldBePaused
override bool ShouldBePaused()
Definition
SCR_PhysicsObserverSystem.c:6
SCR_PhysicsObserverSystem::m_aObservedEntities
ref array< ref Tuple3< IEntity, bool, SCR_PhysicsObserverAttribute > > m_aObservedEntities
Definition
SCR_PhysicsObserverSystem.c:3
World
Definition
World.c:16
WorldSystemInfo
Structure holding world system meta-information required by the engine.
Definition
WorldSystemInfo.c:14
WorldUpdatePointArgs
Structure holding extra data of WorldSystem update point.
Definition
WorldUpdatePointArgs.c:14
IsEnabled
int IsEnabled()
Returns true if the light is enabled.
Definition
SCR_BaseManualCameraComponent.c:239
Tuple3
void Tuple3(T1 p1, T2 p2, T3 p3)
Definition
tuple.c:95
WorldSystemPoint
WorldSystemPoint
Definition
WorldSystemPoint.c:13
WorldSystemLocation
WorldSystemLocation
Definition
WorldSystemLocation.c:13
scripts
Game
Systems
SCR_PhysicsObserverSystem.c
Generated by
1.17.0