Esempio n. 1
0
        static bool Prefix(JobDriver_Lovin __instance)
        {
            var driverTraverse = Traverse.Create(__instance);

            Assert(driverTraverse, "driverTraverse");
            var partner = driverTraverse.Property("Partner").GetValue <Pawn>();

            Assert(partner, "partner");

            var genTicksToNextLovin = driverTraverse.Method("GenerateRandomMinTicksToNextLovin", __instance.pawn);

            Assert(genTicksToNextLovin, "GenTicksMethod");
            var ticksToNextLovin = genTicksToNextLovin.GetValue <int>(__instance.pawn);

            Assert(ticksToNextLovin, "ticksToNextLovin");

            var performanceLevel = LovinUtility.LovinLevel(__instance.pawn, partner);

            // apply the thought
            var thought = ThoughtMaker.MakeThought(ThoughtDefOf.LovinPerformance, performanceLevel);

            __instance.pawn.needs.mood.thoughts.memories.TryGainMemory(thought, partner);

            // we're civilized, not bunnies.
            __instance.pawn.mindState.canLovinTick = Find.TickManager.TicksGame + ticksToNextLovin;

            return(false);
        }
Esempio n. 2
0
        static bool Prefix(object __instance)
        {
            Assert(__instance, "instance");
            var traverse = Traverse.Create(__instance);

            Assert(traverse, "traverse");
            var driver = traverse.Field(DRIVER_FIELD_NAME).GetValue <JobDriver_Lovin>();

            Assert(driver, "driver");

            var driverTraverse = Traverse.Create(driver);

            Assert(driverTraverse, "driverTraverse");
            var partner = driverTraverse.Property("Partner").GetValue <Pawn>();

            Assert(partner, "partner");

            var genTicksToNextLovin = driverTraverse.Method("GenerateRandomMinTicksToNextLovin", driver.pawn);

            Assert(genTicksToNextLovin, "GenTicksMethod");
            var ticksToNextLovin = genTicksToNextLovin.GetValue <int>(driver.pawn);

            Assert(ticksToNextLovin, "ticksToNextLovin");

            var performanceLevel = LovinUtility.LovinLevel(driver.pawn, partner);

            // apply the thought
            var thought = ThoughtMaker.MakeThought(ThoughtDefOf.LovinPerformance, performanceLevel);

            // note that we have to massage the thought a bit due to a bug in vanilla;
            // https://ludeon.com/forums/index.php?topic=33052
            ((Thought_MemorySocial)thought).opinionOffset = thought.CurStage.baseOpinionOffset;
            driver.pawn.needs.mood.thoughts.memories.TryGainMemory(thought, partner);

            // we're civilized, not bunnies.
            driver.pawn.mindState.canLovinTick = Find.TickManager.TicksGame + ticksToNextLovin;

            return(false);
        }