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_MineAwarenessComponent.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted/ScriptWizard"
, description:
""
)]
2
class
SCR_MineAwarenessComponentClass
:
ScriptComponentClass
3
{
4
}
5
6
class
SCR_MineDetectionData
7
{
8
WorldTimestamp
m_fLastTime
;
9
float
m_fTimeElapsed
;
10
}
11
12
class
SCR_MineAwarenessComponent
:
ScriptComponent
13
{
14
protected
ref set<RplId>
m_aDetectedMines
;
15
protected
ref
map<RplId, ref SCR_MineDetectionData>
m_mMineDetection
=
new
map<RplId, ref SCR_MineDetectionData>
();
16
17
//------------------------------------------------------------------------------------------------
19
static
SCR_MineAwarenessComponent
GetLocalInstance
()
20
{
21
PlayerController playerController =
GetGame
().GetPlayerController();
22
if
(!playerController)
23
return
null;
24
25
return
SCR_MineAwarenessComponent
.Cast(playerController.FindComponent(
SCR_MineAwarenessComponent
));
26
}
27
28
//------------------------------------------------------------------------------------------------
32
void
Detect
(
RplId
id
,
bool
instant =
false
)
33
{
34
if
(instant)
35
{
36
m_aDetectedMines
.Insert(
id
);
37
return
;
38
}
39
40
// Only called for mines which are not in m_aDetectedMines
41
if
(!
m_mMineDetection
.Contains(
id
))
42
m_mMineDetection
.Insert(
id
,
new
SCR_MineDetectionData);
43
44
// Check if there is some start time
45
ChimeraWorld
world =
GetOwner
().
GetWorld
();
46
WorldTimestamp
currentTime = world.GetServerTimestamp();
47
SCR_MineDetectionData
data
=
m_mMineDetection
.Get(
id
);
48
if
(
data
.m_fLastTime == 0)
49
data
.m_fLastTime = currentTime;
50
51
float
sinceLastTime = currentTime.DiffMilliseconds(
data
.m_fLastTime);
52
if
(sinceLastTime < 1000)
53
data
.m_fTimeElapsed += sinceLastTime;
54
55
data
.m_fLastTime = currentTime;
56
57
if
(
data
.m_fTimeElapsed > 2000)
58
{
59
m_aDetectedMines
.Insert(
id
);
60
m_mMineDetection
.Remove(
id
);
61
}
62
}
63
64
//------------------------------------------------------------------------------------------------
68
bool
IsDetected
(
IEntity
entity)
69
{
70
RplComponent rplComponent = RplComponent.Cast(entity.
FindComponent
(RplComponent));
71
if
(!rplComponent)
72
return
true
;
// visible by default when entity doesn't have any rpl component
73
74
RplId
id
= rplComponent.Id();
75
bool
isDetected =
m_aDetectedMines
.Contains(
id
);
76
77
if
(!isDetected)
78
Detect
(
id
);
79
80
return
isDetected;
81
}
82
83
//------------------------------------------------------------------------------------------------
84
override
event
protected
void
EOnInit
(
IEntity
owner)
85
{
86
m_aDetectedMines
=
new
set<RplId>();
87
}
88
89
//------------------------------------------------------------------------------------------------
90
override
event
protected
void
OnPostInit
(
IEntity
owner)
91
{
92
SetEventMask
(
GetOwner
(),
EntityEvent
.INIT);
93
}
94
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
data
Get all prefabs that have the spawner data
Definition
SCR_EntityCatalogManagerComponent.c:320
m_fTimeElapsed
float m_fTimeElapsed
Definition
SCR_MineAwarenessComponent.c:9
m_fLastTime
SCR_MineAwarenessComponentClass m_fLastTime
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
ChimeraWorld
Definition
ChimeraWorld.c:13
GenericComponent::SetEventMask
proto external int SetEventMask(notnull IEntity owner, int mask)
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetWorld
proto external BaseWorld GetWorld()
RplId
Replication item identifier.
Definition
RplId.c:14
SCR_MineAwarenessComponentClass
Definition
SCR_MineAwarenessComponent.c:3
SCR_MineAwarenessComponent
Definition
SCR_MineAwarenessComponent.c:13
SCR_MineAwarenessComponent::m_mMineDetection
ref map< RplId, ref SCR_MineDetectionData > m_mMineDetection
Definition
SCR_MineAwarenessComponent.c:15
SCR_MineAwarenessComponent::OnPostInit
void OnPostInit(IEntity owner)
Definition
SCR_MineAwarenessComponent.c:90
SCR_MineAwarenessComponent::EOnInit
void EOnInit(IEntity owner)
Definition
SCR_MineAwarenessComponent.c:84
SCR_MineAwarenessComponent::GetLocalInstance
static SCR_MineAwarenessComponent GetLocalInstance()
Definition
SCR_MineAwarenessComponent.c:19
SCR_MineAwarenessComponent::Detect
void Detect(RplId id, bool instant=false)
Definition
SCR_MineAwarenessComponent.c:32
SCR_MineAwarenessComponent::m_aDetectedMines
ref set< RplId > m_aDetectedMines
Definition
SCR_MineAwarenessComponent.c:14
SCR_MineAwarenessComponent::IsDetected
bool IsDetected(IEntity entity)
Definition
SCR_MineAwarenessComponent.c:68
ScriptComponentClass
Definition
ScriptComponentClass.c:8
ScriptComponent
Definition
ScriptComponent.c:24
ScriptComponent::GetOwner
proto external GenericEntity GetOwner()
Get owner entity.
WorldTimestamp
Definition
WorldTimestamp.c:26
map
Definition
Types.c:486
EntityEvent
EntityEvent
Various entity events.
Definition
EntityEvent.c:14
scripts
Game
Components
Mines
SCR_MineAwarenessComponent.c
Generated by
1.17.0