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_NetworkedStatsComponent.c
Go to the documentation of this file.
1
void
SCR_OnStatChangedMethod
(
SCR_BaseNetworkedStat
changedStat);
2
typedef
func
SCR_OnStatChangedMethod
;
3
typedef
ScriptInvokerBase<SCR_OnStatChangedMethod>
SCR_OnStatChangedInvoker
;
4
5
[
ComponentEditorProps
(
category
:
"GameScripted/Network"
, description:
"Stats Tracker between the Authority and the Proxy"
)]
6
class
SCR_NetworkedStatsComponentClass
:
ScriptComponentClass
7
{
8
protected
ref
SCR_OnStatChangedInvoker
m_OnStatsChanged
;
9
10
//------------------------------------------------------------------------------------------------
13
SCR_OnStatChangedInvoker
GetOnStatsChanged
(
bool
createIfNull =
true
)
14
{
15
if
(!
m_OnStatsChanged
&& createIfNull)
16
m_OnStatsChanged
=
new
SCR_OnStatChangedInvoker
();
17
18
return
m_OnStatsChanged
;
19
}
20
}
21
22
class
SCR_NetworkedStatsComponent :
ScriptComponent
23
{
24
[
Attribute
()]
25
protected
ref array<ref SCR_BaseNetworkedStat> m_aStats;
26
protected
RplComponent
m_RplComponent
;
27
28
[
Attribute
(
"3"
, uiwidget:
UIWidgets
.EditBox,
desc
:
"How many seconds should we wait before checking and updating the stats again?"
)]
29
protected
int
m_iUpdateTimer
;
30
31
//------------------------------------------------------------------------------------------------
34
SCR_BaseNetworkedStat
GetNetworkedStat
(
SCR_ENetworkedStatType
statType)
35
{
36
foreach
(
SCR_BaseNetworkedStat
stat : m_aStats)
37
{
38
if
(stat.GetStatType() == statType)
39
return
stat;
40
}
41
42
return
null;
43
}
44
45
//------------------------------------------------------------------------------------------------
47
SCR_NetworkedStatsComponentClass
GetNetworkedStatPrefabData
()
48
{
49
return
SCR_NetworkedStatsComponentClass
.Cast(
GetOwner
().FindComponentData(
SCR_NetworkedStatsComponentClass
));
50
}
51
52
//------------------------------------------------------------------------------------------------
54
RplComponent
GetRplComponent
()
55
{
56
return
m_RplComponent
;
57
}
58
59
//------------------------------------------------------------------------------------------------
62
void
SetAuthorityStatValue
(
SCR_ENetworkedStatType
statType,
int
valueInt)
63
{
64
if
(
m_RplComponent
.IsProxy())
65
return
;
66
67
Rpc
(
SetStatValueOfAuthority
, statType, valueInt);
68
}
69
70
//------------------------------------------------------------------------------------------------
73
[
RplRpc
(
RplChannel
.Unreliable,
RplRcver
.Broadcast)]
74
void
SetStatValueOfAuthority
(
SCR_ENetworkedStatType
statType,
int
value)
75
{
76
SCR_BaseNetworkedStat
networkedStat =
GetNetworkedStat
(statType);
77
if
(!networkedStat)
78
return
;
79
80
networkedStat.
OnAuthorityStatValueSet
(value);
81
}
82
83
//------------------------------------------------------------------------------------------------
85
void
UpdateStats
()
86
{
87
foreach
(
SCR_BaseNetworkedStat
stat : m_aStats)
88
{
89
stat.UpdateStat();
90
}
91
}
92
93
//------------------------------------------------------------------------------------------------
94
override
void
EOnInit
(
IEntity
owner)
95
{
96
#ifdef WORKBENCH
97
if
(
SCR_Global
.
IsEditMode
())
98
return
;
99
#endif
100
101
m_RplComponent
= RplComponent.Cast(owner.
FindComponent
(RplComponent));
102
// For continuously updating stats. As the tick intervals are huge, EOnUpdate is a serious overkill and not needed.
103
GetGame
().GetCallqueue().CallLater(
UpdateStats
,
m_iUpdateTimer
* 1000,
true
);
104
105
foreach
(
SCR_BaseNetworkedStat
networkedStat : m_aStats)
106
{
107
networkedStat.SetOwner(
this
);
108
}
109
}
110
111
//------------------------------------------------------------------------------------------------
112
override
void
OnPostInit
(
IEntity
owner)
113
{
114
SetEventMask
(owner,
EntityEvent
.INIT);
115
}
116
117
//------------------------------------------------------------------------------------------------
118
override
void
OnDelete
(
IEntity
owner)
119
{
120
GetGame
().GetCallqueue().Remove(
UpdateStats
);
121
}
122
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
ComponentEditorProps
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
Definition
SCR_AIGroupUtilityComponent.c:12
func
func
Definition
SCR_AIThreatSystem.c:6
m_RplComponent
RplComponent m_RplComponent
Definition
SCR_CampaignBuildingManagerComponent.c:64
SCR_ENetworkedStatType
SCR_ENetworkedStatType
Definition
SCR_NetworkedStatTypes.c:2
SCR_OnStatChangedMethod
func SCR_OnStatChangedMethod
Definition
SCR_NetworkedStatsComponent.c:2
SetStatValueOfAuthority
void SetStatValueOfAuthority(SCR_ENetworkedStatType statType, int value)
Definition
SCR_NetworkedStatsComponent.c:74
GetNetworkedStat
SCR_BaseNetworkedStat GetNetworkedStat(SCR_ENetworkedStatType statType)
Definition
SCR_NetworkedStatsComponent.c:34
UpdateStats
void UpdateStats()
Definition
SCR_NetworkedStatsComponent.c:85
m_iUpdateTimer
int m_iUpdateTimer
Definition
SCR_NetworkedStatsComponent.c:29
GetNetworkedStatPrefabData
SCR_NetworkedStatsComponentClass GetNetworkedStatPrefabData()
Definition
SCR_NetworkedStatsComponent.c:47
SetAuthorityStatValue
void SetAuthorityStatValue(SCR_ENetworkedStatType statType, int valueInt)
Definition
SCR_NetworkedStatsComponent.c:62
SCR_OnStatChangedInvoker
ScriptInvokerBase< SCR_OnStatChangedMethod > SCR_OnStatChangedInvoker
Definition
SCR_NetworkedStatsComponent.c:3
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
GenericComponent::SetEventMask
proto external int SetEventMask(notnull IEntity owner, int mask)
GenericComponent::Rpc
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
SCR_BaseNetworkedStat
Definition
SCR_BaseNetworkedStat.c:3
SCR_BaseNetworkedStat::OnAuthorityStatValueSet
void OnAuthorityStatValueSet(int value)
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
SCR_NetworkedStatsComponentClass
Definition
SCR_NetworkedStatsComponent.c:7
SCR_NetworkedStatsComponentClass::m_OnStatsChanged
ref SCR_OnStatChangedInvoker m_OnStatsChanged
Definition
SCR_NetworkedStatsComponent.c:8
SCR_NetworkedStatsComponentClass::GetOnStatsChanged
SCR_OnStatChangedInvoker GetOnStatsChanged(bool createIfNull=true)
Definition
SCR_NetworkedStatsComponent.c:13
ScriptComponentClass
Definition
ScriptComponentClass.c:8
ScriptComponent
Definition
ScriptComponent.c:24
ScriptComponent::GetOwner
proto external GenericEntity GetOwner()
Get owner entity.
ScriptComponent::EOnInit
void EOnInit(IEntity owner)
UIWidgets
Definition
attributes.c:40
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
GetRplComponent
RplComponent GetRplComponent()
Returns the replication component associated to this entity.
Definition
SCR_RespawnComponent.c:188
EntityEvent
EntityEvent
Various entity events.
Definition
EntityEvent.c:14
RplRpc
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition
EnNetwork.c:95
RplRcver
RplRcver
Definition
RplRcver.c:59
RplChannel
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition
RplChannel.c:14
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
OnDelete
@ OnDelete
Definition
SndComponentCallbacks.c:16
scripts
Game
Network
NetworkedStats
Components
SCR_NetworkedStatsComponent.c
Generated by
1.17.0