DayZ 1.24
Loading...
Searching...
No Matches
VicinityItemManager Class Reference
Collaboration diagram for VicinityItemManager:
[legend]

Private Member Functions

void Init ()
 
array< EntityAIGetVicinityItems ()
 
void AddVicinityItems (Object object)
 
array< CargoBaseGetVicinityCargos ()
 
void AddVicinityCargos (CargoBase object)
 
void ResetRefreshCounter ()
 
void Update (float delta_time)
 
bool ExcludeFromContainer_Phase1 (Object actor_in_radius)
 
bool ExcludeFromContainer_Phase2 (Object object_in_radius)
 
bool ExcludeFromContainer_Phase3 (Object object_in_cone)
 
bool CanIgnoreDistanceCheck (EntityAI entity_ai)
 
void RefreshVicinityItems ()
 
bool IsObstructed (Object filtered_object)
 

Static Private Member Functions

static VicinityItemManager GetInstance ()
 

Private Attributes

const float UPDATE_FREQUENCY = 0.25
 
const float VICINITY_DISTANCE = 0.5
 
const float VICINITY_ACTOR_DISTANCE = 2.0
 
const float VICINITY_LARGE_ACTOR_DISTANCE = 3.0
 
const float VICINITY_CONE_DISTANCE = 2.0
 
const float VICINITY_CONE_REACH_DISTANCE = 2.0
 
const float VICINITY_CONE_ANGLE = 30
 
const float VICINITY_CONE_RADIANS = 0.5
 
const string CE_CENTER = "ce_center"
 
const float HEIGHT_OFFSET = 0.2
 
const int OBJECT_OBSTRUCTION_WEIGHT = 10000
 
const float CONE_HEIGHT_MIN = -0.5
 
const float CONE_HEIGHT_MAX = 3.0
 
ref array< EntityAIm_VicinityItems = new array<EntityAI>()
 
ref array< CargoBasem_VicinityCargos = new array<CargoBase>()
 
float m_RefreshCounter
 

Static Private Attributes

static ref VicinityItemManager s_Instance
 

Detailed Description

Definition at line 1 of file VicinityItemManager.c.

Member Function Documentation

◆ AddVicinityCargos()

void VicinityItemManager::AddVicinityCargos ( CargoBase object)
inlineprivate

Definition at line 62 of file VicinityItemManager.c.

63 {
64 if (m_VicinityCargos.Find(object) == INDEX_NOT_FOUND)
65 m_VicinityCargos.Insert(object);
66 }
ref array< CargoBase > m_VicinityCargos
const int INDEX_NOT_FOUND
Definition gameplay.c:13

References INDEX_NOT_FOUND, and m_VicinityCargos.

Referenced by RefreshVicinityItems().

◆ AddVicinityItems()

void VicinityItemManager::AddVicinityItems ( Object object)
inlineprivate

Definition at line 39 of file VicinityItemManager.c.

40 {
41 EntityAI entity = EntityAI.Cast(object);
42 if (!entity)
43 return;
44
46 return;
47
49 {
50 if (!FreeDebugCamera.GetInstance() || FreeDebugCamera.GetInstance().IsActive() == false)
51 return;
52 }
53
54 m_VicinityItems.Insert(entity);
55 }
PlayerBase GetPlayer()
script counterpart to engine's class Inventory
Definition Inventory.c:79
static proto native bool CheckManipulatedObjectsDistances(notnull EntityAI e0, notnull EntityAI e1, float radius)
const float VICINITY_CONE_REACH_DISTANCE
ref array< EntityAI > m_VicinityItems
proto native CGame GetGame()

References GameInventory::CheckManipulatedObjectsDistances(), GetGame(), GetPlayer(), INDEX_NOT_FOUND, m_VicinityItems, and VICINITY_CONE_REACH_DISTANCE.

Referenced by RefreshVicinityItems().

◆ CanIgnoreDistanceCheck()

bool VicinityItemManager::CanIgnoreDistanceCheck ( EntityAI entity_ai)
inlineprivate

Definition at line 193 of file VicinityItemManager.c.

194 {
195 return MiscGameplayFunctions.CanIgnoreDistanceCheck(entity_ai);
196 }

Referenced by RefreshVicinityItems().

◆ ExcludeFromContainer_Phase1()

bool VicinityItemManager::ExcludeFromContainer_Phase1 ( Object actor_in_radius)
inlineprivate

If in free camera, allow viewing of inventory

Definition at line 84 of file VicinityItemManager.c.

