コード例 #1
0
 public AgentSpawnData(MyAgentDefinition agentDefinition, int botId, Vector3D? spawnPosition = null, bool createAlways = false)
 {
     AgentDefinition = agentDefinition;
     SpawnPosition = spawnPosition;
     CreatedByPlayer = createAlways;
     BotId = botId;
 }
コード例 #2
0
 private void CurrentToolbar_SlotActivated(MyToolbar toolbar, MyToolbar.SlotArgs args)
 {
     if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemBot))
         BotToSpawn = null;
     if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemAiCommand))
         CommandDefinition = null;
 }
コード例 #3
0
 private void CurrentToolbar_SelectedSlotChanged(MyToolbar toolbar, MyToolbar.SlotArgs args)
 {
     if (!(toolbar.SelectedItem is MyToolbarItemBot))
         BotToSpawn = null;
     if (!(toolbar.SelectedItem is MyToolbarItemAiCommand))
         CommandDefinition = null;
 }
コード例 #4
0
 public AgentSpawnData(MyAgentDefinition agentDefinition, int botId, Vector3D?spawnPosition = new Vector3D?(), bool createAlways = false)
 {
     this.AgentDefinition = agentDefinition;
     this.SpawnPosition   = spawnPosition;
     this.CreatedByPlayer = createAlways;
     this.BotId           = botId;
 }
コード例 #5
0
        public int SpawnNewBot(MyAgentDefinition agentDefinition)
        {
            Vector3D spawnPosition = default(Vector3D);
            if (!BotFactory.GetBotSpawnPosition(agentDefinition.BehaviorType, out spawnPosition)) 
                return 0;

            return SpawnNewBotInternal(agentDefinition, spawnPosition, false);
        }
コード例 #6
0
        private void SpawnBot(SpawnInfo spawnInfo, MyPlanet planet, MyPlanetAnimalSpawnInfo animalSpawnInfo)
        {
            PlanetAIInfo planetInfo = null;

            if (!m_planets.TryGetValue(planet.EntityId, out planetInfo))
            {
                Debug.Assert(false, "Could not get planet info!");
                return;
            }

            if (planetInfo.BotNumber >= MAX_BOTS_PER_PLANET)
            {
                return;
            }

            Debug.Assert(animalSpawnInfo != null);
            double   spawnDistMin     = animalSpawnInfo.SpawnDistMin;
            double   spawnDistMax     = animalSpawnInfo.SpawnDistMax;
            Vector3D center           = spawnInfo.Position;
            Vector3D planetGravityVec = MyGravityProviderSystem.CalculateNaturalGravityInPoint(center);

            //GR: if gravity is zero provide a random Vector to normalize
            if (planetGravityVec == Vector3D.Zero)
            {
                planetGravityVec = Vector3D.Up;
            }
            planetGravityVec.Normalize();
            Vector3D planetTangent   = Vector3D.CalculatePerpendicularVector(planetGravityVec);
            Vector3D planetBitangent = Vector3D.Cross(planetGravityVec, planetTangent);

            planetTangent.Normalize();
            planetBitangent.Normalize();
            Vector3D spawnPos = MyUtils.GetRandomDiscPosition(ref center, spawnDistMin, spawnDistMax, ref planetTangent, ref planetBitangent);

            spawnPos = planet.GetClosestSurfacePointGlobal(ref spawnPos);
            Vector3D?spawnPosCorrected = MyEntities.FindFreePlace(spawnPos, 2.0f);

            if (spawnPosCorrected.HasValue)
            {
                spawnPos = spawnPosCorrected.Value;
            }

            planet.CorrectSpawnLocation(ref spawnPos, 2.0f);

            MyAgentDefinition botBehavior = GetAnimalDefinition(animalSpawnInfo) as MyAgentDefinition;

            if (botBehavior != null)
            {
                if (botBehavior.Id.SubtypeName == Wolf_SUBTYPE_ID && MySession.Static.EnableWolfs)
                {
                    MyAIComponent.Static.SpawnNewBot(botBehavior, spawnPos);
                }
                else if (botBehavior.Id.SubtypeName != Wolf_SUBTYPE_ID && MySession.Static.EnableSpiders)
                {
                    MyAIComponent.Static.SpawnNewBot(botBehavior, spawnPos);
                }
            }
        }
コード例 #7
0
        public MyAgentBot(MyPlayer player, MyBotDefinition botDefinition)
        {
            m_player           = player;
            m_navigation       = new MyBotNavigation();
            m_actionCollection = null;
            m_botMemory        = new MyBotMemory(this);
            m_botDefinition    = botDefinition as MyAgentDefinition;

            m_player.Controller.ControlledEntityChanged += Controller_ControlledEntityChanged;
            m_navigation.ChangeEntity(m_player.Controller.ControlledEntity);
        }
