Пример #1
0
        public static AgeSetting GetPresent(this List <AgeSetting> ageSettings, Pawn pawn)
        {
            AgeSetting result = null;

            foreach (var ageSetting in ageSettings.FindAll(x => x.gender == Gender.None || x.gender == pawn.gender))
            {
                if (ageSetting.minAge <= pawn.ageTracker.AgeBiologicalYearsFloat)
                {
                    result = ageSetting;
                }
            }
            return(result);
        }
Пример #2
0
        public void CheckAgeSetting()
        {
            var thingDef      = pawn.def as RaceAddonThingDef;
            var newAgeSetting = thingDef.raceAddonSettings.ageSettings.GetPresent(pawn);

            if (presentAgeSetting != newAgeSetting)
            {
                presentAgeSetting = newAgeSetting;
                AppearanceDef appearanceDef = presentAgeSetting.appearances?.GetAppearanceDef(pawn, true);
                if (appearanceDef != null && !presentAgeSetting.keepAppearance)
                {
                    RaceAddon.SetAppearance(pawn, racomp, thingDef, appearanceDef);
                }
                racomp.raceAddonGraphicSet = new RaceAddonGraphicSet(pawn, racomp);
                pawn.Drawer.renderer.graphics.ResolveAllGraphics();
                if (pawn.IsColonist)
                {
                    Find.LetterStack.ReceiveLetter("RaceAddon_GrowUp_Label".Translate(pawn.Name.ToStringShort), "RaceAddon_GrowUp_String".Translate(), LetterDefOf.PositiveEvent);
                }

                /*
                 * if (presentAgeSetting.ageBackstory != null && thingDef.raceAddonSettings.ageSettings[thingDef.raceAddonSettings.ageSettings.IndexOf(presentAgeSetting) - 1].ageBackstory.Backstory == pawn.story.childhood)
                 * {
                 *  pawn.story.childhood = presentAgeSetting.ageBackstory.Backstory;
                 *
                 *  if (presentAgeSetting.ageBackstory.skillGains.Count > 0)
                 *  {
                 *      foreach (SkillGain skillGain in presentAgeSetting.ageBackstory.skillGains)
                 *      {
                 *          pawn.skills.Learn(skillGain.skill, skillGain.xp, true);
                 *          pawn.skills.skills.ForEach(x => x.Level += x.def == skillGain.skill ? skillGain.xp : 0);
                 *      }
                 *  }
                 *  if (presentAgeSetting.ageBackstory.forcedHediffs.Count > 0)
                 *  {
                 *      foreach (var set in presentAgeSetting.ageBackstory.forcedHediffs)
                 *      {
                 *          Hediff hediff = HediffMaker.MakeHediff(set.hediffDef, pawn, set.targetPart.GetBodyPartRecord(pawn.def.race.body));
                 *          hediff.Severity = set.severity;
                 *          pawn.health.AddHediff(hediff);
                 *      }
                 *  }
                 *
                 *  pawn.workSettings = new Pawn_WorkSettings(pawn);
                 *  pawn.workSettings.EnableAndInitialize();
                 * }
                 */
            }
        }
Пример #3
0
        public RaceAddonGraphicSet(Pawn pawn, RaceAddonComp racomp)
        {
            if (pawn.def is RaceAddonThingDef thingDef)
            {
                this.pawn   = pawn;
                this.racomp = racomp;

                presentAgeSetting = thingDef.raceAddonSettings.ageSettings.GetPresent(pawn);

                headMeshSet = new GraphicMeshSet((1.5f * presentAgeSetting.drawSize.head.x) * racomp.drawSizeDeviation, (1.5f * presentAgeSetting.drawSize.head.y) * racomp.drawSizeDeviation);
                bodyMeshSet = new GraphicMeshSet((1.5f * presentAgeSetting.drawSize.body.x) * racomp.drawSizeDeviation, (1.5f * presentAgeSetting.drawSize.body.y) * racomp.drawSizeDeviation);
                //equipmentMeshSet = new GraphicMeshSet(presentAgeSetting.drawSize.equipment.x, presentAgeSetting.drawSize.equipment.y);
                racomp.cachedDrawLocCorrection = 0f;
                if (thingDef.raceAddonSettings.graphicSetting.footPositionCorrection_DrawSize)
                {
                    racomp.cachedDrawLocCorrection += (1.5f - (1.5f * presentAgeSetting.drawSize.body.y)) / 2f;
                }
                if (thingDef.raceAddonSettings.graphicSetting.footPositionCorrection_DrawSizeCurve)
                {
                    racomp.cachedDrawLocCorrection += (1.5f - (1.5f * racomp.drawSizeDeviation)) / 2f;
                }

                eyeBlinker   = thingDef.raceAddonSettings.graphicSetting.eyeBlink ? new EyeBlinker() : null;
                headRotator  = thingDef.raceAddonSettings.graphicSetting.headAnimation ? new HeadRotator() : null;
                headTargeter = thingDef.raceAddonSettings.graphicSetting.headTargeting ? new HeadTargeter(pawn) : null;

                upperFaceGraphic = racomp.upperFaceDef == null ? null : new FaceGraphicRecord(pawn, racomp.upperFaceDef, racomp.faceColor_Main, racomp.faceColor_Sub, thingDef.raceAddonSettings.graphicSetting.fixedUpperFace);
                lowerFaceGraphic = racomp.lowerFaceDef == null ? null : new FaceGraphicRecord(pawn, racomp.lowerFaceDef, racomp.faceColor_Main, racomp.faceColor_Sub, thingDef.raceAddonSettings.graphicSetting.fixedLowerFace);
                foreach (var addonData in racomp.addonDatas)
                {
                    var linkedBodyPart = addonData.addonDef.linkedBodyPart.GetBodyPartRecord(pawn.def.race.body);
                    addonGraphics.Add(new AddonGraphicRecord(addonData, linkedBodyPart, thingDef.raceAddonSettings.graphicSetting.rottingColor));
                }
            }
            else
            {
                RaceAddon.Notify("RaceAddonGraphicSet Init failure, Unkown ThingDef => " + pawn.Name.ToStringShort, true);
            }
        }