Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_doorOpener.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/Utility", description: "Opens door in certain radius.")]
2class SCR_DoorOpenerEntityClass : GenericEntityClass
3{
4};
5
6// doorComp.GetOwner() would solve the need for this
7class DoorStruct
8{
9 IEntity owner;
10 DoorComponent component;
11
12 void DoorStruct(IEntity e, DoorComponent comp)
13 {
14 this.owner = e;
15 this.component = comp;
16 }
17};
18
19class SCR_DoorOpenerEntity : GenericEntity
20{
21 [Attribute(defvalue: "10", uiwidget: UIWidgets.Slider, desc: "Radius in which to open door.", "0 1000 1")]
22 protected float m_fRadius;
23
24 [Attribute(defvalue: "1", uiwidget: UIWidgets.Slider, desc: "How much the doors should be opened", "0. 1 0.01")]
25 protected float m_fControlValue;
26
27
28 private ref array<ref DoorStruct> m_aQueriedDoors;
29
30 #ifdef WORKBENCH
31 private bool m_bVisualize;
32 #endif
33
34 //------------------------------------------------------------------------------------------------
35 private bool QueryEntities(IEntity e)
36 {
38 if (door)
39 m_aQueriedDoors.Insert(new DoorStruct(e, door));
40
41 return true;
42 }
43
44 //------------------------------------------------------------------------------------------------
45 private void GetDoors(float radius)
46 {
47 BaseWorld world = GetWorld();
48 world.QueryEntitiesBySphere(GetOrigin(), radius, QueryEntities);
49 }
50
51 //------------------------------------------------------------------------------------------------
52 override void EOnInit(IEntity owner)
53 {
54 RplId instigatorId;
55
56 // server only
57 RplComponent rplComponent = RplComponent.Cast(owner.FindComponent(RplComponent));
58 if (rplComponent)
59 {
60 if (!rplComponent.IsMaster())
61 return;
62
63 instigatorId = rplComponent.Id();
64 }
65
66 // capture doors around
67 m_aQueriedDoors = {};
68 GetDoors(m_fRadius);
69 // set state
70 foreach (DoorStruct door : m_aQueriedDoors)
71 door.component.SetControlValue(m_fControlValue, instigatorId);
72
73 // cleanup
74 m_aQueriedDoors.Clear();
75 m_aQueriedDoors = null;
76
77 // destroy self
78 delete owner;
79 }
80
81 //------------------------------------------------------------------------------------------------
82 void SCR_DoorOpenerEntity(IEntitySource src, IEntity parent)
83 {
84 if (SCR_Global.IsEditMode(this))
85 return;
86
88 }
89
90 //------------------------------------------------------------------------------------------------
91 void ~SCR_DoorOpenerEntity()
92 {
93 }
94
95 #ifdef WORKBENCH
96
97 private void _CaptureDoors()
98 {
99 m_aQueriedDoors = {};
100 GetDoors(m_fRadius);
101 }
102
103 override bool _WB_OnKeyChanged(BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
104 {
105 _CaptureDoors();
106 return super._WB_OnKeyChanged(src, key, ownerContainers, parent);
107 }
108
109 override void _WB_SetExtraVisualiser(EntityVisualizerType type, IEntitySource src)
110 {
111 m_bVisualize = false;
112 switch (type)
113 {
114 case EntityVisualizerType.EVT_NONE:
115 return;
116
117 case EntityVisualizerType.EVT_NORMAL:
118 return;
119 }
120
121 m_bVisualize = true;
122 _CaptureDoors();
123 super._WB_SetExtraVisualiser(type, src);
124 }
125
126 override int _WB_GetAfterWorldUpdateSpecs(IEntitySource src)
127 {
128 return EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE;
129 }
130
131 override void _WB_AfterWorldUpdate(float timeSlice)
132 {
133 if (m_bVisualize)
134 {
135 auto origin = GetOrigin();
136 auto radiusShape = Shape.CreateSphere(COLOR_YELLOW, ShapeFlags.WIREFRAME | ShapeFlags.ONCE, origin, m_fRadius);
137
138 foreach (DoorStruct door : m_aQueriedDoors)
139 {
140 auto arrowShape = Shape.CreateArrow(origin, door.owner.GetOrigin(), 0.1, COLOR_GREEN, ShapeFlags.ONCE);
141 }
142 }
143
144 super._WB_AfterWorldUpdate(timeSlice);
145 }
146
147 #endif
148
149};
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 Managed FindComponent(typename typeName)
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.
int RplId
Definition EnNetwork.c:33