Exemplo n.º 1
0
        public void CopyFromOtherStack(CorticalStack otherStack)
        {
            this.name                  = otherStack.name;
            this.origPawn              = otherStack.origPawn;
            this.hostilityMode         = otherStack.hostilityMode;
            this.areaRestriction       = otherStack.areaRestriction;
            this.ageChronologicalTicks = otherStack.ageChronologicalTicks;
            this.medicalCareCategory   = otherStack.medicalCareCategory;
            this.selfTend              = otherStack.selfTend;
            this.foodRestriction       = otherStack.foodRestriction;

            this.outfit          = otherStack.outfit;
            this.drugPolicy      = otherStack.drugPolicy;
            this.times           = otherStack.times;
            this.thoughts        = otherStack.thoughts;
            this.faction         = otherStack.faction;
            this.isFactionLeader = otherStack.isFactionLeader;
            this.traits          = otherStack.traits;
            this.relations       = otherStack.relations;
            this.relatedPawns    = otherStack.relatedPawns;

            this.skills     = otherStack.skills;
            this.childhood  = otherStack.childhood;
            this.adulthood  = otherStack.adulthood;
            this.priorities = otherStack.priorities;
            this.hasPawn    = true;
            if (this.gender == Gender.None)
            {
                this.gender = otherStack.gender;
            }
            if (this.race == null)
            {
                this.race = otherStack.race;
            }

            this.pawnID = otherStack.pawnID;

            if (ModLister.RoyaltyInstalled)
            {
                this.royalTitles    = otherStack.royalTitles;
                this.favor          = otherStack.favor;
                this.heirs          = otherStack.heirs;
                this.bondedThings   = otherStack.bondedThings;
                this.factionPermits = otherStack.factionPermits;
                this.permitPoints   = otherStack.permitPoints;
            }
            this.isCopied     = true;
            this.stackGroupID = otherStack.stackGroupID;

            this.sexuality     = otherStack.sexuality;
            this.romanceFactor = otherStack.romanceFactor;

            this.psychologyData = otherStack.psychologyData;
        }
        public static void SetPsychologyData(Pawn pawn, PsychologyData psychologyData)
        {
            var comp = ThingCompUtility.TryGetComp <Psychology.CompPsychology>(pawn);

            if (comp != null)
            {
                var sexualityTracker = new Psychology.Pawn_SexualityTracker(pawn);
                sexualityTracker.sexDrive      = psychologyData.sexDrive;
                sexualityTracker.romanticDrive = psychologyData.romanticDrive;
                sexualityTracker.kinseyRating  = psychologyData.kinseyRating;
                Traverse.Create(sexualityTracker).Field <Dictionary <Pawn, int> >("knownSexualities").Value = psychologyData.knownSexualities;
                comp.Sexuality = sexualityTracker;
            }
        }
        public static PsychologyData GetPsychologyData(Pawn pawn)
        {
            var comp = ThingCompUtility.TryGetComp <Psychology.CompPsychology>(pawn);

            if (comp != null)
            {
                var psychologyData   = new PsychologyData();
                var sexualityTracker = comp.Sexuality;
                psychologyData.sexDrive         = sexualityTracker.sexDrive;
                psychologyData.romanticDrive    = sexualityTracker.romanticDrive;
                psychologyData.kinseyRating     = sexualityTracker.kinseyRating;
                psychologyData.knownSexualities = Traverse.Create(sexualityTracker).Field <Dictionary <Pawn, int> >("knownSexualities").Value;
                return(psychologyData);
            }
            return(null);
        }
