コード例 #1
0
            static void GiveSapientAnimalsNeeds(Pawn_NeedsTracker __instance, Pawn ___pawn, NeedDef nd, ref bool __result)
            {
                if (__result)
                {
                    __result = nd.IsValidFor(___pawn);
                    return;
                }
                if (___pawn?.IsSapientOrFeralFormerHuman() != true)
                {
                    return;
                }
                if (nd?.defName == "SapientAnimalControl")
                {
                    __result = true;
                    return;
                }

                var isColonist = ___pawn.Faction?.IsPlayer == true;

                if (nd.defName == "Mood")
                {
                    __result = true;
                }
                else if (nd.defName == "Joy" && isColonist)
                {
                    __result = true;
                }
            }
コード例 #2
0
            private static void GiveSapientAnimalsNeeds(Pawn_NeedsTracker __instance, Pawn ___pawn, NeedDef nd, ref bool __result)
            {
                if (nd == PMNeedDefOf.SapientAnimalControl)
                {
                    __result = Need_Control.IsEnabledFor(___pawn);
                    return;
                }

                bool isColonist = ___pawn.Faction?.IsPlayer == true;

                bool moodIsEnabled = MoodIsEnabled(___pawn);

                if (nd == PMNeedDefOf.Joy && isColonist)
                {
                    __result = moodIsEnabled;
                }

                if (moodIsEnabled)
                {
                    var defExt = GetSapientAnimalNeed(nd);
                    if (defExt != null)
                    {
                        __result = !defExt.mustBeColonist || ___pawn.IsColonist;
                    }
                }

                if (__result)
                {
                    __result = nd.IsValidFor(___pawn);
                }
            }
コード例 #3
0
        public static void Postfix(Pawn_NeedsTracker __instance)
        {
            var traverse = Traverse.Create(__instance);
            var pp       = traverse.Field("pawn").GetValue <Pawn>();

            if (!pp.IsWarframe())
            {
                return;
            }

            foreach (var nnd in getUselessNeed())
            {
                if (__instance.TryGetNeed(nnd) == null)
                {
                    continue;
                }

                //__instance.RemoveNeed(nnd);
                var item     = __instance.TryGetNeed(nnd);
                var needlist = traverse.Field("needs").GetValue <List <Need> >();
                needlist.Remove(item);

                //    __instance.BindDirectNeedFields();
            }
        }
コード例 #4
0
            private static void GiveSapientAnimalsNeeds(Pawn_NeedsTracker __instance, Pawn ___pawn, NeedDef nd, ref bool __result)
            {
                if (nd == PMNeedDefOf.SapientAnimalControl)
                {
                    __result = Need_Control.IsEnabledFor(___pawn);
                    return;
                }

                bool isColonist = ___pawn.Faction?.IsPlayer == true;

                bool moodIsEnabled = MoodIsEnabled(___pawn);

                if (nd == PMNeedDefOf.Joy && isColonist)
                {
                    __result = moodIsEnabled;
                }

                if (nd == PMNeedDefOf.Mood || nd == PMNeedDefOf.Comfort || nd == PMNeedDefOf.Beauty)
                {
                    __result = moodIsEnabled;
                }


                if (__result)
                {
                    __result = nd.IsValidFor(___pawn);
                }
            }
コード例 #5
0
        public static bool Detour(MethodInfo __originalMethod, Pawn_NeedsTracker __instance, ref string __state)
        {
            if (Active)
            {
                if (__instance.pawn.IsHashIntervalTick(150))
                {
                    for (int i = 0; i < __instance.needs.Count; i++)
                    {
                        if (ByPawn)
                        {
                            __state = $"{__instance.needs[i].GetType().Name} {__instance.needs[i].pawn}";
                        }
                        else
                        {
                            __state = $"{__instance.needs[i].GetType().Name}";
                        }

                        var prof = Analyzer.Start(__state, null, null, null, null, __originalMethod);
                        __instance.needs[i].NeedInterval();
                        prof.Stop();
                    }
                }
                return(false);
            }
            return(true);
        }
コード例 #6
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;
                }
            }
        }
コード例 #7
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;
            }
        }
コード例 #8
0
 public PawnNeeds(Pawn_NeedsTracker n, Settings settings)
 {
     foreach (Need need in n.AllNeeds)
     {
         needs.Add(new KeyValuePair(need.LabelCap, "" + need.CurLevelPercentage));
     }
 }
コード例 #9
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;
                }
            }
        }
コード例 #10
0
 internal static Pawn            pawn(this Pawn_NeedsTracker obj)
 {
     if (_pawn == null)
     {
         _pawn = typeof(Pawn_NeedsTracker).GetField("pawn", BindingFlags.Instance | BindingFlags.NonPublic);
     }
     return((Pawn)_pawn.GetValue(obj));
 }
