Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SpawnPositionComponent.c
Go to the documentation of this file.
2{
3 [Attribute(defvalue: "-0.4 0 -0.3", category: "Position Boundaries")]
5
6 [Attribute(defvalue: "0.4 1.8 0.4", category: "Position Boundaries")]
8
9 //------------------------------------------------------------------------------------------------
12 {
13 return m_vMinBounds;
14 }
15
16 //------------------------------------------------------------------------------------------------
19 {
20 return m_vMaxBounds;
21 }
22}
23
24class SCR_SpawnPositionComponent : ScriptComponent
25{
26#ifdef WORKBENCH
27 protected ref Shape m_DebugShape;
28#endif
29
30 //------------------------------------------------------------------------------------------------
32 bool IsFree()
33 {
35 if (!prefabData)
36 return false;
38 vector transform[4];
39 GetOwner().GetTransform(transform);
40
41 return GetGame().GetWorld().QueryEntitiesByOBB(prefabData.GetMinBoundsVector(), prefabData.GetMaxBoundsVector(), transform, CheckEntity, FilterEntity, EQueryEntitiesFlags.ALL | EQueryEntitiesFlags.WITH_OBJECT);
42 }
43
44 //------------------------------------------------------------------------------------------------
45 protected bool CheckEntity(IEntity ent)
46 {
48 if (!damageManager || !damageManager.IsDestroyed())
49 return false;
50
51 return true;
52 }
53
54 //------------------------------------------------------------------------------------------------
55 protected bool FilterEntity(IEntity ent)
56 {
57 return ent.IsInherited(ChimeraCharacter);
58 }
59
60 //------------------------------------------------------------------------------------------------
61 override void EOnInit(IEntity owner)
62 {
63 SCR_SpawnPositionComponentManager manager = SCR_SpawnPositionComponentManager.GetInstance();
64 if (manager)
65 manager.AddSpawnPosition(this);
66 }
67
68 //------------------------------------------------------------------------------------------------
69 override void OnPostInit(IEntity owner)
70 {
71 super.OnPostInit(owner);
72 SetEventMask(owner, EntityEvent.INIT);
73 }
74
75#ifdef WORKBENCH
76 //------------------------------------------------------------------------------------------------
77 protected void DrawDebugShape()
78 {
79 SCR_SpawnPositionComponentClass prefabData = SCR_SpawnPositionComponentClass.Cast(GetComponentData(GetOwner()));
80 if (!prefabData)
81 return;
82
84 params.TransformMode = ETransformMode.WORLD;
85
86 IEntity owner = GetOwner();
87 owner.GetTransform(params.Transform);
88
89 int shapeFlags = ShapeFlags.WIREFRAME;
90 m_DebugShape = Shape.Create(ShapeType.BBOX, Color.CYAN, shapeFlags, prefabData.GetMinBoundsVector(), prefabData.GetMaxBoundsVector());
91
92 m_DebugShape.SetMatrix(params.Transform);
93 }
94
95 //------------------------------------------------------------------------------------------------
96 override int _WB_GetAfterWorldUpdateSpecs(IEntity owner, IEntitySource src)
97 {
98 return EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE;
99 }
100
101 //------------------------------------------------------------------------------------------------
102 override event void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
103 {
104 if (GetGame().InPlayMode())
105 return;
106
107 if (m_DebugShape)
108 {
109 vector transform[4];
110 owner.GetTransform(transform);
111 m_DebugShape.SetMatrix(transform);
112 }
113 else
114 {
116 }
117 }
118#endif
119
120 //------------------------------------------------------------------------------------------------
121 // destructor
123 {
124 SCR_SpawnPositionComponentManager manager = SCR_SpawnPositionComponentManager.GetInstance(false);
125 if (manager)
126 manager.DeleteSpawnPosition(this);
127 }
128}
ArmaReforgerScripted GetGame()
Definition game.c:1398
bool FilterEntity(IEntity ent)
SCR_CharacterSoundComponentClass GetComponentData()
void DrawDebugShape(bool draw)
void ~SCR_SpawnPositionComponent()
SCR_SpawnPositionComponentClass ScriptComponentClass IsFree()
Returns true, if there is no living character inside of defined boundaries.
bool CheckEntity(IEntity ent)
enum EVehicleType IEntity
event int _WB_GetAfterWorldUpdateSpecs(IEntity owner, IEntitySource src)
Called after _WB_OnInit or also later when editor needs to know whether _WB_AfterWorldUpdate needs to...
proto external int SetEventMask(notnull IEntity owner, int mask)
event void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
Called after updating world in Workbench. The entity must be selected. You can use editor API here an...
proto external Managed FindComponent(typename typeName)
proto external void GetTransform(out vector mat[])
proto external GenericEntity GetOwner()
Get owner entity.
void EOnInit(IEntity owner)
void EntitySpawnParams()
Definition gameLib.c:130
ShapeType
Definition ShapeType.c:13
ShapeFlags
Definition ShapeFlags.c:13
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EQueryEntitiesFlags