Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioFrameworkSlotWaypoint.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/ScenarioFramework/SlotWaypoint", description: "")]
3 {
4  // prefab properties here
5 }
6 
7 //------------------------------------------------------------------------------------------------
9 {
10  [Attribute(desc: "Waypoint settings", category: "Waypoint")]
12 
13  //------------------------------------------------------------------------------------------------
14  override IEntity SpawnAsset()
15  {
16  //If Randomization is enabled, it will try to apply settings from Attributes.
17  //If it fails anywhere, original m_sObjectToSpawn will be used.
18  if (m_bRandomizePerFaction)
19  {
20  ResourceName randomAsset;
21  if (SCR_StringHelper.IsEmptyOrWhiteSpace(GetRandomlySpawnedObject()))
22  {
23  GetRandomAsset(randomAsset);
24  if (!SCR_StringHelper.IsEmptyOrWhiteSpace(randomAsset))
25  m_sObjectToSpawn = randomAsset;
26  }
27  else
28  {
29  randomAsset = GetRandomlySpawnedObject();
30  }
31  }
32 
33  if (m_Waypoint)
34  m_sObjectToSpawn = m_Waypoint.GetWaypointPrefab();
35 
36  Resource resource = Resource.Load(m_sObjectToSpawn);
37  if (!resource || !resource.IsValid())
38  return null;
39 
40  GetOwner().GetWorldTransform(m_SpawnParams.Transform);
41  m_SpawnParams.TransformMode = ETransformMode.WORLD;
42  //--- Apply rotation
43  vector angles = Math3D.MatrixToAngles(m_SpawnParams.Transform);
44  Math3D.AnglesToMatrix(angles, m_SpawnParams.Transform);
45 
46  //--- Spawn the prefab
47  BaseResourceObject resourceObject = resource.GetResource();
48  if (!resourceObject)
49  return null;
50 
51  if (m_bIgnoreOrientChildrenToTerrain)
52  {
53  IEntityComponentSource slotCompositionComponent = SCR_BaseContainerTools.FindComponentSource(resourceObject, SCR_SlotCompositionComponent);
54  if (slotCompositionComponent)
55  {
56  SCR_SlotCompositionComponent.IgnoreOrientChildrenToTerrain();
57  }
58  }
59 
60  IEntity entity = GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), m_SpawnParams);
61  SCR_AIWorld aiWorld = SCR_AIWorld.Cast(GetGame().GetAIWorld());
62  if (aiWorld)
63  aiWorld.RequestNavmeshRebuildEntity(entity);
64 
65  m_aSpawnedEntities.Insert(entity);
66 
67  if (m_vPosition != vector.Zero)
68  entity.SetOrigin(m_vPosition);
69 
70  if (m_Waypoint)
71  {
72  m_Waypoint.m_SlotWaypoint = this;
73  m_Waypoint.SetupWaypoint(entity);
74  }
75 
76  return entity;
77  }
78 
79  //------------------------------------------------------------------------------------------------
80  override protected void DrawDebugShape(bool draw)
81  {
82  if (!draw)
83  return;
84 
85  Shape dbgShapeCenter = null;
86  Shape dbgShapeOuter = null;
87 
88  float radius = m_fDebugShapeRadius;
89  if (m_Waypoint)
90  radius = m_Waypoint.GetWaypointCompletionRadius();
91 
92 
93  dbgShapeCenter = Shape.CreateCylinder(
95  ShapeFlags.TRANSP | ShapeFlags.DOUBLESIDE | ShapeFlags.NOZWRITE | ShapeFlags.ONCE | ShapeFlags.NOOUTLINE,
96  GetOwner().GetOrigin(),
97  0.25,
98  10
99  );
100 
101  dbgShapeOuter = Shape.CreateCylinder(
103  ShapeFlags.TRANSP | ShapeFlags.DOUBLESIDE | ShapeFlags.NOZWRITE | ShapeFlags.ONCE | ShapeFlags.NOOUTLINE,
104  GetOwner().GetOrigin(),
105  radius,
106  2
107  );
108  }
109 
110 #ifdef WORKBENCH
111  //------------------------------------------------------------------------------------------------
112  override bool _WB_OnKeyChanged(IEntity owner, BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
113  {
114  if (key == "m_bShowDebugShapesInWorkbench")
115  DrawDebugShape(m_bShowDebugShapesInWorkbench);
116 
117  if (key == "coords")
118  {
119  SCR_EntityHelper.DeleteEntityAndChildren(m_PreviewEntity);
120 
121  Resource resource = Resource.Load(m_sObjectToSpawn);
122  if (!resource)
123  return false;
124 
125  SpawnEntityPreview(owner, resource);
126  return true;
127  }
128  else if (key == "m_sObjectToSpawn")
129  {
130  SCR_EntityHelper.DeleteEntityAndChildren(m_PreviewEntity);
131  return false;
132  }
133  return false;
134  }
135 #endif
136 
137  //------------------------------------------------------------------------------------------------
138  // constructor
142  void SCR_ScenarioFrameworkSlotWaypoint(IEntityComponentSource src, IEntity ent, IEntity parent)
143  {
144 #ifdef WORKBENCH
145  m_iDebugShapeColor = ARGB(100, 0x00, 0x10, 0xFF);
146 #endif
147  }
148 }
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
Attribute
SCR_ScenarioFrameworkSlotWaypointClass SCR_ScenarioFrameworkSlotBaseClass Attribute(desc:"Waypoint settings", category:"Waypoint")
Definition: SCR_ScenarioFrameworkSlotWaypoint.c:10
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_ScenarioFrameworkSlotBaseClass
Definition: SCR_ScenarioFrameworkSlotBase.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_StringHelper
Definition: SCR_StringHelper.c:1
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
m_PreviewEntity
protected IEntity m_PreviewEntity
Definition: SCR_ItemPlacementComponent.c:23
SCR_ScenarioFrameworkSlotWaypoint
void SCR_ScenarioFrameworkSlotWaypoint(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkSlotWaypoint.c:142
SCR_AIWorld
Definition: SCR_AIWorld.c:23
GetOrigin
vector GetOrigin()
Definition: SCR_AIUtilityComponent.c:279
SCR_ScenarioFrameworkSlotBase
void SCR_ScenarioFrameworkSlotBase(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkSlotBase.c:661
m_Waypoint
protected AIWaypoint m_Waypoint
Definition: SCR_AmbientPatrolSpawnPointComponent.c:48
SCR_ScenarioFrameworkWaypoint
Definition: SCR_ScenarioFrameworkWaypoint.c:3
SCR_ScenarioFrameworkSlotWaypointClass
Definition: SCR_ScenarioFrameworkSlotWaypoint.c:2
m_iDebugShapeColor
protected int m_iDebugShapeColor
Definition: SCR_ScenarioFrameworkLayerBase.c:69
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_BaseContainerTools
Definition: SCR_BaseContainerTools.c:3
GetRandomAsset
ResourceName GetRandomAsset(out ResourceName prefab)
Definition: SCR_ScenarioFrameworkSlotBase.c:448
m_fDebugShapeRadius
protected float m_fDebugShapeRadius
Definition: SCR_ScenarioFrameworkLayerBase.c:66
m_SpawnParams
SCR_ScenarioFrameworkLayerTaskDestroyClass m_SpawnParams
m_vPosition
vector m_vPosition
Definition: SCR_AITalkRequest.c:23
m_aSpawnedEntities
protected ref array< IEntity > m_aSpawnedEntities
Definition: SCR_ScenarioFrameworkLayerBase.c:62
SCR_SlotCompositionComponent
Entity composition which is supposed to fit into a slot.
Definition: SCR_SlotCompositionComponent.c:44
SpawnAsset
IEntity SpawnAsset(string name, ResourceName type, IEntity spawnpoint=null)
Definition: SCR_CampaignTutorialComponentArland.c:1199
GetRandomlySpawnedObject
ResourceName GetRandomlySpawnedObject()
Definition: SCR_ScenarioFrameworkSlotBase.c:236
DrawDebugShape
override protected void DrawDebugShape(bool draw)
Definition: SCR_ScenarioFrameworkSlotWaypoint.c:80
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180