DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ 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

См. определение в файле VicinityItemManager.c строка 209

210 {
211 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
212
213 array<Object> objectsInVicinity = new array<Object>();
214 array<CargoBase> proxyCargos = new array<CargoBase>();
215 array<Object> filteredObjects = new array<Object>();
216 array<Object> allFoundObjects = new array<Object>();
217 vector playerPosition = player.GetPosition();
218 vector playerHeadPositionFixed = playerPosition;
219 playerHeadPositionFixed[1] = playerHeadPositionFixed[1] + GetFixedHeadHeightAdjustment(player);
220 vector headingDirection = MiscGameplayFunctions.GetHeadingVector(player);
221
223 bool cameraActive = FreeDebugCamera.GetInstance() && FreeDebugCamera.GetInstance().IsActive();
224 if (cameraActive)
225 {
226 playerPosition = FreeDebugCamera.GetInstance().GetPosition();
227 playerHeadPositionFixed = playerPosition;
228
229 float headingAngle = FreeDebugCamera.GetInstance().GetOrientation()[0] * Math.DEG2RAD;
230
231 headingDirection[0] = Math.Cos(headingAngle);
232 headingDirection[1] = 0;
233 headingDirection[2] = Math.Sin(headingAngle);
234 headingDirection.Normalize();
235 }
236
237 if (m_VicinityItems)
238 m_VicinityItems.Clear();
239
241 m_VicinityCargos.Clear();
242
243 //1. GetAll actors in VICINITY_ACTOR_DISTANCE
244 //DebugActorsSphereDraw(VICINITY_ACTOR_DISTANCE);
245 GetGame().GetObjectsAtPosition3D(playerPosition, VICINITY_ACTOR_DISTANCE, objectsInVicinity, proxyCargos);
246
247 // no filtering for cargo (initial implementation)
248 foreach (CargoBase cargoObject : proxyCargos)
249 AddVicinityCargos(cargoObject);
250
251 //filter unnecessary and duplicate objects beforehand
252 foreach (Object actorInRadius : objectsInVicinity)
253 {
254 if (allFoundObjects.Find(actorInRadius) == INDEX_NOT_FOUND)
255 allFoundObjects.Insert(actorInRadius);
256
257 if (ExcludeFromContainer_Phase1(actorInRadius))
258 continue;
259
260 if (filteredObjects.Find(actorInRadius) == INDEX_NOT_FOUND)
261 filteredObjects.Insert(actorInRadius);
262 }
263
264 if (objectsInVicinity)
265 objectsInVicinity.Clear();
266
267 //2. GetAll Objects in VICINITY_DISTANCE
268 GetGame().GetObjectsAtPosition3D(playerPosition, VICINITY_DISTANCE, objectsInVicinity, proxyCargos);
269 //DebugObjectsSphereDraw(VICINITY_DISTANCE);
270
271 //filter unnecessary and duplicate objects beforehand
272 foreach (Object objectInRadius : objectsInVicinity)
273 {
274 if (allFoundObjects.Find(objectInRadius) == INDEX_NOT_FOUND)
275 allFoundObjects.Insert(objectInRadius);
276
277 if (ExcludeFromContainer_Phase2(objectInRadius))
278 continue;
279
280 if (filteredObjects.Find(objectInRadius) == INDEX_NOT_FOUND)
281 filteredObjects.Insert(objectInRadius);
282 }
283
284 if (objectsInVicinity)
285 objectsInVicinity.Clear();
286
287 //3. Add objects from GetEntitiesInCone
288 DayZPlayerUtils.GetEntitiesInCone(playerPosition, headingDirection, VICINITY_CONE_ANGLE, VICINITY_CONE_REACH_DISTANCE, CONE_HEIGHT_MIN, CONE_HEIGHT_MAX, objectsInVicinity);
289 //DebugConeDraw(playerPosition, VICINITY_CONE_ANGLE);
290
291 RaycastRVParams rayInput;
292 array<ref RaycastRVResult> raycastResults = new array<ref RaycastRVResult>();
293 //filter unnecessary and duplicate objects beforehand
294 foreach (Object objectInCone : objectsInVicinity)
295 {
296 if (allFoundObjects.Find(objectInCone) == INDEX_NOT_FOUND)
297 allFoundObjects.Insert(objectInCone);
298
299 if (ExcludeFromContainer_Phase3(objectInCone))
300 continue;
301
302 if (filteredObjects.Find(objectInCone) == INDEX_NOT_FOUND)
303 {
304 rayInput = new RaycastRVParams(playerHeadPositionFixed, objectInCone.GetPosition());
305 rayInput.flags = CollisionFlags.ALLOBJECTS;
306 rayInput.type = ObjIntersectView;
307 rayInput.radius = 0.1;
308 DayZPhysics.RaycastRVProxy(rayInput, raycastResults, {player});
309 //Debug.DrawLine(playerHeadPositionFixed,objectInCone.GetPosition(),COLOR_WHITE,ShapeFlags.ONCE);
310
311 foreach (RaycastRVResult result : raycastResults)
312 {
313 if (vector.DistanceSq(result.pos, playerPosition) > VICINITY_CONE_REACH_DISTANCE * VICINITY_CONE_REACH_DISTANCE)
314 continue;
315
316 if (result.hierLevel > 0)
317 {
318 if (result.parent.CanProxyObstruct())
319 break;
320
321 if (result.parent == objectInCone)
322 {
323 filteredObjects.Insert(objectInCone);
324 break;
325 }
326 }
327 else
328 {
329 if (result.obj == objectInCone)
330 {
331 filteredObjects.Insert(objectInCone);
332 break;
333 }
334 }
335 }
336 }
337 }
338
339 //4. Add large objects - particularly buildings and BaseBuildingBase
340 BoxCollidingParams params = new BoxCollidingParams();
341 vector boxEdgeLength = {
345 };
346
347 params.SetParams(playerPosition, headingDirection.VectorToAngles(), boxEdgeLength * 2, ObjIntersect.View, ObjIntersect.Fire, true);
348 array<ref BoxCollidingResult> results = new array<ref BoxCollidingResult>();
349 if (GetGame().IsBoxCollidingGeometryProxy(params, {player}, results))
350 {
351 foreach (BoxCollidingResult bResult : results)
352 {
353 if (bResult.obj && (bResult.obj.CanObstruct() || bResult.obj.CanProxyObstruct()))
354 {
355 if (allFoundObjects.Find(bResult.obj) == INDEX_NOT_FOUND)
356 allFoundObjects.Insert(bResult.obj);
357 }
358
359 if (bResult.parent && (bResult.parent.CanObstruct() || bResult.parent.CanProxyObstruct()))
360 {
361 if (allFoundObjects.Find(bResult.parent) == INDEX_NOT_FOUND)
362 allFoundObjects.Insert(bResult.parent);
363 }
364 }
365 }
366
367 //5. Filter filtered objects with RayCast from the player ( head bone )
368 array<Object> obstructingObjects = new array<Object>();
369 MiscGameplayFunctions.FilterObstructingObjects(allFoundObjects, obstructingObjects);
370
372 if (obstructingObjects.Count() > 0 && !cameraActive)
373 {
374 //obstructingObjects.Debug();
375 if (filteredObjects.Count() > 10)
376 {
377 array<Object> filteredObjectsGrouped = new array<Object>();
378 MiscGameplayFunctions.FilterObstructedObjectsByGrouping(playerHeadPositionFixed, VICINITY_CONE_DISTANCE, 0.3, filteredObjects, obstructingObjects, filteredObjectsGrouped, true, true, VICINITY_CONE_REACH_DISTANCE);
379
380 foreach (Object object: filteredObjectsGrouped)
381 AddVicinityItems(object);
382 }
383 else
384 {
385 foreach (Object filteredObjectClose: filteredObjects)
386 {
387 EntityAI entity;
388 Class.CastTo(entity, filteredObjectClose);
389
390 //distance check
391 if (vector.DistanceSq(playerPosition, entity.GetPosition()) > VICINITY_CONE_REACH_DISTANCE * VICINITY_CONE_REACH_DISTANCE)
392 {
393 if (!CanIgnoreDistanceCheck(entity))
394 {
395 continue;
396 }
397 }
398
399 if (!IsObstructed(filteredObjectClose))
400 {
401 AddVicinityItems(filteredObjectClose);
402 }
403 }
404 }
405 }
406 else
407 {
408 foreach (Object filteredObject: filteredObjects)
409 AddVicinityItems(filteredObject);
410 }
411 }
class LogManager EntityAI
void DayZPlayerUtils()
cannot be instantiated
Определения DayZPlayerUtils.c:465
PlayerBase GetPlayer()
Определения ModifierBase.c:51
proto native void SetParams(vector center, vector orientation, vector edgeLength, ObjIntersect primaryType, ObjIntersect secondaryType, bool fullComponentInfo)
Set the parameters.
proto native void GetObjectsAtPosition3D(vector pos, float radius, out array< Object > objects, out array< CargoBase > proxyCargos)
Returns list of all objects in sphere "radius" around position "pos".
float radius
radius along the ray tested
Определения DayZPhysics.c:57
int type
Определения DayZPhysics.c:73
CollisionFlags flags
Определения DayZPhysics.c:63
bool IsObstructed(Object filtered_object)
Определения VicinityItemManager.c:425
const float VICINITY_CONE_DISTANCE
Определения VicinityItemManager.c:7
const float VICINITY_CONE_REACH_DISTANCE
Определения VicinityItemManager.c:8
void AddVicinityCargos(CargoBase object)
Определения VicinityItemManager.c:68
const float VICINITY_ACTOR_DISTANCE
Определения VicinityItemManager.c:5
const float CONE_HEIGHT_MIN
Определения VicinityItemManager.c:14
bool ExcludeFromContainer_Phase3(Object object_in_cone)
Определения VicinityItemManager.c:177
bool ExcludeFromContainer_Phase1(Object actor_in_radius)
Определения VicinityItemManager.c:92
float GetFixedHeadHeightAdjustment(PlayerBase player)
Определения VicinityItemManager.c:413
const float CONE_HEIGHT_MAX
Определения VicinityItemManager.c:15
const float VICINITY_LARGE_ACTOR_DISTANCE
Определения VicinityItemManager.c:6
void AddVicinityItems(Object object)
Определения VicinityItemManager.c:39
const float VICINITY_CONE_ANGLE
Определения VicinityItemManager.c:9
ref array< EntityAI > m_VicinityItems
Определения VicinityItemManager.c:17
const float VICINITY_DISTANCE
Определения VicinityItemManager.c:4
bool ExcludeFromContainer_Phase2(Object object_in_radius)
Определения VicinityItemManager.c:153
bool CanIgnoreDistanceCheck(EntityAI entity_ai)
Определения VicinityItemManager.c:203
ref array< CargoBase > m_VicinityCargos
Определения VicinityItemManager.c:18
proto float Normalize()
Normalizes vector. Returns length.
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
const int INDEX_NOT_FOUND
Определения gameplay.c:13
class LOD Object
proto native CGame GetGame()
CollisionFlags
Определения EnDebug.c:141

Перекрестные ссылки AddVicinityCargos(), AddVicinityItems(), CanIgnoreDistanceCheck(), Class::CastTo(), CONE_HEIGHT_MAX, CONE_HEIGHT_MIN, Math::Cos(), DayZPlayerUtils(), Math::DEG2RAD, vector::DistanceSq(), ExcludeFromContainer_Phase1(), ExcludeFromContainer_Phase2(), ExcludeFromContainer_Phase3(), RaycastRVParams::flags, GetFixedHeadHeightAdjustment(), GetGame(), CGame::GetObjectsAtPosition3D(), GetPlayer(), INDEX_NOT_FOUND, IsObstructed(), m_VicinityCargos, m_VicinityItems, vector::Normalize(), RaycastRVParams::radius, DayZPhysics::RaycastRVProxy(), BoxCollidingParams::SetParams(), Math::Sin(), RaycastRVParams::type, vector::VectorToAngles(), VICINITY_ACTOR_DISTANCE, VICINITY_CONE_ANGLE, VICINITY_CONE_DISTANCE, VICINITY_CONE_REACH_DISTANCE, VICINITY_DISTANCE и VICINITY_LARGE_ACTOR_DISTANCE.

Используется в OnShow() и Update().