コード例 #1
0
        public static bool ShouldHaveNeed(this Source _this, NeedDef nd)
        {
            Pawn pawn = (Pawn)typeof(RimWorld.Pawn_NeedsTracker).GetField("pawn", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(_this);

            // BASE
            if (pawn.RaceProps.intelligence < nd.minIntelligence)
            {
                return(false);
            }
            if ((nd == NeedDefOf.Joy || nd == defComfort || nd == defBeauty || nd == defSpace) && pawn.IsGuest()) // ADDED
            {
                return(true);
            }
            if (nd.colonistsOnly && (pawn.Faction == null || !pawn.Faction.IsPlayer))
            {
                return(false);
            }
            if (nd.colonistAndPrisonersOnly && (pawn.Faction == null || !pawn.Faction.IsPlayer) && (pawn.HostFaction == null || pawn.HostFaction != Faction.OfPlayer))
            {
                return(false);
            }
            if (nd.onlyIfCausedByHediff && !pawn.health.hediffSet.hediffs.Any((Hediff x) => x.def.causesNeed == nd))
            {
                return(false);
            }
            if (nd == NeedDefOf.Food)
            {
                return(pawn.RaceProps.EatsFood);
            }

            return(nd != NeedDefOf.Rest || pawn.RaceProps.needsRest);
        }
コード例 #2
0
 public override void Randomize()
 {
     base.Randomize();
     need           = PossibleNeeds().RandomElement();
     levelRange.max = Rand.Range(0f, 1f);
     levelRange.min = levelRange.max * Rand.Range(0f, 0.95f);
 }
コード例 #3
0
ファイル: HarmonyPatches.cs プロジェクト: Slate5521/Momu
        public static void Pawn_NeedsTracker__ShouldHaveNeedPostfix
            (Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result)
        {
            // Get the pawn through Reflection
            Pawn p = typeof(Pawn_NeedsTracker)
                     .GetField(@"pawn", BindingFlags.NonPublic | BindingFlags.Instance)
                     .GetValue(__instance) as Pawn;

            // Check if it's from the Momu mod
            if (p.def == MomuDefOf.Alien_Momu)
            {   // It's a Momu
                if (nd == MomuDefOf.Outdoors)
                {
                    __result = false;
                }

                if (nd == MomuDefOf.MomuNeedOutdoors)
                {
                    // Our own Momu outdoor need.
                    __result = true;
                }
            }
            else if (p.def == LaiDefOf.Momu_Lai_Chrysalis)
            {   // It's a Lai Chrysalis, and they don't have any needs.
                if (nd == NeedDefOf.Food)
                {
                    __result = false;
                }

                if (nd == NeedDefOf.Rest)
                {
                    __result = false;
                }
            }
        }
コード例 #4
0
        static void Postfix(Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_NeedsTracker), "pawn").GetValue(__instance);

            Log.Message("Pawn battery check: " + pawn.Name);
            if (nd.needClass == typeof(Need_Battery))
            {
                if (pawn.def.thingClass == typeof(ArcBaseRobot))
                {
                    ArcBaseRobot robot = (ArcBaseRobot)pawn;
                    if (robot.isRobot())
                    {
                        Log.Message("Pawn need battery : " + pawn.Name);
                        __result = true;
                    }
                    else
                    {
                        __result = false;
                    }
                }
                else
                {
                    __result = false;
                }
            }
            else if (pawn.def.thingClass == typeof(ArcBaseRobot))
            {
                __result = false;
            }
        }