85 {
88 return true;
89
91 if (entity == player)
92 return true;
93 if (entity.IsParticle())
94 return true;
95 if (entity.IsScriptedLight())
96 return true;
97 if (entity.IsBeingPlaced())
98 return true;
99 if (entity.IsHologram())
100 return true;
101 if (entity.IsMan() || entity.IsZombie() || entity.IsZombieMilitary())
102 {
103 //visibility cone check
104 vector entityPosition = entity.GetPosition();
105
106 if (entity && entity.IsMan())
107 {
109 if (vicinityPlayer)
110 entityPosition = vicinityPlayer.GetBonePositionWS(vicinityPlayer.GetBoneIndexByName("spine3"));
111 }
112 else if (entity && (entity.IsZombie() || entity.IsZombieMilitary()))
113 {
115 if (zombie)
116 entityPosition = zombie.GetBonePositionWS(zombie.GetBoneIndexByName("spine3"));
117 }
118
120 if (FreeDebugCamera.GetInstance() && FreeDebugCamera.GetInstance().IsActive())
121 return false;
122
124 entityDirection.Normalize();
125 entityDirection[1] = 0; //ignore height
126
128 playerDirection.Normalize();
129 playerDirection[1] = 0; //ignore height
130
132 if (dotRadians > -0.5)
133 return true;
134 }
135
136 return false;
137 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Definition EnConvert.c:271
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), vector::Dot(), GetGame(), and GetPlayer().

Referenced by RefreshVicinityItems().

◆ ExcludeFromContainer_Phase2()

bool VicinityItemManager::ExcludeFromContainer_Phase2 ( Object object_in_radius)
inlineprivate

Definition at line 139 of file VicinityItemManager.c.

140 {
142
144 return true;
145 if (entity == PlayerBase.Cast(GetGame().GetPlayer()))
146 return true;
147 if (entity.IsParticle())
148 return true;
149 if (entity.IsScriptedLight())
150 return true;
151 if (entity.IsBeingPlaced())
152 return true;
153 if (entity.IsHologram())
154 return true;
155
158 return true;
159 if (!item.IsTakeable())
160 return true;
161
162 return false;
163 }

References Class::CastTo(), GetGame(), and GetPlayer().

Referenced by RefreshVicinityItems().

◆ ExcludeFromContainer_Phase3()

bool VicinityItemManager::ExcludeFromContainer_Phase3 ( Object object_in_cone)
inlineprivate

Definition at line 165 of file VicinityItemManager.c.

166 {
169
170 //Print("---object in cone: " + object_in_cone);
172 return true;
173 if (entity == player)
174 return true;
175 if (entity.IsParticle())
176 return true;
177 if (entity.IsScriptedLight())
178 return true;
179 if (entity.IsBeingPlaced())
180 return true;
181 if (entity.IsHologram())
182 return true;
183
186 return true;
187 if (item && !item.IsTakeable())
188 return true;
189
190 return false;
191 }

References Class::CastTo(), GetGame(), and GetPlayer().

Referenced by RefreshVicinityItems().

◆ GetInstance()

static VicinityItemManager VicinityItemManager::GetInstance ( )
inlinestaticprivate

Definition at line 22 of file VicinityItemManager.c.

23 {
24 if (!s_Instance)
26
27 return s_Instance;
28 }
static ref VicinityItemManager s_Instance

References s_Instance.

Referenced by MissionBase::HideInventory(), OnShow(), and VicinityContainer::UpdateInterval().

◆ GetVicinityCargos()

array< CargoBase > VicinityItemManager::GetVicinityCargos ( )
inlineprivate

Definition at line 57 of file VicinityItemManager.c.

58 {
59 return m_VicinityCargos;
60 }

References m_VicinityCargos.

◆ GetVicinityItems()

array< EntityAI > VicinityItemManager::GetVicinityItems ( )
inlineprivate

Definition at line 34 of file VicinityItemManager.c.

35 {
36 return m_VicinityItems;
37 }

References m_VicinityItems.

◆ Init()

void VicinityItemManager::Init ( )
inlineprivate

Definition at line 30 of file VicinityItemManager.c.

31 {
32 }

◆ IsObstructed()

bool VicinityItemManager::IsObstructed ( Object filtered_object)
inlineprivate

Definition at line 386 of file VicinityItemManager.c.

387 {
388 return MiscGameplayFunctions.IsObjectObstructed(filtered_object);
389 }

Referenced by RefreshVicinityItems().

◆ RefreshVicinityItems()

void VicinityItemManager::RefreshVicinityItems ( )
inlineprivate

If in free camera, override the position that the inventory gets generated from

If in free camera, don't worry about obstructed objects if there are any

Definition at line 199 of file VicinityItemManager.c.

