コード例 #1
0
 public SaveRecordPawnV3(CustomPawn pawn)
 {
     this.gender           = pawn.Gender;
     this.adulthood        = pawn.Adulthood.uniqueSaveKey;
     this.childhood        = pawn.Childhood.uniqueSaveKey;
     this.skinColor        = pawn.SkinColor;
     this.hairDef          = pawn.HairDef.defName;
     this.hairColor        = pawn.GetColor(PawnLayers.Hair);
     this.headGraphicPath  = pawn.HeadGraphicPath;
     this.firstName        = pawn.FirstName;
     this.nickName         = pawn.NickName;
     this.lastName         = pawn.LastName;
     this.age              = 0;
     this.biologicalAge    = pawn.BiologicalAge;
     this.chronologicalAge = pawn.ChronologicalAge;
     foreach (var trait in pawn.Traits)
     {
         if (trait != null)
         {
             this.traitNames.Add(trait.def.defName);
             this.traitDegrees.Add(trait.Degree);
         }
     }
     foreach (var skill in pawn.Pawn.skills.skills)
     {
         this.skillNames.Add(skill.def.defName);
         this.skillValues.Add(pawn.GetUnmodifiedSkillLevel(skill.def));
         this.passions.Add(pawn.currentPassions[skill.def]);
         this.originalPassions.Add(pawn.originalPassions[skill.def]);
     }
     for (int layer = 0; layer < PawnLayers.Count; layer++)
     {
         ThingDef thingDef = pawn.GetAcceptedApparel(layer);
         ThingDef stuffDef = pawn.GetSelectedStuff(layer);
         Color    color    = pawn.GetColor(layer);
         if (thingDef != null)
         {
             this.apparelLayers.Add(layer);
             this.apparel.Add(thingDef.defName);
             this.apparelStuff.Add(stuffDef != null ? stuffDef.defName : "");
             this.apparelColors.Add(color);
         }
     }
     this.randomInjuries = pawn.RandomInjuries;
     foreach (Implant implant in pawn.Implants)
     {
         this.implants.Add(new SaveRecordImplantV3(implant));
     }
     foreach (Injury injury in pawn.Injuries)
     {
         this.injuries.Add(new SaveRecordInjuryV3(injury));
     }
 }
