Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SpawnPositionComponent.c
Go to the documentation of this file.
1 class SCR_SpawnPositionComponentClass : ScriptComponentClass
2 {
3  [Attribute(defvalue: "-0.4 0 -0.3", category: "Position Boundaries")]
4  protected vector m_vMinBounds;
5 
6  [Attribute(defvalue: "0.4 1.8 0.4", category: "Position Boundaries")]
7  protected vector m_vMaxBounds;
8 
9  //------------------------------------------------------------------------------------------------
11  vector GetMinBoundsVector()
12  {
13  return m_vMinBounds;
14  }
15 
16  //------------------------------------------------------------------------------------------------
18  vector GetMaxBoundsVector()
19  {
20  return m_vMaxBounds;
21  }
22 }
23 
24 class SCR_SpawnPositionComponent : ScriptComponent
25 {
26 #ifdef WORKBENCH
27  protected ref Shape m_DebugShape;
28 #endif
29 
30  //------------------------------------------------------------------------------------------------
32  bool IsFree()
33  {
34  SCR_SpawnPositionComponentClass prefabData = SCR_SpawnPositionComponentClass.Cast(GetComponentData(GetOwner()));
35  if (!prefabData)
36  return false;
37 
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  {
47  DamageManagerComponent damageManager = DamageManagerComponent.Cast(ent.FindComponent(DamageManagerComponent));
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 
83  EntitySpawnParams params = new EntitySpawnParams();
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 event void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
97  {
98  if (GetGame().InPlayMode())
99  return;
100 
101  if (m_DebugShape)
102  {
103  vector transform[4];
104  owner.GetTransform(transform);
105  m_DebugShape.SetMatrix(transform);
106  }
107  else
108  {
109  DrawDebugShape();
110  }
111  }
112 #endif
113 
114  //------------------------------------------------------------------------------------------------
115  // destructor
117  {
118  SCR_SpawnPositionComponentManager manager = SCR_SpawnPositionComponentManager.GetInstance(false);
119  if (manager)
120  manager.DeleteSpawnPosition(this);
121  }
122 }
m_vMaxBounds
protected vector m_vMaxBounds
Definition: SCR_SpawnPositionComponent.c:6
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
DrawDebugShape
protected void DrawDebugShape(bool draw)
Definition: SCR_ScenarioFrameworkLayerBase.c:829
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_vMinBounds
protected vector m_vMinBounds
Definition: SCR_SpawnPositionComponent.c:3
IsFree
SCR_SpawnPositionComponentClass ScriptComponentClass IsFree()
Returns true, if there is no living character inside of defined boundaries.
Definition: SCR_SpawnPositionComponent.c:32
SCR_SpawnPositionComponentClass
Definition: SCR_SpawnPositionComponent.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
OnPostInit
override void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_SpawnPositionComponent.c:69
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
CheckEntity
protected bool CheckEntity(IEntity ent)
Definition: SCR_SpawnPositionComponent.c:45
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_SpawnPositionComponent.c:61
~SCR_SpawnPositionComponent
void ~SCR_SpawnPositionComponent()
Definition: SCR_SpawnPositionComponent.c:116
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
FilterEntity
protected bool FilterEntity(IEntity ent)
Definition: SCR_SpawnPositionComponent.c:55
DamageManagerComponent
Definition: DamageManagerComponent.c:12
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180