Beispiel #1
0
    public static void TenantWanted(Pawn pawn)
    {
        var tenantComp = pawn.GetTenantComponent();

        if (Rand.Value < 0.66 && tenantComp.WantedBy.HostileTo(Find.FactionManager.OfPlayer) &&
            !MapComponent_Tenants.GetComponent(pawn.Map).WantedTenants.Contains(pawn))
        {
            MapComponent_Tenants.GetComponent(pawn.Map).WantedTenants.Add(pawn);
            var parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, pawn.Map);
            parms.raidStrategy = RaidStrategyDefOf.WantedRaid;
            parms.forced       = true;
            Find.Storyteller.incidentQueue.Add(IncidentDefOf.WantedRaid,
                                               Find.TickManager.TicksGame + Rand.Range(100000, 300000), parms, 60000);
        }
        else if (Rand.Value < 0.5)
        {
            tenantComp.WantedBy.RelationWith(Find.FactionManager.OfPlayer).baseGoodwill -=
                SettingsHelper.LatestVersion.HarborPenalty;
            Find.FactionManager.OfPlayer.RelationWith(tenantComp.WantedBy).baseGoodwill -=
                SettingsHelper.LatestVersion.HarborPenalty;

            Messages.Message(
                "HarboringWantedTenant".Translate(pawn.GetTenantComponent().WantedBy,
                                                  SettingsHelper.LatestVersion.HarborPenalty, pawn.Named("PAWN")),
                MessageTypeDefOf.NegativeEvent);
        }
    }
    protected override string GetLetterText(IncidentParms parms, List <Pawn> pawns)
    {
        try
        {
            MapComponent_Tenants.GetComponent((Map)parms.target).Broadcast = false;
            var basic = string.Format(parms.raidArrivalMode.textEnemy, parms.faction.def.pawnsPlural,
                                      parms.faction.Name);
            basic += "\n\n";
            basic += "TenantOpportunists".Translate();
            var leader = pawns.Find(x => x.Faction.leader == x);
            if (leader == null)
            {
                return(basic);
            }

            basic += "\n\n";
            basic += "EnemyRaidLeaderPresent".Translate(leader.Faction.def.pawnsPlural, leader.LabelShort,
                                                        leader.Named("LEADER"));
            return(basic);
        }
        catch (Exception)
        {
            return(base.GetLetterText(parms, pawns));
        }
    }