コード例 #5
0
            public static void Listener(NeedDef nd, ref bool __result, Pawn ___pawn)
            {
                try
                {
                    var isAndroid = Utils.ExceptionAndroidList.Contains(___pawn.def.defName);


                    if (!isAndroid)
                    {
                        return;
                    }

                    var advancedAndroids = Utils.ExceptionAndroidListAdvanced.Contains(___pawn.def.defName);

                    if (Utils.ExceptionAndroidListBasic.Contains(___pawn.def.defName) &&
                        nd.defName == "Outdoors" ||
                        ___pawn.def.defName == "Android1Tier" && nd.defName == "Beauty" ||
                        isAndroid && (nd.defName == "Hygiene" || nd.defName == "Bladder" || nd.defName == "DBHThirst") ||
                        nd.defName == "Comfort" && (!advancedAndroids || advancedAndroids && Settings.removeComfortNeedForT3T4))
                    {
                        __result = false;
                    }


                    if (___pawn.def.defName == "M7Mech" && ___pawn.IsSurrogateAndroid() && nd.defName == "Food")
                    {
                        __result = true;
                    }
                }
                catch (Exception e)
                {
                    Log.Message("[ATPP] Pawn_StoryTracker.ShouldHaveNeed : " + e.Message + " - " + e.StackTrace);
                }
            }
コード例 #6
0
        public void ExposeData()
        {
            Scribe_Values.LookValue <objectType>(ref oType, "oType");
            Scribe_Values.LookValue <float>(ref minWidthDesired, "minWidthDesired");
            Scribe_Values.LookValue <string>(ref this.label, "label");

            switch (oType)
            {
            case objectType.Stat:
                StatDef tempObjectS = (StatDef)displayObject;
                Scribe_Defs.LookDef(ref tempObjectS, "displayObject");
                displayObject = tempObjectS;
                break;

            case objectType.Skill:
                SkillDef tempObjectK = (SkillDef)displayObject;
                Scribe_Defs.LookDef(ref tempObjectK, "displayObject");
                displayObject = tempObjectK;
                break;

            case objectType.Need:
                NeedDef tempObjectN = (NeedDef)displayObject;
                Scribe_Defs.LookDef(ref tempObjectN, "displayObject");
                displayObject = tempObjectN;
                break;
            }
        }
コード例 #7
0
        // RimWorld.Pawn_NeedsTracker
        public static void ShouldHaveNeed_Vamp(Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result)
        {
            Pawn p = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (p.VampComp() != null && p.VampComp().IsVampire)
            {
                if (nd == NeedDefOf.Food)
                {
                    __result = false;
                    return;
                }
            }

            if (nd == VampDefOf.ROMV_Blood)
            {
                if (p?.RaceProps?.IsMechanoid ?? false)
                {
                    __result = false;
                    return;
                }

                string typeString = p.GetType().ToString();
                //////Log.Message(typeString);
                if (p.GetType().ToString() == "ProjectJedi.PawnGhost")
                {
                    __result = false;
                    return;
                }
            }
        }
コード例 #8
0
 static void Postfix(ref bool __result, NeedDef nd, Pawn ___pawn)
 {
     if (nd == RatkinNeedDefOf.Outdoors && ___pawn.def == RatkinRaceDefOf.Ratkin)
     {
         __result = false;
     }
 }
コード例 #9
0
        public NeedModel(PawnModel model, NeedDef def) : base(model)
        {
            var need = model.Base.needs?.TryGetNeed(def);

            if (need == null)
            {
                Hidden = true;
                return;
            }

            Label = def.LabelCap;

            Max        = 1f;
            Value      = need.CurLevelPercentage;
            ValueStyle = HudBar.ValueStyle.Percentage;

            if (def == Access.NeedDefOfMood)
            {
                Tooltip    = model.Mind.Tooltip;
                Thresholds = new[] { model.MoodThresholdMinor, model.MoodThresholdMajor, model.MoodThresholdExtreme };
            }
            else
            {
                Tooltip    = null;
                Thresholds = null;
            }
        }
