Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RequiredDeployablePart.c
Go to the documentation of this file.
2{
3 [Attribute(uiwidget: UIWidgets.ResourcePickerThumbnail, desc: "Prefab which is going to be required in order to deploy the main entity", params: "et")]
5
6 [Attribute(defvalue: "1", desc: "How many required prefabs need to be found in order to meet this requirement", params: "1 inf 1")]
8
9 [Attribute(desc: "Localized string used to tell the player which part he is missing when wont be found")]
11
12 [Attribute(defvalue: "1", desc: "Dictates whether elements found for this requirement are meant to be deleted upon deployment")]
14
15 [Attribute(defvalue: "0", desc: "Should game detach the magazines from weapons that are used for this requirement")]
17
18 protected ref array<IEntity> m_aFoundEntities;
19
20 //------------------------------------------------------------------------------------------------
23 {
24 return m_sPrefab;
25 }
26
27 //------------------------------------------------------------------------------------------------
28 void SetNumberOfRequiredPrefabs(int newValue)
29 {
31 }
32
33 //------------------------------------------------------------------------------------------------
39
40 //------------------------------------------------------------------------------------------------
43 {
44 return m_sPartName;
45 }
46
47 //------------------------------------------------------------------------------------------------
53
54 //------------------------------------------------------------------------------------------------
57 bool IsRequirementMet(out int difference)
58 {
59 difference = m_iNumberOfRequiredPrefabs;
61 return false;
62
63 difference -= m_aFoundEntities.Count();
64 return difference == 0;
65 }
66
67 //------------------------------------------------------------------------------------------------
70 {
72 return 0;
73
74 return m_aFoundEntities.Count();
75 }
76
77 //------------------------------------------------------------------------------------------------
83
84 //------------------------------------------------------------------------------------------------
86 array<IEntity> GetFoundEntities()
87 {
88 return m_aFoundEntities;
89 }
90
91 //------------------------------------------------------------------------------------------------
99 bool EvaluateFoundEntity(vector origin, float distanceSqToFoundEntity, notnull BaseContainer foundPrefab, notnull IEntity foundEntity)
100 {
101 Resource res = Resource.Load(m_sPrefab);
102 if (!res.IsValid())
103 return false;
104
105 BaseResourceObject resObject = res.GetResource();
106 if (!resObject)
107 return false;
108
109 BaseContainer requiredPrefab = resObject.ToBaseContainer();
110 if (requiredPrefab != foundPrefab)
111 return false;
112
114 {
115 AddFoundEntity(foundEntity);
116 return true;
117 }
118
119 foreach (int id, IEntity foundElement : m_aFoundEntities)
120 {
121 if (vector.DistanceSq(foundElement.GetOrigin(), origin) <= distanceSqToFoundEntity)
122 continue;
123
124 ReplaceFoundEntity(foundEntity, id);
125 return true;
126 }
127
128 return false;
129 }
130
131 //------------------------------------------------------------------------------------------------
136 bool DeleteFoundEntity(int id, notnull IEntity user)
137 {
138 if (!m_aFoundEntities || !m_aFoundEntities.IsIndexValid(id))
139 return false;
140
141 IEntity deletedEntity = m_aFoundEntities[id];
142 if (!deletedEntity)
143 return false;
144
146 SCR_MultiPartDeployableItemComponent.TryRemoveMagazineFromWeapons(deletedEntity, user);
147
148 GetGame().GetCallqueue().CallLater(SCR_EntityHelper.DeleteEntityAndChildren, param1: deletedEntity);//to give the time for the RPC calls to be sent
149 m_aFoundEntities.Remove(id);
150 return true;
151 }
152
153 //------------------------------------------------------------------------------------------------
156 void AddFoundEntity(notnull IEntity entity)
157 {
158 if (!m_aFoundEntities)
159 m_aFoundEntities = {entity};
160 else if (!m_aFoundEntities.Contains(entity))
161 m_aFoundEntities.Insert(entity);
162 }
163
164 //------------------------------------------------------------------------------------------------
168 void ReplaceFoundEntity(notnull IEntity entity, int id)
169 {
170 if (!m_aFoundEntities || m_aFoundEntities.IsEmpty())
171 return;
172
173 if (!m_aFoundEntities.IsIndexValid(id) || m_aFoundEntities.Contains(entity))
174 return;
175
176 m_aFoundEntities[id] = entity;
177 }
178
179 //------------------------------------------------------------------------------------------------
186}
AddonBuildInfoTool id
ArmaReforgerScripted GetGame()
Definition game.c:1398
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
bool IsRequirementMet(out int difference)
bool DeleteFoundEntity(int id, notnull IEntity user)
SCR_RequiredDeployablePart DeepClone()
void AddFoundEntity(notnull IEntity entity)
bool EvaluateFoundEntity(vector origin, float distanceSqToFoundEntity, notnull BaseContainer foundPrefab, notnull IEntity foundEntity)
void ReplaceFoundEntity(notnull IEntity entity, int id)
SCR_FieldOfViewSettings Attribute
Tuple param1
class Class Clone()
Return shallow copy of object, or null if it is not allowed (not public constructor).