Beispiel #3
0
 public static void TenantInvite(Building_CommsConsole comms, Pawn pawn)
 {
     Messages.Message("InviteTenantMessage".Translate(), MessageTypeDefOf.NeutralEvent);
     MapComponent_Tenants.GetComponent(pawn.Map).Broadcast = true;
     if (Rand.Value < 0.20f)
     {
         var parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, pawn.Map);
         parms.raidStrategy = RaidStrategyDefOf.Retribution;
         parms.forced       = true;
         Find.Storyteller.incidentQueue.Add(IncidentDefOf.Opportunists,
                                            Find.TickManager.TicksGame + Rand.Range(25000, 150000), parms, 240000);
     }
     else
     {
         var parms = new IncidentParms {
             target = pawn.Map, forced = true
         };
         Find.Storyteller.incidentQueue.Add(IncidentDefOf.RequestForTenancy,
                                            Find.TickManager.TicksGame + Rand.Range(15000, 120000), parms, 240000);
         while (Rand.Value < 0.10)
         {
             Find.Storyteller.incidentQueue.Add(IncidentDefOf.RequestForTenancy,
                                                Find.TickManager.TicksGame + Rand.Range(15000, 120000), parms, 240000);
         }
     }
 }
    protected override string GetLetterText(IncidentParms parms, List <Pawn> pawns)
    {
        try
        {
            var mole       = MapComponent_Tenants.GetComponent((Map)parms.target).Moles[0];
            var tenantComp = mole.GetTenantComponent();
            if (Rand.Value < 0.66f)
            {
                mole.SetFaction(mole.GetTenantComponent().HiddenFaction);
                tenantComp.IsTenant = false;
            }

            var str = string.Format(parms.raidArrivalMode.textEnemy, parms.faction.def.pawnsPlural,
                                    parms.faction.Name);
            str += "\n\n";
            str += "TenantMoles".Translate();
            var pawn = pawns.Find(x => x.Faction.leader == x);
            if (pawn != null)
            {
                str += "\n\n";
                str += "EnemyRaidLeaderPresent".Translate(pawn.Faction.def.pawnsPlural, pawn.LabelShort,
                                                          pawn.Named("LEADER"));
            }

            MapComponent_Tenants.GetComponent((Map)parms.target).CapturedTenantsToAvenge.Remove(mole);
            return(str);
        }
        catch (Exception)
        {
            return(Utility.NewBasicRaidMessage(parms, pawns));
        }
    }
    protected override string GetLetterText(IncidentParms parms, List <Pawn> pawns)
    {
        try
        {
            var related = pawns[pawns.Count - 1];
            if (MapComponent_Tenants.GetComponent(related.Map).DeadTenantsToAvenge.Count > 0)
            {
                var dead = MapComponent_Tenants.GetComponent(related.Map).DeadTenantsToAvenge[0];
                if (dead.ageTracker.AgeBiologicalYears > 25)
                {
                    related.relations.AddDirectRelation(PawnRelationDefOf.Parent, dead);
                }
                else
                {
                    dead.relations.AddDirectRelation(PawnRelationDefOf.Parent, related);
                }

                var str = string.Format(parms.raidArrivalMode.textEnemy, parms.faction.def.pawnsPlural,
                                        parms.faction.Name);
                str += "\n\n";
                str += "TenantDeathRetribution".Translate(
                    related.GetRelations(dead).FirstOrDefault()?.GetGenderSpecificLabel(dead),
                    related.Named("PAWN"));
                var pawn = pawns.Find(x => x.Faction.leader == x);
                if (pawn != null)
                {
                    str += "\n\n";
                    str += "EnemyRaidLeaderPresent".Translate(pawn.Faction.def.pawnsPlural, pawn.LabelShort,
                                                              pawn.Named("LEADER"));
                }

                MapComponent_Tenants.GetComponent(pawns[0].Map).DeadTenantsToAvenge.Remove(dead);
                return(str);
            }

            var basic = string.Format(parms.raidArrivalMode.textEnemy, parms.faction.def.pawnsPlural,
                                      parms.faction.Name);
            basic += "\n\n";
            basic += parms.raidStrategy.arrivalTextEnemy;
            var leader = pawns.Find(x => x.Faction.leader == x);
            if (leader == null)
            {
                return(basic);
            }

            basic += "\n\n";
            basic += "EnemyRaidLeaderPresent".Translate(leader.Faction.def.pawnsPlural, leader.LabelShort,
                                                        leader.Named("LEADER"));
            return(basic);
        }
        catch (Exception)
        {
            return(Utility.NewBasicRaidMessage(parms, pawns));
        }
    }
Beispiel #6
0
    public static void TenantDeath(Pawn pawn)
    {
        var tenantComp = pawn.GetTenantComponent();

        tenantComp.IsTenant = false;
        string text = "TenantDeath".Translate(pawn.Named("PAWN"));

        text = text.AdjustedFor(pawn);
        string label = "Death".Translate() + ": " + pawn.LabelShortCap;

        Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.Death, pawn);
        pawn.SetFaction(tenantComp.HiddenFaction);
        if (pawn.Faction.HostileTo(Find.FactionManager.OfPlayer))
        {
            if (!(Rand.Value < 0.5f))
            {
                return;
            }

            if (tenantComp.HiddenFaction.def == FactionDefOf.Ancients)
            {
                return;
            }

            var relation = tenantComp.HiddenFaction.RelationWith(Find.FactionManager.OfPlayer);
            relation.baseGoodwill -= SettingsHelper.LatestVersion.OutragePenalty * 2;
            Messages.Message(
                "TenantFactionOutrage".Translate(pawn.Faction, SettingsHelper.LatestVersion.OutragePenalty,
                                                 pawn.Named("PAWN")), MessageTypeDefOf.NegativeEvent);
            MapComponent_Tenants.GetComponent(pawn.Map).DeadTenantsToAvenge.Add(pawn);
            var parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, pawn.Map);
            parms.raidStrategy = RaidStrategyDefOf.Retribution;
            parms.forced       = true;
            Find.Storyteller.incidentQueue.Add(IncidentDefOf.RetributionForDead,
                                               Find.TickManager.TicksGame + Rand.Range(15000, 90000), parms, 240000);
        }
        else
        {
            if (!(Rand.Value < 0.66f))
            {
                return;
            }

            if (tenantComp.HiddenFaction.def == FactionDefOf.Ancients)
            {
                return;
            }

            var relation = tenantComp.HiddenFaction.RelationWith(Find.FactionManager.OfPlayer);
            relation.baseGoodwill -= SettingsHelper.LatestVersion.OutragePenalty * 2;
            Messages.Message(
                "TenantFactionOutrage".Translate(pawn.Faction, SettingsHelper.LatestVersion.OutragePenalty * 2,
                                                 pawn.Named("PAWN")), MessageTypeDefOf.NegativeEvent);
        }
    }
    protected override bool CanFireNowSub(IncidentParms parms)
    {
        var canFire = base.CanFireNowSub(parms);

        if (MapComponent_Tenants.GetComponent((Map)parms.target).WantedTenants.Count < 1)
        {
            canFire = false;
        }

        return(canFire);
    }
