Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioFrameworkQRFSlotAI.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/ScenarioFramework/Slot", description: "")]
3 {
4 }
5 
6 class SCR_ScenarioFrameworkQRFSlotAI : SCR_ScenarioFrameworkSlotAI
7 {
8  [Attribute(SCR_EQRFGroupType.INFANTRY.ToString(), UIWidgets.Flags, desc: "For which group types this spawn point is meant to be used", enums: ParamEnumArray.FromEnum(SCR_EQRFGroupType))]
9  protected int m_iGroupType;
10 
11  [Attribute(desc: "List of containing distance that this spawn point requires in order to spawn QRF of given type - when spawn point allows for QRF type for which it doesnt have the safe distance then its considered good for use even when player is standing on that position")]
12  protected ref array<ref SCR_QRFSpawnSafeZone> m_aSCR_QRFSpawnSafeZone;
13 
14  protected ref array<ref SCR_QRFWaypointConfig> m_aQRFWaypoints = {};
15 
16  //------------------------------------------------------------------------------------------------
19  {
20  return m_iGroupType;
21  }
22 
23  //------------------------------------------------------------------------------------------------
25  array<ref SCR_QRFSpawnSafeZone> GetSpawnSafeZones()
26  {
28  }
29 
30  //------------------------------------------------------------------------------------------------
31  void SetObjectToSpawn(ResourceName newObjectPrefab)
32  {
33  if (Resource.Load(newObjectPrefab).IsValid())
34  m_sObjectToSpawn = newObjectPrefab;
35  }
36 
37  //------------------------------------------------------------------------------------------------
40  {
41  return m_aWaypoints.Count();
42  }
43 
44  //------------------------------------------------------------------------------------------------
46  void ClearWaypoints(bool deleteWaypointEntities = false)
47  {
48  if (deleteWaypointEntities)
49  {
50  for (int i = m_aWaypoints.Count() - 1; i >= 0; i --)
51  {
52  SCR_EntityHelper.DeleteEntityAndChildren(m_aWaypoints[i]);
53  }
54  }
55  m_aWaypoints.Clear();
56  m_aQRFWaypoints.Clear();
57  }
58 
59  //------------------------------------------------------------------------------------------------
61  AIWaypoint CreateWaypoint(vector position, ResourceName wpPrefab)
62  {
63  AIWaypoint wp = SpawnWaypoint(position, wpPrefab);
64  if (!wp)
65  return null;
66 
67  m_aQRFWaypoints.Insert(new SCR_QRFWaypointConfig(wpPrefab, wpPosition : position));
68  return wp;
69  }
70 
71  //------------------------------------------------------------------------------------------------
73  protected AIWaypoint SpawnWaypoint(vector position, ResourceName wpPrefab)
74  {
75  EntitySpawnParams paramsPatrolWP = new EntitySpawnParams();
76  paramsPatrolWP.TransformMode = ETransformMode.WORLD;
77  paramsPatrolWP.Transform[3] = position;
78 
79  Resource resWP = Resource.Load(wpPrefab);
80  if (!resWP.IsValid())
81  return null;
82 
83  AIWaypoint waypoint = AIWaypoint.Cast(GetGame().SpawnEntityPrefab(resWP, GetGame().GetWorld(), paramsPatrolWP));
84  if (!waypoint)
85  return null;
86 
87  SCR_EntityHelper.SnapToGround(waypoint, onlyStatic : true);
88  m_aWaypoints.Insert(waypoint);
89  return waypoint;
90  }
91 
92  //------------------------------------------------------------------------------------------------
95  {
97  if (m_aQRFWaypoints.IsEmpty() || m_aSpawnedEntities.IsEmpty())
98  return;
99 
100  m_aWaypoints.Clear();
101  foreach (SCR_QRFWaypointConfig wpConfig : m_aQRFWaypoints)
102  {
103  m_aWaypoints.Insert(SpawnWaypoint(wpConfig.GetPosition(), wpConfig.GetWaypointPrefabName()));
104  }
105 
106  SCR_AIGroup group;
107  foreach (IEntity entity : m_aSpawnedEntities)
108  {
109  group = SCR_AIGroup.Cast(entity);
110  if (!group)
111  continue;
112 
113  foreach (AIWaypoint wp : m_aWaypoints)
114  {
115  group.AddWaypoint(wp);
116  }
117  }
118  }
119 
120  //------------------------------------------------------------------------------------------------
121  override void Init(SCR_ScenarioFrameworkArea area = null, SCR_ScenarioFrameworkEActivationType activation = SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT)
122  {
123  if (m_bDynamicallyDespawned && !m_aQRFWaypoints.IsEmpty() && !SCR_StringHelper.IsEmptyOrWhiteSpace(m_sObjectToSpawn))
124  {
127  }
128  super.Init(area, activation);
129  }
130 
131  //------------------------------------------------------------------------------------------------
132  protected override void SetWaypointToAI(SCR_ScenarioFrameworkLayerBase layer)
133  {
135  if (!m_Entity || (!Resource.Load(m_sWPToSpawn).IsValid() && m_aSlotWaypoints.IsEmpty()))
136  return;
137 
138  super.SetWaypointToAI(layer);
139  }
140 }
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SetObjectToSpawn
void SetObjectToSpawn(ResourceName newObjectPrefab)
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:31
Attribute
SCR_ScenarioFrameworkQRFSlotAIClass SCR_ScenarioFrameworkSlotAIClass Attribute(SCR_EQRFGroupType.INFANTRY.ToString(), UIWidgets.Flags, desc:"For which group types this spawn point is meant to be used", enums:ParamEnumArray.FromEnum(SCR_EQRFGroupType))] protected int m_iGroupType
CreateWaypoint
AIWaypoint CreateWaypoint(vector position, ResourceName wpPrefab)
Creation of waypoint entity and storing of waypoint information for dynamic respawn of this slot.
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:61
SCR_QRFWaypointConfig
void SCR_QRFWaypointConfig(ResourceName wpPrefab, SCR_EQRFGroupOrderType groupType=SCR_EQRFGroupOrderType.ANY, int distanceOffset=0, vector wpPosition=vector.Zero)
Definition: SCR_QRFWaypointConfig.c:50
GetOnAllChildrenSpawned
ScriptInvokerScenarioFrameworkLayer GetOnAllChildrenSpawned()
Definition: SCR_ScenarioFrameworkLayerBase.c:450
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SetWaypointToAI
protected override void SetWaypointToAI(SCR_ScenarioFrameworkLayerBase layer)
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:132
ClearWaypoints
void ClearWaypoints(bool deleteWaypointEntities=false)
Clears both array of queued waypoint configs and waypoints entities with option to delete them.
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:46
SCR_StringHelper
Definition: SCR_StringHelper.c:1
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
m_Entity
enum EAITargetInfoCategory m_Entity
GetSpawnSafeZones
array< ref SCR_QRFSpawnSafeZone > GetSpawnSafeZones()
Getter for an array of configs defining group types and their respective distances to nearest observe...
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:25
GetGroupType
int GetGroupType()
Getter for type of groups that are intended to be spawned with this slot.
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:18
m_bDynamicallyDespawned
protected bool m_bDynamicallyDespawned
Definition: SCR_ScenarioFrameworkLayerBase.c:74
SCR_ScenarioFrameworkArea
Definition: SCR_ScenarioFrameworkArea.c:24
m_aSCR_QRFSpawnSafeZone
protected ref array< ref SCR_QRFSpawnSafeZone > m_aSCR_QRFSpawnSafeZone
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:12
m_aWaypoints
protected ref array< Widget > m_aWaypoints
Definition: SCR_CampaignTutorialComponentArland.c:42
SCR_ScenarioFrameworkSlotAI
void SCR_ScenarioFrameworkSlotAI(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkSlotAI.c:558
m_aSlotWaypoints
ref array< SCR_ScenarioFrameworkSlotWaypoint > m_aSlotWaypoints
Definition: SCR_ScenarioFrameworkSlotAI.c:51
ProcessQueuedWaypoints
protected void ProcessQueuedWaypoints(SCR_ScenarioFrameworkLayerBase layer)
Creation and assignment of queued waypoints after this slot is dynamically respawned.
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:94
SpawnWaypoint
protected AIWaypoint SpawnWaypoint(vector position, ResourceName wpPrefab)
Creation and storage of waypoint entity.
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:73
SCR_EQRFGroupType
SCR_EQRFGroupType
Definition: SCR_QRFGroupConfig.c:1
SCR_ScenarioFrameworkQRFSlotAIClass
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:2
Init
override void Init(SCR_ScenarioFrameworkArea area=null, SCR_ScenarioFrameworkEActivationType activation=SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT)
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:121
SCR_ScenarioFrameworkSlotAIClass
Definition: SCR_ScenarioFrameworkSlotAI.c:2
SCR_AIGroup
Definition: SCR_AIGroup.c:68
GetNumberOfExistingWaypoints
int GetNumberOfExistingWaypoints()
Getter that returns number of existing waypoints for the entity that was the last one to be spawned.
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:39
SCR_ScenarioFrameworkLayerBase
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkLayerBase.c:875
ProcessWaypoints
protected void ProcessWaypoints(SCR_ScenarioFrameworkLayerBase layer)
Definition: SCR_ScenarioFrameworkSlotAI.c:409
m_aSpawnedEntities
protected ref array< IEntity > m_aSpawnedEntities
Definition: SCR_ScenarioFrameworkLayerBase.c:62
m_aQRFWaypoints
protected ref array< ref SCR_QRFWaypointConfig > m_aQRFWaypoints
Definition: SCR_ScenarioFrameworkQRFSlotAI.c:14
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180