コード例 #1
0
        public bool CanSpawnMoreBots(MyPlayer.PlayerId pid)
        {
            if (!Sync.IsServer)
            {
                Debug.Assert(false, "Server only");
                return(false);
            }

            int perPlayerBotMultiplier = (MySession.Static.CreativeMode ? MySession.Static.MaxPlayers : 1);

            if (MySteam.UserId == pid.SteamId)
            {
                AgentSpawnData spawnData = default(AgentSpawnData);
                if (m_agentsToSpawn.TryGetValue(pid.SerialId, out spawnData))
                {
                    if (spawnData.CreatedByPlayer)
                    {
                        return(Bots.GetCreatedBotCount() < BotFactory.MaximumBotPerPlayer * perPlayerBotMultiplier);
                    }
                    else
                    {
                        return(Bots.GetGeneratedBotCount() < BotFactory.MaximumUncontrolledBotCount);
                    }
                }
                else
                {
                    Debug.Assert(false, "Bot doesn't exist");
                    return(false);
                }
            }
            else
            {
                int botCount     = 0;
                var lookedPlayer = pid.SteamId;
                var players      = Sync.Players.GetAllPlayers();

                if (MySession.Static.CreativeMode)
                {
                    foreach (var player in players)
                    {
                        if (player.SerialId != 0)
                        {
                            ++botCount;
                        }
                    }
                }
                else
                {
                    foreach (var player in players)
                    {
                        if (player.SteamId == lookedPlayer && player.SerialId != 0)
                        {
                            botCount++;
                        }
                    }
                }

                return(botCount < BotFactory.MaximumBotPerPlayer * perPlayerBotMultiplier);
            }
        }
コード例 #2
0
        public bool CanSpawnMoreBots(MyPlayer.PlayerId pid)
        {
            if (!Sync.IsServer)
            {
                Debug.Assert(false, "Server only");
                return(false);
            }

            if (MyFakes.ENABLE_BRAIN_SIMULATOR)
            {
                return(true);
            }

            if (MyFakes.DEVELOPMENT_PRESET)
            {
                return(true);
            }

            if (MySteam.UserId == pid.SteamId)
            {
                AgentSpawnData spawnData = default(AgentSpawnData);
                if (m_agentsToSpawn.TryGetValue(pid.SerialId, out spawnData))
                {
                    if (spawnData.CreatedByPlayer)
                    {
                        return(Bots.GetCreatedBotCount() < BotFactory.MaximumBotPerPlayer);
                    }
                    else
                    {
                        return(Bots.GetGeneratedBotCount() < BotFactory.MaximumUncontrolledBotCount);
                    }
                }
                else
                {
                    Debug.Assert(false, "Bot doesn't exist");
                    return(false);
                }
            }
            else
            {
                int botCount     = 0;
                var lookedPlayer = pid.SteamId;
                var players      = Sync.Players.GetOnlinePlayers();

                foreach (var player in players)
                {
                    if (player.Id.SteamId == lookedPlayer && player.Id.SerialId != 0)
                    {
                        botCount++;
                    }
                }

                return(botCount < BotFactory.MaximumBotPerPlayer);
            }
        }
コード例 #3
0
 public int GetAvailableUncontrolledBotsCount()
 {
     return BotFactory.MaximumUncontrolledBotCount - Bots.GetGeneratedBotCount();
 }