コード例 #2
0
        public SaveRecordPawnV4(CustomPawn pawn)
        {
            this.id       = pawn.Id;
            this.thingDef = pawn.Pawn.def.defName;
            this.type     = pawn.Type.ToString();
            if (pawn.Type == CustomPawnType.World && pawn.Faction != null)
            {
                this.faction        = new SaveRecordFactionV4();
                this.faction.def    = pawn.Faction.Def != null ? pawn.Faction.Def.defName : null;
                this.faction.index  = pawn.Faction.Index;
                this.faction.leader = pawn.Faction.Leader;
            }
            this.pawnKindDef        = pawn.OriginalKindDef != null ? pawn.OriginalKindDef.defName : pawn.Pawn.kindDef.defName;
            this.originalFactionDef = pawn.OriginalFactionDef != null ? pawn.OriginalFactionDef.defName : null;
            this.gender             = pawn.Gender;
            if (pawn.Adulthood != null)
            {
                this.adulthood = pawn.Adulthood.identifier;
            }
            else
            {
                this.adulthood = pawn.LastSelectedAdulthoodBackstory?.identifier;
            }
            this.childhood        = pawn.Childhood.identifier;
            this.skinColor        = pawn.Pawn.story.SkinColor;
            this.melanin          = pawn.Pawn.story.melanin;
            this.hairDef          = pawn.HairDef.defName;
            this.hairColor        = pawn.Pawn.story.hairColor;
            this.headGraphicPath  = pawn.HeadGraphicPath;
            this.bodyType         = pawn.BodyType.defName;
            this.firstName        = pawn.FirstName;
            this.nickName         = pawn.NickName;
            this.lastName         = pawn.LastName;
            this.age              = 0;
            this.biologicalAge    = pawn.BiologicalAge;
            this.chronologicalAge = pawn.ChronologicalAge;
            foreach (var trait in pawn.Traits)
            {
                if (trait != null)
                {
                    this.traitNames.Add(trait.def.defName);
                    this.traitDegrees.Add(trait.Degree);
                }
            }
            foreach (var skill in pawn.Pawn.skills.skills)
            {
                SaveRecordSkillV4 skillRecord = new SaveRecordSkillV4();
                skillRecord.name    = skill.def.defName;
                skillRecord.value   = pawn.GetUnmodifiedSkillLevel(skill.def);
                skillRecord.passion = pawn.currentPassions[skill.def];
                this.skills.Add(skillRecord);
            }
            foreach (var layer in PrepareCarefully.Instance.Providers.PawnLayers.GetLayersForPawn(pawn))
            {
                if (layer.Apparel)
                {
                    ThingDef apparelThingDef = pawn.GetAcceptedApparel(layer);
                    Color    color           = pawn.GetColor(layer);
                    if (apparelThingDef != null)
                    {
                        ThingDef            apparelStuffDef = pawn.GetSelectedStuff(layer);
                        SaveRecordApparelV4 apparelRecord   = new SaveRecordApparelV4();
                        apparelRecord.layer   = layer.Name;
                        apparelRecord.apparel = apparelThingDef.defName;
                        apparelRecord.stuff   = apparelStuffDef != null ? apparelStuffDef.defName : "";
                        apparelRecord.color   = color;
                        this.apparel.Add(apparelRecord);
                    }
                }
            }
            OptionsHealth healthOptions = PrepareCarefully.Instance.Providers.Health.GetOptions(pawn);

            foreach (Implant implant in pawn.Implants)
            {
                var saveRecord = new SaveRecordImplantV3(implant);
                if (implant.BodyPartRecord != null)
                {
                    UniqueBodyPart part = healthOptions.FindBodyPartsForRecord(implant.BodyPartRecord);
                    if (part != null && part.Index > 0)
                    {
                        saveRecord.bodyPartIndex = part.Index;
                    }
                }
                this.implants.Add(saveRecord);
            }
            foreach (Injury injury in pawn.Injuries)
            {
                var saveRecord = new SaveRecordInjuryV3(injury);
                if (injury.BodyPartRecord != null)
                {
                    UniqueBodyPart part = healthOptions.FindBodyPartsForRecord(injury.BodyPartRecord);
                    if (part != null && part.Index > 0)
                    {
                        saveRecord.bodyPartIndex = part.Index;
                    }
                }
                this.injuries.Add(saveRecord);
            }

            ThingComp alienComp = ProviderAlienRaces.FindAlienCompForPawn(pawn.Pawn);

            if (alienComp != null)
            {
                alien                 = new SaveRecordAlienV4();
                alien.crownType       = ProviderAlienRaces.GetCrownTypeFromComp(alienComp);
                alien.skinColor       = ProviderAlienRaces.GetSkinColorFromComp(alienComp);
                alien.skinColorSecond = ProviderAlienRaces.GetSkinColorSecondFromComp(alienComp);
                alien.hairColorSecond = ProviderAlienRaces.GetHairColorSecondFromComp(alienComp);
            }
        }