コード例 #8
0
        public int ForceSpawnNewBot(MyAgentDefinition agentDefinition, Vector3D?spawnPosition)
        {
            //if (!MyAIComponent.Static.CanSpawnMoreBots(agentDefinition.BehaviorType))
            //{
            //    var botHandle = m_botCollection.GetHandleToFirstBot(agentDefinition.BehaviorType);
            //    var player = Sync.Players.TryGetPlayerById(new MyPlayer.PlayerId(MySteam.UserId, botHandle));
            //    Sync.Players.RemovePlayer(player);
            //}

            return(SpawnNewBotInternal(agentDefinition, spawnPosition, true));
        }
コード例 #9
0
        private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = null, bool createdByPlayer = false)
        {
            var currentHighestBotID = MyAIComponent.GenerateBotId(m_lastSpawnedBot);
            var newBotId            = currentHighestBotID;

            EnsureIdentityUniqueness(newBotId);
            m_agentsToSpawn[newBotId] = new AgentSpawnData(agentDefinition, spawnPosition, createdByPlayer);
            m_lastSpawnedBot          = newBotId;

            Sync.Players.RequestNewPlayer(newBotId, MyDefinitionManager.Static.GetRandomCharacterName(), agentDefinition.BotModel);
            return(newBotId);
        }
コード例 #10
0
        private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = null, bool createAlways = false)
        {
            var currentHighestBotID = MyAIComponent.GenerateBotId(m_lastSpawnedBot);
            var newBotId            = currentHighestBotID;

            EnsureIdentityUniqueness(newBotId);
            m_agentsToSpawn[newBotId] = new AgentSpawnData(agentDefinition, spawnPosition, createAlways);
            m_lastSpawnedBot          = newBotId;

            Sync.Players.RequestNewPlayer(newBotId, agentDefinition.DisplayNameText, agentDefinition.BotModel);
            return(newBotId);
        }
コード例 #11
0
        public int SpawnNewBot(MyAgentDefinition agentDefinition)
        {
            //if (!MyAIComponent.Static.CanSpawnMoreBots(agentDefinition.BehaviorType))
            //    return 0;

            Vector3D spawnPosition = default(Vector3D);

            if (!BotFactory.GetBotSpawnPosition(agentDefinition.BehaviorType, out spawnPosition))
            {
                return(0);
            }

            return(SpawnNewBotInternal(agentDefinition, spawnPosition, false));
        }
コード例 #12
0
        public MySandboxBot(MyPlayer botPlayer, MyBotDefinition botDefinition)
        {
            m_definition = botDefinition as MyAgentDefinition;

            m_player             = botPlayer;
            m_navigation         = new MyBotNavigation();
            m_respawnRequestSent = false;
            m_actionCollection   = null;
            m_botMemory          = new MyBotMemory(this);

            m_player.Controller.ControlledEntityChanged += Controller_ControlledEntityChanged;

            m_navigation.ChangeEntity(m_player.Controller.ControlledEntity);
        }
コード例 #13
0
 public MyAgentBot(MyPlayer player, MyBotDefinition botDefinition)
 {
     this.m_player             = player;
     this.m_navigation         = new MyBotNavigation();
     this.m_actionCollection   = null;
     this.m_botMemory          = new MyBotMemory(this);
     this.m_botDefinition      = botDefinition as MyAgentDefinition;
     this.m_removeAfterDeath   = this.m_botDefinition.RemoveAfterDeath;
     this.m_respawnRequestSent = false;
     this.m_botRemoved         = false;
     this.m_player.Controller.ControlledEntityChanged += new Action <IMyControllableEntity, IMyControllableEntity>(this.Controller_ControlledEntityChanged);
     this.m_navigation.ChangeEntity(this.m_player.Controller.ControlledEntity);
     MyCestmirDebugInputComponent.PlacedAction += new Action <Vector3D, MyEntity>(this.DebugGoto);
 }
コード例 #14
0
        public MyAgentBot(MyPlayer player, MyBotDefinition botDefinition)
        {
            m_player           = player;
            m_navigation       = new MyBotNavigation();
            m_actionCollection = null;
            m_botMemory        = new MyBotMemory(this);
            m_botDefinition    = botDefinition as MyAgentDefinition;

            m_removeAfterDeath   = m_botDefinition.RemoveAfterDeath;
            m_respawnRequestSent = false;
            m_botRemoved         = false;

            m_player.Controller.ControlledEntityChanged += Controller_ControlledEntityChanged;
            m_navigation.ChangeEntity(m_player.Controller.ControlledEntity);

            Sandbox.Game.Gui.MyCestmirDebugInputComponent.PlacedAction += DebugGoto;
        }
