Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
WorldSystemsDocs.c
Go to the documentation of this file.
1
2#ifdef DOXYGEN
3
5class HelloWorldSystem : WorldSystem // 1.
6{
7 override static void InitInfo(WorldSystemInfo outInfo) // 2.
8 {
9 outInfo.SetAbstract(false); // 3.
10 }
11
12 void HelloWorldSystem()
13 {
14 Print("Hello world (systems)");
15 }
16}
18
20modded class HelloWorldSystem
21{
23 override static void InitInfo(WorldSystemInfo outInfo)
24 {
25 super.InitInfo(outInfo); // 1.
26 outInfo.AddPoint(WorldSystemPoint.Frame); // 2.
27 }
29
30 private int m_FrameCount = 0;
31
32 override void OnUpdatePoint(WorldUpdatePointArgs args)
33 {
34 if (args.GetPoint() == WorldSystemPoint.Frame)
35 {
36 int frameIndex = m_FrameCount;
37 PrintFormat("Hello world (systems) frame %1", frameIndex);
38
39 m_FrameCount += 1;
40
41 // Stop when we've done 10 frame updates (printed frame numbers from 0 to 9).
42 if (m_FrameCount == 10)
43 this.Enable(false);
44 }
45 }
46}
48
50class MultiPointSystem : WorldSystem
51{
52 override static void InitInfo(WorldSystemInfo outInfo)
53 {
54 outInfo
55 .SetAbstract(false)
56 // 1.
57 .AddPoint(WorldSystemPoint.Frame)
58 .AddPoint(WorldSystemPoint.FixedFrame)
59 .AddPoint(WorldSystemPoint.SimulatePhysics)
60 // 2.
61 .AddExecuteBefore(HelloWorldSystem, WorldSystemPoint.Frame);
62 }
63
64 private int m_FrameCount = 0;
65 private int m_FixedFrameCount = 0;
66 private int m_SimulatePhysicsCount = 0;
67
68 override void OnUpdatePoint(WorldUpdatePointArgs args)
69 {
70 switch (args.GetPoint())
71 {
72 case WorldSystemPoint.Frame:
73 PrintFormat("MultiPointSystem Frame %1", m_FrameCount);
74 m_FrameCount += 1;
75 break;
76 case WorldSystemPoint.FixedFrame:
77 PrintFormat("MultiPointSystem FixedFrame %1", m_FixedFrameCount);
78 m_FixedFrameCount += 1;
79 break;
80 case WorldSystemPoint.SimulatePhysics:
81 PrintFormat("MultiPointSystem SimulatePhysics %1", m_SimulatePhysicsCount);
82 m_SimulatePhysicsCount += 1;
83 break;
84 }
85
86 int total = m_FrameCount + m_FixedFrameCount + m_SimulatePhysicsCount;
87 if (total >= 100)
88 this.Enable(false);
89 }
90}
92
94class ConfigurableSystem : WorldSystem
95{
96 override static void InitInfo(WorldSystemInfo outInfo)
97 {
98 outInfo.SetAbstract(false);
99 }
100
101 [Attribute(defvalue: "2")] // 2.
102 private int m_ConfigInt; // 1.
103
104 void ConfigurableSystem()
105 {
106 PrintFormat("ConfigurableSystem.ctor m_ConfigInt = %1", m_ConfigInt); // 3.
107 }
108}
110
112class GameMode : WorldSystem
113{
114 override static void InitInfo(WorldSystemInfo outInfo)
115 {
116 // 1.
117 outInfo
118 .SetAbstract(true)
119 .SetUnique(true);
120 }
121
122 // 2.
123 override protected void OnInit()
124 {
125 Print("GameMode.OnInit()");
126 }
127
128 // 3.
129 void Notify();
130}
131
132class DeathmatchMode : GameMode
133{
134 override static void InitInfo(WorldSystemInfo outInfo)
135 {
136 // 1.
137 outInfo.SetAbstract(false);
138 }
139
140 // 2.
141 override protected void OnInit()
142 {
143 Print("DeathmatchMode.OnInit()");
144 }
145
146 // 3.
147 override void Notify()
148 {
149 Print("DeathmatchMode.Notify()");
150 }
151}
152
153class TeamDeathmatchMode : GameMode
154{
155 override static void InitInfo(WorldSystemInfo outInfo)
156 {
157 // 1.
158 outInfo.SetAbstract(false);
159 }
160
161 // 2.
162 override protected void OnInit()
163 {
164 Print("TeamDeathmatchMode.OnInit()");
165 }
166
167 // 3.
168 override void Notify()
169 {
170 Print("TeamDeathmatchMode.Notify()");
171 }
172}
174
175
177class PlayerNameInputSystem : WorldSystem // 1.
178{
179 override static void InitInfo(WorldSystemInfo outInfo)
180 {
181 // 2.
182 outInfo
183 .SetAbstract(false)
184 .SetLocation(WorldSystemLocation.Client)
185 .AddPoint(WorldSystemPoint.Frame)
186 .AddController(PlayerNameInputController);
187 }
188
189 override void OnUpdatePoint(WorldUpdatePointArgs args)
190 {
191 string playerName;
192 bool apply = false;
193
194 // Display DbgUI window which allows player to change their name.
195 DbgUI.Begin("Player name input");
196 DbgUI.InputText("name", playerName);
197 apply = DbgUI.Button("Apply");
198 DbgUI.End();
199
200 if (apply)
201 {
202 // 4.
203 auto controller = PlayerNameInputController.Cast(
204 GetSystems().FindMyController(PlayerNameInputController)
205 );
206 controller.RequestNameChange(playerName);
207 }
208 }
209}
210
211class PlayerNameInputController : WorldController // 1.
212{
213 override static void InitInfo(WorldControllerInfo outInfo)
214 {
215 // 3.
216 outInfo.SetPublic(true);
217 }
218
219 [RplProp(onRplName: "OnPlayerNameChanged")]
220 string m_PlayerName;
221
222 void RequestNameChange(string newPlayerName)
223 {
224 Rpc(Rpc_NameChange_S, newPlayerName);
225 }
226
227 [RplRpc(RplChannel.Reliable, RplRcver.Server)]
228 private void Rpc_NameChange_S(string newPlayerName)
229 {
230 if (m_PlayerName == newPlayerName)
231 return;
232
233 m_PlayerName = newPlayerName;
234 Replication.BumpMe();
235 // We invoke callback explicitly on server. On clients, it will be invoked
236 // automatically when replication changes m_PlayerName value.
237 this.OnPlayerNameChanged();
238 }
239
240 private void OnPlayerNameChanged()
241 {
242 PlayerId ownerPlayerId = this.GetOwnerPlayerId();
243 // This message will appear on server and all clients.
244 PrintFormat("Player %1 name '%2'", ownerPlayerId, m_PlayerName);
245 }
246}
247
249
251modded class PlayerNameInputController
252{
253 override protected void OnAuthorityReady()
254 {
255 Print("PlayerNameInputController.OnAuthorityReady()");
256 }
257
258 private bool RplGiven(ScriptBitReader reader)
259 {
260 Print("PlayerNameInputController.RplGiven()");
261 return true;
262 }
263}
265
266#endif
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
void Enable(bool enable)
void OnAuthorityReady()
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)
void OnInit()
void OnUpdatePoint(WorldUpdatePointArgs args)
Called at specific points during World update.
int PlayerId
Definition gameLib.c:1
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
WorldSystemPoint
WorldSystemLocation