Exemplo n.º 4
0
        public void SavePawnToCorticalStack(Pawn pawn)
        {
            this.name     = pawn.Name;
            this.origPawn = pawn;
            if (pawn.playerSettings != null)
            {
                this.hostilityMode       = (int)pawn.playerSettings.hostilityResponse;
                this.areaRestriction     = pawn.playerSettings.AreaRestriction;
                this.medicalCareCategory = pawn.playerSettings.medCare;
                this.selfTend            = pawn.playerSettings.selfTend;
            }
            if (pawn.ageTracker != null)
            {
                this.ageChronologicalTicks = pawn.ageTracker.AgeChronologicalTicks;
            }
            this.foodRestriction = pawn.foodRestriction?.CurrentFoodRestriction;
            this.outfit          = pawn.outfits?.CurrentOutfit;
            this.drugPolicy      = pawn.drugs?.CurrentPolicy;
            this.times           = pawn.timetable?.times;
            this.thoughts        = pawn.needs?.mood?.thoughts?.memories?.Memories;
            this.faction         = pawn.Faction;
            if (pawn.Faction.leader == pawn)
            {
                this.isFactionLeader = true;
            }
            this.traits       = pawn.story?.traits?.allTraits;
            this.relations    = pawn.relations?.DirectRelations;
            this.relatedPawns = pawn.relations?.RelatedPawns?.ToHashSet();
            foreach (var otherPawn in pawn.relations.RelatedPawns)
            {
                foreach (var rel2 in pawn.GetRelations(otherPawn))
                {
                    if (this.relations.Where(r => r.def == rel2 && r.otherPawn == otherPawn).Count() == 0)
                    {
                        //Log.Message("00000 Rel: " + otherPawn?.Name + " - " + rel2 + " - " + pawn.Name, true);
                        if (!rel2.implied)
                        {
                            this.relations.Add(new DirectPawnRelation(rel2, otherPawn, 0));
                        }
                    }
                }
                relatedPawns.Add(otherPawn);
            }
            this.skills    = pawn.skills?.skills;
            this.childhood = pawn.story?.childhood?.identifier;
            if (pawn.story?.adulthood != null)
            {
                this.adulthood = pawn.story.adulthood.identifier;
            }
            this.priorities = new Dictionary <WorkTypeDef, int>();
            if (pawn.workSettings != null && Traverse.Create(pawn.workSettings).Field("priorities").GetValue <DefMap <WorkTypeDef, int> >() != null)
            {
                foreach (WorkTypeDef w in DefDatabase <WorkTypeDef> .AllDefs)
                {
                    this.priorities[w] = pawn.workSettings.GetPriority(w);
                }
            }
            this.hasPawn = true;
            this.pawnID  = pawn.ThingID;
            if (ModLister.RoyaltyInstalled && pawn.royalty != null)
            {
                this.royalTitles = pawn.royalty?.AllTitlesForReading;
                this.favor       = Traverse.Create(pawn.royalty).Field("favor").GetValue <Dictionary <Faction, int> >();
                this.heirs       = Traverse.Create(pawn.royalty).Field("heirs").GetValue <Dictionary <Faction, Pawn> >();
                foreach (var map in Find.Maps)
                {
                    foreach (var thing in map.listerThings.AllThings)
                    {
                        var comp = thing.TryGetComp <CompBladelinkWeapon>();
                        if (comp != null && comp.bondedPawn == pawn)
                        {
                            this.bondedThings.Add(thing);
                        }
                    }
                    foreach (var gear in pawn.apparel?.WornApparel)
                    {
                        var comp = gear.TryGetComp <CompBladelinkWeapon>();
                        if (comp != null && comp.bondedPawn == pawn)
                        {
                            this.bondedThings.Add(gear);
                        }
                    }
                    foreach (var gear in pawn.equipment?.AllEquipmentListForReading)
                    {
                        var comp = gear.TryGetComp <CompBladelinkWeapon>();
                        if (comp != null && comp.bondedPawn == pawn)
                        {
                            this.bondedThings.Add(gear);
                        }
                    }
                    foreach (var gear in pawn.inventory?.innerContainer)
                    {
                        var comp = gear.TryGetComp <CompBladelinkWeapon>();
                        if (comp != null && comp.bondedPawn == pawn)
                        {
                            this.bondedThings.Add(gear);
                        }
                    }
                }
                this.factionPermits = Traverse.Create(pawn.royalty).Field("factionPermits").GetValue <List <FactionPermit> >();
                this.permitPoints   = Traverse.Create(pawn.royalty).Field("permitPoints").GetValue <Dictionary <Faction, int> >();
            }

            if (ModCompatibility.IndividualityIsActive)
            {
                this.sexuality     = ModCompatibility.GetSyrTraitsSexuality(pawn);
                this.romanceFactor = ModCompatibility.GetSyrTraitsRomanceFactor(pawn);
            }
            if (ModCompatibility.PsychologyIsActive)
            {
                this.psychologyData = ModCompatibility.GetPsychologyData(pawn);
            }
        }