コード例 #11
0
        // RimWorld.Pawn_NeedsTracker
        private static void Vamp_FullBladder(Pawn_NeedsTracker __instance, ref float __result)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_NeedsTracker), "pawn").GetValue(__instance);

            if (pawn.IsVampire())
            {
                __result = 1.0f;
            }
        }
コード例 #12
0
 static void Postfix(Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result)
 {
     if (nd == MizuDef.Need_Water)
     {
         if (__instance.food == null)
         {
             __result = false;
         }
     }
 }
コード例 #13
0
            static bool AddEnergySourceCheck(bool __result, Pawn_NeedsTracker __instance, NeedDef nd, Pawn ___pawn)
            {
                var net = PawnPartPowerNet.Get(___pawn);

                if (nd != CyberizationDefOf.PartEnergy)
                {
                    return(__result);
                }

                return(net.Nodes.Any());
            }
コード例 #14
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);
        }
 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;
     }
 }
コード例 #16
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("---");
 }
コード例 #17
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 || nd == defComfort || nd == defBeauty || nd == defSpace) && pawn.IsGuest()) // ADDED
                {
                    __result = true;
                    return(false);
                }
                return(true);
            }
コード例 #18
0
 public static bool Skip(Pawn_NeedsTracker instance)
 {
     if (instance.pawn.ATCompSurrogateOwner?.skyCloudHost != null)
     {
         return(false);
     }
     if (instance.pawn.IsBlankAndroid())
     {
         return(false);
     }
     return(true);
 }
        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;
                }
            }
        }
コード例 #20
0
        static void Postfix(Pawn_NeedsTracker __instance)
        {
            MultiplayerPawnComp comp = __instance.pawn.GetComp <MultiplayerPawnComp>();

            if (__instance.mood == null)
            {
                comp.thoughtsForInterface = null;
            }
            else
            {
                SituationalThoughtHandler thoughts = new SituationalThoughtHandler(__instance.pawn);
                comp.thoughtsForInterface = thoughts;
            }
        }
コード例 #21
0
            static void postfix(ref Pawn_NeedsTracker __instance)
            {
                Pawn_NeedsTracker tr        = __instance;
                FieldInfo         fieldInfo = AccessTools.Field(typeof(Pawn_NeedsTracker), "pawn");
                Pawn pawn = fieldInfo.GetValue(__instance) as Pawn;

                if (xxx.is_human(pawn) && pawn.ageTracker.CurLifeStageIndex < AgeStage.Teenager)
                {
                    if (tr.TryGetNeed(NeedDefOf.Joy) == null)
                    {
                        MethodInfo method = AccessTools.Method(typeof(Pawn_NeedsTracker), "AddNeed");
                        method.Invoke(tr, new object[] { NeedDefOf.Joy });
                    }
                }
            }
コード例 #22
0
        public static bool Prefix(Pawn_NeedsTracker __instance)
        {
            Traverse traverse = Traverse.Create(__instance);
            Pawn     pawn     = (Pawn)AvP_Pawn_NeedsTracker_Patch.pawn.GetValue(__instance);
            bool     flag     = pawn != null;

            if (flag)
            {
                bool flag2 = (pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Cocooned));
                bool flag3 = (pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_FaceHuggerInfection) && Find.TickManager.TicksGame % 5 != 0);
                if (flag2 || flag3)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #23
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;
                        }
                    }
                }
            }
        }
コード例 #24
0
ファイル: NeedsUtility.cs プロジェクト: kfish610/Nutrition
        public static IEnumerable <Need_FoodGroup> GetFoodGroups(this Pawn_NeedsTracker needs)
        {
            Need_Dairy dairy = needs.TryGetNeed <Need_Dairy>();

            if (dairy == null)
            {
                yield break;
            }
            yield return(dairy);

            yield return(needs.TryGetNeed <Need_Fruit>());

            yield return(needs.TryGetNeed <Need_Vegetables>());

            yield return(needs.TryGetNeed <Need_Protein>());

            yield return(needs.TryGetNeed <Need_Grain>());
        }
コード例 #25
0
 public static void Postfix(Pawn_NeedsTracker __instance, Pawn ___pawn)
 {
     if (___pawn is Wendigo)
     {
         var removed = __instance.AllNeeds.RemoveAll(x => x.GetType() == typeof(Need_Food));
         if (!(__instance.food is Need_Flesh))
         {
             var need = __instance.AllNeeds.FirstOrDefault(x => x.GetType() == typeof(Need_Flesh));
             if (need is null)
             {
                 need     = (Need)Activator.CreateInstance(WendigoDefOf.RCW_Flesh.needClass, ___pawn);
                 need.def = WendigoDefOf.RCW_Flesh;
                 __instance.AllNeeds.Add(need);
                 need.SetInitialLevel();
             }
             __instance.food = __instance.TryGetNeed <Need_Flesh>();
         }
     }
 }
