Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
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)]
4class ScriptModelClass
5{
6
7}
8
9ScriptModelClass ScriptModelSource;
10
11class 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
Object GetObject()
int[] IEntitySource
Definition enentity.c:2
proto native void SetFlags(ShapeFlags flags)
void ParamEnum(string key, string value, string desc="")
Definition enentity.c:811
EntityFlags
Entity flags.
Definition enentity.c:115
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:856
proto native dGeom dGeomCreateBox(vector size)
Creates box geometry.
ActiveState
Definition activestate.c:10
proto native void dBodyDestroy(notnull IEntity ent)
Destroys attached physics body.
proto native void dBodyActive(notnull IEntity ent, ActiveState activeState)
proto native void dBodyDynamic(notnull IEntity ent, bool dynamic)
proto bool dBodyCreateDynamicEx(notnull IEntity ent, vector centerOfMass, float mass, PhysicsGeomDef geoms[])
proto native void dBodySetMass(notnull IEntity body, float mass)
proto native bool dBodyIsSet(notnull IEntity ent)
Has the entity attached physics body?
proto native void ReleaseObject(vobject object, int flag=0)
string Type
int[] vobject
Definition proto.c:46