3 static const int COLOR_OBJ_BBOX_NORMAL = 0x00000000;
4 static const int COLOR_OBJ_BBOX_SELECT = 0x1f007C00;
7 protected Shape m_DebugShapeBBox;
8 protected string m_InitScript;
9 protected string m_ObjectName;
10 protected string m_ObjectNameOrigin;
24 m_ObjectNameOrigin = obj_name;
26 bool is_ai =
GetGame().IsKindOf(obj_name,
"DZ_LightAI");
28 PluginDeveloper module_dev = PluginDeveloper.Cast(
GetPlugin(PluginDeveloper));
29 EntityAI e = module_dev.SpawnEntityOnGroundPos(PluginSceneManager.PLAYER, obj_name, 100, 0.0, pos);
36 if (item.HasQuantity())
37 item.SetQuantity(item.GetQuantityMax());
40 m_ObjectName = e.GetType();
43 else if (obj_name !=
"player")
83 string GetInitScript()
91 void SetInitScript(
string init_script)
93 m_InitScript = init_script;
99 void EditorShapeUpdatePos()
101 if (m_DebugShapeBBox != NULL)
104 GetObject().GetTransform(mat);
106 if (m_DebugShapeBBox != NULL)
108 m_DebugShapeBBox.SetMatrix(mat);
116 void EditorShapeSetColor(
int color)
118 if (m_DebugShapeBBox)
120 m_DebugShapeBBox.SetColor(color);
127 void EditorShapeSelect()
129 EditorShapeSetColor(COLOR_OBJ_BBOX_SELECT);
135 void EditorShapeDeselect()
137 EditorShapeSetColor(COLOR_OBJ_BBOX_NORMAL);
150 GetObject().GetCollisionBox(min_max);
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];
160 Print(
"Error: SceneObject "+ m_ObjectNameOrigin +
" dont has game object.");
169 void EditorShapeAdd()
171 if (m_DebugShapeBBox != NULL)
179 float width = size[0];
180 float height = size[1];
181 float length = size[2];
183 float width_h = width*0.5;
184 float lenght_h = length*0.5;
196 m_DebugShapeBBox =
Debug.DrawBox(min, max);
197 EditorShapeUpdatePos();
198 EditorShapeDeselect();
204 void EditorShapeRemove()
206 if (m_DebugShapeBBox != NULL)
208 m_DebugShapeBBox.Destroy();
209 m_DebugShapeBBox = NULL;
218 for (
int i = 0; i < m_LinkedSceneObjectsShapes.Count(); i++)
220 if (m_LinkedSceneObjectsShapes.GetKey(i) == obj)
222 m_LinkedSceneObjectsShapes.GetElement(i).Destroy();
223 m_LinkedSceneObjectsShapes.Remove(obj);
234 if (obj.GetObject() != NULL && GetObject() != NULL)
236 if (m_LinkedSceneObjectsShapes.Contains(obj))
238 EditorLineRemove(obj);
241 vector pos1 = obj.GetSize();
242 pos1[0] = 0; pos1[1] = pos1[1] / 2; pos1[2] = 0;
243 pos1 = pos1 + obj.GetObject().GetPosition();
246 pos2[0] = 0; pos2[1] = pos2[1] / 2; pos2[2] = 0;
247 pos2 = pos2 + GetObject().GetPosition();
249 m_LinkedSceneObjectsShapes.Insert(obj,
Debug.DrawArrow(pos1, pos2));
264 bool IsLinkedWithSceneObject(
SceneObject scene_object)
266 int index = m_LinkedSceneObjects.Find(scene_object);
280 void LinkSceneObject(
SceneObject scene_object,
bool draw_line =
true)
282 if (!IsLinkedWithSceneObject(scene_object))
286 EditorLineAdd(scene_object);
288 m_LinkedSceneObjects.Insert(scene_object);
297 int index = m_LinkedSceneObjects.Find(scene_object);
298 if (index >= 0 && index < m_LinkedSceneObjects.Count())
300 EditorLineRemove(scene_object);
301 m_LinkedSceneObjects.Remove(index);
310 int link_count = GetLinkedSceneObjectsCount();
314 for (
int i = 0; i < link_count; ++i)
316 PluginSceneManager.GetInstance().UnlinkSceneObjects(
this, GetLinkedSceneObject(0));
326 return m_LinkedSceneObjects;
332 int GetLinkedSceneObjectsCount()
334 return m_LinkedSceneObjects.Count();
342 return m_LinkedSceneObjects.Get(i);
350 return GetLinkedSceneObject(i).GetObject();
360 GetGame().ObjectDelete(m_ObjectPtr);
364 for (
int i = 0; i < m_LinkedSceneObjects.Count(); i++)
366 EditorLineRemove(m_LinkedSceneObjects.Get(i));
377 return m_ObjectPtr.GetType();
383 void PlaceOnSurface()
390 SceneObjectSynch(par);
394 m_ObjectPtr.PlaceOnSurface();
402 void SetPosition(
vector pos)
409 SceneObjectSynch(par);
413 m_ObjectPtr.SetPosition(pos);
417 EditorShapeUpdatePos();
426 return m_ObjectPtr.GetPosition();
436 return m_ObjectPtr.GetHealth(
"",
"");
446 return m_ObjectPtr.GetMaxHealth(
"",
"");
453 void SetHealth(
float value)
460 SceneObjectSynch(par);
464 m_ObjectPtr.SetHealth(
"",
"", value);
472 string GetPositionAsString()
475 return m_ObjectPtr.GetPosition().ToString(
false);
476 return Vector(0,0,0).ToString(
false);
482 void SetPositionAsString(
string string_pos)
484 SetPosition(string_pos.ToVector());
494 vector v = m_ObjectPtr.GetOrientation();
504 void SetRotation(
float rot)
508 vector v = m_ObjectPtr.GetOrientation();
510 m_ObjectPtr.SetOrientation(v);
511 EditorShapeUpdatePos();
515 void SceneObjectSynch(
Param p)
523 void AddRotation(
float add_rot)
530 SceneObjectSynch(par);
534 vector v = m_ObjectPtr.GetOrientation();
535 v[0] = v[0] + add_rot;
536 m_ObjectPtr.SetOrientation(v);
538 EditorShapeUpdatePos();
546 void AddAttachment(
string att_name)
548 GetObject().GetInventory().CreateAttachment(att_name);
556 return GetObject().GetInventory().CanAddAttachment(e);
574 for (
int i = 0; i < GetObject().GetInventory().AttachmentCount(); ++i)
576 ret.Insert(GetObject().GetInventory().GetAttachmentFromIndex(i));
587 string type_name = GetTypeName();
605 GetGame().ConfigGetTextArray(cfg_path, cfg_attachments);
607 return cfg_attachments;