Exemplo n.º 1
0
        private void CollectNearbyEntitiesInternal(int gameTime, float maxDistanceDelta)
        {
            if (gameTime - _lastFullUpdateTime > 5000)
            {
                MemoryAccess.CollectEntitiesFull();

                _lastFullUpdateTime = gameTime;
            }

            if (gameTime > _nextUpdateTime)
            {
                foreach (var ent in MemoryAccess.GetAllEntitiesInternal())
                {
                    if (_pulledEntities.Count >= MaxEntityCount)
                    {
                        break;
                    }

                    if (_pulledEntities.ContainsKey(ent.Handle) ||
                        ent.Position.DistanceTo2D(_position) > maxDistanceDelta ||
                        ent.HeightAboveGround > 300.0f)
                    {
                        continue;
                    }

                    if (ent is Ped && !(ent as Ped).IsRagdoll && ent.HeightAboveGround > 2.0f)
                    {
                        Function.Call(Hash.SET_PED_TO_RAGDOLL, ent.Handle, 800, 1500, 2, 1, 1, 0);
                    }

                    AddEntity(new ActiveEntity(ent, 3.0f * Probability.GetScalar(), 3.0f * Probability.GetScalar()));
                }

                _nextUpdateTime = gameTime + 200;
            }
        }