Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SlotDisabler.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/Utility", description: "Disables slots in certain radius.")]
2class SCR_SlotDisablerEntityClass : GenericEntityClass
3{
4};
5
6class SCR_SlotDisablerEntity : GenericEntity
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 {
45 SCR_EditableEntityComponent comp = SCR_EditableEntityComponent.Cast(slot.FindComponent(SCR_EditableEntityComponent));
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
66 }
67
68 //------------------------------------------------------------------------------------------------
69 void ~SCR_SlotDisablerEntity()
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 int _WB_GetAfterWorldUpdateSpecs(IEntitySource src)
105 {
106 return EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE;
107 }
108
109 override void _WB_AfterWorldUpdate(float timeSlice)
110 {
111 if (m_bVisualize)
112 {
113 auto origin = GetOrigin();
114 auto radiusShape = Shape.CreateSphere(COLOR_YELLOW, ShapeFlags.WIREFRAME | ShapeFlags.ONCE, origin, m_fRadius);
115
116 foreach (SCR_SiteSlotEntity slot : m_aQueriedSlots)
117 {
118 auto arrowShape = Shape.CreateArrow(origin, slot.GetOrigin(), 0.1, COLOR_GREEN, ShapeFlags.ONCE);
119 }
120 }
121
122 super._WB_AfterWorldUpdate(timeSlice);
123 }
124
125 #endif
126
127};
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
EDamageType type
void QueryEntities(vector min, vector max, vector m_vMatrix[4])
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
event void _WB_AfterWorldUpdate(float timeSlice)
Called after updating world in Workbench. The entity must be visible in frustum, selected or named....
event bool _WB_OnKeyChanged(BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
Any property value has been changed. You can use editor API here and do some additional edit actions ...
event int _WB_GetAfterWorldUpdateSpecs(IEntitySource src)
Called after _WB_OnInit or also later when editor needs to know whether _WB_AfterWorldUpdate needs to...
event void _WB_SetExtraVisualiser(EntityVisualizerType type, IEntitySource src)
If entity needs to have a special visualizer instead of default one, here is the place where you can ...
void IEntity(IEntitySource src, IEntity parent)
protected script Constructor
proto external EntityEvent SetEventMask(EntityEvent e)
proto external vector GetOrigin()
proto external BaseWorld GetWorld()
const int COLOR_GREEN
Definition constants.c:22
const int COLOR_YELLOW
Definition constants.c:24
ShapeFlags
Definition ShapeFlags.c:13
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EntityVisualizerType
Game editor entity visualizer type.