コード例 #10
0
            public static void Listener(NeedDef nd, ref bool __result, Pawn ___pawn)
            {
                try
                {
                    bool isAndroid = Utils.ExceptionAndroidList.Contains(___pawn.def.defName);

                    //SI pas un androide on jerte
                    if (!isAndroid)
                    {
                        return;
                    }

                    bool advancedAndroids = Utils.ExceptionAndroidListAdvanced.Contains(___pawn.def.defName);

                    if ((Utils.ExceptionAndroidListBasic.Contains(___pawn.def.defName) &&
                         (nd.defName == "Outdoors")) ||
                        (___pawn.def.defName == "Android1Tier" && nd.defName == "Beauty") ||
                        (isAndroid && (nd.defName == "Hygiene" || nd.defName == "Bladder" || nd.defName == "DBHThirst")) ||
                        (nd.defName == "Comfort" && (!advancedAndroids || (advancedAndroids && Settings.removeComfortNeedForT3T4))))
                    {
                        __result = false;
                    }

                    //Activation besoin de bouffe pour les M7 surrogates (SM7)
                    if (___pawn.def.defName == "M7Mech" && ___pawn.IsSurrogateAndroid() && nd.defName == "Food")
                    {
                        __result = true;
                    }
                }
                catch (Exception e)
                {
                    Log.Message("[ATPP] Pawn_StoryTracker.ShouldHaveNeed : " + e.Message + " - " + e.StackTrace);
                }
            }
コード例 #11
0
        public override ThinkNode DeepCopy(bool resolve = true)
        {
            var ThinkNode_ModNeedPercentageAbove = (ThinkNode_ModNeedPercentageAbove)base.DeepCopy(resolve);

            ThinkNode_ModNeedPercentageAbove.need      = need;
            ThinkNode_ModNeedPercentageAbove.threshold = threshold;
            return(ThinkNode_ModNeedPercentageAbove);
        }
コード例 #12
0
 public static bool ShouldHaveNeedPrisoner(NeedDef nd, Pawn pawn)
 {
     if ((nd.defName == "PrisonLabor_Motivation" || nd.defName == "PrisonLabor_Treatment") && !(pawn.IsPrisoner && PrisonLaborPrefs.EnableMotivationMechanics))
     {
         return(false);
     }
     return(true);
 }
コード例 #13
0
        public override void Randomize()
        {
            base.Randomize();
            need = DefDatabase <NeedDef> .AllDefs.Where((NeedDef x) => x.major).RandomElement();

            levelRange.max = Rand.Range(0f, 1f);
            levelRange.min = levelRange.max * Rand.Range(0f, 0.95f);
        }
 public static bool Listener(Pawn pawn, ref bool __result, NeedDef ___need)
 {
     if (pawn.needs.TryGetNeed(___need) == null)
     {
         __result = true;
         return(false);
     }
     return(true);
 }
コード例 #15
0
 public static bool Prefix(ref bool __result, NeedDef nd, Pawn ___pawn)
 {
     if ((nd == NeedDefOf.Joy || nd == defComfort || nd == defBeauty || nd == defSpace) && ___pawn.IsGuest()) // ADDED
     {
         __result = true;
         return(false);
     }
     return(true);
 }
コード例 #16
0
 static void Postfix(Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result)
 {
     if (nd == MizuDef.Need_Water)
     {
         if (__instance.food == null)
         {
             __result = false;
         }
     }
 }
コード例 #17
0
        static SapientAnimalNeed GetSapientAnimalNeed([NotNull] NeedDef need)
        {
            if (_needLookup.TryGetValue(need, out var ext))
            {
                return(ext);
            }

            ext = need.GetModExtension <SapientAnimalNeed>();
            _needLookup[need] = ext;
            return(ext);
        }
コード例 #18
0
        public static bool Prefix(Pawn_NeedsTracker __instance, ref bool __result, NeedDef nd)
        {
            var pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if ((nd == NeedDefOf.Joy) && pawn.IsCarny())
            {
                __result = true;
                return(false);
            }
            return(true);
        }