Beispiel #8
0
    public static void TenantMole(Pawn pawn)
    {
        var tenantComp = pawn.GetTenantComponent();

        tenantComp.MoleActivated = true;
        tenantComp.MoleMessage   = true;
        MapComponent_Tenants.GetComponent(pawn.Map).Moles.Add(pawn);
        var parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, pawn.Map);

        parms.raidStrategy = RaidStrategyDefOf.MoleRaid;
        parms.forced       = true;
        Find.Storyteller.incidentQueue.Add(IncidentDefOf.MoleRaid,
                                           Find.TickManager.TicksGame + Rand.Range(5000, 30000), parms, 90000);
    }
Beispiel #9
0
 public static void TenantLeave(Pawn pawn)
 {
     Utility.MakePayment(pawn);
     pawn.jobs.ClearQueuedJobs();
     pawn.SetFaction(null);
     pawn.GetTenantComponent().CleanTenancy();
     LordMaker.MakeNewLord(pawn.Faction, new LordJob_ExitMapBest(), pawn.Map, new List <Pawn> {
         pawn
     });
     if (MapComponent_Tenants.GetComponent(pawn.Map).WantedTenants.Contains(pawn))
     {
         MapComponent_Tenants.GetComponent(pawn.Map).WantedTenants.Remove(pawn);
     }
 }
Beispiel #10
0
    public static bool Courier(Map map, Building box)
    {
        try
        {
            if (!Utility.TryFindSpawnSpot(map, out var spawnSpot))
            {
                return(false);
            }

            if (MapComponent_Tenants.GetComponent(map).BroadcastCourier)
            {
                MapComponent_Tenants.GetComponent(map).BroadcastCourier = false;
            }

            if (MapComponent_Tenants.GetComponent(map).KilledCourier > 0)
            {
                MapComponent_Tenants.GetComponent(map).KilledCourier--;
                string courierDeniedLabel = "CourierDeniedTitle".Translate(map.Parent.Label);
                string courierDeniedText  = "CourierDeniedMessage".Translate();
                Find.LetterStack.ReceiveLetter(courierDeniedLabel, courierDeniedText, LetterDefOf.NegativeEvent);
                return(true);
            }

            var pawn = Utility.FindRandomCourier();
            if (pawn == null)
            {
                return(false);
            }

            GenSpawn.Spawn(pawn, spawnSpot, map);
            //pawn.SetFaction(Faction.OfAncients);
            pawn.relations.everSeenByPlayer = true;
            Utility.CourierDress(pawn, map);
            Utility.CourierInventory(pawn, map);
            string letterLabel = "CourierArrivedTitle".Translate(map.Parent.Label);
            string letterText  = "CourierArrivedMessage".Translate(pawn.Named("PAWN"));
            Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.PositiveEvent, pawn);
            LordMaker.MakeNewLord(pawn.Faction,
                                  new LordJob_CourierDeliver(box), pawn.Map, new List <Pawn> {
                pawn
            });
            return(true);
        }
        catch (Exception ex)
        {
            Log.Message(ex.Message);
            return(false);
        }
    }
 public override void ResolveRaidStrategy(IncidentParms parms, PawnGroupKindDef groupKind)
 {
     try
     {
         base.ResolveRaidStrategy(parms, groupKind);
         var mole = MapComponent_Tenants.GetComponent((Map)parms.target).Moles[0];
         if (mole.GetTenantComponent().HiddenFaction.def.techLevel >= TechLevel.Spacer && Rand.Value < 0.5f)
         {
             parms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop;
         }
     }
     catch (Exception)
     {
         base.ResolveRaidStrategy(parms, groupKind);
     }
 }
