9 [
Attribute(
"10 5 10", UIWidgets.EditBox,
"Size of box")]
11 [
Attribute(
"1", UIWidgets.CheckBox,
"Show prefab preview?")]
16 SetFlags(EntityFlags.ACTIVE);
17 SetEventMask(EntityEvent.INIT | EntityEvent.TOUCH | EntityEvent.CONTACT);
25 override private void EOnInit(IEntity owner)
28 autoptr PhysicsGeomDef geoms[] = {PhysicsGeomDef(
"", PhysicsGeom.CreateBox(m_size),
"material/default", EPhysicsLayerDefs.Vehicle | EPhysicsLayerDefs.Character)};
29 Physics.CreateGhostEx(
this, geoms);
37 override void _WB_AfterWorldUpdate(
float timeSlice)
39 Shape dbgShape =
null;
40 int color = ARGB(64, 0x33, 0x66, 0x99);
41 vector m_start = {m_size[0] * -0.5, m_size[1] * -0.5, m_size[2] * -0.5};
42 vector m_end = {m_size[0] * 0.5, m_size[1] * 0.5, m_size[2] * 0.5};
44 dbgShape = Shape.Create(ShapeType.BBOX, color, ShapeFlags.TRANSP | ShapeFlags.DOUBLESIDE | ShapeFlags.NOZWRITE | ShapeFlags.ONCE | ShapeFlags.NOOUTLINE, m_start, m_end);
47 GetWorldTransform(mat);
48 dbgShape.SetMatrix(mat);
50 override bool _WB_OnKeyChanged(BaseContainer src,
string key, BaseContainerList ownerContainers, IEntity parent)
53 bool m_showPreviewLocal;
54 src.Get(
"m_showPreview",m_showPreviewLocal);
55 if (m_showPreviewLocal)
70 override private void EOnTouch(IEntity owner, IEntity other,
int touchTypesMask)
72 PrintFormat(
"OnTouch triggered by entity %1 of type %2", other,touchTypesMask);
76 override private void EOnContact(IEntity owner, IEntity other, Contact contact)
78 PrintFormat(
"OnContact triggered by entity %1 of type %2", other, contact);
87 WorldEditorAPI m_API = _WB_GetEditorAPI();
90 Print(
"No children of sector spawn found!");
96 prefabSpawnPoint.GetWorldTransform(mat);
98 if (prefabSpawnPoint.ShouldSnapToGround())
104 EntitySpawnParams spawnParams =
new EntitySpawnParams;
105 spawnParams.TransformMode = ETransformMode.WORLD;
106 spawnParams.Transform = mat;
107 Resource resource = Resource.Load(prefabSpawnPoint.m_sLoadoutResource);
111 IEntity entity =
GetGame().SpawnEntityPrefab(resource, m_API.GetWorld(), spawnParams);
115 Print(
"Something is awfully wrong somewhere");
119 prefabSpawnPoint.AddChild(entity,0, EAddChildFlags.AUTO_TRANSFORM);
120 prefabSpawnPoint.GetWorldTransform(mat);
121 entity.SetWorldTransform(mat);
123 child = child.GetSibling();
126 Print(
"Running game mode");
132 void DespawnChildren()
137 IEntity ent = spawnPoint.GetChildren();
140 spawnPoint.RemoveChild(ent);
143 spawnPoint = spawnPoint.GetSibling();