コード例 #19
0
 public static void AddNeed(this Pawn_NeedsTracker needs, NeedDef def)
 {
     needs.GetType()
     .GetMethod("AddNeed", BindingFlags.Instance | BindingFlags.NonPublic)
     .Invoke(needs, new object[] { def });
     foreach (var need in needs.AllNeeds)
     {
         Log.Message(need.LabelCap);
     }
     Log.Message("---");
 }
 private static void Postfix(Pawn_NeedsTracker __instance, Pawn ___pawn, NeedDef nd, ref bool __result)
 {
     if (___pawn.isOrkoid() && nd == AdeptusNeedDefOf.Beauty)
     {
         __result = false;
     }
     if (!___pawn.isOrkoid() && nd == AdeptusNeedDefOf.OG_Ork_Fightyness)
     {
         __result = false;
     }
 }
        public static void RoyalEggSize(Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (pawn.def == USCMDefOf.RRY_Synth)
            {
                if (nd == NeedDefOf.Rest)
                {
                    __result = false;
                }
            }
        }
コード例 #22
0
        public static void Pawn_NeedsTracker_ShouldHaveNeed_Postfix(NeedDef nd, Pawn ___pawn, ref bool __result)
        {
            var raceSettings = AutomataRaceSettingCache.Get(___pawn.def);

            if (raceSettings != null)
            {
                if (raceSettings.needBlacklists.Contains(nd))
                {
                    __result = false;
                }
            }
        }
コード例 #23
0
 static void OffsetNeed(Pawn pawn, NeedDef nd, float offsetPct)
 {
     if (pawn != null)
     {
         Need need = pawn.needs.TryGetNeed(nd);
         if (need != null)
         {
             need.CurLevel += offsetPct * need.MaxLevel;
             pawn.Drawer.Notify_DebugAffected();
         }
     }
 }
コード例 #24
0
        public static void Pawn_NeedsTracker_ShouldHaveNeed_Postfix(NeedDef nd, Pawn ___pawn, ref bool __result)
        {
            var raceSettings = DefDatabase <AutomataRaceSettings> .GetNamed(___pawn.def.defName, errorOnFail : false);

            if (raceSettings != null)
            {
                if (raceSettings.needBlacklists.Contains(nd))
                {
                    __result = false;
                }
            }
        }
コード例 #25
0
        public static float GetHygieneNeed(Pawn pawn)
        {
            NeedDef hygiene = DefDatabase <NeedDef> .AllDefsListForReading.Find(x => x.defName == "Hygiene");

            if (hygiene == null)
            {
                return(1f);
            }
            else
            {
                return(pawn.needs.TryGetNeed(hygiene).CurLevelPercentage);
            }
        }
