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_ResourceSystem.c
Go to the documentation of this file.
1
class
SCR_ResourceSystem
:
GameSystem
2
{
3
override
static
void
InitInfo(
WorldSystemInfo
outInfo)
4
{
5
outInfo
6
.SetAbstract(
false
)
7
.SetUnique(
true
);
8
}
9
10
static
const
int
SUBSCRIBED_INTERACTORS_MAX_FRAME_BUDGET = 10;
11
static
const
int
CONTAINERS_MAX_FRAME_BUDGET = 10;
12
13
protected
int
m_iSubscribedInteractorsPivot
;
14
protected
int
m_iContainersPivot
;
15
16
protected
ref array<SCR_ResourceInteractor>
m_aSubscribedInteractors
= {};
17
protected
ref array<SCR_ResourceContainer>
m_aContainers
= {};
18
protected
SCR_ResourceSystemSubscriptionManager
m_ResourceSystemSubscriptionManager
;
19
protected
ref
SCR_ResourceGrid
m_ResourceGrid
;
20
21
//------------------------------------------------------------------------------------------------
22
bool
IsRegistered
(notnull
SCR_ResourceContainer
container)
23
{
24
return
m_aContainers
.Contains(container);
25
}
26
27
//------------------------------------------------------------------------------------------------
28
override
protected
void
OnUpdatePoint
(
WorldUpdatePointArgs
args)
29
{
30
if
(args.GetPoint() !=
ESystemPoint
.FixedFrame)
31
return
;
32
33
// 1. Cleanup and setup.
34
m_aContainers
.RemoveItem(null);
35
m_aSubscribedInteractors
.RemoveItem(null);
36
m_ResourceSystemSubscriptionManager
.ProcessGracefulHandles();
37
m_ResourceGrid
.ProcessFlaggedItems();
38
m_ResourceGrid
.ResetFrameBudget();
39
40
// 2. Update.
41
m_ResourceGrid
.Update();
42
43
for
(
int
i = 0; i <
SCR_ResourceSystem
.CONTAINERS_MAX_FRAME_BUDGET && !
m_aContainers
.IsEmpty(); ++i)
44
{
45
m_aContainers
[
m_iContainersPivot
++ %
m_aContainers
.Count()].Update(GetWorld().GetTimestamp());
46
}
47
48
49
for
(
int
i = 0; i <
SCR_ResourceSystem
.SUBSCRIBED_INTERACTORS_MAX_FRAME_BUDGET && !
m_aSubscribedInteractors
.IsEmpty(); ++i)
50
{
51
m_ResourceGrid
.UpdateInteractor(
m_aSubscribedInteractors
[
m_iSubscribedInteractorsPivot
++ %
m_aSubscribedInteractors
.Count()],
true
);
52
53
if
(
m_ResourceGrid
.GetFrameBudget() <= 0)
54
break
;
55
}
56
57
// 3. Replicate.
58
m_ResourceSystemSubscriptionManager
.ReplicateListeners();
59
}
60
61
//------------------------------------------------------------------------------------------------
62
override
protected
void
OnDiag
(
float
timeSlice)
63
{
64
DbgUI
.Begin(
ClassName
());
65
DbgUI
.Text(
"Containers: "
+
m_aContainers
.Count());
66
DbgUI
.Text(
"Subscribed interactors: "
+
m_aSubscribedInteractors
.Count());
67
68
if
(
DbgUI
.Button(
"Dump active components"
))
69
{
70
foreach
(
SCR_ResourceContainer
container :
m_aContainers
)
71
{
72
Print
(container.GetOwner(),
LogLevel
.ERROR);
73
}
74
75
foreach
(SCR_ResourceInteractor interactor :
m_aSubscribedInteractors
)
76
{
77
Print
(interactor.GetOwner(),
LogLevel
.ERROR);
78
}
79
}
80
81
DbgUI
.End();
82
}
83
84
//------------------------------------------------------------------------------------------------
85
void
RegisterContainer
(notnull
SCR_ResourceContainer
container)
86
{
87
const
RplComponent rplComponent = container.GetComponent().GetReplicationComponent();
88
89
if
(rplComponent.Role() !=
RplRole
.Authority ||
m_aContainers
.Contains(container))
90
return
;
91
92
container.SetLastUpdateTimestamp(GetWorld().GetTimestamp());
93
m_aContainers
.Insert(container);
94
}
95
96
//------------------------------------------------------------------------------------------------
97
void
RegisterSubscribedInteractor
(notnull SCR_ResourceInteractor interactor)
98
{
99
if
(!
m_aSubscribedInteractors
.Contains(interactor))
100
m_aSubscribedInteractors
.Insert(interactor);
101
}
102
103
//------------------------------------------------------------------------------------------------
104
void
UnregisterContainer
(notnull
SCR_ResourceContainer
container)
105
{
106
m_aContainers
.RemoveItem(container);
107
}
108
109
//------------------------------------------------------------------------------------------------
110
void
UnregisterSubscribedInteractor
(notnull SCR_ResourceInteractor interactor)
111
{
112
m_aSubscribedInteractors
.RemoveItem(interactor);
113
}
114
115
//------------------------------------------------------------------------------------------------
116
override
event
protected
void
OnStarted
()
117
{
118
m_ResourceGrid
=
GetGame
().GetResourceGrid();
119
m_ResourceSystemSubscriptionManager
=
GetGame
().GetResourceSystemSubscriptionManager();
120
121
}
122
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
ClassName
proto native owned external string ClassName()
DbgUI
Definition
DbgUI.c:66
GameSystem
Definition
GameSystem.c:16
SCR_ResourceContainer
Definition
SCR_ResourceContainer.c:35
SCR_ResourceGrid
Definition
SCR_ResourceGrid.c:2
SCR_ResourceSystem
Definition
SCR_ResourceSystem.c:2
SCR_ResourceSystem::m_aContainers
ref array< SCR_ResourceContainer > m_aContainers
Definition
SCR_ResourceSystem.c:17
SCR_ResourceSystem::OnUpdatePoint
void OnUpdatePoint(WorldUpdatePointArgs args)
Definition
SCR_ResourceSystem.c:28
SCR_ResourceSystem::UnregisterContainer
void UnregisterContainer(notnull SCR_ResourceContainer container)
Definition
SCR_ResourceSystem.c:104
SCR_ResourceSystem::m_iContainersPivot
int m_iContainersPivot
Definition
SCR_ResourceSystem.c:14
SCR_ResourceSystem::UnregisterSubscribedInteractor
void UnregisterSubscribedInteractor(notnull SCR_ResourceInteractor interactor)
Definition
SCR_ResourceSystem.c:110
SCR_ResourceSystem::OnStarted
void OnStarted()
Definition
SCR_ResourceSystem.c:116
SCR_ResourceSystem::m_iSubscribedInteractorsPivot
int m_iSubscribedInteractorsPivot
Definition
SCR_ResourceSystem.c:13
SCR_ResourceSystem::m_aSubscribedInteractors
ref array< SCR_ResourceInteractor > m_aSubscribedInteractors
Definition
SCR_ResourceSystem.c:16
SCR_ResourceSystem::RegisterContainer
void RegisterContainer(notnull SCR_ResourceContainer container)
Definition
SCR_ResourceSystem.c:85
SCR_ResourceSystem::RegisterSubscribedInteractor
void RegisterSubscribedInteractor(notnull SCR_ResourceInteractor interactor)
Definition
SCR_ResourceSystem.c:97
SCR_ResourceSystem::m_ResourceGrid
ref SCR_ResourceGrid m_ResourceGrid
Definition
SCR_ResourceSystem.c:19
SCR_ResourceSystem::OnDiag
void OnDiag(float timeSlice)
Definition
SCR_ResourceSystem.c:62
SCR_ResourceSystem::m_ResourceSystemSubscriptionManager
SCR_ResourceSystemSubscriptionManager m_ResourceSystemSubscriptionManager
Definition
SCR_ResourceSystem.c:18
SCR_ResourceSystem::IsRegistered
bool IsRegistered(notnull SCR_ResourceContainer container)
Definition
SCR_ResourceSystem.c:22
SCR_ResourceSystemSubscriptionManager
Definition
SCR_ResourceSystemSubscriptionManager.c:2
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
ESystemPoint
WorldSystemPoint ESystemPoint
Definition
gameLib.c:7
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
RplRole
RplRole
Role of replicated node (and all items in it) within the replication system.
Definition
RplRole.c:14
scripts
Game
Systems
SCR_ResourceSystem.c
Generated by
1.17.0