Beispiel #12
0
    public static void MakePayment(Pawn pawn)
    {
        var tenantComp = pawn.GetTenantComponent();
        var payment    = tenantComp.ContractLength / 60000 * tenantComp.Payment;

        while (payment > 500)
        {
            var silver = ThingMaker.MakeThing(RimWorld.ThingDefOf.Silver);
            silver.stackCount = 500;
            MapComponent_Tenants.GetComponent(pawn.Map).IncomingMail.Add(silver);
            payment -= 500;
        }

        var silverRest = ThingMaker.MakeThing(RimWorld.ThingDefOf.Silver);

        silverRest.stackCount = payment;
        MapComponent_Tenants.GetComponent(pawn.Map).IncomingMail.Add(silverRest);
    }
    protected override bool TryResolveRaidFaction(IncidentParms parms)
    {
        try
        {
            parms.faction = MapComponent_Tenants.GetComponent((Map)parms.target).WantedTenants[0]
                            .GetTenantComponent().WantedBy;
            if (FactionCanBeGroupSource(parms.faction, (Map)parms.target))
            {
                return(true);
            }

            return(false);
        }
        catch (Exception)
        {
            return(base.TryResolveRaidFaction(parms));
        }
    }
Beispiel #14
0
 public static void CourierInvite(Building_CommsConsole comms, Pawn pawn)
 {
     if (MapComponent_Tenants.GetComponent(pawn.Map).KilledCourier > 0)
     {
         string courierDeniedLabel = "CourierDeniedTitle".Translate(pawn.Map.Parent.Label);
         string courierDeniedText  = "CourierDeniedRadioMessage".Translate();
         Find.LetterStack.ReceiveLetter(courierDeniedLabel, courierDeniedText, LetterDefOf.NegativeEvent);
     }
     else
     {
         Messages.Message("CourierInvited".Translate(SettingsHelper.LatestVersion.CourierCost),
                          MessageTypeDefOf.NeutralEvent);
         MapComponent_Tenants.GetComponent(pawn.Map).BroadcastCourier = true;
         var parms = new IncidentParms {
             target = pawn.Map, forced = true
         };
         Find.Storyteller.incidentQueue.Add(IncidentDefOf.TenantCourier,
                                            Find.TickManager.TicksGame + Rand.Range(15000, 90000), parms, 240000);
         var silver = ThingMaker.MakeThing(RimWorld.ThingDefOf.Silver);
         silver.stackCount = (int)SettingsHelper.LatestVersion.CourierCost;
         MapComponent_Tenants.GetComponent(pawn.Map).CourierCost.Add(silver);
     }
 }
Beispiel #15
0
    public override void UpdateAllDuties()
    {
        foreach (var pawn in lord.ownedPawns)
        {
            pawn.mindState.duty = new PawnDuty(DutyDefOf.TravelOrWait);
        }

        if (MailBox == null || MapComponent_Tenants.GetComponent(MailBox.Map).IncomingMail.Count <= 0)
        {
            return;
        }

        int cost = 0, taken = 0;
        // C# is such that doing it like this will modify the original list
        var courierCostList = MapComponent_Tenants.GetComponent(MailBox.Map).CourierCost;

        if (courierCostList.Count > 0)
        {
            foreach (var thing in courierCostList)
            {
                cost += thing.stackCount;
            }
        }

        var mailBoxComp = MailBox.GetMailBoxComponent();

        foreach (var thing in MapComponent_Tenants.GetComponent(MailBox.Map).IncomingMail)
        {
            if (cost > 0)
            {
                if (thing.stackCount > cost)
                {
                    thing.stackCount -= cost;
                    taken            += cost;
                    cost              = 0;
                }
                else
                {
                    cost            -= thing.stackCount;
                    taken           += thing.stackCount;
                    thing.stackCount = 0;
                }
            }

            if (thing.stackCount > 0)
            {
                mailBoxComp.Items.Add(thing);
            }
        }

        // carefully resolve the courier cost list to reset courier delivery cost
        // each silver taken as cost must match each remaining courier silver cost
        // at this point, "taken" = how many silver taken as cost, and "cost" = how many cost remaining
        var remainingResolve = taken;

        while (remainingResolve > 0 && courierCostList.Count > 0)
        {
            // we inspect this cost silver stack. how many to remove?
            if (courierCostList[0] == null)
            {
                // invalid cost!
                courierCostList.RemoveAt(0);
                continue;
            }

            // we still have something remaining to match
            if (remainingResolve > courierCostList[0].stackCount)
            {
                // current cost stack not enough to match remaining outstanding costs
                remainingResolve -= courierCostList[0].stackCount;
                courierCostList.RemoveAt(0);
            }
            else
            {
                // current cost stack is enough to match remaining outstanding costs
                courierCostList[0].stackCount -= remainingResolve;
                remainingResolve = 0;
            }
        }

        var remainingCost = 0;

        foreach (var costStack in courierCostList)
        {
            // we make no assumptions. calculate the remaining cost from the cost list.
            remainingCost += costStack.stackCount;
        }

        //Log.Message("Courier costs: taken " + taken + ", resolve " + remainingResolve + "=0, remaining1 " + cost +
        //            " = remaining2 " + remainingCost);
        MapComponent_Tenants.GetComponent(MailBox.Map).IncomingMail.Clear();
        var stringBuilder = new StringBuilder("");

        stringBuilder.Append("MailDelivered".Translate());
        if (taken > 0)
        {
            stringBuilder.Append("CourierCost".Translate(taken));
        }

        if (remainingCost > 0)
        {
            stringBuilder.AppendInNewLine("CourierRemainingCost".Translate(remainingCost));
        }

        Messages.Message(stringBuilder.ToString(), MailBox, MessageTypeDefOf.NeutralEvent);
    }
