Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RadioVehicleSpawnPointComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/GameMode", description: "Spawn point entity", visible: false)]
3 {
4 }
5 
6 class SCR_RadioVehicleSpawnPoint : SCR_SpawnPoint
7 {
8  protected SCR_PlayerSpawnPointManagerComponent m_PlayerSpawnPointManager;
9  protected Physics m_Physics;
10 
11  //------------------------------------------------------------------------------------------------
12  override void EOnInit(IEntity owner)
13  {
14  super.EOnInit(owner);
15 
16  BaseGameMode gameMode = GetGame().GetGameMode();
17  if (gameMode)
18  m_PlayerSpawnPointManager = SCR_PlayerSpawnPointManagerComponent.Cast(gameMode.FindComponent(SCR_PlayerSpawnPointManagerComponent));
19 
20  IEntity parent = owner.GetParent();
21  while (parent && !m_Physics)
22  {
23  if (Vehicle.Cast(parent))
24  {
25  m_Physics = parent.GetPhysics();
26  parent = parent.GetParent();
27  break;
28  }
29 
30  parent = parent.GetParent();
31  }
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  override bool IsSpawnPointEnabled()
36  {
37  return m_bSpawnPointEnabled && (!m_PlayerSpawnPointManager || m_PlayerSpawnPointManager.IsRadioVehicleSpawningEnabled());
38  }
39 
40  //------------------------------------------------------------------------------------------------
41  override bool CanReserveFor_S(int playerId, out SCR_ESpawnResult result = SCR_ESpawnResult.SPAWN_NOT_ALLOWED)
42  {
43  if (!super.CanReserveFor_S(playerId, result))
44  {
45  if (m_PlayerSpawnPointManager && !m_PlayerSpawnPointManager.IsRadioVehicleSpawningEnabled())
46  result = SCR_ESpawnResult.NOT_ALLOWED_RADIO_VEHICLE_SPAWNING_DISABLED;
47 
48  return false;
49  }
50 
51  //~ Vehicle is moving
52  if (m_Physics)
53  {
54  if (m_Physics.GetVelocity() != vector.Zero || m_Physics.GetAngularVelocity() != vector.Zero)
55  {
56  result = SCR_ESpawnResult.NOT_ALLOWED_VEHICLE_MOVING;
57  return false;
58  }
59  }
60 
61 
62  //~ Check if occupied
64  {
65  Faction defaultFaction = m_FactionAffiliationComponent.GetDefaultAffiliatedFaction();
66  Faction currentFaction = m_FactionAffiliationComponent.GetAffiliatedFaction();
67 
68  if (!currentFaction)
69  return true;
70 
71  if (defaultFaction != currentFaction)
72  {
73  SCR_Faction scrDefaultFaction = SCR_Faction.Cast(defaultFaction);
74 
75  if (!scrDefaultFaction || !scrDefaultFaction.IsFactionFriendly(currentFaction))
76  {
77  result = SCR_ESpawnResult.NOT_ALLOWED_SPAWNPOINT_OCCUPIED_BY_HOSTILE;
78  return false;
79  }
80  }
81  }
82 
83  return true;
84  }
85 
86  //------------------------------------------------------------------------------------------------
87  protected override void InitFactionAffiliation(IEntity owner)
88  {
89  IEntity parent = owner.GetParent();
90  while (parent && !m_FactionAffiliationComponent)
91  {
94  parent = parent.GetParent();
95  }
96 
99 
101  {
102  Faction faction = m_FactionAffiliationComponent.GetDefaultAffiliatedFaction();
103  if (faction)
104  m_sFaction = faction.GetFactionKey();
105  }
106  }
107 }
SCR_ESpawnResult
SCR_ESpawnResult
Definition: SCR_ESpawnResult.c:8
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
IsSpawnPointEnabled
override bool IsSpawnPointEnabled()
Definition: SCR_RadioVehicleSpawnPointComponent.c:35
SCR_SpawnPoint
Spawn point entity defines positions on which players can possibly spawn.
Definition: SCR_SpawnPoint.c:27
SCR_SpawnPointClass
Definition: SCR_SpawnPoint.c:2
m_Physics
protected Physics m_Physics
Definition: SCR_RadioVehicleSpawnPointComponent.c:9
InitFactionAffiliation
protected override void InitFactionAffiliation(IEntity owner)
Definition: SCR_RadioVehicleSpawnPointComponent.c:87
m_PlayerSpawnPointManager
SCR_RadioVehicleSpawnPointClass m_PlayerSpawnPointManager
CanReserveFor_S
override bool CanReserveFor_S(int playerId, out SCR_ESpawnResult result=SCR_ESpawnResult.SPAWN_NOT_ALLOWED)
Definition: SCR_RadioVehicleSpawnPointComponent.c:41
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_RadioVehicleSpawnPointComponent.c:12
Faction
Definition: Faction.c:12
m_FactionAffiliationComponent
protected FactionAffiliationComponent m_FactionAffiliationComponent
Definition: SCR_BaseSupportStationComponent.c:122
SCR_RadioVehicleSpawnPointClass
Definition: SCR_RadioVehicleSpawnPointComponent.c:2
SCR_FactionAffiliationComponent
Definition: SCR_FactionAffiliationComponent.c:10
SCR_Faction
Definition: SCR_Faction.c:6
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180