//public static void Tick_PostFix(Pawn __instance) {
        //    Tenant tenantComp = __instance.GetTenantComponent();
        //    if (tenantComp != null && tenantComp.IsTenant && __instance.IsColonist) {

        //    }
        //}
        public static void TickRare_PostFix(Pawn __instance)
        {
            if (__instance.IsColonist)
            {
                Tenant tenantComp = __instance.GetTenantComponent();
                if (tenantComp != null && tenantComp.IsTenant)
                {
                    //If a tenant has joined but has no contract.
                    if (!tenantComp.Contracted)
                    {
                        tenantComp.IsTenant = false;
                    }
                    //Tenant alone with no colonist
                    Pawn colonist = __instance.Map.mapPawns.FreeColonists.FirstOrDefault(x => x.GetTenantComponent().IsTenant == false);
                    if (colonist == null)
                    {
                        Events.ContractConclusion(__instance, true, 1f);
                        return;
                    }
                    //Tenant contract is out
                    if (Find.TickManager.TicksGame >= tenantComp.ContractEndTick)
                    {
                        Events.ContractConclusion(__instance, false);
                        return;
                    }

                    //If tenancy is to be terminated.
                    if (tenantComp.IsTerminated)
                    {
                        if (__instance.health.Downed)
                        {
                            Messages.Message("ContractTerminateFail".Translate(), MessageTypeDefOf.NeutralEvent);
                        }
                        else
                        {
                            Events.TenantCancelContract(__instance);
                            return;
                        }
                        tenantComp.IsTerminated = false;
                    }
                    ////Operations queue for tenancy rejected.
                    if (__instance.BillStack.Count > 0)
                    {
                        if ((__instance.BillStack.Bills.Where(x => x.recipe.isViolation == true).Count() > 0))
                        {
                            __instance.BillStack.Clear();
                            tenantComp.SurgeryQueue++;
                            if (tenantComp.SurgeryQueue < 2)
                            {
                                Messages.Message("TenantSurgeryWarning".Translate(__instance.Named("PAWN")), MessageTypeDefOf.NeutralEvent);
                            }
                            else
                            {
                                Messages.Message("TenantSurgeryLeave".Translate(__instance.Named("PAWN")), MessageTypeDefOf.NegativeEvent);
                                Events.TenantLeave(__instance);
                            }
                        }
                    }
                    //Tenancy tick per day
                    if (Find.TickManager.TicksGame % 60000 == 0)
                    {
                        if (tenantComp.Wanted)
                        {
                            if (!MapComponent_Tenants.GetComponent(__instance.Map).WantedTenants.Contains(__instance))
                            {
                                Events.TenantWanted(__instance);
                            }
                        }
                    }
                    //Tenancy tick 1/10 per day
                    if (Find.TickManager.TicksGame % 6000 == 0)
                    {
                        if (tenantComp.MoleMessage)
                        {
                            tenantComp.MoleMessage = false;
                            Messages.Message("TenantMoleMessage".Translate(), MessageTypeDefOf.NegativeEvent);
                        }
                        if (tenantComp.Mole && !tenantComp.MoleActivated)
                        {
                            if (Utility.CalculateMood(tenantComp) < 1 && tenantComp.NeutralMoodCount > 2)
                            {
                                Building building = __instance.Map.listerBuildings.allBuildingsColonist.FirstOrDefault(x => x.def.defName.Contains("commsconsole") || x.def.defName.Contains("CommsConsole"));
                                if (building != null)
                                {
                                    Job job = new Job(JobDefOf.JobUseCommsConsoleMole, building);
                                    __instance.jobs.TryTakeOrderedJob(job);
                                }
                            }
                        }
                        if (__instance.needs.mood.CurInstantLevel > 0.8f)
                        {
                            Events.TenantWantToJoin(__instance);
                        }

                        //Calculate mood
                        if (__instance.needs.mood.CurInstantLevel > 0.66f)
                        {
                            tenantComp.HappyMoodCount++;
                            tenantComp.RecentBadMoodsCount = 0;
                        }
                        else if (__instance.needs.mood.CurInstantLevel < __instance.mindState.mentalBreaker.BreakThresholdMinor)
                        {
                            tenantComp.SadMoodCount++;
                            tenantComp.RecentBadMoodsCount++;
                            if (tenantComp.RecentBadMoodsCount > 5)
                            {
                                Events.ContractConclusion(__instance, true);
                            }
                        }
                        else
                        {
                            tenantComp.NeutralMoodCount++;
                            tenantComp.RecentBadMoodsCount = 0;
                        }
                    }
                }
            }
        }