Exemplo n.º 5
0
        public void SavePawnFromHediff(Hediff_CorticalStack hediff)
        {
            this.name                  = hediff.name;
            this.origPawn              = hediff.origPawn;
            this.hostilityMode         = hediff.hostilityMode;
            this.areaRestriction       = hediff.areaRestriction;
            this.ageChronologicalTicks = hediff.ageChronologicalTicks;
            this.medicalCareCategory   = hediff.medicalCareCategory;
            this.selfTend              = hediff.selfTend;
            this.foodRestriction       = hediff.foodRestriction;
            this.outfit                = hediff.outfit;
            this.drugPolicy            = hediff.drugPolicy;
            this.times                 = hediff.times;
            this.thoughts              = hediff.thoughts;
            this.faction               = hediff.faction;
            this.isFactionLeader       = hediff.isFactionLeader;
            this.traits                = hediff.traits;
            this.relations             = hediff.relations;
            this.relatedPawns          = hediff.relatedPawns;
            this.skills                = hediff.skills;
            if (hediff.negativeSkillsOffsets != null)
            {
                foreach (var negativeOffset in hediff.negativeSkillsOffsets)
                {
                    var skill = this.skills.Where(x => x.def == negativeOffset.skill).FirstOrDefault();
                    if (skill != null)
                    {
                        skill.Level += negativeOffset.offset;
                    }
                }
            }
            if (hediff.negativeSkillPassionsOffsets != null)
            {
                foreach (var negativeOffset in hediff.negativeSkillPassionsOffsets)
                {
                    var skill = this.skills.Where(x => x.def == negativeOffset.skill).FirstOrDefault();
                    if (skill != null)
                    {
                        var finalValue = (int)skill.passion + negativeOffset.offset + 1;
                        //Log.Message("finalValue: " + finalValue, true);
                        if (finalValue <= 2)
                        {
                            switch (finalValue)
                            {
                            case 0:
                                skill.passion = Passion.None;
                                //Log.Message(skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.None");
                                break;

                            case 1:
                                skill.passion = Passion.Minor;
                                //Log.Message(skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.Minor");
                                break;

                            case 2:
                                skill.passion = Passion.Major;
                                //Log.Message(skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.Major");
                                break;

                            default:
                                skill.passion = Passion.None;
                                //Log.Message("default: " + skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.None");
                                break;
                            }
                        }
                        else
                        {
                            skill.passion = Passion.None;
                            //Log.Message("2 default: " + skill.def + " - finalValue: " + finalValue + " - skill.passion = Passion.None");
                        }
                    }
                }
            }

            this.childhood  = hediff.childhood;
            this.adulthood  = hediff.adulthood;
            this.priorities = hediff.priorities;
            this.hasPawn    = true;

            if (this.gender == Gender.None)
            {
                this.gender = hediff.gender;
            }
            if (this.race == null)
            {
                this.race = hediff.race;
            }


            this.pawnID = hediff.pawnID;

            if (ModLister.RoyaltyInstalled)
            {
                this.royalTitles    = hediff.royalTitles;
                this.favor          = hediff.favor;
                this.heirs          = hediff.heirs;
                this.bondedThings   = hediff.bondedThings;
                this.permitPoints   = hediff.permitPoints;
                this.factionPermits = hediff.factionPermits;
            }
            this.isCopied     = hediff.isCopied;
            this.stackGroupID = hediff.stackGroupID;

            this.sexuality     = hediff.sexuality;
            this.romanceFactor = hediff.romanceFactor;

            this.psychologyData = hediff.psychologyData;
        }