コード例 #26
0
 public static bool ShouldHaveNeedPrisoner(NeedDef nd, Pawn pawn)
 {
     if (nd.defName == "PrisonLabor_Motivation")
     {
         if (pawn.IsPrisoner && PrisonLaborPrefs.EnableMotivationMechanics && !PrisonLaborPrefs.DisableMod)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #27
0
 public static bool Prefix(Pawn ___pawn, NeedDef nd, ref bool __result)
 {
     if (___pawn is Wendigo)
     {
         if (nd == NeedDefOf.Food)
         {
             return(false);
         }
         else if (nd == WendigoDefOf.RCW_Flesh)
         {
             __result = true;
             return(false);
         }
     }
     return(true);
 }
コード例 #28
0
 public static bool Prefix(Pawn ___pawn, NeedDef nd, ref bool __result)
 {
     if (___pawn is Machine)
     {
         if (nd == VFEDefOf.VFE_Mechanoids_Power)
         {
             __result = true;
             return(false);
         }
     }
     else if (nd == VFEDefOf.VFE_Mechanoids_Power)
     {
         return(false);
     }
     return(true);
 }
コード例 #29
0
        public static IEnumerable <StatDrawEntry> DrugAddictionStats(CompProperties_Drug comp, StatRequest req, int displayOffset = 0)
        {
            ThingDef thingDef = (ThingDef)req.Def;
            var      category = DefDatabase <StatCategoryDef> .GetNamed("DrugAddiction");

            HediffDef addictionHediff = comp.chemical?.addictionHediff;
            NeedDef   addictionNeed   = addictionHediff?.causesNeed;
            HediffCompProperties_SeverityPerDay addictionSeverityComp =
                (HediffCompProperties_SeverityPerDay)addictionHediff?.CompPropsFor(typeof(HediffComp_SeverityPerDay))
            ;

            // Addictiveness
            yield return(new StatDrawEntry(
                             category:    category,
                             label:       "Addictiveness".Translate(),
                             reportText:  "Stat_Thing_Drug_Addictiveness_Desc".Translate(),
                             valueString: comp.addictiveness.ToStringPercent(),
                             displayPriorityWithinCategory: displayOffset + 99
                             ));

            if (addictionSeverityComp != null)
            {
                // Addiction decay per day
                yield return(new StatDrawEntry(
                                 category:    category,
                                 label:       "Stat_Thing_Drug_AddictionDecay_Name".Translate(),
                                 reportText:  "Stat_Thing_Drug_AddictionDecay_Desc".Translate(),
                                 valueString: addictionSeverityComp.severityPerDay.ToStringPercent(),
                                 displayPriorityWithinCategory: displayOffset + 98
                                 ));

                // Time to shake addiction
                float daysToShakeAddiction = addictionHediff.initialSeverity / addictionSeverityComp.severityPerDay * -1;
                yield return(new StatDrawEntry(
                                 category:    category,
                                 label:       "Stat_Thing_Drug_TimeToShakeAddiction_Name".Translate(),
                                 reportText:  "Stat_Thing_Drug_TimeToShakeAddiction_Desc".Translate(),
                                 valueString: ToStringDaysToPeriod(daysToShakeAddiction),
                                 displayPriorityWithinCategory: displayOffset + 98
                                 ));
            }

            if (addictionHediff != null)
            {
                yield return(FindHediffRisks(addictionHediff, "AddictionRisks", category, displayOffset));
            }
        }
コード例 #30
0
        // RimWorld.Pawn_NeedsTracker
        public static void ShouldHaveNeed_Vamp(Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result)
        {
            Pawn p = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (p.VampComp() != null && p.VampComp().IsVampire)
            {
                if (nd == NeedDefOf.Food)
                {
                    __result = false;
                    return;
                }
            }

            if (nd == VampDefOf.ROMV_Blood)
            {
                if (p?.RaceProps?.IsMechanoid ?? false)
                {
                    __result = false;
                    return;
                }

                string typeString = p.GetType().ToString();
                //////Log.Message(typeString);
                ///
                if (DefDatabase <BloodNeedExceptions> .GetNamedSilentFail("ExceptionsList") is Vampire.BloodNeedExceptions exceptionList)
                {
                    foreach (string s in exceptionList.thingClasses)
                    {
                        if (p?.GetType()?.ToString() == s)
                        {
                            __result = false;
                            return;
                        }
                    }
                    foreach (ThingDef d in exceptionList.raceThingDefs)
                    {
                        if (p?.def == d)
                        {
                            __result = false;
                            return;
                        }
                    }
                }
            }
        }
コード例 #31
0
 internal bool _ShouldHaveNeed( NeedDef nd )
 {
     var pawn = this.pawn();
     if( pawn.RaceProps.intelligence < nd.minIntelligence )
     {
         return false;
     }
     if( nd == NeedDefOf.Food )
     {
         return pawn.RaceProps.EatsFood;
     }
     if( nd == NeedDefOf.Rest )
     {
         return pawn.RaceProps.needsRest;
     }
     /*
     if(
         ( nd == NeedDefOf.Joy )&&
         ( pawn.HostFaction != null )
     )
     {
         return false;
     }
     */
     if(
         ( !nd.colonistAndPrisonersOnly )||
         ( pawn.Faction != null )&&
         ( pawn.Faction.IsPlayer )
     )
     {
         return true;
     }
     if( pawn.HostFaction != null )
     {
         return pawn.HostFaction == Faction.OfPlayer;
     }
     return false;
 }