DayZ 1.24
Loading...
Searching...
No Matches
PluginSceneManager.c
Go to the documentation of this file.
1class PluginSceneManager extends PluginBase
2{
3 static string SCENE_DEFAULT_NAME = "default";
4 static string SCENE_SUFIX = "scene";
6 static PluginSceneManager instance;
7
12
13 static const int SCENE_EDITOR_CMD_REFRESH = 0;
14 static const int SCENE_EDITOR_CMD_POPUP = 1;
15 static const int SCENE_EDITOR_CMD_SAVE = 2;
16
17 //---------------------------------------------------------------------------------
18 // >> Public scope
19
20 // System Events
22 {
23 if (instance == NULL)
24 instance = this;
25 }
26
27 // System Events
29 {
30 if (instance == NULL)
31 instance = this;
32 }
33
34 static PluginSceneManager GetInstance()
35 {
36 return PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
37 }
38
39 //==========================================
40 // OnInit (System Event)
41 //==========================================
42 override void OnInit()
43 {
44 m_ModuleDeveloper = PluginDeveloper.Cast(GetPlugin(PluginDeveloper));
45 m_ModuleConfigScene = PluginConfigScene.Cast(GetPlugin(PluginConfigScene));
46 m_ModuleConfigDebugProfile = PluginConfigDebugProfile.Cast(GetPlugin(PluginConfigDebugProfile));
47
48 //Ruler
49 m_RulerActivated = false;
50 m_RulerPoints = new array<vector>;
51 m_RulerLines = new array<Shape>;
52 m_RulerSpheres = new array<Shape>;
53 }
54
55 //==========================================
56 // OnDestroy (destructor)
57 //==========================================
58 override void OnDestroy()
59 {
60 SceneUnload();
61 }
62
63 //==========================================
64 // OnMouseWheel
65 //==========================================
67 {
68 if (!IsMouseInScene())
69 return;
70
71 if (GetSelectedSceneObject())
72 GetSelectedSceneObject().AddRotation(GetRotationAngle() * wheel);
73
74 EditorUpdate();
75 }
76
77 //==========================================
78 // OnUIEditorOpened
79 //==========================================
81 {
82 m_IsOpen = true;
83
85
86 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(this.FreeCameraControlDisable);
87
88 EditorUpdate();
89 }
90
91 //==========================================
92 // OnUIEditorClosed
93 //==========================================
95 {
96 m_IsOpen = false;
97
98 FreeCameraControlEnable();
99
100 m_ModuleDeveloper.ToggleFreeCameraBackPos();
101
102 EditorUpdate();
103 }
104
105 //::::::::::::::::::::::::::::::::::::::::::
106 // Event_OnClick
107 //::::::::::::::::::::::::::::::::::::::::::
109 {
110 if (!IsMouseInScene() || !m_IsOpen)
111 return;
112
113 // Direction Vector from current active Camera
114 vector dir = GetGame().GetPointerDirection();
115
116 // Raycast from
117 vector from = FreeDebugCamera.GetInstance().GetPosition();
118 // Raycast to
119 vector to = from + (dir * 10000);
120 // Raycast out parameter
125 bool selected = false;
126
128 {
129 for (int i = 0; i < objects.Count(); ++i)
130 {
131 Object obj = objects.Get(i);
132
133 if (obj.IsInherited(EntityAI))
134 {
135 SceneObject sc_object = SceneObject.Cast(m_SceneData.GetSceneObjectByEntityAI(EntityAI.Cast(obj)));
136
137 if (sc_object == NULL)
138 {
139 //sc_object = m_SceneData.AddObject(obj);
140 return;
141 }
142
143 SelectObject(sc_object);
144 selected = true;
145
146 break;
147 }
148 }
149 }
150
151 if (!selected)
152 {
153 DeselectObject();
154
155 // Ruler
156 if (IsRulerActivated() && GetSelectedSceneObject() == NULL)
157 RulerAddPoint();
158 }
159
160 EditorUpdate();
161 }
162
163 //::::::::::::::::::::::::::::::::::::::::::
164 // Event_OnClickMiddle
165 //::::::::::::::::::::::::::::::::::::::::::
167 {
168 if (!IsMouseInScene() || !m_IsOpen)
169 return;
170
171 if (GetSelectedSceneObject() != NULL)
172 {
173 // Direction Vector from current active Camera
174 vector dir = GetGame().GetPointerDirection();
175
176 // Raycast from
177 vector from = FreeDebugCamera.GetInstance().GetPosition();
178 // Raycast to
179 vector to = from + (dir * 10000);
180 // Raycast out parameter
185 bool selected = false;
186
188 {
189 for (int i = 0; i < objects.Count(); ++i)
190 {
191 Object obj = objects.Get(i);
192
193 if (obj.IsInherited(EntityAI))
194 {
195 EntityAI eai = EntityAI.Cast(obj);
196 SceneObject scene_object = m_SceneData.GetSceneObjectByEntityAI(eai);
197
198 if (!scene_object.IsPlayer())
199 {
200 if (scene_object != NULL && scene_object != GetSelectedSceneObject())
201 {
202 if (!AreSceneObjectsLinked(GetSelectedSceneObject(), scene_object))
203 LinkSceneObjects(GetSelectedSceneObject(), scene_object);
204 else
205 UnlinkSceneObjects(GetSelectedSceneObject(), scene_object);
206 }
207 }
208 else
209 SceneEditorMenuCmdPopup("I am sorry. You cant create link on player!");
210 }
211 }
212 }
213 }
214
215 EditorUpdate();
216 }
217
218 //::::::::::::::::::::::::::::::::::::::::::
219 // Event_OnDrag
220 //::::::::::::::::::::::::::::::::::::::::::
222 {
223 if (!IsMouseInScene() || !m_IsOpen)
224 return;
225
226 if (GetSelectedSceneObject() != NULL)
227 {
228 // Direction Vector from current active Camera
229 vector dir = GetGame().GetPointerDirection();
230
231 // Raycast from
232 vector from = FreeDebugCamera.GetInstance().GetPosition();
233 // Raycast to
234 vector to = from + (dir * 10000);
235 // Raycast out parameter
239
240 //Raycast(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, out set<Object> results = NULL, Object with = NULL, Object ignore = NULL, bool sorted = false, bool ground_only = false, int iType = ObjIntersectView, float radius = 0.0);
241
243 GetSelectedSceneObject().SetPosition(contact_pos);
244
245 EditorUpdate();
246 }
247 }
248
249 //::::::::::::::::::::::::::::::::::::::::::
250 // Event_OnDoubleClick
251 //::::::::::::::::::::::::::::::::::::::::::
253 {
254 if (!IsMouseInScene() || !m_IsOpen || m_ClassBrowserSelected == "")
255 return null;
256
257 // Direction Vector from current active Camera
258 vector dir = GetGame().GetPointerDirection();
259
260 // Raycast from
261 vector from = FreeDebugCamera.GetInstance().GetPosition();
262 // Raycast to
263 vector to = from + (dir * 10000);
264 // Raycast out parameter
268
270 {
271 SceneObject obj = m_SceneData.CreateSceneObject(m_ClassBrowserSelected, contact_pos);
272
273 if (obj != NULL)
274 {
275 SelectObject(obj);
276 return obj;
277 }
278 }
279
280 return NULL;
281 }
282
283 //==========================================
284 // Load
285 //==========================================
286 void InitLoad()
287 {
289
290 SceneLoad(PluginMissionConfig.GetInstance().GetSceneEditorName());
291
292 RestoreSceneObjectsLinks();
293
294 ExecuteInitScripts();
295 }
296
297 //==========================================
298 // RestoreSceneObjectsLinks
299 //==========================================
301 {
302 array<ref SceneObject> scene_objects = GetSceneObjects();
303
304 for (int i = 0; i < scene_objects.Count(); i++)
305 {
307
308 array<int> linked_scene_objects_indices = scene_object.m_LinkedSceneObjectsIndices;
310 {
311 for (int j = 0; j < linked_scene_objects_indices.Count(); j++)
312 {
314 if (index >= 0 && index < scene_objects.Count())
315 {
316 scene_object.LinkSceneObject(scene_objects.Get(index), false);
317
318 //PrintString("Load link: "+ ToString(scene_object.GetObject()) +" <-> "+ ToString(scene_objects.Get(index).GetObject()) );
319 }
320 }
321 }
322 scene_object.m_LinkedSceneObjectsIndices = NULL;
323 }
324 }
325
326 //==========================================
327 // ExecuteInitScripts
328 //==========================================
330 {
331 array<ref SceneObject> scene_objects = GetSceneObjects();
332 for (int i = 0; i < scene_objects.Count(); i++)
333 {
335 ExecuteEnforceScript(i, scene_object, scene_object.GetInitScript());
336 }
337 }
338
339 //==========================================
340 // EditorToggle
341 //==========================================
343 {
344 //Log("EditorToggle");
345
346 if (GetGame().IsMultiplayer())
347 return;
348
349 if (IsOpened())
350 {
351 // Close UI Scene Editor Menu
352 GetGame().GetUIManager().Back();
353 }
354 else
355 {
356 // Open UI Scene Editor Menu
357 GetGame().GetUIManager().EnterScriptedMenu(MENU_SCENE_EDITOR, NULL);
358 EditorUpdate();
359 }
360 }
361
362 //==========================================
363 // IsOpened
364 //==========================================
365 bool IsOpened()
366 {
367 return m_IsOpen;
368 }
369
370 //==========================================
371 // SelectClassName
372 //==========================================
374 {
375 m_ClassBrowserSelected = class_name;
376 }
377
378 //==========================================
379 // FreeCameraControlEnable
380 //==========================================
382 {
383 // Enable Camera control
384 GetGame().GetInput().ChangeGameFocus(-1);
385
386 // Disable Cursor
387 GetGame().GetUIManager().ShowUICursor(false);
388
389 if (GetGame().GetUIManager().GetMenu())
390 GetGame().GetUIManager().GetMenu().OnHide();
391 }
392
393 //==========================================
394 // FreeCameraControlDisable
395 //==========================================
397 {
398 // Disable Camera control
399 GetGame().GetInput().ChangeGameFocus(1);
400
401 // Enable Cursor
402 GetGame().GetUIManager().ShowUICursor(true);
403
404 if (GetGame().GetUIManager().GetMenu())
405 GetGame().GetUIManager().GetMenu().OnShow();
406 }
407
408 //==========================================
409 // DeleteSelectedObject
410 //==========================================
412 {
413 SceneObject selected_obj = GetSelectedSceneObject();
414
415 if (selected_obj != NULL)
416 {
417 if (!selected_obj.IsPlayer())
418 {
419 array<ref SceneObject> scene_objects = GetSceneObjects();
420 for (int i = 0; i < scene_objects.Count(); i++)
421 {
422 if (AreSceneObjectsLinked(scene_objects.Get(i), selected_obj))
423 UnlinkSceneObjects(scene_objects.Get(i), selected_obj);
424 }
425
426 m_SceneData.DeleteSceneObject(selected_obj);
427
428 scene_objects.RemoveItem(selected_obj);
429
430 DeselectObject();
431 }
432 else
433 SceneEditorMenuCmdPopup("You cant delete player!");
434 }
435
436 EditorUpdate();
437 }
438
439 //==========================================
440 // SelectObject
441 //==========================================
443 {
444 if (GetSelectedSceneObject() != NULL && GetSelectedSceneObject() == obj)
445 return;
446
447 DeselectObject();
448
449 m_SelectedObject = obj;
450
451 EditorUpdate();
452 }
453
454 //==========================================
455 // GetSelectedSceneObject
456 //==========================================
461
462 //==========================================
463 // SelectedObjectDuplicate
464 //==========================================
466 {
467 SceneObject selected_obj = GetSelectedSceneObject();
468
469 if (selected_obj)
470 {
471 if (selected_obj.GetObject() == PLAYER)
472 return;
473
474 vector size = GetSelectedSceneObject().GetSize();
475
476 vector new_pos = selected_obj.GetPosition() + Vector(1, 0, 1) + size;
477
478 SceneObject obj = m_SceneData.CreateSceneObject(selected_obj.GetTypeName(), new_pos);
479 obj.SetRotation(selected_obj.GetRotation());
480
481 array<EntityAI> attachments = selected_obj.GetAttachments();
482 for (int i = 0; i < attachments.Count(); i++)
483 obj.AddAttachment(attachments.Get(i).GetType());
484
485 SelectObject(obj);
486 }
487 }
488
489 //==========================================
490 // SelectedObjectSetRot
491 //==========================================
492 void SelectedObjectSetRot(float dir)
493 {
494 if (GetSelectedSceneObject())
495 {
496 GetSelectedSceneObject().SetRotation(dir);
497
498 EditorUpdate();
499 }
500 }
501
502 //==========================================
503 // SelectedObjectSetPosX
504 //==========================================
506 {
507 SceneObject selected_obj = GetSelectedSceneObject();
508
509 if (selected_obj)
510 {
511 vector v = selected_obj.GetPosition();
512 v[0] = value;
513 selected_obj.SetPosition(v);
514
515 EditorUpdate();
516 }
517 }
518
519 //==========================================
520 // SelectedObjectSetPosY
521 //==========================================
523 {
524 SceneObject selected_obj = GetSelectedSceneObject();
525
526 if (selected_obj)
527 {
528 vector v = selected_obj.GetPosition();
529 v[1] = value;
530 selected_obj.SetPosition(v);
531
532 EditorUpdate();
533 }
534 }
535
536 //==========================================
537 // SelectedObjectSetPosZ
538 //==========================================
540 {
541 SceneObject selected_obj = GetSelectedSceneObject();
542
543 if (GetSelectedSceneObject())
544 {
545 vector v = selected_obj.GetPosition();
546 v[2] = value;
547 selected_obj.SetPosition(v);
548
549 EditorUpdate();
550 }
551 }
552
553 //==========================================
554 // SelectedObjectSetDamage
555 //==========================================
557 {
558 SceneObject selected_obj = GetSelectedSceneObject();
560
561 if (selected_obj)
562 {
563 selected_obj.SetHealth(Math.Clamp(value, 0, selected_obj_EAI.GetMaxHealth("", "")));
564
565 EditorUpdate();
566 }
567 }
568
569 //==========================================
570 // SelectedObjectFocus
571 //==========================================
573 {
574 SceneObject selected_obj = GetSelectedSceneObject();
575
576 if (selected_obj)
577 {
578 vector cam_pos = FreeDebugCamera.GetInstance().GetPosition();
579 vector obj_pos = selected_obj.GetPosition();
581
582 vector obj_size = selected_obj.GetSize();
583
585
586 cam_pos[0] = cam_pos[0] + (obj_size[0] * 2);
587 cam_pos[1] = cam_pos[1] + obj_size[1] + 0.5;
588 cam_pos[2] = cam_pos[2] + (obj_size[2] * 2);
589
590 view_target[1] = view_target[1] + (obj_size[1] * 0.5);
591
593 cam_dir.Normalize();
594
595 FreeDebugCamera.GetInstance().SetPosition(cam_pos);
596 FreeDebugCamera.GetInstance().SetDirection(cam_dir);
597
598 //vector debug_pos = cam_pos + (cam_dir * 50);
599 //Debug.DrawLine(cam_pos, debug_pos);
600 //Debug.DrawSphere(cam_pos);
601 }
602 }
603
604 //==========================================
605 // SelectedObjectAddAttachment
606 //==========================================
608 {
609 if (GetSelectedSceneObject())
610 GetSelectedSceneObject().AddAttachment(att_name);
611
612 EditorUpdate();
613 }
614
615 //==========================================
616 // SelectedObjectRemoveAttachment
617 //==========================================
619 {
620 if (GetSelectedSceneObject())
621 GetSelectedSceneObject().RemoveAttachment(e);
622
623 EditorUpdate();
624 }
625
626 //==========================================
627 // LinkSceneObjects
628 //==========================================
634
635 //==========================================
636 // UnlinkSceneObjects
637 //==========================================
643
644 //==========================================
645 // AreSceneObjectsLinked
646 //==========================================
648 {
649 if (scene_object1.IsLinkedWithSceneObject(scene_object2) && scene_object2.IsLinkedWithSceneObject(scene_object1))
650 return true;
651 else
652 return false;
653 }
654
655 //==========================================
656 // SetDrawSelection
657 //==========================================
659 {
660 m_ModuleConfigDebugProfile.SetSceneEditorDrawSelection(draw);
661
662 EditorUpdate();
663 }
664
665 //==========================================
666 // GetDrawSelection
667 //==========================================
669 {
670 return m_ModuleConfigDebugProfile.GetSceneEditorDrawSelection();
671 }
672
673 //==========================================
674 // SetLoadPlayerPos
675 //==========================================
677 {
678 m_ModuleConfigDebugProfile.SetSceneEditorLoadPlayerPos(save);
679 }
680
681 //==========================================
682 // SetLoadPlayerPos
683 //==========================================
685 {
686 return m_ModuleConfigDebugProfile.GetSceneEditorLoadPlayerPos();
687 }
688
689 //==========================================
690 // SetRotationAngle
691 //==========================================
693 {
694 m_ModuleConfigDebugProfile.SetSceneEditorRotationAngle(angle);
695 }
696
697 //==========================================
698 // GetRotationAngle
699 //==========================================
701 {
702 return m_ModuleConfigDebugProfile.GetSceneEditorRotationAngle();
703 }
704
705 //==========================================
706 // SceneLoad
707 //==========================================
709 {
710 SceneUnload();
711
712 PluginMissionConfig.GetInstance().SetSceneEditorName(scene_name);
713 m_SceneData = m_ModuleConfigScene.SceneDataLoad(scene_name);
714
715 if (!(GetGame().IsMultiplayer() && GetGame().IsServer()))
716 EditorUpdate();
717 }
718
719 //==========================================
720 // SceneUnload
721 //==========================================
723 {
724 m_SceneData = NULL;
725 DeselectObject();
726 }
727
728 //==========================================
729 // SceneSave
730 //==========================================
732 {
733 m_ModuleConfigScene.ClearParams();
734 m_ModuleConfigScene.SceneDataSave(m_SceneData);
735 SceneEditorMenuCmdSave();
736 EditorUpdate();
737 }
738
739 //==========================================
740 // SceneDelete
741 //==========================================
743 {
744 if (scene_name == m_SceneData.GetNameScene())
745 return false;
746
747 return true;
748 }
749
750 //==========================================
751 // SceneDelete
752 //==========================================
754 {
755 if (scene_name == m_SceneData.GetNameScene())
756 return false;
757
758 m_ModuleConfigScene.SceneDelete(scene_name);
759
760 EditorUpdate();
761
762 return true;
763 }
764
765 //==========================================
766 // SceneDelete
767 //==========================================
769 {
770 m_ModuleConfigScene.SceneDuplicate(scene_name);
771
772 EditorUpdate();
773 }
774
775 //==========================================
776 // SceneRename
777 //==========================================
778 void SceneRename(string scene_name, string new_name)
779 {
780 m_ModuleConfigScene.SceneRename(scene_name, new_name);
781
782 if (scene_name == m_SceneData.GetNameScene())
783 m_SceneData.SetNameScene(new_name);
784
785 EditorUpdate();
786 }
787
788 //==========================================
789 // SceneGetName
790 //==========================================
792 {
793 if (m_SceneData)
794 return m_SceneData.GetNameScene();
795
796 return STRING_EMPTY;
797 }
798
799 //==========================================
800 // SetWeather
801 //==========================================
802 void SetWeather(float overcast, float rain, float fog, float wind_force)
803 {
804 m_SceneData.SetInitOvercast(overcast);
805 m_SceneData.SetInitRain(rain);
806 m_SceneData.SetInitFog(fog);
807 m_SceneData.SetInitWindForce(wind_force);
808 }
809
810 //==========================================
811 // SetDate
812 //==========================================
813 void SetDate(int year, int month, int day, int hour, int minute)
814 {
815 m_SceneData.SetInitYear(year);
816 m_SceneData.SetInitMonth(month);
817 m_SceneData.SetInitDay(day);
818 m_SceneData.SetInitHour(hour);
819 m_SceneData.SetInitMinute(minute);
820 }
821
822 //==========================================
823 // SelectAndFocusPlayerObject
824 //==========================================
826 {
827 array<ref SceneObject> scene_objects = GetSceneObjects();
828 for (int i = 0; i < scene_objects.Count(); i++)
829 {
830 if (scene_objects.Get(i).GetObject() == GetGame().GetPlayer())
831 {
832 SelectObject(scene_objects.Get(i));
833 SelectedObjectFocus();
834 break;
835 }
836 }
837 }
838
839 //------------------------------------------
840 // ExecuteEnforceScript
841 //------------------------------------------
843 {
844 if (script != "")
845 {
846 string cls = scene_object.GetObject().ClassName();
847 string wrapped_script = "void scMngMain() \n{\n PluginSceneManager se = GetPlugin(Type(\"PluginSceneManager\")); \n SceneObject this_obj = se.GetSceneObjectByIndex(" + index.ToString() + "); \n " + cls + " this_eai = this_obj.GetObject(); \n " + script + "\n}\n";
848
849 GetGame().ExecuteEnforceScript(wrapped_script, "scMngMain");
850 }
851 }
852
853 //==========================================
854 // RulerToggle
855 //==========================================
857 {
858 if (IsRulerActivated())
859 m_RulerActivated = false;
860 else
861 m_RulerActivated = true;
862
863 SceneEditorMenuCmdRefresh();
864 }
865
866 //==========================================
867 // ActivateRuler
868 //==========================================
870 {
871 return m_RulerActivated;
872 }
873
874 //==========================================
875 // RulerAddPoint
876 //==========================================
878 {
879 vector point_pos = GetMousePositionInScene();
880
881 m_RulerPoints.Insert(point_pos);
882
883 EditorUpdateRuler();
884 }
885
886 //------------------------------------------
887 // RulerClearVisuals
888 //------------------------------------------
890 {
891 for (int i = 0; i < m_RulerLines.Count(); ++i)
892 m_RulerLines.Get(i).Destroy();
893 m_RulerLines.Clear();
894
895 for (int j = 0; j < m_RulerSpheres.Count(); ++j)
896 m_RulerSpheres.Get(j).Destroy();
897 m_RulerSpheres.Clear();
898 }
899
900 //------------------------------------------
901 // RulerDelete
902 //------------------------------------------
904 {
905 m_RulerPoints.Clear();
906
907 EditorUpdateRuler();
908 }
909
910 //==========================================
911 // GetLoadedScene
912 //==========================================
914 {
915 return m_SceneData;
916 }
917
918 //==========================================
919 // GetSelectedSceneObjectIndex
920 //==========================================
922 {
923 array<ref SceneObject> scene_objects = GetSceneObjects();
924 for (int i = 0; i < scene_objects.Count(); i++)
925 {
926 if (GetSelectedSceneObject() == scene_objects.Get(i))
927 return i;
928 }
929
930 return -1;
931 }
932
933 //==========================================
934 // GetSceneObjects
935 //==========================================
937 {
938 if (m_SceneData)
939 return m_SceneData.GetSceneObjects();
940
941 return NULL;
942 }
943
944 //==========================================
945 // GetScenePlayers
946 //==========================================
948 {
949 if (m_SceneData)
950 return m_SceneData.GetScenePlayers();
951
952 return NULL;
953 }
954
955 //==========================================
956 // GetSceneObjectsAll
957 //==========================================
959 {
960 if (m_SceneData)
961 return m_SceneData.GetSceneObjectsAll();
962
963 return NULL;
964 }
965
966 //==========================================
967 // GetSceneObjectByIndex
968 //==========================================
970 {
971 array<ref SceneObject> scene_objects = GetSceneObjects();
972
973 if (scene_objects != NULL)
974 {
975 if (index > -1 && index < scene_objects.Count())
976 return scene_objects.Get(index);
977 }
978
979 return NULL;
980 }
981
982 //==========================================
983 // GetSceneObjectByEntity
984 //==========================================
986 {
987 array<ref SceneObject> scene_objects = GetSceneObjects();
988
989 if (scene_objects != NULL)
990 {
991 for (int i = 0; i <= scene_objects.Count(); ++i)
992 {
993 SceneObject obj = scene_objects.Get(i);
994 EntityAI e = obj.GetObject();
995
996 if (e == entity)
997 return obj;
998 }
999 }
1000
1001 return NULL;
1002 }
1003
1004 //==========================================
1005 // GetSceneList
1006 //==========================================
1008 {
1009 return m_ModuleConfigScene.GetSceneList();
1010 }
1011
1012 //==========================================
1013 // DeleteSceneObject
1014 //==========================================
1016 {
1017 if (obj != NULL)
1018 {
1019 if (obj.GetObject() != GetGame().GetPlayer())
1020 {
1021 obj.UnlinkAll();
1022
1023 if (GetSelectedSceneObject() != NULL && GetSelectedSceneObject() == obj)
1024 DeselectObject();
1025
1026 m_SceneData.DeleteSceneObject(obj);
1027 }
1028 else
1029 SceneEditorMenuCmdPopup("You cant delete player!");
1030 }
1031
1032 EditorUpdate();
1033 }
1034
1035 //---------------------------------------------------------------------------------
1036 // >> Protected scope
1037 protected PluginDeveloper m_ModuleDeveloper;
1040
1041 //---------------------------------------------------------------------------------
1042 // >> protected Scope
1043 protected float m_TimeLastClickRelease;
1044 protected float m_TimeLastClickPress;
1045 protected int m_PressedMouseID;
1046 protected bool m_IsDragging;
1051 protected string m_ClassBrowserSelected;
1052 protected bool m_IsOpen;
1053
1054 //------------------------------------------
1055 // DeselectObject
1056 //------------------------------------------
1057 private void DeselectObject()
1058 {
1060 }
1061
1062 //------------------------------------------
1063 // EditorUpdate
1064 //------------------------------------------
1065 protected void EditorUpdate()
1066 {
1067 if (GetGame().IsMultiplayer())
1068 return;
1069
1070 array<ref SceneObject> objects = GetSceneObjects();
1071 if (!objects)
1072 return;
1073 for (int i = 0; i < objects.Count(); ++i)
1074 {
1075 SceneObject obj = objects.Get(i);
1076
1078 int j;
1079
1080 if (IsOpened())
1081 {
1082 obj.EditorShapeAdd();
1083
1084 if (GetSelectedSceneObject() && GetSelectedSceneObject() == obj)
1085 {
1086 if (GetDrawSelection())
1087 obj.EditorShapeSelect();
1088 }
1089 else
1090 obj.EditorShapeDeselect();
1091
1092 for (j = 0; j < linked_scene_objects.Count(); j++)
1094 }
1095 else
1096 {
1097 obj.EditorShapeRemove();
1098
1100 {
1101 for (j = 0; j < linked_scene_objects.Count(); j++)
1103 }
1104 }
1105 }
1106
1107 SceneEditorMenuCmdRefresh();
1108 }
1109
1110 //------------------------------------------
1111 // SceneEditorMenuRefresh
1112 //------------------------------------------
1114 {
1115 CallMethod(CALL_ID_SCENE_EDITOR_COMMAND, new Param2<int, Param>(SCENE_EDITOR_CMD_REFRESH, NULL));
1116 }
1117
1118 //------------------------------------------
1119 // SceneEditorMenuCmdPopup
1120 //------------------------------------------
1122 {
1123 CallMethod(CALL_ID_SCENE_EDITOR_COMMAND, new Param2<int, Param1<string>>(SCENE_EDITOR_CMD_POPUP, new Param1<string>(message)));
1124 }
1125
1126 //------------------------------------------
1127 // SceneEditorMenuCmdSave
1128 //------------------------------------------
1130 {
1131 CallMethod(CALL_ID_SCENE_EDITOR_COMMAND, new Param2<int, Param>(SCENE_EDITOR_CMD_SAVE, NULL));
1132 }
1133
1134 //------------------------------------------
1135 // IsMouseInScene
1136 //------------------------------------------
1137 private bool IsMouseInScene()
1138 {
1140
1141 if (widget_under_mouse != NULL && widget_under_mouse.GetName() == "pnl_SceneControl")
1142 return true;
1143
1144 return false;
1145 }
1146
1147 //------------------------------------------
1148 // EditorUpdateRuler
1149 //------------------------------------------
1150 private void EditorUpdateRuler()
1151 {
1152 RulerClearVisuals();
1153
1154 for (int i = 0; i < m_RulerPoints.Count(); ++i)
1155 {
1156 vector pos1 = m_RulerPoints.Get(i);
1157
1158 m_RulerSpheres.Insert(Debug.DrawSphere(pos1, 0.1));
1159
1160 if (i < m_RulerPoints.Count() - 1)
1161 {
1162 vector pos2 = m_RulerPoints.Get(i + 1);
1163 m_RulerLines.Insert(Debug.DrawLine(pos1, pos2));
1164 }
1165 }
1166 }
1167
1168 //------------------------------------------
1169 // GetMousePositionInScene
1170 //------------------------------------------
1172 {
1173 vector dir = GetGame().GetPointerDirection();
1174 vector from = FreeDebugCamera.GetInstance().GetPosition();
1175 vector to = from + (dir * 10000);
1179
1181 return contact_pos;
1182
1183 return "0 0 0";
1184 }
1185}
bool IsOpened()
@ PLAYER
indicates if driver is controlled by player
Definition Car.c:12
const CallID CALL_ID_SCENE_EDITOR_COMMAND
Definition Dispatcher.c:9
Param CallMethod(CallID call_id, Param params)
Definition Dispatcher.c:36
PlayerBase GetPlayer()
class OptionSelectorMultistate extends OptionSelector class_name
PluginBase GetPlugin(typename plugin_type)
Widget m_SelectedObject
Definition RadialMenu.c:16
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
Definition Debug.c:14
static Shape DrawSphere(vector pos, float size=1, int color=0x1fff7f7f, ShapeFlags flags=ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE)
Definition Debug.c:434
static Shape DrawLine(vector from, vector to, int color=0xFFFFFFFF, int flags=0)
Definition Debug.c:489
static void EnableFreeCameraSceneEditor(PlayerBase player)
Definition EnMath.c:7
void SelectAndFocusPlayerObject()
void ExecuteInitScripts()
void SetRotationAngle(int angle)
void OnUIEditorOpened()
SceneObject m_SelectedObject
bool SceneCanDelete(string scene_name)
void SetLoadPlayerPos(bool save)
void SelectedObjectDuplicate()
void ~PluginSceneManager()
override void OnInit()
void Event_OnClickMiddle()
ref SceneData m_SceneData
array< ref ScenePlayer > GetScenePlayers()
void OnMouseWheel(int wheel)
void RestoreSceneObjectsLinks()
void DeleteSceneObject(SceneObject obj)
void SelectedObjectSetDamage(float value)
void SceneLoad(string scene_name)
void SelectedObjectSetPosZ(float value)
void LinkSceneObjects(SceneObject scene_object1, SceneObject scene_object2)
TStringArray GetSceneList()
void SceneDuplicate(string scene_name)
bool SceneDelete(string scene_name)
SceneObject GetSceneObjectByIndex(int index)
SceneObject Event_OnDoubleClick()
void SetDrawSelection(bool draw)
void SelectedObjectSetPosX(float value)
void PluginSceneManager()
SceneObject GetSceneObjectByEntity(EntityAI entity)
array< ref SceneObject > GetSceneObjects()
void SelectedObjectFocus()
void SceneEditorMenuCmdSave()
ref array< Shape > m_ShapesSceneObjects
static PluginSceneManager instance
void SelectedObjectSetPosY(float value)
ref array< Shape > m_RulerLines
void SceneEditorMenuCmdRefresh()
array< ref SceneObject > GetSceneObjectsAll()
void SelectObject(SceneObject obj)
void FreeCameraControlDisable()
void ExecuteEnforceScript(int index, SceneObject scene_object, string script)
vector GetMousePositionInScene()
ref array< vector > m_RulerPoints
string SceneGetName()
SceneObject GetSelectedSceneObject()
string m_ClassBrowserSelected
override void OnDestroy()
void OnUIEditorClosed()
void SelectedObjectAddAttachment(string att_name)
void UnlinkSceneObjects(SceneObject scene_object1, SceneObject scene_object2)
PluginConfigScene m_ModuleConfigScene
static PlayerBase PLAYER
SceneData GetLoadedScene()
bool AreSceneObjectsLinked(SceneObject scene_object1, SceneObject scene_object2)
void SceneRename(string scene_name, string new_name)
void DeleteSelectedObject()
void SetWeather(float overcast, float rain, float fog, float wind_force)
PluginConfigDebugProfile m_ModuleConfigDebugProfile
static PluginSceneManager GetInstance()
void FreeCameraControlEnable()
void SelectedObjectSetRot(float dir)
void SelectedObjectRemoveAttachment(EntityAI e)
void SelectClassName(string class_name)
void SetDate(int year, int month, int day, int hour, int minute)
ref array< Shape > m_RulerSpheres
ref map< int, KeyBinding > m_KeyBindings
void SceneEditorMenuCmdPopup(string message)
int GetSelectedSceneObjectIndex()
void EditorShapeDeselect()
array< SceneObject > GetLinkedSceneObjects()
void EditorShapeSelect()
void SetRotation(float rot)
void UnlinkAll()
void AddAttachment(string att_name)
void EditorLineAdd(SceneObject obj)
void EditorShapeRemove()
void EditorLineRemove(SceneObject obj)
void EditorShapeAdd()
EntityAI GetObject()
Definition SceneObject.c:57
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
const int MENU_SCENE_EDITOR
Definition constants.c:167
const string STRING_EMPTY
Definition constants.c:54
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
proto native Widget GetWidgetUnderCursor()