Beispiel #16
0
    public static bool ContractTenancy(Map map)
    {
        if (!Utility.TryFindSpawnSpot(map, out var spawnSpot))
        {
            return(false);
        }

        var pawn = Utility.FindRandomTenant();

        if (pawn == null)
        {
            return(false);
        }

        pawn.relations.everSeenByPlayer = true;
        var tenantComp = pawn.TryGetComp <Tenant>();

        Utility.GenerateBasicTenancyContract(tenantComp);
        var stringBuilder = new StringBuilder("");

        //Check if pawn is special
        //Wanted
        if (SettingsHelper.LatestVersion.WantedTenants && Rand.Value < 0.2f)
        {
            Utility.GenerateWanted(pawn);
        }

        //Mole
        if (SettingsHelper.LatestVersion.MoleTenants && Rand.Value < 0.33f &&
            tenantComp.HiddenFaction.HostileTo(Find.FactionManager.OfPlayer))
        {
            tenantComp.Mole = true;
        }

        string title;
        string text;

        if (pawn.GetTenantComponent().Wanted)
        {
            stringBuilder.Append("RequestForTenancyHiding".Translate(tenantComp.WantedBy, pawn.Named("PAWN")));
            title = "RequestForTenancyHidingTitle".Translate(map.Parent.Label);
            tenantComp.Payment *= 2;
            text = Utility.AppendContractDetails(stringBuilder.ToString(), pawn);
            return(Utility.GenerateContractDialogue(title, text, pawn, map, spawnSpot));
        }

        //Broadcasted
        if (MapComponent_Tenants.GetComponent(map).Broadcast)
        {
            stringBuilder.Append("RequestForTenancyOpportunity".Translate(pawn.Named("PAWN")));
            title = "RequestForTenancyTitle".Translate(map.Parent.Label);
            MapComponent_Tenants.GetComponent(map).Broadcast = false;
            text = Utility.AppendContractDetails(stringBuilder.ToString(), pawn);
            return(Utility.GenerateContractDialogue(title, text, pawn, map, spawnSpot));
        }

        //Normal
        stringBuilder.Append("RequestForTenancyInitial".Translate(pawn.Named("PAWN")));
        title = "RequestForTenancyTitle".Translate(map.Parent.Label);
        text  = Utility.AppendContractDetails(stringBuilder.ToString(), pawn);
        return(Utility.GenerateContractDialogue(title, text, pawn, map, spawnSpot));
    }
Beispiel #17
0
    //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)
        {
            return;
        }

        var tenantComp = __instance.GetTenantComponent();

        if (tenantComp == null || !tenantComp.IsTenant)
        {
            return;
        }

        //If a tenant has joined but has no contract.
        if (!tenantComp.Contracted)
        {
            tenantComp.IsTenant = false;
        }

        //Tenant alone with no colonist
        var 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.Any(x => x.recipe.isViolation))
            {
                __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)
        {
            return;
        }

        {
            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)
                {
                    var building = __instance.Map.listerBuildings.allBuildingsColonist.FirstOrDefault(x =>
                                                                                                      x.def.defName.Contains("commsconsole") || x.def.defName.Contains("CommsConsole"));
                    if (building != null)
                    {
                        var 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;
            }
        }
    }