200 {
202
207 vector playerPosition = player.GetPosition();
211
213 bool cameraActive = FreeDebugCamera.GetInstance() && FreeDebugCamera.GetInstance().IsActive();
214 if (cameraActive)
215 {
216 playerPosition = FreeDebugCamera.GetInstance().GetPosition();
218
219 float headingAngle = FreeDebugCamera.GetInstance().GetOrientation()[0] * Math.DEG2RAD;
220
222 headingDirection[1] = 0;
224 headingDirection.Normalize();
225 }
226
227 if (m_VicinityItems)
228 m_VicinityItems.Clear();
229
231 m_VicinityCargos.Clear();
232
233 //1. GetAll actors in VICINITY_ACTOR_DISTANCE
234 //DebugActorsSphereDraw(VICINITY_ACTOR_DISTANCE);
236
237 // no filtering for cargo (initial implementation)
240
241 //filter unnecessary and duplicate objects beforehand
243 {
246
248 continue;
249
252 }
253
255 objectsInVicinity.Clear();
256
257 //2. GetAll Objects in VICINITY_DISTANCE
259 //DebugObjectsSphereDraw(VICINITY_DISTANCE);
260
261 //filter unnecessary and duplicate objects beforehand
263 {
266
268 continue;
269
272 }
273
275 objectsInVicinity.Clear();
276
277 //3. Add objects from GetEntitiesInCone
279 //DebugConeDraw(playerPosition, VICINITY_CONE_ANGLE);
280
283 //filter unnecessary and duplicate objects beforehand
285 {
288
290 continue;
291
293 {
294 //Test distance to closest component first
296 rayInput.flags = CollisionFlags.NEARESTCONTACT;
298 rayInput.radius = 0.1;
300
302 {
304 continue;
305
306 if (result.hierLevel > 0 && result.parent == objectInCone)
308 else if (result.hierLevel == 0 && result.obj == objectInCone)
310 }
311 }
312 }
313
314 //4. Add large objects - particularly buildings and BaseBuildingBase
320 };
321
322 params.SetParams(playerPosition, headingDirection.VectorToAngles(), boxEdgeLength * 2, ObjIntersect.View, ObjIntersect.Fire, true);
324 if (GetGame().IsBoxCollidingGeometryProxy(params, {player}, results))
325 {
327 {
328 if (bResult.obj && (bResult.obj.CanObstruct() || bResult.obj.CanProxyObstruct()))
329 {
330 if (allFoundObjects.Find(bResult.obj) == INDEX_NOT_FOUND)
331 allFoundObjects.Insert(bResult.obj);
332 }
333
334 if (bResult.parent && (bResult.parent.CanObstruct() || bResult.parent.CanProxyObstruct()))
335 {
336 if (allFoundObjects.Find(bResult.parent) == INDEX_NOT_FOUND)
337 allFoundObjects.Insert(bResult.parent);
338 }
339 }
340 }
341
342 //5. Filter filtered objects with RayCast from the player ( head bone )
345
347 if (obstructingObjects.Count() > 0 && !cameraActive)
348 {
349 if (filteredObjects.Count() > 10)
350 {
352 MiscGameplayFunctions.GetHeadBonePos(player, rayStart);
353
356
357 foreach (Object object: filteredObjectsGrouped)
359 }
360 else
361 {
363 {
366
367 //distance check
369 {
371 continue;
372 }
373
376 }
377 }
378 }
379 else
380 {
383 }
384 }
void DayZPlayerUtils()
cannot be instantiated
Class that holds parameters to feed into CGame.IsBoxCollidingGeometryProxy.
represents base for cargo storage for entities
Definition Cargo.c:7
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
Definition EnMath.c:7
bool IsObstructed(Object filtered_object)
const float VICINITY_CONE_DISTANCE
void AddVicinityCargos(CargoBase object)
const float VICINITY_ACTOR_DISTANCE
bool ExcludeFromContainer_Phase3(Object object_in_cone)
bool ExcludeFromContainer_Phase1(Object actor_in_radius)
const float VICINITY_LARGE_ACTOR_DISTANCE
void AddVicinityItems(Object object)
const float VICINITY_CONE_ANGLE
bool ExcludeFromContainer_Phase2(Object object_in_radius)
bool CanIgnoreDistanceCheck(EntityAI entity_ai)
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
CollisionFlags
Definition EnDebug.c:141
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static const float DEG2RAD
Definition EnMath.c:17

