Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SlotDisabler.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Utility", description: "Disables slots in certain radius.")]
2 class SCR_SlotDisablerEntityClass : GenericEntityClass
3 {
4 };
5 
7 {
8  [Attribute(defvalue: "10", uiwidget: UIWidgets.Slider, desc: "Radius in which to disable slots.", "0 1000 1")]
9  protected float m_fRadius;
10 
11  private ref array<SCR_SiteSlotEntity> m_aQueriedSlots;
12 
13  #ifdef WORKBENCH
14  private bool m_bVisualize;
15  #endif
16 
17  //------------------------------------------------------------------------------------------------
18  private bool QueryEntities(IEntity e)
19  {
21 
22  if (slot)
23  m_aQueriedSlots.Insert(slot);
24 
25  return true;
26  }
27 
28  //------------------------------------------------------------------------------------------------
29  private void GetSlots(float radius)
30  {
31  BaseWorld world = GetWorld();
32  world.QueryEntitiesBySphere(GetOrigin(), radius, QueryEntities);
33  }
34 
35  //------------------------------------------------------------------------------------------------
36  override void EOnInit(IEntity owner)
37  {
38  // capture slots around
39  m_aQueriedSlots = {};
40  GetSlots(m_fRadius);
41 
42  // disable slots
43  foreach (SCR_SiteSlotEntity slot : m_aQueriedSlots)
44  {
46 
47  if (comp)
48  comp.SetVisible(false);
49  }
50 
51  // cleanup
52  m_aQueriedSlots.Clear();
53  m_aQueriedSlots = null;
54 
55  // destroy self
56  delete owner;
57  }
58 
59  //------------------------------------------------------------------------------------------------
60  void SCR_SlotDisablerEntity(IEntitySource src, IEntity parent)
61  {
62  if (SCR_Global.IsEditMode(this))
63  return;
64 
65  SetEventMask(EntityEvent.INIT);
66  }
67 
68  //------------------------------------------------------------------------------------------------
70  {
71  }
72 
73  #ifdef WORKBENCH
74 
75  private void _CaptureDoors()
76  {
77  m_aQueriedSlots = {};
78  GetSlots(m_fRadius);
79  }
80 
81  override bool _WB_OnKeyChanged(BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
82  {
83  _CaptureDoors();
84  return super._WB_OnKeyChanged(src, key, ownerContainers, parent);
85  }
86 
87  override void _WB_SetExtraVisualiser(EntityVisualizerType type, IEntitySource src)
88  {
89  m_bVisualize = false;
90  switch (type)
91  {
92  case EntityVisualizerType.EVT_NONE:
93  return;
94 
95  case EntityVisualizerType.EVT_NORMAL:
96  return;
97  }
98 
99  m_bVisualize = true;
100  _CaptureDoors();
101  super._WB_SetExtraVisualiser(type, src);
102  }
103 
104  override void _WB_AfterWorldUpdate(float timeSlice)
105  {
106  if (m_bVisualize)
107  {
108  auto origin = GetOrigin();
109  auto radiusShape = Shape.CreateSphere(COLOR_YELLOW, ShapeFlags.WIREFRAME | ShapeFlags.ONCE, origin, m_fRadius);
110 
111  foreach (SCR_SiteSlotEntity slot : m_aQueriedSlots)
112  {
113  auto arrowShape = Shape.CreateArrow(origin, slot.GetOrigin(), 0.1, COLOR_GREEN, ShapeFlags.ONCE);
114  }
115  }
116 
117  super._WB_AfterWorldUpdate(timeSlice);
118  }
119 
120  #endif
121 
122 };
SCR_SlotDisablerEntity
Definition: SCR_SlotDisabler.c:6
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
GetOrigin
vector GetOrigin()
Definition: SCR_AIUtilityComponent.c:279
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_fRadius
float m_fRadius
Definition: SCR_AITargetClusterState.c:30
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_Global
Definition: Functions.c:6
SCR_SiteSlotEntity
Definition: SCR_SiteSlotEntity.c:26
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
SCR_SlotDisablerEntityClass
Definition: SCR_SlotDisabler.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180