コード例 #1
0
        public static string GetIdentifier(XElement bs)
        {
            XElement BaseDesc = bs.GetField("BaseDesc");
            int      num      = Mathf.Abs(GenText.StableStringHash(BaseDesc.Value) % 100);
            XElement Title    = bs.GetField("Title");
            string   s        = Title.Value.Replace('-', ' ');

            s = GenText.CapitalizedNoSpaces(s);
            return(GenText.RemoveNonAlphanumeric(s) + num);
        }
コード例 #2
0
ファイル: Backstory.cs プロジェクト: sachdevs/RW-Decompile
        public void ResolveReferences()
        {
            int    num = Mathf.Abs(GenText.StableStringHash(this.baseDesc) % 100);
            string s   = this.title.Replace('-', ' ');

            s = GenText.CapitalizedNoSpaces(s);
            this.identifier = GenText.RemoveNonAlphanumeric(s) + num.ToString();
            foreach (KeyValuePair <string, int> current in this.skillGains)
            {
                this.skillGainsResolved.Add(DefDatabase <SkillDef> .GetNamed(current.Key, true), current.Value);
            }
            this.skillGains = null;
        }
コード例 #3
0
        public static bool PrefResolveReferences(Backstory __instance)
        {
            int    num = Mathf.Abs(GenText.StableStringHash(__instance.baseDesc) % 100);
            string s   = __instance.Title.Replace('-', ' ');

            s = GenText.CapitalizedNoSpaces(s);
            __instance.identifier = GenText.RemoveNonAlphanumeric(s) + num.ToString();
            foreach (KeyValuePair <string, int> keyValuePair in __instance.skillGains)
            {
                if (keyValuePair.Value != 0)                 // Changed line.
                {
                    __instance.skillGainsResolved.Add(DefDatabase <SkillDef> .GetNamed(keyValuePair.Key, true), keyValuePair.Value);
                }
            }
            __instance.skillGains = null;

            return(false);
        }
コード例 #4
0
ファイル: Backstory.cs プロジェクト: KraigXu/GameProject
        public void ResolveReferences()
        {
            int    num = Mathf.Abs(GenText.StableStringHash(baseDesc) % 100);
            string s   = title.Replace('-', ' ');

            s          = GenText.CapitalizedNoSpaces(s);
            identifier = GenText.RemoveNonAlphanumeric(s) + num.ToString();
            foreach (KeyValuePair <string, int> skillGain in skillGains)
            {
                skillGainsResolved.Add(DefDatabase <SkillDef> .GetNamed(skillGain.Key), skillGain.Value);
            }
            skillGains = null;
            if (!bodyTypeGlobal.NullOrEmpty())
            {
                bodyTypeGlobalResolved = DefDatabase <BodyTypeDef> .GetNamed(bodyTypeGlobal);
            }
            if (!bodyTypeFemale.NullOrEmpty())
            {
                bodyTypeFemaleResolved = DefDatabase <BodyTypeDef> .GetNamed(bodyTypeFemale);
            }
            if (!bodyTypeMale.NullOrEmpty())
            {
                bodyTypeMaleResolved = DefDatabase <BodyTypeDef> .GetNamed(bodyTypeMale);
            }
            if (!nameMaker.NullOrEmpty())
            {
                nameMakerResolved = DefDatabase <RulePackDef> .GetNamed(nameMaker);
            }
            if (slot == BackstorySlot.Adulthood && bodyTypeGlobalResolved == null)
            {
                if (bodyTypeMaleResolved == null)
                {
                    Log.Error("Adulthood backstory " + title + " is missing male body type. Defaulting...");
                    bodyTypeMaleResolved = BodyTypeDefOf.Male;
                }
                if (bodyTypeFemaleResolved == null)
                {
                    Log.Error("Adulthood backstory " + title + " is missing female body type. Defaulting...");
                    bodyTypeFemaleResolved = BodyTypeDefOf.Female;
                }
            }
        }
コード例 #5
0
        public void ResolveReferences()
        {
            int    num = Mathf.Abs(GenText.StableStringHash(this.baseDesc) % 100);
            string s   = this.title.Replace('-', ' ');

            s = GenText.CapitalizedNoSpaces(s);
            this.identifier = GenText.RemoveNonAlphanumeric(s) + num.ToString();
            foreach (KeyValuePair <string, int> keyValuePair in this.skillGains)
            {
                this.skillGainsResolved.Add(DefDatabase <SkillDef> .GetNamed(keyValuePair.Key, true), keyValuePair.Value);
            }
            this.skillGains = null;
            if (!this.bodyTypeGlobal.NullOrEmpty())
            {
                this.bodyTypeGlobalResolved = DefDatabase <BodyTypeDef> .GetNamed(this.bodyTypeGlobal, true);
            }
            if (!this.bodyTypeFemale.NullOrEmpty())
            {
                this.bodyTypeFemaleResolved = DefDatabase <BodyTypeDef> .GetNamed(this.bodyTypeFemale, true);
            }
            if (!this.bodyTypeMale.NullOrEmpty())
            {
                this.bodyTypeMaleResolved = DefDatabase <BodyTypeDef> .GetNamed(this.bodyTypeMale, true);
            }
            if (this.slot == BackstorySlot.Adulthood)
            {
                if (this.bodyTypeGlobalResolved == null)
                {
                    if (this.bodyTypeMaleResolved == null)
                    {
                        Log.Error("Adulthood backstory " + this.title + " is missing male body type. Defaulting...", false);
                        this.bodyTypeMaleResolved = BodyTypeDefOf.Male;
                    }
                    if (this.bodyTypeFemaleResolved == null)
                    {
                        Log.Error("Adulthood backstory " + this.title + " is missing female body type. Defaulting...", false);
                        this.bodyTypeFemaleResolved = BodyTypeDefOf.Female;
                    }
                }
            }
        }
コード例 #6
0
ファイル: BackStoryCreator.cs プロジェクト: SwimUp/worldedit
        private void SaveBacktoryToWorld()
        {
            WorkTags blockTags = WorkTags.None;
            WorkTags reqTags   = WorkTags.None;

            foreach (var tag in workStatus)
            {
                if (tag.Value == 1)
                {
                    blockTags |= tag.Key;
                }
                else if (tag.Value == 2)
                {
                    reqTags |= tag.Key;
                }
            }
            blockTags ^= WorkTags.None;
            reqTags   ^= WorkTags.None;

            story.workDisables     = blockTags;
            story.requiredWorkTags = reqTags;

            story.forcedTraits     = new List <TraitEntry>();
            story.disallowedTraits = new List <TraitEntry>();

            foreach (var trait in traitEntrys)
            {
                if (trait.status == 1)
                {
                    story.forcedTraits.Add(trait.trait);
                }
                else if (trait.status == 2)
                {
                    story.disallowedTraits.Add(trait.trait);
                }
            }

            if (!edit)
            {
                story.PostLoad();
                int    num = Mathf.Abs(GenText.StableStringHash(story.baseDesc) % 100);
                string s   = story.title.Replace('-', ' ');
                s = GenText.CapitalizedNoSpaces(s);
                story.identifier = GenText.RemoveNonAlphanumeric(s) + num.ToString();

                BackstoryDatabase.AddBackstory(story);

                CustomBacktories.CustomStories.Add(story);

                CreateNew();
            }
            else
            {
                if (!CustomBacktories.CustomStories.Contains(story))
                {
                    CustomBacktories.CustomStories.Add(story);
                }
            }

            if (!onlyCreate)
            {
                PawnMenu.RecacheSkillsData();
            }

            Messages.Message($"Success", MessageTypeDefOf.NeutralEvent);
        }