Exemplo n.º 1
0
 public void SpawnRequest(SpawnProfile spawn)
 {
     if (this.SpawnInProgress == true)
     {
         return;
     }
 }
Exemplo n.º 2
0
        public static void SpawnRequest(SpawnProfile spawn = null)
        {
            if (spawn != null)
            {
                _pendingSpawns.Add(spawn);
            }

            if (_spawnInProgress == true || _pendingSpawns.Count == 0)
            {
                return;
            }

            _currentSpawn = _pendingSpawns[0];
            _pendingSpawns.RemoveAt(0);
            _spawnInProgress = true;
            MyAPIGateway.Parallel.Start(SpawningParallelChecks, CompleteSpawning);
        }
Exemplo n.º 3
0
        public static void Setup()
        {
            var definitionList = MyDefinitionManager.Static.GetEntityComponentDefinitions();

            //Get All Chat, Spawner
            foreach (var def in definitionList)
            {
                try {
                    if (string.IsNullOrWhiteSpace(def.DescriptionText) == true)
                    {
                        continue;
                    }

                    if (def.DescriptionText.Contains("[RivalAI Chat]") == true && ChatObjectTemplates.ContainsKey(def.Id.SubtypeName) == false)
                    {
                        var chatObject = new ChatProfile();
                        chatObject.InitTags(def.DescriptionText);
                        chatObject.ProfileSubtypeId = def.Id.SubtypeName;
                        var chatBytes = MyAPIGateway.Utilities.SerializeToBinary <ChatProfile>(chatObject);
                        //Logger.WriteLog("Chat Profile Added: " + def.Id.SubtypeName);
                        ChatObjectTemplates.Add(def.Id.SubtypeName, chatBytes);
                        continue;
                    }

                    if (def.DescriptionText.Contains("[RivalAI Spawn]") == true && SpawnerObjectTemplates.ContainsKey(def.Id.SubtypeName) == false)
                    {
                        var spawnerObject = new SpawnProfile();
                        spawnerObject.InitTags(def.DescriptionText);
                        spawnerObject.ProfileSubtypeId = def.Id.SubtypeName;
                        var spawnerBytes = MyAPIGateway.Utilities.SerializeToBinary <SpawnProfile>(spawnerObject);
                        //Logger.WriteLog("Spawner Profile Added: " + def.Id.SubtypeName);
                        SpawnerObjectTemplates.Add(def.Id.SubtypeName, spawnerBytes);
                        continue;
                    }
                } catch (Exception) {
                    Logger.MsgDebug(string.Format("Caught Error While Processing Definition {0}", def.Id));
                }
            }

            foreach (var def in definitionList)
            {
                try {
                    if (string.IsNullOrWhiteSpace(def.DescriptionText) == true)
                    {
                        continue;
                    }

                    if (def.DescriptionText.Contains("[RivalAI Action]") == true && ActionObjectTemplates.ContainsKey(def.Id.SubtypeName) == false)
                    {
                        var actionObject = new ActionProfile();
                        actionObject.InitTags(def.DescriptionText);
                        actionObject.ProfileSubtypeId = def.Id.SubtypeName;
                        var targetBytes = MyAPIGateway.Utilities.SerializeToBinary <ActionProfile>(actionObject);
                        //Logger.WriteLog("Action Profile Added: " + def.Id.SubtypeName);
                        ActionObjectTemplates.Add(def.Id.SubtypeName, targetBytes);
                        continue;
                    }

                    if (def.DescriptionText.Contains("[RivalAI Condition]") == true && ChatObjectTemplates.ContainsKey(def.Id.SubtypeName) == false)
                    {
                        var conditionObject = new ConditionProfile();
                        conditionObject.InitTags(def.DescriptionText);
                        conditionObject.ProfileSubtypeId = def.Id.SubtypeName;
                        var conditionBytes = MyAPIGateway.Utilities.SerializeToBinary <ConditionProfile>(conditionObject);
                        //Logger.WriteLog("Condition Profile Added: " + def.Id.SubtypeName);
                        ConditionObjectTemplates.Add(def.Id.SubtypeName, conditionBytes);
                        continue;
                    }

                    if (def.DescriptionText.Contains("[RivalAI Target]") == true && TargetObjectTemplates.ContainsKey(def.Id.SubtypeName) == false)
                    {
                        var targetObject = new TargetProfile();
                        targetObject.InitTags(def.DescriptionText);
                        targetObject.ProfileSubtypeId = def.Id.SubtypeName;
                        var targetBytes = MyAPIGateway.Utilities.SerializeToBinary <TargetProfile>(targetObject);
                        //Logger.WriteLog("Target Profile Added: " + def.Id.SubtypeName);
                        TargetObjectTemplates.Add(def.Id.SubtypeName, targetBytes);
                        continue;
                    }
                } catch (Exception e) {
                    Logger.WriteLog(string.Format("Caught Error While Processing Definition {0}", def.Id));
                    Logger.WriteLog(e.ToString());
                }
            }

            //Get All Triggers - Build With Action, Chat and Spawner
            foreach (var def in definitionList)
            {
                if (string.IsNullOrWhiteSpace(def.DescriptionText) == true)
                {
                    continue;
                }

                if (def.DescriptionText.Contains("[RivalAI Trigger]") == true && TriggerObjectTemplates.ContainsKey(def.Id.SubtypeName) == false)
                {
                    var triggerObject = new TriggerProfile();
                    triggerObject.InitTags(def.DescriptionText);
                    triggerObject.ProfileSubtypeId = def.Id.SubtypeName;
                    var triggerBytes = MyAPIGateway.Utilities.SerializeToBinary <TriggerProfile>(triggerObject);
                    //Logger.WriteLog("Trigger Profile Added: " + def.Id.SubtypeName);
                    TriggerObjectTemplates.Add(def.Id.SubtypeName, triggerBytes);
                    continue;
                }
            }

            //Get All TriggerGroups, Autopilot
            foreach (var def in definitionList)
            {
                if (string.IsNullOrWhiteSpace(def.DescriptionText) == true)
                {
                    continue;
                }

                if (def.DescriptionText.Contains("[RivalAI Autopilot]") == true && AutopilotObjectTemplates.ContainsKey(def.Id.SubtypeName) == false)
                {
                    var autopilotObject = new AutoPilotProfile();
                    autopilotObject.InitTags(def.DescriptionText);
                    autopilotObject.ProfileSubtypeId = def.Id.SubtypeName;
                    var autopilotBytes = MyAPIGateway.Utilities.SerializeToBinary <AutoPilotProfile>(autopilotObject);
                    //Logger.WriteLog("Trigger Profile Added: " + def.Id.SubtypeName);
                    AutopilotObjectTemplates.Add(def.Id.SubtypeName, autopilotBytes);
                    continue;
                }

                if (def.DescriptionText.Contains("[RivalAI TriggerGroup]") == true && TriggerObjectTemplates.ContainsKey(def.Id.SubtypeName) == false)
                {
                    var triggerObject = new TriggerGroupProfile();
                    triggerObject.InitTags(def.DescriptionText);
                    triggerObject.ProfileSubtypeId = def.Id.SubtypeName;
                    var triggerBytes = MyAPIGateway.Utilities.SerializeToBinary <TriggerGroupProfile>(triggerObject);
                    //Logger.WriteLog("Trigger Profile Added: " + def.Id.SubtypeName);
                    TriggerGroupObjectTemplates.Add(def.Id.SubtypeName, triggerBytes);
                    continue;
                }
            }

            //Get All Behavior
            foreach (var def in definitionList)
            {
                if (string.IsNullOrWhiteSpace(def.DescriptionText))
                {
                    continue;
                }

                if ((def.DescriptionText.Contains("[RivalAI Behavior]") || def.DescriptionText.Contains("[Rival AI Behavior]")) && BehaviorTemplates.ContainsKey(def.Id.SubtypeName) == false)
                {
                    BehaviorTemplates.Add(def.Id.SubtypeName, def.DescriptionText);
                    continue;
                }
            }

            //Print Profile Names To Log:
            BuildKeyListAndWriteToLog("Behavior", BehaviorTemplates.Keys);
            BuildKeyListAndWriteToLog("Autopilot", AutopilotObjectTemplates.Keys);
            BuildKeyListAndWriteToLog("Trigger", TriggerObjectTemplates.Keys);
            BuildKeyListAndWriteToLog("TriggerGroup", TriggerGroupObjectTemplates.Keys);
            BuildKeyListAndWriteToLog("Condition", ConditionObjectTemplates.Keys);
            BuildKeyListAndWriteToLog("Action", ActionObjectTemplates.Keys);
            BuildKeyListAndWriteToLog("Chat", ChatObjectTemplates.Keys);
            BuildKeyListAndWriteToLog("Spawn", SpawnerObjectTemplates.Keys);
            BuildKeyListAndWriteToLog("Target", TargetObjectTemplates.Keys);
        }