private static void ApplyBedThoughts(Pawn actor) { if (actor.needs.mood == null) { return; } var memories = actor.needs.mood.thoughts.memories; Building_Bed building_Bed = actor.CurrentBed(); memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBedroom); memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBarracks); memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOutside); memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOnGround); memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInCold); memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInHeat); if (actor.GetRoom(RegionType.Set_Passable).PsychologicallyOutdoors) { memories.TryGainMemory(ThoughtDefOf.SleptOutside, null); } if (building_Bed == null || building_Bed.CostListAdjusted().Count == 0) { memories.TryGainMemory(ThoughtDefOf.SleptOnGround, null); } if (actor.AmbientTemperature < actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null)) { memories.TryGainMemory(ThoughtDefOf.SleptInCold, null); } if (actor.AmbientTemperature > actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax, null)) { memories.TryGainMemory(ThoughtDefOf.SleptInHeat, null); } if (building_Bed != null && building_Bed == actor.ownership.OwnedBed && !building_Bed.ForPrisoners && !actor.story.traits.HasTrait(TraitDefOf.Ascetic)) { ThoughtDef thoughtDef = null; if (building_Bed.GetRoom(RegionType.Set_Passable).Role == RoomRoleDefOf.Bedroom) { thoughtDef = ThoughtDefOf.SleptInBedroom; } else if (building_Bed.GetRoom(RegionType.Set_Passable).Role == RoomRoleDefOf.Barracks) { thoughtDef = ThoughtDefOf.SleptInBarracks; } if (thoughtDef != null) { int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(building_Bed.GetRoom(RegionType.Set_Passable).GetStat(RoomStatDefOf.Impressiveness)); if (thoughtDef.stages[scoreStageIndex] != null) { memories.TryGainMemory(ThoughtMaker.MakeThought(thoughtDef, scoreStageIndex), null); } } } }
public static bool Replacement(Pawn actor) { if (actor.needs.mood == null) { return(false); } Building_Bed building_Bed = actor.CurrentBed(); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBedroom); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBarracks); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOutside); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOnGround); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInCold); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInHeat); if (actor.GetRoom().PsychologicallyOutdoors) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptOutside); } if (building_Bed == null || building_Bed.CostListAdjusted().Count == 0) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptOnGround); } if (actor.AmbientTemperature < actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin)) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptInCold); } if (actor.AmbientTemperature > actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax)) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptInHeat); } if (building_Bed != null && AddedBedIsOwned(actor, building_Bed) && !building_Bed.ForPrisoners && !actor.story.traits.HasTrait(TraitDefOf.Ascetic)) { ThoughtDef thoughtDef = null; // ADDED: if (building_Bed.GetRoom().Role == BedUtility.roleDefGuestRoom) { thoughtDef = building_Bed.GetRoom().OnlyOneBed() ? ThoughtDefOf.SleptInBedroom : ThoughtDefOf.SleptInBarracks; } //// else if (building_Bed.GetRoom().Role == RoomRoleDefOf.Bedroom) { thoughtDef = ThoughtDefOf.SleptInBedroom; } else if (building_Bed.GetRoom().Role == RoomRoleDefOf.Barracks) { thoughtDef = ThoughtDefOf.SleptInBarracks; } if (thoughtDef != null) { int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(building_Bed.GetRoom().GetStat(RoomStatDefOf.Impressiveness)); if (thoughtDef.stages[scoreStageIndex] != null) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(thoughtDef, scoreStageIndex)); } } } return(false); }
public static bool Prefix(object __instance, Pawn actor) { bool result; if (actor.needs.mood == null) { result = false; } else if (actor.CurrentBed() == null) { result = true; } else { //Log.Message("ApplyBedThoughts is relevant for " + actor); Building_Bed bed = new Building_Bed(); bed = actor.CurrentBed(); bool hospitalityIsGuest = false; if (isHospitalityLoaded) { //Correcting for Hospitality 1.0.25 hospitalityIsGuest = AddedBedIsOwned(__instance, actor, bed); // } actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBedroom); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInBarracks); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOutside); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptOnGround); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInCold); actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInHeat); if (actor.GetRoom(RegionType.Set_Passable).PsychologicallyOutdoors) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptOutside, null); } if (bed == null || bed.CostListAdjusted().Count == 0) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptOnGround, null); } //taking bed insulation into consideration: //Log.Message("bedStats: cold = " + bed.GetStatValue(BedInsulationCold.Bed_Insulation_Cold, true)+", heat ="+ bed.GetStatValue(BedInsulationHeat.Bed_Insulation_Heat)); float minTempInBed = actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null) - bed.GetStatValue(BedInsulationCold.Bed_Insulation_Cold, true); float maxTempInBed = actor.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax, null) + bed.GetStatValue(BedInsulationHeat.Bed_Insulation_Heat, true); if (actor.AmbientTemperature < minTempInBed) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptInCold, null); //Log.Message("Temperature is " + actor.AmbientTemperature + " and bed insulation is " + minTempInBed + ", so " + actor + " gains cold memory"); } if (actor.AmbientTemperature > maxTempInBed) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SleptInHeat, null); //Log.Message("Temperature is " + actor.AmbientTemperature + " and bed insulation is " + maxTempInBed + ", so " + actor + " gains heat memory"); } //adapted for hospitality: if (bed != null && (hospitalityIsGuest || bed == actor.ownership.OwnedBed) && !bed.ForPrisoners && !actor.story.traits.HasTrait(TraitDefOf.Ascetic)) { ThoughtDef thoughtDef = null; Room room = bed.GetRoom(); //Correcting for Hospitality 1.0.25 if (hospitalityIsGuest) { bool hospitalityOnlyOneBed = room.ContainedBeds.Count() == 1; if (room.Role == DefDatabase <RoomRoleDef> .GetNamed("GuestRoom", true))// easier to replicate GuestUtility.roleDefGuestRoom than reflecting it! { thoughtDef = hospitalityOnlyOneBed ? ThoughtDefOf.SleptInBedroom : ThoughtDefOf.SleptInBarracks; } } else if (room.Role == RoomRoleDefOf.Bedroom) { thoughtDef = ThoughtDefOf.SleptInBedroom; } else if (room.Role == RoomRoleDefOf.Barracks) { thoughtDef = ThoughtDefOf.SleptInBarracks; } if (thoughtDef != null) { int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(bed.GetRoom(RegionType.Set_Passable).GetStat(RoomStatDefOf.Impressiveness)); if (thoughtDef.stages[scoreStageIndex] != null) { actor.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(thoughtDef, scoreStageIndex), null); } } } result = false; } return(result); }