コード例 #26
0
        // RimWorld.Pawn_NeedsTracker
        private static bool Vamp_NoBladderNeed(Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_NeedsTracker), "pawn").GetValue(__instance);

            if (pawn.IsVampire())
            {
                if (nd.defName == "Bladder")
                {
                    __result = false;
                    return(false);
                }
                if (nd.defName == "DBHThirst")
                {
                    __result = false;
                    return(false);
                }
            }

            return(true);
        }
コード例 #27
0
        static void Postfix(Pawn_NeedsTracker __instance, NeedDef nd, ref bool __result)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_NeedsTracker), "pawn").GetValue(__instance);

            if (nd.needClass == typeof(Need_Battery))
            {
                if (pawn.def.thingClass == typeof(ArcBaseRobot))
                {
                    __result = true;
                }
                else
                {
                    __result = false;
                }
            }
            else if (pawn.def.thingClass == typeof(ArcBaseRobot))
            {
                __result = false;
            }
        }
コード例 #28
0
ファイル: AQUtility.cs プロジェクト: Cody-Spring/Aquarium
        // Token: 0x06000006 RID: 6 RVA: 0x00002210 File Offset: 0x00000410
        internal static void ApplyMoodBoostAndInspire(Pawn pawn, Thing FishyThing)
        {
            CompAquarium      CompAQ = FishyThing.TryGetComp <CompAquarium>();
            Pawn_NeedsTracker needs  = pawn.needs;

            if ((needs?.mood) != null)
            {
                float fishFactor = 1f;
                float agefactor  = 1f;
                float compare    = 30f;
                if (CompAQ != null && CompAQ.numFish > 0 && pawn.IsHashIntervalTick(1000))
                {
                    List <string> list = CompAQ.fishData;
                    if (list.Count > 0)
                    {
                        foreach (string listing in list)
                        {
                            ThingDef fishdef = ThingDef.Named(CompAquarium.StringValuePart(listing, 1));
                            if (fishdef != null)
                            {
                                float value = Math.Max(10f, Math.Min(50f, fishdef.BaseMarketValue));
                                fishFactor *= value / compare;
                                agefactor  *= Mathf.Lerp(0.75f, 1f, Math.Min(CompAquarium.oldFishAge, CompAquarium.NumValuePart(listing, 3)) / CompAquarium.oldFishAge);
                            }
                        }
                    }
                    if (IsInspired((int)(CompAQ.numFish * 25 * fishFactor * agefactor)))
                    {
                        ThoughtDef fishRelaxDef = ThoughtDef.Named("AQObserveFish");
                        pawn.needs.mood.thoughts.memories.TryGainMemory(fishRelaxDef, null);
                    }
                }
            }
            if (CompAQ != null && CompAQ.numFish > 0 && Controller.Settings.AllowInspire && pawn.IsHashIntervalTick(1000) && !pawn.IsPrisoner && IsInspired((int)(CompAQ.numFish * Controller.Settings.BaseInspChance)) && !pawn.mindState.inspirationHandler.Inspired)
            {
                InspirationDef IDef = (from x in DefDatabase <InspirationDef> .AllDefsListForReading
                                       where x.Worker.InspirationCanOccur(pawn)
                                       select x).RandomElementByWeightWithFallback((InspirationDef x) => x.Worker.CommonalityFor(pawn), null);
                pawn.mindState.inspirationHandler.TryStartInspiration_NewTemp(IDef, null);
            }
        }
コード例 #29
0
        public static void Pawn_NeedsTracker_ShouldHaveNeed_Postfix(Pawn_NeedsTracker __instance, ref bool __result, Pawn ___pawn, NeedDef nd)
        {
            if (!__result)
            {
                return;
            }
            if (!PeacekeeperUtility.IsPeacekeeper(___pawn))
            {
                return;
            }

            var t             = PatchesCompatibility.hygieneAssembly.GetType("DubsBadHygiene.NeedsUtil");
            var checkInfo     = t.GetMethod("IsHygieneNeed", new[] { typeof(NeedDef) });
            var isHygieneNeed = (bool)checkInfo.Invoke(null, new object[] { nd });

            if (!isHygieneNeed)
            {
                return;
            }
            __result = false;
        }
コード例 #30
0
        internal static bool _ShouldHaveNeed(this Pawn_NeedsTracker obj, NeedDef nd)
        {
            var pawn = obj.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 )&&
             *  ( this.pawn.HostFaction != null )
             * )
             * {
             *  return false;
             * }
             */
            if (
                (!nd.colonistAndPrisonersOnly) ||
                (pawn.Faction != null) &&
                (pawn.Faction.def == FactionDefOf.Colony)
                )
            {
                return(true);
            }
            if (pawn.HostFaction != null)
            {
                return(pawn.HostFaction == Faction.OfColony);
            }
            return(false);
        }