コード例 #1
0
        private static TagSet prepareTags(MechComponent target)
        {
            //Control.Log($"Prepating tags for "+target.defId);
            string GUID = target.getCCGUID();
            TagSet tags = null;

            if (CustomCombatTagsHelper.tagsCache.ContainsKey(GUID) == false)
            {
                //Control.Log($" not in cache");
                if (CustomCombatTagsHelper.checkExistance(target.StatCollection, CustomCombatTagsHelper.CCComponentTagsStatName) == false)
                {
                    //Control.Log($" have no statistic value:"+ CustomCombatTagsHelper.CCComponentTagsStatName);
                    tags = new TagSet();
                    tags.AddRange(target.componentDef.ComponentTags);
                }
                else
                {
                    string tags_string = target.StatCollection.GetStatistic(CustomCombatTagsHelper.CCComponentTagsStatName).Value <string>();
                    tags = TagSet.Parse(tags_string);
                    //Control.Log($" have statistic value:" + CustomCombatTagsHelper.CCComponentTagsStatName+":"+tags_string);
                }
                CustomCombatTagsHelper.tagsCache[GUID] = tags;
            }
            else
            {
                //Control.Log($" in cache");
                tags = CustomCombatTagsHelper.tagsCache[GUID];
            }
            return(tags);
        }
コード例 #2
0
        public static void AddTags(this MechComponent target, IEnumerable <string> itemsToAdd)
        {
            TagSet tags = CustomCombatTagsHelper.prepareTags(target);

            if (tags == null)
            {
                return;
            }
            tags.AddRange(itemsToAdd);
            CustomCombatTagsHelper.saveTags(target, tags);
        }
コード例 #3
0
        private static PilotDef GenerateCrew(StarSystem starSystem, string callsign, PilotDef pilotDef)
        {
            Mod.Log.Debug?.Write($"Generating support crew with callsign: {callsign}");

            // Generate the lifepath we'll use
            LifePath lifePath = LifePathHelper.GetRandomLifePath();

            int initialAge = ModState.SimGameState.Constants.Pilot.MinimumPilotAge +
                             ModState.SimGameState.NetworkRandom.Int(1, ModState.SimGameState.Constants.Pilot.StartingAgeRange + 1);
            int currentAge = Mod.Random.Next(initialAge, 70);

            Mod.Log.Debug?.Write($" - currentAge: {currentAge}");

            Gender newGender   = RandomGender();
            Gender voiceGender = newGender;

            if (voiceGender == Gender.NonBinary)
            {
                voiceGender = ((!(ModState.SimGameState.NetworkRandom.Float() < 0.5f)) ? Gender.Female : Gender.Male);
            }
            string voice        = RandomUnusedVoice(voiceGender);
            string newFirstName = ModState.CrewCreateState.NameGenerator.GetFirstName(newGender);
            string newLastName  = ModState.CrewCreateState.NameGenerator.GetLastName();

            Mod.Log.Debug?.Write($" - gender: {newGender}  voiceGender: {voiceGender}  firstName: {newFirstName}  lastName: {newLastName}");
            pilotDef.SetVoice(voice);

            StringBuilder lifepathDescParagraphs = new StringBuilder();
            string        backgroundTitle        = new Text(lifePath.Description.Title).ToString();
            string        backgroundDesc         = new Text(lifePath.Description.Description).ToString();
            // DETAILS string is EXTREMELY picky, see HumanDescriptionDef.GetLocalizedDetails. There format must be followed *exactly*
            string formattedBackground = $"{Environment.NewLine}<b>{backgroundTitle}:</b>  {backgroundDesc}";

            Mod.Log.Debug?.Write($" - Background: {formattedBackground}");
            lifepathDescParagraphs.Append(formattedBackground);

            // Add tags from the lifepath
            TagSet tagSet = new TagSet();

            tagSet.AddRange(lifePath.RequiredTags);

            foreach (string tag in lifePath.RandomTags)
            {
                double tagRoll = Mod.Random.NextDouble();
                if (tagRoll <= Mod.Config.HiringHall.LifePath.RandomTagChance)
                {
                    tagSet.Add(tag);
                }
            }
            Mod.Log.Debug?.Write($" - Tags: {String.Join(", ", tagSet)}");

            // Add tags to the background
            foreach (string tagId in tagSet)
            {
                Tag_MDD tagIfExists = MetadataDatabase.Instance.GetTagIfExists(tagId);
                if (tagIfExists != null)
                {
                    TagDataStruct tagStruct    = new TagDataStruct(tagId, tagIfExists.PlayerVisible, tagIfExists.Important, tagIfExists.Name, tagIfExists.FriendlyName, tagIfExists.Description);
                    string        formattedTag = $"<b><color=#ff8c00>{tagStruct.FriendlyName}:</b>  <color=#ffffff>{tagStruct.DescriptionTag}";
                    lifepathDescParagraphs.Append(formattedTag);
                }
            }

            string id = GenerateID();
            HumanDescriptionDef descriptionDef = new HumanDescriptionDef(id, callsign, newFirstName, newLastName, callsign, newGender,
                                                                         FactionEnumeration.GetNoFactionValue(), currentAge, lifepathDescParagraphs.ToString(), null);

            StatCollection statCollection = pilotDef.GetStats();
            int            spentXPPilot   = GetSpentXPPilot(statCollection);

            List <string> alreadyAssignedPortraits = new List <string>();

            if (ModState.SimGameState.Commander != null && ModState.SimGameState.Commander.pilotDef.PortraitSettings != null)
            {
                alreadyAssignedPortraits.Add(ModState.SimGameState.Commander.pilotDef.PortraitSettings.Description.Id);
            }
            foreach (Pilot activePilot in ModState.SimGameState.PilotRoster)
            {
                if (activePilot.pilotDef.PortraitSettings != null)
                {
                    alreadyAssignedPortraits.Add(activePilot.pilotDef.PortraitSettings.Description.Id);
                }
            }

            PilotDef pilotDef2 = new PilotDef(descriptionDef, pilotDef.BaseGunnery, pilotDef.BasePiloting, pilotDef.BaseGuts, pilotDef.BaseTactics, 0,
                                              ModState.SimGameState.CombatConstants.PilotingConstants.DefaultMaxInjuries, lethalInjury: false, 0, voice, pilotDef.abilityDefNames,
                                              AIPersonality.Undefined, 0, tagSet, spentXPPilot, 0)
            {
                DataManager      = ModState.SimGameState.DataManager,
                PortraitSettings = GetPortraitForGenderAndAge(voiceGender, currentAge, alreadyAssignedPortraits)
            };

            ModState.SimGameState.pilotGenCallsignDiscardPile.Add(pilotDef2.Description.Callsign);

            return(pilotDef2);
        }
