DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
SceneObject.c
См. документацию.
2{
3 static const int COLOR_OBJ_BBOX_NORMAL = 0x00000000;
4 static const int COLOR_OBJ_BBOX_SELECT = 0x1f007C00;
5
8 protected string m_InitScript;
9 protected string m_ObjectName;
10 protected string m_ObjectNameOrigin;
11
14
16
17 //========================================
18 // SceneObject
19 //========================================
20 SceneObject Init(string obj_name, vector pos)
21 {
22 if (obj_name != STRING_EMPTY)
23 {
24 m_ObjectNameOrigin = obj_name;
25
26 bool is_ai = GetGame().IsKindOf(obj_name, "DZ_LightAI");
27
28 PluginDeveloper module_dev = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
29 EntityAI e = module_dev.SpawnEntityOnGroundPos(PluginSceneManager.PLAYER, obj_name, 100, 0.0, pos);
30
31 if (e != NULL)
32 {
33 if (e.IsInherited(ItemBase))
34 {
35 ItemBase item = ItemBase.Cast(e);
36 if (item.HasQuantity())
37 item.SetQuantity(item.GetQuantityMax());
38 }
39
40 m_ObjectName = e.GetType();
41 LinkEntityAI(e);
42 }
43 else if (obj_name != "player")
44 {
45 return NULL;
46 }
47 }
48
52
53 return this;
54 }
55
56 //----------------------------------------
57 // GetObject
58 //----------------------------------------
60 {
61 return m_ObjectPtr;
62 }
63
64 //----------------------------------------
65 // GetName
66 //----------------------------------------
67 string GetName()
68 {
69 return m_ObjectName;
70 }
71
72 //----------------------------------------
73 // IsPlayer
74 //----------------------------------------
75 bool IsPlayer()
76 {
77 return false;
78 }
79
80 //----------------------------------------
81 // GetInitScript
82 //----------------------------------------
84 {
85 return m_InitScript;
86 }
87
88 //----------------------------------------
89 // SetInitScript
90 //----------------------------------------
91 void SetInitScript(string init_script)
92 {
93 m_InitScript = init_script;
94 }
95
96 //========================================
97 // EditorShapeUpdatePos
98 //========================================
100 {
101 if (m_DebugShapeBBox != NULL)
102 {
103 vector mat[4];
104 GetObject().GetTransform(mat);
105
106 if (m_DebugShapeBBox != NULL)
107 {
108 m_DebugShapeBBox.SetMatrix(mat);
109 }
110 }
111 }
112
113 //========================================
114 // EditorShapeSetColor
115 //========================================
116 void EditorShapeSetColor(int color)
117 {
119 {
120 m_DebugShapeBBox.SetColor(color);
121 }
122 }
123
124 //========================================
125 // EditorShapeSelect
126 //========================================
131
132 //========================================
133 // EditorShapeDeselect
134 //========================================
139
140 //========================================
141 // GetSize
142 //========================================
144 {
145 vector size = Vector(1,1,1);
146 vector min_max[2];
147
148 if (GetObject())
149 {
150 GetObject().GetCollisionBox(min_max);
151
152 size[0] = min_max[1][0] - min_max[0][0];
153 size[2] = min_max[1][2] - min_max[0][2];
154 size[1] = min_max[1][1] - min_max[0][1];
155
156 return size;
157 }
158 else
159 {
160 Print("Error: SceneObject "+ m_ObjectNameOrigin +" dont has game object.");
161 }
162
163 return size;
164 }
165
166 //========================================
167 // EditorShapeAdd
168 //========================================
170 {
171 if (m_DebugShapeBBox != NULL)
172 return;
173
174 vector min = "0 0 0";
175 vector max = "0 0 0";
176
177 vector size = GetSize();
178
179 float width = size[0];
180 float height = size[1];
181 float length = size[2];
182
183 float width_h = width*0.5;
184 float lenght_h = length*0.5;
185
186 min[0] = -width_h;
187 min[1] = 0;
188 min[2] = -lenght_h;
189
190 max[0] = width_h;
191 max[1] = height;
192 max[2] = lenght_h;
193
194 //Log("EditorShapeAdd -> "+m_ObjectPtr.Ptr().GetType());
195
196 m_DebugShapeBBox = Debug.DrawBox(min, max);
199 }
200
201 //========================================
202 // EditorShapeRemove
203 //========================================
205 {
206 if (m_DebugShapeBBox != NULL)
207 {
208 m_DebugShapeBBox.Destroy();
209 m_DebugShapeBBox = NULL;
210 }
211 }
212
213 //========================================
214 // EditorLineRemove
215 //========================================
217 {
218 for (int i = 0; i < m_LinkedSceneObjectsShapes.Count(); i++)
219 {
220 if (m_LinkedSceneObjectsShapes.GetKey(i) == obj)
221 {
222 m_LinkedSceneObjectsShapes.GetElement(i).Destroy();
223 m_LinkedSceneObjectsShapes.Remove(obj);
224 break;
225 }
226 }
227 }
228
229 //========================================
230 // EditorLineAdd
231 //========================================
233 {
234 if (obj.GetObject() != NULL && GetObject() != NULL)
235 {
236 if (m_LinkedSceneObjectsShapes.Contains(obj))
237 {
238 EditorLineRemove(obj);
239 }
240
241 vector pos1 = obj.GetSize();
242 pos1[0] = 0; pos1[1] = pos1[1] / 2; pos1[2] = 0;
243 pos1 = pos1 + obj.GetObject().GetPosition();
244
245 vector pos2 = GetSize();
246 pos2[0] = 0; pos2[1] = pos2[1] / 2; pos2[2] = 0;
247 pos2 = pos2 + GetObject().GetPosition();
248
249 m_LinkedSceneObjectsShapes.Insert(obj, Debug.DrawArrow(pos1, pos2));
250 }
251 }
252
253 //========================================
254 // LinkEntityAI
255 //========================================
257 {
258 m_ObjectPtr = e;
259 }
260
261 //========================================
262 // IsLinkedWithSceneObject
263 //========================================
265 {
266 int index = m_LinkedSceneObjects.Find(scene_object);
267 if (index >= 0)
268 {
269 return true;
270 }
271 else
272 {
273 return false;
274 }
275 }
276
277 //========================================
278 // LinkEntityAI
279 //========================================
280 void LinkSceneObject(SceneObject scene_object, bool draw_line = true)
281 {
282 if (!IsLinkedWithSceneObject(scene_object))
283 {
284 if (draw_line)
285 {
286 EditorLineAdd(scene_object);
287 }
288 m_LinkedSceneObjects.Insert(scene_object);
289 }
290 }
291
292 //========================================
293 // UnlinkSceneObject
294 //========================================
296 {
297 int index = m_LinkedSceneObjects.Find(scene_object);
298 if (index >= 0 && index < m_LinkedSceneObjects.Count())
299 {
300 EditorLineRemove(scene_object);
301 m_LinkedSceneObjects.Remove(index);
302 }
303 }
304
305 //========================================
306 // UnlinkAll
307 //========================================
309 {
310 int link_count = GetLinkedSceneObjectsCount();
311
312 if (link_count > 0)
313 {
314 for (int i = 0; i < link_count; ++i)
315 {
316 PluginSceneManager.GetInstance().UnlinkSceneObjects(this, GetLinkedSceneObject(0));
317 }
318 }
319 }
320
321 //========================================
322 // GetLinkedSceneObjects
323 //========================================
328
329 //========================================
330 // GetLinkedSceneObjectsCount
331 //========================================
333 {
334 return m_LinkedSceneObjects.Count();
335 }
336
337 //========================================
338 // GetLinkedSceneObject
339 //========================================
341 {
342 return m_LinkedSceneObjects.Get(i);
343 }
344
345 //========================================
346 // GetLinkedObject
347 //========================================
349 {
351 }
352
353 //========================================
354 // Destructor
355 //========================================
357 {
359 {
361 m_ObjectPtr = NULL;
362 }
363
364 for (int i = 0; i < m_LinkedSceneObjects.Count(); i++)
365 {
367 }
368
370 }
371
372 //========================================
373 // GetTypeName
374 //========================================
375 string GetTypeName()
376 {
377 return m_ObjectPtr.GetType();
378 }
379
380 //========================================
381 // PlaceOnSurface
382 //========================================
384 {
385 if (m_ObjectPtr)
386 {
387 if (GetGame().IsClient() && GetGame().IsMultiplayer())
388 {
389 Param par = new Param3<string, EntityAI, Param>("PlaceOnSurface" , m_ObjectPtr, NULL);
390 SceneObjectSynch(par);
391 }
392 else
393 {
394 m_ObjectPtr.PlaceOnSurface();
395 }
396 }
397 }
398
399 //========================================
400 // SetPosition
401 //========================================
403 {
404 if (m_ObjectPtr)
405 {
406 if (GetGame().IsClient() && GetGame().IsMultiplayer())
407 {
408 Param par = new Param3<string, EntityAI, Param>("SetPosition" , m_ObjectPtr, new Param1<vector>(pos));
409 SceneObjectSynch(par);
410 }
411 else
412 {
413 m_ObjectPtr.SetPosition(pos);
414 }
415 }
418 }
419
420 //========================================
421 // GetPosition
422 //========================================
424 {
425 if (m_ObjectPtr)
426 return m_ObjectPtr.GetPosition();
427 return Vector(0,0,0);
428 }
429
430 //========================================
431 // GetHealth
432 //========================================
433 float GetHealth()
434 {
435 if (m_ObjectPtr)
436 return m_ObjectPtr.GetHealth("", "");
437 return 0;
438 }
439
440 //========================================
441 // GetHealth
442 //========================================
444 {
445 if (m_ObjectPtr)
446 return m_ObjectPtr.GetMaxHealth("", "");
447 return 0;
448 }
449
450 //========================================
451 // SetHealth
452 //========================================
453 void SetHealth(float value)
454 {
455 if (m_ObjectPtr)
456 {
457 if (GetGame().IsClient() && GetGame().IsMultiplayer())
458 {
459 Param par = new Param3<string, EntityAI, Param>("SetHealth" , m_ObjectPtr, new Param1<float>(value));
460 SceneObjectSynch(par);
461 }
462 else
463 {
464 m_ObjectPtr.SetHealth("", "", value);
465 }
466 }
467 }
468
469 //========================================
470 // GetPositionAsString
471 //========================================
473 {
474 if (m_ObjectPtr)
475 return m_ObjectPtr.GetPosition().ToString(false);
476 return Vector(0,0,0).ToString(false);
477 }
478
479 //========================================
480 // SetPositionAsString
481 //========================================
482 void SetPositionAsString(string string_pos)
483 {
484 SetPosition(string_pos.ToVector());
485 }
486
487 //========================================
488 // GetRotation
489 //========================================
491 {
492 if (m_ObjectPtr)
493 {
494 vector v = m_ObjectPtr.GetOrientation();
495 return v[0];
496 }
497
498 return 0;
499 }
500
501 //========================================
502 // SetRotation
503 //========================================
504 void SetRotation(float rot)
505 {
506 if (m_ObjectPtr)
507 {
508 vector v = m_ObjectPtr.GetOrientation();
509 v[0] = rot;
510 m_ObjectPtr.SetOrientation(v);
512 }
513 }
514
516 {
517 GetGame().RPCSingleParam(GetGame().GetPlayer(), ERPCs.RPC_SYNC_SCENE_OBJECT, p, true, NULL);
518 }
519
520 //========================================
521 // AddRotation
522 //========================================
523 void AddRotation(float add_rot)
524 {
525 if (m_ObjectPtr)
526 {
527 if (GetGame().IsClient() && GetGame().IsMultiplayer())
528 {
529 Param par = new Param3<string, EntityAI, Param>("AddRotation" , m_ObjectPtr, new Param1<float>(add_rot));
530 SceneObjectSynch(par);
531 }
532 else
533 {
534 vector v = m_ObjectPtr.GetOrientation();
535 v[0] = v[0] + add_rot;
536 m_ObjectPtr.SetOrientation(v);
537
539 }
540 }
541 }
542
543 //========================================
544 // AddRotation
545 //========================================
546 void AddAttachment(string att_name)
547 {
548 GetObject().GetInventory().CreateAttachment(att_name);
549 }
550
551 //========================================
552 // CanAttachment
553 //========================================
555 {
556 return GetObject().GetInventory().CanAddAttachment(e);
557 }
558
559 //========================================
560 // AddRotation
561 //========================================
563 {
565 }
566
567 //========================================
568 // GetAttachments
569 //========================================
571 {
573
574 for (int i = 0; i < GetObject().GetInventory().AttachmentCount(); ++i)
575 {
576 ret.Insert(GetObject().GetInventory().GetAttachmentFromIndex(i));
577 }
578
579 return ret;
580 }
581
582 //========================================
583 // GetConfigAttachments
584 //========================================
586 {
587 string type_name = GetTypeName();
588 TStringArray cfg_attachments = new TStringArray;
589
590 string cfg_path;
591
592 if (GetGame().ConfigIsExisting(CFG_VEHICLESPATH+" "+type_name))
593 {
594 cfg_path = CFG_VEHICLESPATH+" "+type_name+" attachments";
595 }
596 else if (GetGame().ConfigIsExisting(CFG_WEAPONSPATH+" "+type_name))
597 {
598 cfg_path = CFG_WEAPONSPATH+" "+type_name+" attachments";
599 }
600 else if (GetGame().ConfigIsExisting(CFG_MAGAZINESPATH+" "+type_name))
601 {
602 cfg_path = CFG_MAGAZINESPATH+" "+type_name+" attachments";
603 }
604
605 GetGame().ConfigGetTextArray(cfg_path, cfg_attachments);
606
607 return cfg_attachments;
608 }
609}
map
Определения ControlsXboxNew.c:4
ERPCs
Определения ERPCs.c:2
PlayerBase GetPlayer()
Определения ModifierBase.c:51
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:316
proto native void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
bool IsKindOf(string cfg_class_name, string cfg_parent_name)
Returns is class name inherited from parent class name.
Определения Game.c:1339
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto native void ObjectDelete(Object obj)
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
Определения Debug.c:286
static Shape DrawArrow(vector from, vector to, float size=0.5, int color=0xFFFFFFFF, int flags=0)
Определения Debug.c:404
Определения Debug.c:2
Определения Building.c:6
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
Определения InventoryItem.c:731
Определения EntityAI.c:95
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
void AddRotation(float add_rot)
Определения SceneObject.c:523
int GetLinkedSceneObjectsCount()
Определения SceneObject.c:332
void EditorShapeDeselect()
Определения SceneObject.c:135
array< SceneObject > GetLinkedSceneObjects()
Определения SceneObject.c:324
EntityAI m_ObjectPtr
Определения SceneObject.c:6
ref array< SceneObject > m_LinkedSceneObjects
Определения SceneObject.c:12
SceneObject GetLinkedSceneObject(int i)
Определения SceneObject.c:340
bool IsLinkedWithSceneObject(SceneObject scene_object)
Определения SceneObject.c:264
void LinkEntityAI(EntityAI e)
Определения SceneObject.c:256
float GetHealth()
Определения SceneObject.c:433
void SetInitScript(string init_script)
Определения SceneObject.c:91
void EditorShapeSelect()
Определения SceneObject.c:127
EntityAI GetLinkedObject(int i)
Определения SceneObject.c:348
string m_ObjectName
Определения SceneObject.c:9
TStringArray GetConfigAttachments()
Определения SceneObject.c:585
void SetRotation(float rot)
Определения SceneObject.c:504
Shape m_DebugShapeBBox
Определения SceneObject.c:7
string GetTypeName()
Определения SceneObject.c:375
ref array< int > m_LinkedSceneObjectsIndices
Определения SceneObject.c:15
bool IsPlayer()
Определения SceneObject.c:75
void SetPositionAsString(string string_pos)
Определения SceneObject.c:482
void UnlinkAll()
Определения SceneObject.c:308
void SetHealth(float value)
Определения SceneObject.c:453
float GetRotation()
Определения SceneObject.c:490
void EditorShapeUpdatePos()
Определения SceneObject.c:99
void RemoveAttachment(EntityAI e)
Определения SceneObject.c:562
void AddAttachment(string att_name)
Определения SceneObject.c:546
static const int COLOR_OBJ_BBOX_NORMAL
Определения SceneObject.c:3
string m_InitScript
Определения SceneObject.c:8
void EditorLineAdd(SceneObject obj)
Определения SceneObject.c:232
void EditorShapeSetColor(int color)
Определения SceneObject.c:116
string GetName()
Определения SceneObject.c:67
void LinkSceneObject(SceneObject scene_object, bool draw_line=true)
Определения SceneObject.c:280
void EditorShapeRemove()
Определения SceneObject.c:204
void EditorLineRemove(SceneObject obj)
Определения SceneObject.c:216
string GetPositionAsString()
Определения SceneObject.c:472
array< EntityAI > GetAttachments()
Определения SceneObject.c:570
bool CanAttachment(EntityAI e)
Определения SceneObject.c:554
void SetPosition(vector pos)
Определения SceneObject.c:402
vector GetPosition()
Определения SceneObject.c:423
SceneObject Init(string obj_name, vector pos)
Определения SceneObject.c:20
ref map< SceneObject, Shape > m_LinkedSceneObjectsShapes
Определения SceneObject.c:13
void ~SceneObject()
Определения SceneObject.c:356
vector GetSize()
Определения SceneObject.c:143
void SceneObjectSynch(Param p)
Определения SceneObject.c:515
string GetInitScript()
Определения SceneObject.c:83
void EditorShapeAdd()
Определения SceneObject.c:169
EntityAI GetObject()
Определения SceneObject.c:59
static const int COLOR_OBJ_BBOX_SELECT
Определения SceneObject.c:4
string m_ObjectNameOrigin
Определения SceneObject.c:10
void UnlinkSceneObject(SceneObject scene_object)
Определения SceneObject.c:295
void PlaceOnSurface()
Определения SceneObject.c:383
float GetMaxHealth()
Определения SceneObject.c:443
Определения SceneObject.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString(bool beautify=true)
Vector to string.
Определения EnConvert.c:106
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
array< string > TStringArray
Определения EnScript.c:685
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
const string CFG_VEHICLESPATH
Определения constants.c:220
const string CFG_WEAPONSPATH
Определения constants.c:221
const string CFG_MAGAZINESPATH
Определения constants.c:222
const string STRING_EMPTY
Определения constants.c:54
proto vector ToVector()
Returns a vector from a string.