コード例 #15
0
        private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = null, bool createdByPlayer = false)
        {
            int newBotId = 0;

            foreach (var player in Sync.Players.GetOnlinePlayers())
            {
                if (player.Id.SteamId == Sync.MyId && player.Id.SerialId > newBotId)
                {
                    newBotId = player.Id.SerialId;
                }
            }
            newBotId++;

            m_agentsToSpawn[newBotId] = new AgentSpawnData(agentDefinition, spawnPosition, createdByPlayer);

            Sync.Players.RequestNewPlayer(newBotId, MyDefinitionManager.Static.GetRandomCharacterName(), agentDefinition.BotModel);
            return(newBotId);
        }
コード例 #16
0
        private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D? spawnPosition = null, bool createdByPlayer = false)
        {
            m_lock.AcquireExclusive();
            foreach (var player in Sync.Players.GetOnlinePlayers())
            {
                if (player.Id.SteamId == Sync.MyId && player.Id.SerialId > m_lastBotId)
                {
                    m_lastBotId = player.Id.SerialId;
                }
            }
            m_lastBotId++;
            var lastBotId = m_lastBotId;
            m_lock.ReleaseExclusive();

            m_processQueue.Enqueue(new AgentSpawnData(agentDefinition, lastBotId, spawnPosition, createdByPlayer));

            return lastBotId;
        }
コード例 #17
0
        private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = new Vector3D?(), bool createdByPlayer = false)
        {
            int lastBotId;

            using (this.m_lock.AcquireExclusiveUsing())
            {
                foreach (MyPlayer player in Sync.Players.GetOnlinePlayers())
                {
                    if (player.Id.SteamId != Sync.MyId)
                    {
                        continue;
                    }
                    if (player.Id.SerialId > this.m_lastBotId)
                    {
                        this.m_lastBotId = player.Id.SerialId;
                    }
                }
                this.m_lastBotId++;
                lastBotId = this.m_lastBotId;
            }
            this.m_processQueue.Enqueue(new AgentSpawnData(agentDefinition, lastBotId, spawnPosition, createdByPlayer));
            return(lastBotId);
        }
コード例 #18
0
 public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D position)
 {
     return(SpawnNewBotInternal(agentDefinition, position, true));
 }
コード例 #19
0
 private void CurrentToolbar_Unselected(MyToolbar toolbar)
 {
     BotToSpawn = null;
     CommandDefinition = null;
 }
コード例 #20
0
 public AgentSpawnData(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = null, bool createAlways = false)
 {
     AgentDefinition = agentDefinition;
     SpawnPosition   = spawnPosition;
     CreateAlways    = createAlways;
 }
コード例 #21
0
 public void TrySpawnBot(MyAgentDefinition agentDefinition)
 {
     BotToSpawn = agentDefinition;
     TrySpawnBot();
 }
コード例 #22
0
 public AgentGroupData(MyAgentDefinition agentDefinition, int count)
 {
     AgentDefinition = agentDefinition;
     Count = count;
 }
コード例 #23
0
        public int SpawnNewBot(MyAgentDefinition agentDefinition)
        {
            Vector3D spawnPosition = new Vector3D();

            return(BotFactory.GetBotSpawnPosition(agentDefinition.BehaviorType, out spawnPosition) ? this.SpawnNewBotInternal(agentDefinition, new Vector3D?(spawnPosition), false) : 0);
        }
コード例 #24
0
 public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D? spawnPosition)
 {
     return SpawnNewBotInternal(agentDefinition, spawnPosition, true);
 }
コード例 #25
0
 public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D position, bool createdByPlayer = true)
 {
     return SpawnNewBotInternal(agentDefinition, position, createdByPlayer);
 }
コード例 #26
0
 public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D position, bool createdByPlayer = true) =>
 this.SpawnNewBotInternal(agentDefinition, new Vector3D?(position), createdByPlayer);
コード例 #27
0
 public void TrySpawnBot(MyAgentDefinition agentDefinition)
 {
     this.BotToSpawn = agentDefinition;
     this.TrySpawnBot();
 }
コード例 #28
0
 public AgentGroupData(MyAgentDefinition agentDefinition, int count)
 {
     this.AgentDefinition = agentDefinition;
     this.Count           = count;
 }