コード例 #3
0
        public SaveRecordPawnV5(CustomPawn pawn)
        {
            this.id       = pawn.Id;
            this.thingDef = pawn.Pawn.def.defName;
            this.type     = pawn.Type.ToString();
            if (pawn.Type == CustomPawnType.World && pawn.Faction != null)
            {
                this.faction = new SaveRecordFactionV4()
                {
                    def    = pawn.Faction?.Def?.defName,
                    index  = pawn.Faction.Index,
                    leader = pawn.Faction.Leader
                };
            }
            this.pawnKindDef        = pawn.OriginalKindDef?.defName ?? pawn.Pawn.kindDef.defName;
            this.originalFactionDef = pawn.OriginalFactionDef?.defName;
            this.gender             = pawn.Gender;
            this.adulthood          = pawn.Adulthood?.identifier ?? pawn.LastSelectedAdulthoodBackstory?.identifier;
            this.childhood          = pawn.Childhood?.identifier;
            this.skinColor          = pawn.Pawn.story.SkinColor;
            this.melanin            = pawn.Pawn.story.melanin;
            this.hairDef            = pawn.HairDef.defName;
            this.hairColor          = pawn.Pawn.story.hairColor;
            this.headGraphicPath    = pawn.HeadGraphicPath;
            this.bodyType           = pawn.BodyType.defName;
            this.firstName          = pawn.FirstName;
            this.nickName           = pawn.NickName;
            this.lastName           = pawn.LastName;
            this.age              = 0;
            this.biologicalAge    = pawn.BiologicalAge;
            this.chronologicalAge = pawn.ChronologicalAge;
            foreach (var trait in pawn.Traits)
            {
                if (trait != null)
                {
                    this.traits.Add(new SaveRecordTraitV5()
                    {
                        def    = trait.def.defName,
                        degree = trait.Degree
                    });
                }
            }
            foreach (var skill in pawn.Pawn.skills.skills)
            {
                this.skills.Add(new SaveRecordSkillV4()
                {
                    name    = skill.def.defName,
                    value   = pawn.GetUnmodifiedSkillLevel(skill.def),
                    passion = pawn.currentPassions[skill.def]
                });
            }
            foreach (var layer in PrepareCarefully.Instance.Providers.PawnLayers.GetLayersForPawn(pawn))
            {
                if (layer.Apparel)
                {
                    ThingDef apparelThingDef = pawn.GetAcceptedApparel(layer);
                    Color    color           = pawn.GetColor(layer);
                    if (apparelThingDef != null)
                    {
                        ThingDef apparelStuffDef = pawn.GetSelectedStuff(layer);
                        this.apparel.Add(new SaveRecordApparelV4()
                        {
                            layer   = layer.Name,
                            apparel = apparelThingDef.defName,
                            stuff   = apparelStuffDef?.defName ?? "",
                            color   = color
                        });
                    }
                }
            }
            OptionsHealth healthOptions = PrepareCarefully.Instance.Providers.Health.GetOptions(pawn);

            foreach (Implant implant in pawn.Implants)
            {
                var saveRecord = new SaveRecordImplantV3(implant);
                if (implant.BodyPartRecord != null)
                {
                    UniqueBodyPart part = healthOptions.FindBodyPartsForRecord(implant.BodyPartRecord);
                    if (part != null && part.Index > 0)
                    {
                        saveRecord.bodyPartIndex = part.Index;
                    }
                }
                this.implants.Add(saveRecord);
            }
            foreach (Injury injury in pawn.Injuries)
            {
                var saveRecord = new SaveRecordInjuryV3(injury);
                if (injury.BodyPartRecord != null)
                {
                    UniqueBodyPart part = healthOptions.FindBodyPartsForRecord(injury.BodyPartRecord);
                    if (part != null && part.Index > 0)
                    {
                        saveRecord.bodyPartIndex = part.Index;
                    }
                }
                this.injuries.Add(saveRecord);
            }

            pawnCompsSaver = new PawnCompsSaver(pawn.Pawn, DefaultPawnCompRules.RulesForSaving);
        }
コード例 #4
0
        protected void DrawColorSelector(CustomPawn customPawn, float cursorY, List <Color> colors, bool allowAnyColor)
        {
            Color currentColor = customPawn.GetColor(selectedPawnLayer);
            Rect  rect         = new Rect(SwatchPosition.x, cursorY, SwatchSize.x, SwatchSize.y);

            if (colors != null)
            {
                foreach (Color color in colors)
                {
                    bool selected = (color == currentColor);
                    if (selected)
                    {
                        Rect selectionRect = new Rect(rect.x - 2, rect.y - 2, SwatchSize.x + 4, SwatchSize.y + 4);
                        GUI.color = ColorSwatchSelection;
                        GUI.DrawTexture(selectionRect, BaseContent.WhiteTex);
                    }

                    Rect borderRect = new Rect(rect.x - 1, rect.y - 1, SwatchSize.x + 2, SwatchSize.y + 2);
                    GUI.color = ColorSwatchBorder;
                    GUI.DrawTexture(borderRect, BaseContent.WhiteTex);

                    GUI.color = color;
                    GUI.DrawTexture(rect, BaseContent.WhiteTex);

                    if (!selected)
                    {
                        if (Widgets.ButtonInvisible(rect, false))
                        {
                            SetColor(customPawn, color);
                            currentColor = color;
                        }
                    }

                    rect.x += SwatchSpacing.x;
                    if (rect.x >= SwatchLimit - SwatchSize.x)
                    {
                        rect.y += SwatchSpacing.y;
                        rect.x  = SwatchPosition.x;
                    }
                }
            }

            GUI.color = Color.white;
            if (!allowAnyColor)
            {
                return;
            }

            if (rect.x != SwatchPosition.x)
            {
                rect.x  = SwatchPosition.x;
                rect.y += SwatchSpacing.y;
            }
            rect.y     += 4;
            rect.width  = 49;
            rect.height = 49;
            GUI.color   = ColorSwatchBorder;
            GUI.DrawTexture(rect, BaseContent.WhiteTex);
            GUI.color = currentColor;
            GUI.DrawTexture(rect.ContractedBy(1), BaseContent.WhiteTex);

            GUI.color = Color.red;
            float originalR = currentColor.r;
            float originalG = currentColor.g;
            float originalB = currentColor.b;
            float r         = GUI.HorizontalSlider(new Rect(rect.x + 56, rect.y - 1, 136, 16), currentColor.r, 0, 1);

            GUI.color = Color.green;
            float g = GUI.HorizontalSlider(new Rect(rect.x + 56, rect.y + 19, 136, 16), currentColor.g, 0, 1);

            GUI.color = Color.blue;
            float b = GUI.HorizontalSlider(new Rect(rect.x + 56, rect.y + 39, 136, 16), currentColor.b, 0, 1);

            if (!CloseEnough(r, originalR) || !CloseEnough(g, originalG) || !CloseEnough(b, originalB))
            {
                SetColor(customPawn, new Color(r, g, b));
            }

            GUI.color = Color.white;
        }
