DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
BunkerBroadcastComponent.c
См. документацию.
2{
3 protected bool m_IsActive;
4 protected string m_LockCode;
5 protected vector m_Position;
6 protected int m_Id;
7
9 protected EntityAI m_Parent;
16
18 {
19 m_Parent = parent;
20 }
21
22 void Init()
23 {
24 if (g_Game.IsServer())
25 {
28
29 m_Position = m_Parent.GetWorldPosition();
30
32 m_Id = m_Position.ToString().Hash();
33
35 if (m_Handler)
36 m_Handler.Register(this);
37 }
38 }
39
40 // --------------------------------------------------------------------------------
41
46
47 // --------------------------------------------------------------------------------
48
53
54 // --------------------------------------------------------------------------------
55
56 void OnUpdate(float deltaTime)
57 {
58 }
59
60 // --------------------------------------------------------------------------------
61
62 int GetId()
63 {
64 return m_Id;
65 }
66
67 // --------------------------------------------------------------------------------
68
70 {
71 return m_Position;
72 }
73
74 // --------------------------------------------------------------------------------
75
76 void OnActivate(string code, bool loadedAsActive = false)
77 {
78 m_LockCode = code;
79 SetActive(true);
80 m_OnActivated.Invoke(loadedAsActive, code);
81 }
82
83 // --------------------------------------------------------------------------------
84
86 {
87 m_LockCode = "-";
88 SetActive(false);
89 m_OnDeactivated.Invoke();
90 }
91
92 // --------------------------------------------------------------------------------
93
94 string GetLockCode()
95 {
96 return m_LockCode;
97 }
98
99 // --------------------------------------------------------------------------------
100
101 bool IsActive()
102 {
103 return m_IsActive;
104 }
105
106 // --------------------------------------------------------------------------------
107
108 protected void SetActive(bool state)
109 {
110 m_IsActive = state;
111
112 #ifdef SERVER
113 if (m_Parent)
114 m_Parent.SetSynchDirty();
115 #endif
116 }
117
118 // --------------------------------------------------------------------------------
119}
120
121#ifdef DIAG_DEVELOPER
122class BunkerBroadcastComponentDebugData : Param
123{
124 bool m_IsActive;
125 string m_LockCode;
126
128 {
129 m_IsActive = component.IsActive();
130 m_LockCode = component.GetLockCode();
131 }
132
133 // --------------------------------------------------------------------------------
134
135 override bool Serialize(Serializer ctx)
136 {
137 return ctx.Write(m_IsActive) && ctx.Write(m_LockCode);
138 }
139
140 // --------------------------------------------------------------------------------
141
142 override bool Deserializer(Serializer ctx)
143 {
144 return ctx.Read(m_IsActive) && ctx.Read(m_LockCode);
145 }
146}
147#endif
148
150{
151 #ifdef DIAG_DEVELOPER
152 protected ref array<Shape> m_DebugShapes = new array<Shape>();
153 protected ref array<ref DebugTextWorldSpace> m_DebugTextsWS;
154 #endif
155
156 void BunkerBroadcastComponent(notnull EntityAI parent)
158 #ifdef DIAG_DEVELOPER
159 m_DebugTextsWS = new array<ref DebugTextWorldSpace>();
160 #endif
161 }
162
163 // --------------------------------------------------------------------------------
164
165 override void OnUpdate(float deltaTime)
166 {
167 super.OnUpdate(deltaTime);
168
169 #ifdef DIAG_DEVELOPER
170 if (g_Game.IsServer())
172 BunkerBroadcastComponentDebugData data = null;
173 if (m_IsActive)
174 data = GetDebugData();
175 GetGame().RPCSingleParam(m_Parent, ERPCs.DIAG_MISC_RADIOGAMEPLAY_DEBUG_DATA, data, true);
177 #endif
178 }
179
180 // --------------------------------------------------------------------------------
181
182 void OnRPC(PlayerIdentity sender, int rpcType, ParamsReadContext ctx)
183 {
184 switch (rpcType)
185 {
186 #ifdef DIAG_DEVELOPER
187 case ERPCs.DIAG_MISC_RADIOGAMEPLAY_DEBUG_DATA:
188 BunkerBroadcastComponentDebugData data = new BunkerBroadcastComponentDebugData();
189 ctx.Read(data);
190 if (!DiagMenu.GetBool(DiagMenuIDs.RADIOGAMEPLAY_DEBUG) || (g_Game.GetUIManager().GetMenu() && g_Game.GetUIManager().GetMenu().GetID() >= 0))
191 {
192 Debug.CleanupTextsWS(m_DebugTextsWS);
193 Debug.CleanupDrawShapes(m_DebugShapes);
194 break;
195 }
197 ShowDebugInfo(DiagMenu.GetBool(DiagMenuIDs.RADIOGAMEPLAY_DEBUG), data);
198 UpdateDebugDraws(DiagMenu.GetBool(DiagMenuIDs.RADIOGAMEPLAY_DEBUG), data);
199 break;
200 #endif
201 }
202 }
204 // --------------------------------------------------------------------------------
205
206 #ifdef DIAG_DEVELOPER
207 BunkerBroadcastComponentDebugData GetDebugData()
208 {
209 BunkerBroadcastComponentDebugData data = new BunkerBroadcastComponentDebugData();
210 data.Synch(this);
211
212 return data;
213 }
214
215 // --------------------------------------------------------------------------------
217 void ShowDebugInfo(bool enabled, BunkerBroadcastComponentDebugData data)
218 {
219 Debug.CleanupTextsWS(m_DebugTextsWS);
220 DrawDebugText(enabled, data);
221 }
222
223 // --------------------------------------------------------------------------------
224
225 void UpdateDebugDraws(bool enabled, BunkerBroadcastComponentDebugData data)
226 {
227
228 Debug.CleanupDrawShapes(m_DebugShapes);
229 DrawActivityDebugMarker(enabled, data);
231
232 // --------------------------------------------------------------------------------
233
234 private void DrawActivityDebugMarker(bool enabled, BunkerBroadcastComponentDebugData data)
235 {
236 if (data && enabled)
237 {
238 int color = COLOR_RED;
239 if (data.m_IsActive)
240 color = COLOR_GREEN;
241
243 position[1] = position[1] + 10.0;
244
245 m_DebugShapes.Insert(Shape.CreateSphere(color, ShapeFlags.NOZWRITE|ShapeFlags.NOOUTLINE, position, 0.5));
246 }
247 }
249 // --------------------------------------------------------------------------------
250
251 private void DrawDebugText(bool enabled, BunkerBroadcastComponentDebugData data)
252 {
253 if (data && enabled)
254 {
255 string text = "";
256 string lockCode = "unset";
257 int color = 0xffff0000;
258 if (data.m_IsActive)
259 {
260 lockCode = data.m_LockCode;
261 color = 0xff00ff00;
263
264 text += string.Format("Bunker\n");
265 text += string.Format("Code: %1\n", lockCode);
266
267 BunkerBroadcastProxy proxy = BunkerBroadcastProxy.Cast(m_Parent);
268 Bunker bunker = proxy.GetBunker();
269 if (bunker)
270 {
271 vector position = bunker.GetSelectionBasePositionLS("att_codelock");
272 position = bunker.ModelToWorld(position);
273 position[1] = position[1] + 0.2;
274 m_DebugTextsWS.Insert(DebugTextWorldSpace.Create(text, DebugTextFlags.ONCE, position[0], position[1], position[2], 14, color, 0x00000000));
275 }
276 }
277 }
278 #endif
279
280 // --------------------------------------------------------------------------------
281}
class LogManager EntityAI
void Serialize()
bool m_IsActive
Определения BunkerBroadcastComponent.c:157
BunkerBroadcastComponentBase Managed BunkerBroadcastComponent(notnull EntityAI parent)
Определения BunkerBroadcastComponent.c:156
string m_LockCode
Определения BunkerBroadcastComponent.c:158
void BunkerBroadcastComponentBase(notnull EntityAI parent)
Определения BunkerBroadcastComponent.c:171
Entity m_Parent
Определения CachedEquipmentStorageBase.c:17
DayZGame g_Game
Определения DayZGame.c:4074
static proto native void DrawDebugText(string text, vector pos, float size)
vector position
Определения DustKickupEffects.c:20
DiagMenuIDs
Определения EDiagMenuIDs.c:2
ERPCs
Определения ERPCs.c:2
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
void Synch(EntityAI victim)
keeping "step" here for consistency only
Определения TrapBase.c:290
void SetActive()
Определения TrapBase.c:413
void SetActive(bool state)
Определения BunkerBroadcastComponent.c:108
void BunkerBroadcastComponentBase(notnull EntityAI parent)
Определения BunkerBroadcastComponent.c:17
ScriptInvoker GetOnDeactivated()
Определения BunkerBroadcastComponent.c:49
void OnUpdate(float deltaTime)
Определения BunkerBroadcastComponent.c:56
ScriptInvoker GetOnActivated()
Определения BunkerBroadcastComponent.c:42
ref ScriptInvoker m_OnDeactivated
Определения BunkerBroadcastComponent.c:15
BunkerBroadcastHandler m_Handler
Определения BunkerBroadcastComponent.c:11
void OnActivate(string code, bool loadedAsActive=false)
Определения BunkerBroadcastComponent.c:76
ref ScriptInvoker m_OnActivated
Определения BunkerBroadcastComponent.c:13
static BunkerBroadcastHandler GetInstance()
Определения BunkerBroadcastHandler.c:134
Bunker GetBunker()
Определения BunkerBroadcastProxy.c:66
static void CleanupTextsWS(array< ref DebugTextWorldSpace > texts)
Определения 3_Game/DayZ/tools/Debug.c:454
static void CleanupDrawShapes(array< Shape > shapes)
Определения 3_Game/DayZ/tools/Debug.c:438
Определения 3_Game/DayZ/tools/Debug.c:2
Определения EnDebug.c:241
void OnRPC(ParamsReadContext ctx)
Определения TransferValues.c:165
TODO doc.
Определения EnScript.c:118
TODO doc.
Определения EnScript.c:123
bool Deserializer(Serializer ctx)
Определения param.c:18
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
The class that will be instanced (moddable)
Определения gameplay.c:389
ScriptInvoker Class provide list of callbacks usage:
Определения 2_GameLib/DayZ/tools.c:116
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:119
Serializer ParamsReadContext
Определения gameplay.c:15
DayZGame GetGame()
Определения gameplay.c:636
const int COLOR_RED
Определения 1_Core/DayZ/constants.c:64
const int COLOR_GREEN
Определения 1_Core/DayZ/constants.c:65
DebugTextFlags
Определения DebugTextFlags.c:8
ShapeFlags
Определения EnDebug.c:126
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
static proto string Format(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)
Gets n-th character from string.
proto native void OnUpdate()
Определения 3_Game/DayZ/tools/tools.c:349