Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
scriptmodel.c
Go to the documentation of this file.
1 #ifdef GAME_TEMPLATE
2 
3 [EditorAttribute("box", "GameLib/Scripted", "Script model", "-0.25 -0.25 -0.25", "0.25 0.25 0.25", "255 0 0 255", "0 0 0 0", true, true, true)]
4 class ScriptModelClass
5 {
6 
7 }
8 
9 ScriptModelClass ScriptModelSource;
10 
11 class ScriptModel: GenericEntity
12 {
13  [Attribute("", "resourceNamePicker", "Model", "xob")]
14  string Model;
15  [Attribute("1", "combobox", "Physics", "", { ParamEnum("None", "2"), ParamEnum("Static", "1"), ParamEnum("Dynamic", "0") } )]
16  int Type;
17 
18  void ScriptModel(IEntitySource src, IEntity parent)
19  {
20  if (Model== "")
21  return;
22 
23  SetFlags(EntityFlags.ACTIVE | EntityFlags.SOLID | EntityFlags.VISIBLE, false);
24 
25  vobject vobj = GetObject(Model);
26  SetObject(vobj, "");
27  ReleaseObject(vobj, false);
28 
29  if (Type == 1)
30  {
31  dBodyCreateStatic(this, 0xffffffff); // todo - defines for layer mask
32  }
33  else if (Type == 0)
34  {
35  if(!dBodyCreateDynamic(this, 1.0, 0xffffffff))
36  {
37  //create implicit box
38  vector mins, maxs;
39  GetBounds(mins, maxs);
40  vector center = (mins + maxs) * 0.5;
41  vector size = maxs - mins;
42 
43  PhysicsGeomDef geoms[] = {PhysicsGeomDef("", dGeomCreateBox(size), "material/default", 0xffffffff)};
44  dBodyCreateDynamicEx(this, center, 1, geoms);
45  }
46  if(dBodyIsSet(this))
47  {
48  dBodySetMass(this, 1.0);
49  dBodyActive(this, ActiveState.ACTIVE);
50  dBodyDynamic(this, true);
51  }
52  }
53  }
54 
55  void ~ScriptModel()
56  {
57  if(dBodyIsSet(this))
58  dBodyDestroy(this);
59  }
60 }
61 
62 #endif
PhysicsGeomDef
Definition: enphysics.c:31
IEntitySource
Definition: enentity.c:15
EntityFlags
EntityFlags
Entity flags.
Definition: enentity.c:114
vobject
Definition: proto.c:48
ReleaseObject
proto native void ReleaseObject(vobject object, int flag=0)
ActiveState
ActiveState
state of a rigidbody
Definition: enphysics.c:85
dBodyActive
proto native void dBodyActive(notnull IEntity ent, ActiveState activeState)
dBodyDestroy
proto native void dBodyDestroy(notnull IEntity ent)
Destroys attached physics body.
IEntity
Definition: enentity.c:164
dBodyCreateDynamicEx
proto bool dBodyCreateDynamicEx(notnull IEntity ent, vector centerOfMass, float mass, PhysicsGeomDef geoms[])
dBodyDynamic
proto native void dBodyDynamic(notnull IEntity ent, bool dynamic)
dBodyIsSet
proto native bool dBodyIsSet(notnull IEntity ent)
Has the entity attached physics body?
vector
Definition: enconvert.c:105
Attribute
Definition: enentity.c:823
EditorAttribute
void EditorAttribute(string style, string category, string description, vector sizeMin, vector sizeMax, string color, string color2="0 0 0 0", bool visible=true, bool insertable=true, bool dynamicBox=false)
Definition: enentity.c:854
SetFlags
proto native void SetFlags(ShapeFlags flags)
dBodySetMass
proto native void dBodySetMass(notnull IEntity body, float mass)
GetObject
proto native vobject GetObject(string name)
Loads object from data, or gets it from cache. Object must be released when not used.
dGeomCreateBox
proto native dGeom dGeomCreateBox(vector size)
Creates box geometry.
ParamEnum
void ParamEnum(string key, string value, string desc="")
Definition: enentity.c:8
Type
string Type
Definition: jsondatacontaminatedarea.c:11