private void LookupMobs(
            RequestCache requestCache)
        {
            int mobCount = requestCache.GetMobs(m_room_key).Count();
            int mobIndex = 0;

            m_mobs = new MobState[mobCount];
            foreach (Mob mob in requestCache.GetMobs(m_room_key))
            {
                m_mobs[mobIndex] = new MobState
                {
                    mob_id        = mob.ID,
                    mob_type_name = mob.MobType.Name,
                    health        = mob.Health,
                    energy        = mob.Energy,
                    game_id       = mob.RoomKey.game_id,
                    room_x        = mob.RoomKey.x,
                    room_y        = mob.RoomKey.y,
                    room_z        = mob.RoomKey.z,
                    x             = mob.Position.x,
                    y             = mob.Position.y,
                    z             = mob.Position.z,
                    angle         = mob.Angle
                };

                ++mobIndex;
            }
        }
Esempio n. 2
0
        private bool DetermineSpawnCount(
            RequestCache requestCache)
        {
            m_max_spawn_count     = m_world.WorldTemplate.MaxSpawnsPerRoomEntry;
            m_current_spawn_count = requestCache.GetMobs(m_room.room_key).Count();

            return(m_current_spawn_count < m_max_spawn_count);
        }
        private int LookupEntities(
            RequestCache requestCache)
        {
            foreach (Mob mob in requestCache.GetMobs(m_roomKey))
            {
                m_mobContexts.Add(new MobUpdateContext(this, mob));
            }

            // Don't bother looking up anything else if there are no mobs
            if (m_mobContexts.Count > 0)
            {
                m_energyTanks = requestCache.GetEnergyTanks(m_roomKey).ToList();
                m_players     = requestCache.GetPlayers(m_roomKey).ToList();
            }

            return(m_mobContexts.Count);
        }
Esempio n. 4
0
        private bool ChooseMobSpawners(
            RequestCache requestCache,
            out string result_code)
        {
            bool success           = true;
            int  desiredSpawnCount = m_max_spawn_count - m_current_spawn_count;

            result_code = SuccessMessages.GENERAL_SUCCESS;

            // Compute a list of all the occupied nav cells
            List <int> occupiedNavCells =
                requestCache.GetMobs(m_room.room_key).Select(m => m_room.runtime_nav_mesh.ComputeNavRefAtPoint(m.Position).NavCellIndex).ToList();

            // Only use mob spawners that have a non zero remaining spawn count
            // and don't have a mob currently standing over stop of it.
            List <MobSpawner> availableMobSpawners =
                (from s in m_room.mobSpawners
                 where s.RemainingSpawnCount > 0 &&
                 !occupiedNavCells.Contains(m_room.runtime_nav_mesh.ComputeNavRefAtPoint(s.Position).NavCellIndex)
                 select s).ToList <MobSpawner>();

            // Shuffle the list and pick the top N spawners (where N is based on difficulty)
            if (availableMobSpawners.Count > 0)
            {
                RNGUtilities.DeterministicKnuthShuffle(m_room.random_seed, availableMobSpawners);

                for (int spawnerIndex = 0;
                     spawnerIndex < availableMobSpawners.Count && spawnerIndex < desiredSpawnCount;
                     spawnerIndex++)
                {
                    m_chosenMobSpawners.Add(availableMobSpawners[spawnerIndex]);
                }
            }

            return(success);
        }
        private bool ChooseMobSpawners(
            RequestCache requestCache,
            out string result_code)
        {
            bool success= true;
            int desiredSpawnCount = m_max_spawn_count - m_current_spawn_count;

            result_code = SuccessMessages.GENERAL_SUCCESS;

            // Compute a list of all the occupied nav cells
            List<int> occupiedNavCells =
                requestCache.GetMobs(m_room.room_key).Select(m => m_room.runtime_nav_mesh.ComputeNavRefAtPoint(m.Position).NavCellIndex).ToList();

            // Only use mob spawners that have a non zero remaining spawn count
            // and don't have a mob currently standing over stop of it.
            List<MobSpawner> availableMobSpawners =
                (from s in m_room.mobSpawners
                where s.RemainingSpawnCount > 0 &&
                        !occupiedNavCells.Contains(m_room.runtime_nav_mesh.ComputeNavRefAtPoint(s.Position).NavCellIndex)
                select s).ToList<MobSpawner>();

            // Shuffle the list and pick the top N spawners (where N is based on difficulty)
            if (availableMobSpawners.Count > 0)
            {
                RNGUtilities.DeterministicKnuthShuffle(m_room.random_seed, availableMobSpawners);

                for (int spawnerIndex = 0;
                    spawnerIndex < availableMobSpawners.Count && spawnerIndex < desiredSpawnCount;
                    spawnerIndex++)
                {
                    m_chosenMobSpawners.Add(availableMobSpawners[spawnerIndex]);
                }
            }

            return success;
        }
        private void LookupMobs(
            RequestCache requestCache)
        {
            int mobCount = requestCache.GetMobs(m_room_key).Count();
            int mobIndex = 0;

            m_mobs = new MobState[mobCount];
            foreach (Mob mob in requestCache.GetMobs(m_room_key))
            {
                m_mobs[mobIndex] = new MobState
                {
                    mob_id = mob.ID,
                    mob_type_name = mob.MobType.Name,
                    health = mob.Health,
                    energy = mob.Energy,
                    game_id = mob.RoomKey.game_id,
                    room_x = mob.RoomKey.x,
                    room_y = mob.RoomKey.y,
                    room_z = mob.RoomKey.z,
                    x = mob.Position.x,
                    y = mob.Position.y,
                    z = mob.Position.z,
                    angle = mob.Angle
                };

                ++mobIndex;
            }
        }
        private bool DetermineSpawnCount(
            RequestCache requestCache)
        {
            m_max_spawn_count = m_world.WorldTemplate.MaxSpawnsPerRoomEntry;
            m_current_spawn_count = requestCache.GetMobs(m_room.room_key).Count();

            return m_current_spawn_count < m_max_spawn_count;
        }
        private int LookupEntities(
            RequestCache requestCache)
        {
            foreach (Mob mob in requestCache.GetMobs(m_roomKey))
            {
                m_mobContexts.Add(new MobUpdateContext(this, mob));
            }

            // Don't bother looking up anything else if there are no mobs
            if (m_mobContexts.Count > 0)
            {
                m_energyTanks = requestCache.GetEnergyTanks(m_roomKey).ToList();
                m_players = requestCache.GetPlayers(m_roomKey).ToList();
            }

            return m_mobContexts.Count;
        }