コード例 #4
0
ファイル: Upgrade.cs プロジェクト: mad2342/FellOffACargoShip
        public static void Add(string param)
        {
            SimGameState simGameState = SceneSingletonBehavior <UnityGameInstance> .Instance.Game.Simulation;
            DataProvider dataProvider = new DataProvider();

            if (param == "help")
            {
                string help = "";
                help += "• This command will add modules to your dropship";
                help += Environment.NewLine;
                help += "• Params: 'All', 'all' or the id of some module";
                help += Environment.NewLine;
                help += "• Example: '/upgr argoUpgrade_power2'";
                help += Environment.NewLine;
                help += "• Example: '/upgr all'";
                PopupHelper.Info(help);

                return;
            }



            if (simGameState.CurDropship != DropshipType.Argo)
            {
                string message = $"You need a better dropship first.";
                Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                PopupHelper.Info(message);

                return;
            }

            List <ShipModuleUpgrade> ___shipUpgrades          = (List <ShipModuleUpgrade>)AccessTools.Field(typeof(SimGameState), "shipUpgrades").GetValue(simGameState);
            List <string>            ___purchasedArgoUpgrades = (List <string>)AccessTools.Field(typeof(SimGameState), "purchasedArgoUpgrades").GetValue(simGameState);
            TagSet        ___companyTags    = (TagSet)AccessTools.Field(typeof(SimGameState), "companyTags").GetValue(simGameState);
            List <string> argoUpgradesToAdd = dataProvider.ArgoUpgradeIds;

            foreach (string id in ___purchasedArgoUpgrades)
            {
                argoUpgradesToAdd.Remove(id);
            }

            if (argoUpgradesToAdd.Count <= 0)
            {
                string message = $"No upgrades left to build.";
                Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                PopupHelper.Info(message);

                return;
            }


            if (param == "All" || param == "all")
            {
                foreach (string id in argoUpgradesToAdd)
                {
                    ShipModuleUpgrade upgrade = simGameState.DataManager.ShipUpgradeDefs.Get(id);
                    //__instance.AddArgoUpgrade(upgrade);

                    // BEN: Custom AddArgoUpgrade (No timeline refresh, this will be applied later ONE TIME ONLY)
                    ___shipUpgrades.Add(upgrade);
                    ___purchasedArgoUpgrades.Add(upgrade.Description.Id);
                    if (simGameState.CurDropship == DropshipType.Argo)
                    {
                        if (upgrade.Tags != null && !upgrade.Tags.IsEmpty)
                        {
                            ___companyTags.AddRange(upgrade.Tags);
                        }
                        foreach (SimGameStat companyStat in upgrade.Stats)
                        {
                            simGameState.SetCompanyStat(companyStat);
                        }
                        // Apply Actions?

                        /*
                         * if (upgrade.Actions != null)
                         * {
                         *  SimGameResultAction[] actions = upgrade.Actions;
                         *  for (int i = 0; i < actions.Length; i++)
                         *  {
                         *      SimGameState.ApplyEventAction(actions[i], null);
                         *  }
                         * }
                         */
                    }
                    string message = $"Added upgrade {id} to the Argo.";
                    Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                    PopupHelper.Info(message);
                }
                // Refresh timeline ONCE
                simGameState.RoomManager.RefreshTimeline(false);
            }
            else
            {
                if (argoUpgradesToAdd.Contains(param))
                {
                    ShipModuleUpgrade upgrade = simGameState.DataManager.ShipUpgradeDefs.Get(param);
                    simGameState.AddArgoUpgrade(upgrade);

                    string message = $"Added upgrade {param} to the Argo.";
                    Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                    PopupHelper.Info(message);
                }
                else
                {
                    string message = $"Upgrade is unknown or already built: {param}";
                    Logger.Debug($"[Cheater_Upgrade_Add] {message}");
                    PopupHelper.Info(message);
                }
            }
        }