コード例 #5
0
        public SaveRecordPawnV3(CustomPawn pawn)
        {
            this.id          = pawn.Id;
            this.thingDef    = pawn.Pawn.def.defName;
            this.pawnKindDef = pawn.Pawn.kindDef.defName;
            this.gender      = pawn.Gender;
            if (pawn.Adulthood != null)
            {
                this.adulthood = pawn.Adulthood.identifier;
            }
            else
            {
                this.adulthood = pawn.LastSelectedAdulthoodBackstory.identifier;
            }
            this.childhood        = pawn.Childhood.identifier;
            this.skinColor        = pawn.Pawn.story.SkinColor;
            this.melanin          = pawn.Pawn.story.melanin;
            this.hairDef          = pawn.HairDef.defName;
            this.hairColor        = pawn.GetColor(PawnLayers.Hair);
            this.headGraphicPath  = pawn.HeadGraphicPath;
            this.bodyType         = Enum.GetName(typeof(BodyType), pawn.BodyType);
            this.firstName        = pawn.FirstName;
            this.nickName         = pawn.NickName;
            this.lastName         = pawn.LastName;
            this.age              = 0;
            this.biologicalAge    = pawn.BiologicalAge;
            this.chronologicalAge = pawn.ChronologicalAge;
            foreach (var trait in pawn.Traits)
            {
                if (trait != null)
                {
                    this.traitNames.Add(trait.def.defName);
                    this.traitDegrees.Add(trait.Degree);
                }
            }
            foreach (var skill in pawn.Pawn.skills.skills)
            {
                this.skillNames.Add(skill.def.defName);
                this.skillValues.Add(pawn.GetUnmodifiedSkillLevel(skill.def));
                this.passions.Add(pawn.currentPassions[skill.def]);
                this.originalPassions.Add(pawn.originalPassions[skill.def]);
            }
            for (int layer = 0; layer < PawnLayers.Count; layer++)
            {
                ThingDef apparelThingDef = pawn.GetAcceptedApparel(layer);
                ThingDef apparelStuffDef = pawn.GetSelectedStuff(layer);
                Color    color           = pawn.GetColor(layer);
                if (apparelThingDef != null)
                {
                    this.apparelLayers.Add(layer);
                    this.apparel.Add(apparelThingDef.defName);
                    this.apparelStuff.Add(apparelStuffDef != null ? apparelStuffDef.defName : "");
                    this.apparelColors.Add(color);
                }
            }
            OptionsHealth healthOptions = PrepareCarefully.Instance.Providers.Health.GetOptions(pawn);

            foreach (Implant implant in pawn.Implants)
            {
                var saveRecord = new SaveRecordImplantV3(implant);
                if (implant.BodyPartRecord != null)
                {
                    UniqueBodyPart part = healthOptions.FindBodyPartsForRecord(implant.BodyPartRecord);
                    if (part != null && part.Index > 0)
                    {
                        saveRecord.bodyPartIndex = part.Index;
                    }
                }
                this.implants.Add(saveRecord);
            }
            foreach (Injury injury in pawn.Injuries)
            {
                var saveRecord = new SaveRecordInjuryV3(injury);
                if (injury.BodyPartRecord != null)
                {
                    UniqueBodyPart part = healthOptions.FindBodyPartsForRecord(injury.BodyPartRecord);
                    if (part != null && part.Index > 0)
                    {
                        saveRecord.bodyPartIndex = part.Index;
                    }
                }
                this.injuries.Add(saveRecord);
            }
        }