Exemple #1
0
        /// <summary>
        /// Calculates the multiplier from dark adaptation
        /// </summary>
        /// <param name="pawn">The pawn to check dark adaptation on</param>
        /// <returns>multiplier</returns>
        private static float MiningMultiplier(Pawn pawn, bool useMultiplier = true)
        {
            if (adaptation && useMultiplier && pawn?.health.hediffSet.HasHediff(Cutebold_DefOf.CuteboldDarkAdaptation) == true)
            {
                Hediff_CuteboldDarkAdaptation darkAdaptation = (Hediff_CuteboldDarkAdaptation)pawn.health.hediffSet.GetFirstHediffOfDef(Cutebold_DefOf.CuteboldDarkAdaptation);
                var severity = darkAdaptation.Severity;
                return(darkAdaptation.WearingGoggles ? 0.25f : (severity < 0.25f) ? 0.25f : (severity < 0.5f) ? 0.5f : (severity < 0.75f) ? 0.75f : 1f);
            }

            return(1f);
        }
Exemple #2
0
        /// <summary>
        /// Overrides the regular glow curve for cutebolds to allow for dark adaptation.
        /// </summary>
        /// <param name="__result">The previous glow curve result.</param>
        /// <param name="t">The thing that is being evaluated.</param>
        private static void CuteboldFactorFromGlowPostfix(StatPart_Glow __instance, ref float __result, Thing t)
        {
            if (t.def.defName == Cutebold_Assemblies.RaceName)
            {
                switch (__instance.parentStat.defName)
                {
                case "MoveSpeed":
                case "SurgerySuccessChanceFactor":
                case "WorkSpeedGlobal":
                    Hediff_CuteboldDarkAdaptation hediff = (Hediff_CuteboldDarkAdaptation)((Pawn)t).health.hediffSet.GetFirstHediffOfDef(Cutebold_DefOf.CuteboldDarkAdaptation);
                    if (hediff != null)
                    {
                        __result = hediff.GlowCurve.Evaluate(t.Map.glowGrid.GameGlowAt(t.Position));
                    }
                    break;

                default:
                    break;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Applies the dark adaptation hediff to cutebolds as they spawn if they don't have it.
        /// </summary>
        /// <param name="__instance">The pawn</param>
        /// <param name="map">The map they are located on. (unused)</param>
        /// <param name="respawningAfterLoad">If the pawn is spawning after a reload.</param>
        private static void CuteboldAdaptationSpawnSetupPostfix(Pawn __instance, Map map, bool respawningAfterLoad)
        {
            if (__instance.Dead || __instance?.def.defName != Cutebold_Assemblies.RaceName || __instance.kindDef == null)
            {
                return;
            }

            if (__instance.health.hediffSet.GetFirstHediffOfDef(Cutebold_DefOf.CuteboldDarkAdaptation) == null)
            {
                Hediff_CuteboldDarkAdaptation hediff = (Hediff_CuteboldDarkAdaptation)HediffMaker.MakeHediff(Cutebold_DefOf.CuteboldDarkAdaptation, __instance);
                float minSeverity = 0f;
                float maxSeverity = 0.1f;
                bool  goggles     = false;

                foreach (Apparel apparel in __instance.apparel.WornApparel)
                {
                    if (apparel.def == Cutebold_DefOf.Cutebold_Goggles)
                    {
                        goggles = true;
                    }
                }

                if (!(__instance.story.traits.HasTrait(TraitDef.Named("Wimp")) && __instance.health.hediffSet.PainTotal > 0.0f) && __instance.health.hediffSet.PainTotal <= 0.5f && !respawningAfterLoad)
                {
                    if (__instance.story.childhood != null && Cutebold_Patch_Names.CuteboldUndergroundChildBackstories.Contains(__instance.story.childhood))
                    {
                        minSeverity += 0.05f;
                        maxSeverity += 0.15f;
                    }

                    if (__instance.story.adulthood != null && Cutebold_Patch_Names.CuteboldUndergroundAdultBackstories.Contains(__instance.story.childhood))
                    {
                        minSeverity += 0.20f;
                        maxSeverity += 0.30f;
                    }

                    if (__instance.story.traits.HasTrait(TraitDefOf.Undergrounder))
                    {
                        minSeverity += 0.10f;
                        maxSeverity += 0.20f;
                    }

                    if (__instance.story.traits.HasTrait(TraitDef.Named("Wimp")) && !goggles)
                    {
                        minSeverity = minSeverity > 0.5f ? 0.5f : minSeverity;
                        maxSeverity = maxSeverity > 0.7f ? 0.7f : maxSeverity;
                    }
                    else if (goggles)
                    {
                        minSeverity = minSeverity * 3f + 0.3f;
                        maxSeverity = maxSeverity * 3f + 0.4f;
                    }
                }

                hediff.Severity = new FloatRange(minSeverity, maxSeverity).RandomInRange;

                __instance.health.AddHediff(hediff);
            }

            Hediff_CuteboldDarkAdaptation darkAdaptation = (Hediff_CuteboldDarkAdaptation)__instance.health.hediffSet.GetFirstHediffOfDef(Cutebold_DefOf.CuteboldDarkAdaptation);

            darkAdaptation.UpdateGoggles();
            darkAdaptation.UpdateEyes();
        }