References AddVicinityCargos(), AddVicinityItems(), CanIgnoreDistanceCheck(), Class::CastTo(), CONE_HEIGHT_MAX, CONE_HEIGHT_MIN, Math::Cos(), DayZPlayerUtils(), Math::DEG2RAD, vector::DistanceSq(), ExcludeFromContainer_Phase1(), ExcludeFromContainer_Phase2(), ExcludeFromContainer_Phase3(), GetGame(), GetPlayer(), INDEX_NOT_FOUND, IsObstructed(), m_VicinityCargos, m_VicinityItems, DayZPhysics::RaycastRVProxy(), Math::Sin(), VICINITY_ACTOR_DISTANCE, VICINITY_CONE_ANGLE, VICINITY_CONE_DISTANCE, VICINITY_CONE_REACH_DISTANCE, VICINITY_DISTANCE, and VICINITY_LARGE_ACTOR_DISTANCE.

Referenced by Update().

◆ ResetRefreshCounter()

void VicinityItemManager::ResetRefreshCounter ( )
inlineprivate

Definition at line 68 of file VicinityItemManager.c.

69 {
71 }

References m_RefreshCounter.

◆ Update()

void VicinityItemManager::Update ( float delta_time)
inlineprivate

Member Data Documentation

◆ CE_CENTER

const string VicinityItemManager::CE_CENTER = "ce_center"
private

Definition at line 11 of file VicinityItemManager.c.

◆ CONE_HEIGHT_MAX

const float VicinityItemManager::CONE_HEIGHT_MAX = 3.0
private

Definition at line 15 of file VicinityItemManager.c.

Referenced by RefreshVicinityItems().

◆ CONE_HEIGHT_MIN

const float VicinityItemManager::CONE_HEIGHT_MIN = -0.5
private

Definition at line 14 of file VicinityItemManager.c.

Referenced by RefreshVicinityItems().

◆ HEIGHT_OFFSET

const float VicinityItemManager::HEIGHT_OFFSET = 0.2
private

Definition at line 12 of file VicinityItemManager.c.

◆ m_RefreshCounter

float VicinityItemManager::m_RefreshCounter
private

Definition at line 19 of file VicinityItemManager.c.

Referenced by ResetRefreshCounter(), and Update().

◆ m_VicinityCargos

ref array<CargoBase> VicinityItemManager::m_VicinityCargos = new array<CargoBase>()
private

◆ m_VicinityItems

ref array<EntityAI> VicinityItemManager::m_VicinityItems = new array<EntityAI>()
private

Definition at line 17 of file VicinityItemManager.c.

Referenced by AddVicinityItems(), GetVicinityItems(), and RefreshVicinityItems().

◆ OBJECT_OBSTRUCTION_WEIGHT

const int VicinityItemManager::OBJECT_OBSTRUCTION_WEIGHT = 10000
private

Definition at line 13 of file VicinityItemManager.c.

◆ s_Instance

ref VicinityItemManager VicinityItemManager::s_Instance
staticprivate

Definition at line 20 of file VicinityItemManager.c.

Referenced by GetInstance().

◆ UPDATE_FREQUENCY

const float VicinityItemManager::UPDATE_FREQUENCY = 0.25
private

Definition at line 3 of file VicinityItemManager.c.

Referenced by Update().

◆ VICINITY_ACTOR_DISTANCE

const float VicinityItemManager::VICINITY_ACTOR_DISTANCE = 2.0
private

Definition at line 5 of file VicinityItemManager.c.

Referenced by RefreshVicinityItems().

◆ VICINITY_CONE_ANGLE

const float VicinityItemManager::VICINITY_CONE_ANGLE = 30
private

Definition at line 9 of file VicinityItemManager.c.

Referenced by RefreshVicinityItems().

◆ VICINITY_CONE_DISTANCE

const float VicinityItemManager::VICINITY_CONE_DISTANCE = 2.0
private

Definition at line 7 of file VicinityItemManager.c.

Referenced by RefreshVicinityItems().

◆ VICINITY_CONE_RADIANS

const float VicinityItemManager::VICINITY_CONE_RADIANS = 0.5
private

Definition at line 10 of file VicinityItemManager.c.

◆ VICINITY_CONE_REACH_DISTANCE

const float VicinityItemManager::VICINITY_CONE_REACH_DISTANCE = 2.0
private

Definition at line 8 of file VicinityItemManager.c.

Referenced by AddVicinityItems(), and RefreshVicinityItems().

◆ VICINITY_DISTANCE

const float VicinityItemManager::VICINITY_DISTANCE = 0.5
private

Definition at line 4 of file VicinityItemManager.c.

Referenced by RefreshVicinityItems().

◆ VICINITY_LARGE_ACTOR_DISTANCE

const float VicinityItemManager::VICINITY_LARGE_ACTOR_DISTANCE = 3.0
private

Definition at line 6 of file VicinityItemManager.c.

Referenced by RefreshVicinityItems().


The documentation for this class was generated from the following file: