protected override IEnumerable <Toil> MakeNewToils() { //Check si TargetIndex.A est un Bed si oui alors juste un Toil_Bed.GotoBed suivant d'un LayDownCustomFood if (this.TargetThingA is Building_Bed) { Building_Bed pod = (Building_Bed)this.TargetThingA; yield return(Toils_Bed.GotoBed(TargetIndex.A)); //yield return Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell); yield return(Toils_LayDownPower.LayDown(TargetIndex.A, true, false, false, true)); } else { Toil gotoCell = Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell); Toil nothing = new Toil(); yield return(gotoCell); Toil setSkin = new Toil(); setSkin.initAction = delegate { pawn.Rotation = Rot4.South; }; yield return(setSkin); yield return(nothing); yield return(Toils_General.Wait(50)); yield return(Toils_Jump.JumpIf(nothing, () => this.pawn.needs.food.CurLevelPercentage < 1.0f && !this.job.targetB.ThingDestroyed && !((Building)this.job.targetB).IsBrokenDown() && ((Building)this.job.targetB).TryGetComp <CompPowerTrader>().PowerOn)); } }
public void Notify_RoomShapeOrContainedBedsChanged() { this.cachedCellCount = -1; this.cachedOpenRoofCount = -1; if (Current.ProgramState == ProgramState.Playing && !this.Fogged) { this.Map.autoBuildRoofAreaSetter.TryGenerateAreaFor(this); } this.isPrisonCell = false; if (Building_Bed.RoomCanBePrisonCell(this)) { List <Thing> containedAndAdjacentThings = this.ContainedAndAdjacentThings; for (int i = 0; i < containedAndAdjacentThings.Count; i++) { Building_Bed building_Bed = containedAndAdjacentThings[i] as Building_Bed; if (building_Bed != null && building_Bed.ForPrisoners) { this.isPrisonCell = true; break; } } } if (Current.ProgramState == ProgramState.Playing && this.isPrisonCell) { foreach (Building_Bed current in this.ContainedBeds) { current.ForPrisoners = true; } } this.lastChangeTick = Find.TickManager.TicksGame; this.statsAndRoleDirty = true; FacilitiesUtility.NotifyFacilitiesAboutChangedLOSBlockers(this.regions); }
protected override Job TryGiveJob(Pawn pawn) { if (pawn != null && pawn.Map != null && pawn.health != null && pawn.health.hediffSet != null && pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_ChiHD) && !pawn.Drafted) { if (pawn.InBed() || HealthAIUtility.ShouldSeekMedicalRest(pawn) || !(pawn.GetPosture() == PawnPosture.Standing)) { return(null); } Need_Joy curJoy = pawn.needs.joy; if (curJoy == null) { return(null); } if (curJoy.CurLevel >= .8f) { return(null); } CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>(); if (comp != null) { MightPower mightPower = comp.MightData.MightPowersM.FirstOrDefault <MightPower>((MightPower x) => x.abilityDef == TorannMagicDefOf.TM_Meditate); if (mightPower == null) { return(null); } if (!mightPower.AutoCast) { return(null); } Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD); PawnAbility ability = pawn.GetComp <CompAbilityUserMight>().AbilityData.Powers.FirstOrDefault((PawnAbility x) => x.Def == TorannMagicDefOf.TM_Meditate); if (ability.CooldownTicksLeft > 0 || hediff.Severity >= 70) { return(null); } Building_Bed building_Bed = pawn.ownership.OwnedBed; if (building_Bed != null) { if (building_Bed.GetRoom() != null && !building_Bed.GetRoom().PsychologicallyOutdoors) { List <IntVec3> roomCells = building_Bed.GetRoom().Cells.ToList(); for (int i = 0; i < roomCells.Count; i++) { if (roomCells[i].IsValid && roomCells[i].Walkable(pawn.Map) && roomCells[i].GetFirstBuilding(pawn.Map) == null) { return(new Job(TorannMagicDefOf.JobDriver_TM_Meditate, roomCells[i])); } } } } return(new Job(TorannMagicDefOf.JobDriver_TM_Meditate, pawn.Position)); } } return(null); }
//Copied from vanilla, prefixing and replacing is safe because of the check for Building_MechanoidPlatform static bool Prefix(Building_Bed __instance, int slotIndex, ref Pawn __result) { if (!(__instance is Building_BaseMechanoidPlatform) && !(__instance is Building_HackingTable)) { return(true); } if (!__instance.Spawned) { return(false); } IntVec3 sleepingSlotPos = __instance.GetSleepingSlotPos(slotIndex); List <Thing> list = __instance.Map.thingGrid.ThingsListAt(sleepingSlotPos); for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i] as Pawn; if (pawn != null) { if (__instance is Building_BaseMechanoidPlatform && pawn.IsHacked()) { __result = pawn; } else if (pawn.CurJob != null) { __result = pawn; } } } return(false); }
static bool Prefix(ref bool __result, Verse.Thing item) { if (item != null) { if (item.GetType() == typeof(Pawn)) { Pawn p = (Pawn)item; //搬运的是人形 bool hasBondageBed = false; //没有被束缚床束缚 for (int i = 0; i < p.health.hediffSet.hediffs.Count; i++) { if (p.health.hediffSet.hediffs[i].def == SR.DA.Hediff.HediffDefOf.SR_Hediff_BondageBed) { hasBondageBed = true; break; } } //如果已经被束缚 if (hasBondageBed) { Building_Bed bbb = (Building_BondageBed)p.CurrentBed();//获取当前躺着的束缚床 if (bbb != null) { CompRemoveEffectBondageBed crebb = bbb.GetComp <CompRemoveEffectBondageBed>(); if (crebb != null) { crebb.DoEffect(p);//解除束缚 } } } } } return(true); }
public bool HasHediffsNeedingTendByColony(bool forAlert = false) { if (this.HasHediffsNeedingTend(forAlert)) { if (this.pawn.NonHumanlikeOrWildMan()) { if (this.pawn.Faction == Faction.OfPlayer) { return(true); } Building_Bed building_Bed = this.pawn.CurrentBed(); if (building_Bed != null && building_Bed.Faction == Faction.OfPlayer) { return(true); } } else { if (this.pawn.Faction == Faction.OfPlayer && this.pawn.HostFaction == null) { goto IL_0096; } if (this.pawn.HostFaction == Faction.OfPlayer) { goto IL_0096; } } } return(false); IL_0096: return(true); }
static bool Prefix(Pawn p, ref Building_Bed __result) { if (p.jobs == null || p.CurJob == null) { return(true); } if (!(p.RaceProps != null && p.RaceProps.IsMechanoid) || p.Map == null) { return(true); } if (p.CurJob.def != WTH_DefOf.WTH_Mechanoid_Rest) { return(true); } List <Thing> thingList = p.Position.GetThingList(p.Map); foreach (Thing thing in thingList) { if (thing is Building_HackingTable hackingTable && p.Position == hackingTable.GetSleepingSlotPos(Building_HackingTable.SLOTINDEX)) { __result = (Building_Bed)thing; return(false); } if (thing is Building_BaseMechanoidPlatform platform && p.Position == platform.GetSleepingSlotPos(Building_BaseMechanoidPlatform.SLOTINDEX)) { __result = (Building_Bed)thing; return(false); } } return(true); }
public static Toil GoToPlatform(TargetIndex bedIndex) { Toil gotoBed = new Toil(); gotoBed.initAction = delegate { Pawn actor = gotoBed.actor; Building_Bed bed = (Building_Bed)actor.CurJob.GetTarget(bedIndex).Thing; IntVec3 bedSleepingSlotPosFor = RestUtility.GetBedSleepingSlotPosFor(actor, bed); if (actor.Position == bedSleepingSlotPosFor) { actor.jobs.curDriver.ReadyForNextToil(); } else { actor.pather.StartPath(bedSleepingSlotPosFor, PathEndMode.OnCell); } }; gotoBed.tickAction = delegate { Pawn actor = gotoBed.actor; Building_Bed building_Bed = (Building_Bed)actor.CurJob.GetTarget(bedIndex).Thing; Pawn curOccupantAt = building_Bed.GetCurOccupantAt(actor.pather.Destination.Cell); if (curOccupantAt != null && curOccupantAt != actor) { actor.pather.StartPath(RestUtility.GetBedSleepingSlotPosFor(actor, building_Bed), PathEndMode.OnCell); } }; gotoBed.defaultCompleteMode = ToilCompleteMode.PatherArrival; gotoBed.FailOnPlatformNoLongerUsable(bedIndex); //gotoBed.FailOnBedNoLongerUsable(bedIndex); return(gotoBed); }
public static void Swap(object __instance, Building_Bed bed, StorageSettings settings, CompMakeableBed compMakeable) { //reflection info Type guestBed = AccessTools.TypeByName("Hospitality.Building_GuestBed"); MethodInfo makeBedinfo = AccessTools.Method(guestBed, "MakeBed", new[] { typeof(Building_Bed), typeof(string) }); // Building_Bed newBed; string newName; if (bed.GetType() == guestBed) { newName = bed.def.defName.Split(new string[] { "Guest" }, StringSplitOptions.RemoveEmptyEntries)[0]; } else { newName = bed.def.defName + "Guest"; } // Thanks again to @Zamu for figuring out it was actually very simple! newBed = (Building_Bed)makeBedinfo.Invoke(__instance, new object[] { bed, newName }); newBed.SetFactionDirect(bed.Faction); var spawnedBed = (Building_Bed)GenSpawn.Spawn(newBed, bed.Position, bed.Map, bed.Rotation); spawnedBed.HitPoints = bed.HitPoints; spawnedBed.ForPrisoners = bed.ForPrisoners; // This should be on Hospitality, Orion! spawnedBed.AllComps.Clear(); spawnedBed.AllComps.AddRange(bed.AllComps); foreach (ThingComp comp in spawnedBed.AllComps) { comp.parent = spawnedBed; } compMakeable.parent.Notify_ColorChanged(); Find.Selector.Select(spawnedBed, false, true); }
public static Building_Bed FindCribFor(Pawn baby, Pawn traveler) { Building_Bed crib = null; // Is a crib already assigned to the baby? if (baby.ownership != null && baby.ownership.OwnedBed != null && ChildrenUtility.IsBedCrib(baby.ownership.OwnedBed)) { Building_Bed bedThing = baby.ownership.OwnedBed; if (RestUtility.IsValidBedFor(bedThing, baby, traveler, false, false)) { crib = baby.ownership.OwnedBed; } } // If not, let's look for one else { foreach (var thingDef in RestUtility.AllBedDefBestToWorst) { if (RestUtility.CanUseBedEver(baby, thingDef) && thingDef.building.bed_maxBodySize <= 0.6f) { Building_Bed find_crib = (Building_Bed)GenClosest.ClosestThingReachable(baby.Position, baby.Map, ThingRequest.ForDef(thingDef), PathEndMode.OnCell, TraverseParms.For(traveler), 9999f, (Thing b) => (RestUtility.IsValidBedFor(b, baby, traveler, false, false)), null); if (find_crib != null) { crib = find_crib; } } } } return(crib); }
static NewThingReplacement() { replacements = new List <Replacement>(); //--------------------------------------------- //--------------------------------------------- //Here are valid replacements: replacements.Add(new Replacement(d => d.IsWall() || (d.building?.isFence ?? false) || typeof(Building_Door).IsAssignableFrom(d.thingClass))); replacements.Add(new Replacement(d => typeof(Building_Cooler).IsAssignableFrom(d.thingClass), postAction: (n, o) => { Building_Cooler newCooler = n as Building_Cooler; Building_Cooler oldCooler = o as Building_Cooler; //newCooler.compPowerTrader.PowerOn = oldCooler.compPowerTrader.PowerOn; //should be flickable newCooler.compTempControl.targetTemperature = oldCooler.compTempControl.targetTemperature; } )); replacements.Add(new Replacement(d => typeof(Building_Bed).IsAssignableFrom(d.thingClass), preAction: (n, o) => { Building_Bed newBed = n as Building_Bed; Building_Bed oldBed = o as Building_Bed; newBed.ForPrisoners = oldBed.ForPrisoners; newBed.Medical = oldBed.Medical; oldBed.OwnersForReading.ListFullCopy().ForEach(p => p.ownership.ClaimBedIfNonMedical(newBed)); } )); DesignationCategoryDef fencesDef = DefDatabase <DesignationCategoryDef> .GetNamed("Fences", false); if (fencesDef != null) { replacements.Add(new Replacement(d => d.designationCategory == fencesDef)); } Action <Thing, Thing> transferBills = (n, o) => { Building_WorkTable newTable = n as Building_WorkTable; Building_WorkTable oldTable = o as Building_WorkTable; foreach (Bill bill in oldTable.BillStack) { newTable.BillStack.AddBill(bill); } }; replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricStove, n => n == NewThingDefOf.FueledStove, transferBills)); replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricTailoringBench, n => n == NewThingDefOf.HandTailoringBench, transferBills)); replacements.Add(new Replacement(d => d.IsTable)); replacements.Add(new Replacement(d => d.thingClass == FridgeCompat.fridgeType, postAction: (n, o) => { FridgeCompat.DesiredTempInfo.SetValue(n, FridgeCompat.DesiredTempInfo.GetValue(o)); })); replacements.Add(new Replacement(d => d.building?.isSittable ?? false)); //--------------------------------------------- //--------------------------------------------- }
static void Postfix(Building_Bed __instance, ref Color __result) { if (__instance is Building_BaseMechanoidPlatform || __instance is Building_HackingTable) { __result = new Color(1f, 1f, 1f); } }
static void Postfix(ref IntVec3 __result, ref Building_Bed __instance, int index) { if (__instance.def.thingClass == typeof(Building_BedMedPod)) { __result = __instance.Position; } }
static void Postfix(ref int __result, ref Building_Bed __instance) { if (__instance.def.thingClass == typeof(Building_BedMedPod)) { __result = 1; } }
public static void Postfix(PawnRenderer __instance, Pawn ___pawn, Vector3 drawLoc) { Building_Bed softWarmBed = ___pawn.CurrentBed(); CompMakeableBed bedComp = softWarmBed.TryGetComp <CompMakeableBed>(); if (___pawn.RaceProps.Humanlike && bedComp != null)//___pawn.CurrentBed() is Building_SoftWarmBed) { if (!bedComp.Loaded) { // Thanks to @Zamu & @Mehni! var rotDrawMode = (RotDrawMode)AccessTools.Property(typeof(PawnRenderer), "CurRotDrawMode").GetGetMethod(true).Invoke(__instance, new object[0]); MethodInfo layingFacing = AccessTools.Method(type: typeof(PawnRenderer), name: "LayingFacing"); Rot4 rot = (Rot4)layingFacing.Invoke(__instance, new object[0]); float angle; Vector3 rootLoc; Rot4 rotation = softWarmBed.Rotation; rotation.AsInt += 2; angle = rotation.AsAngle; AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)softWarmBed.def.altitudeLayer, 15); Vector3 vector2 = ___pawn.Position.ToVector3ShiftedWithAltitude(altLayer); Vector3 vector3 = vector2; vector3.y += 0.02734375f; float d = -__instance.BaseHeadOffsetAt(Rot4.South).z; Vector3 a = rotation.FacingCell.ToVector3(); rootLoc = vector2 + a * d; rootLoc.y += 0.0078125f; MethodInfo renderPawnInternal = AccessTools.Method(type: typeof(PawnRenderer), name: "RenderPawnInternal", parameters: new[] { typeof(Vector3), typeof(float), typeof(bool), typeof(Rot4), typeof(Rot4), typeof(RotDrawMode), typeof(bool), typeof(bool), typeof(bool) }); renderPawnInternal.Invoke(__instance, new object[] { rootLoc, angle, true, rot, rot, rotDrawMode, false, false, false }); } } }
public override bool StateCanOccur(Pawn pawn) { bool result; if (!base.StateCanOccur(pawn)) { result = false; } else { Building_Bed ownedBed = pawn.ownership.OwnedBed; if (ownedBed == null || ownedBed.GetRoom(RegionType.Set_Passable) == null || ownedBed.GetRoom(RegionType.Set_Passable).PsychologicallyOutdoors) { result = false; } else { MentalStateWorker_BedroomTantrum.tmpThings.Clear(); TantrumMentalStateUtility.GetSmashableThingsIn(ownedBed.GetRoom(RegionType.Set_Passable), pawn, MentalStateWorker_BedroomTantrum.tmpThings, null, 0); bool flag = MentalStateWorker_BedroomTantrum.tmpThings.Any <Thing>(); MentalStateWorker_BedroomTantrum.tmpThings.Clear(); result = flag; } } return(result); }
public static void Postfix(Pawn p, ref FloatRange __result) { if (p.InBed()) { Building_Bed bed = p.CurrentBed(); float InsulationCold = bed.GetStatValue(BedInsulationCold.Bed_Insulation_Cold, true); float InsulationHeat = bed.GetStatValue(BedInsulationHeat.Bed_Insulation_Heat, true); if (InsulationCold != 0 || InsulationHeat != 0) { ThingDef raceDef = p.kindDef.race; FloatRange altResult = new FloatRange(raceDef.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null), raceDef.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax, null)); altResult.min -= InsulationCold; altResult.max += InsulationHeat; if (__result.min > altResult.min) { __result.min = altResult.min; } if (__result.max < altResult.max) { __result.max = altResult.max; } //Log.Message(bed+" insulation cold is "+bed.GetStatValue(BedInsulationCold.Bed_Insulation_Cold, true)); //Log.Message("comfortable range modified for " + p + " by bed" + bed + ": " + __result.ToString()); } } }
private static FloatMenuOption GetFailureReason(Building_Bed bed, Pawn myPawn) { if (!myPawn.CanReach(bed, PathEndMode.InteractionCell, Danger.Some, false, TraverseMode.ByPawn)) { return(new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } if (bed.Spawned && bed.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.SolarFlare)) { return(new FloatMenuOption("CannotUseSolarFlare".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } if (!bed.TryGetComp <CompPowerTrader>().PowerOn) { return(new FloatMenuOption("CannotUseNoPower".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } if (!Utils.ExceptionAndroidList.Contains(myPawn.def.defName)) { return(new FloatMenuOption("ATPP_CanOnlyBeUsedByAndroid".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } CompAndroidState ca = myPawn.ATCompState; if (ca == null || !ca.UseBattery) { return(new FloatMenuOption("ATPP_CannotUseBecauseNotInBatteryMode".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } return(null); }
public void Notify_TuckedIntoBed(Building_Bed bed) { this.pawn.Position = RestUtility.GetBedSleepingSlotPosFor(this.pawn, bed); this.pawn.Notify_Teleported(false); this.pawn.stances.CancelBusyStanceHard(); this.StartJob(new Job(JobDefOf.LayDown, bed), JobCondition.InterruptForced, null, false, true, null, JobTag.TuckedIntoBed, false); }
public static void Listener(Pawn myPawn, Building_Bed __instance, ref IEnumerable <FloatMenuOption> __result) { if ((__instance.def.defName != "ATPP_AndroidPod" && __instance.def.defName != "ATPP_AndroidPodMech") || __instance.Medical || (myPawn.ownership != null && myPawn.ownership.OwnedBed != null && myPawn.ownership.OwnedBed != __instance)) { return; } if (__result == null) { __result = new List <FloatMenuOption>(); } FloatMenuOption failureReason = GetFailureReason(__instance, myPawn); if (failureReason != null) { __result = __result.AddItem(failureReason); } else { __result = __result.AddItem(new FloatMenuOption("ATPP_ForceReload".Translate(), delegate() { //Affectation du pod a myPawn pour eviter le rehet du job myPawn.ownership.ClaimBedIfNonMedical(__instance); Job job = new Job(DefDatabase <JobDef> .GetNamed("ATPP_GoReloadBattery"), new LocalTargetInfo(__instance)); myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } }
static void Postfix(Building_Bed __instance, ref IntVec3 __result) { if (__instance is Building_MechanoidPlatform) { __result = __instance.InteractionCell; } }
protected override Job TryGiveJob(Pawn pawn) { Predicate <Thing> validator = delegate(Thing t) { Pawn pawn3 = (Pawn)t; return((pawn3.Downed && pawn3.Faction == pawn.Faction && !pawn3.InBed() && pawn.CanReserve(pawn3) && !pawn3.IsForbidden(pawn) && !GenAI.EnemyIsNear(pawn3, 25f)) ? true : false); }; Pawn pawn2 = (Pawn)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(pawn), radius, validator); if (pawn2 == null) { return(null); } Building_Bed building_Bed = RestUtility.FindBedFor(pawn2, pawn, checkSocialProperness: false); if (building_Bed == null || !pawn2.CanReserve(building_Bed)) { return(null); } Job job = JobMaker.MakeJob(JobDefOf.Rescue, pawn2, building_Bed); job.count = 1; return(job); }
public static void Set(Pawn pawn, Building_Bed bed) { var comp = Current.Game.GetComponent <HomeBedComp>(); comp.homeBeds[pawn] = bed; comp.bedOwners[bed] = pawn; }
public static void Postfix(Building_Bed __instance) { Map map = __instance.Map; if (map == null) { return; //If it's not spawned, there should be no owners. } // If it got despawned, owners were already removed. // If it hasn't spawned yet, there should be no opportunity to set owners. // This can be hit when the Replace Stuff mod transfers settings from a medical bed to a new bed built over it // The new bed is not yet spawned, but gets the medical setting from the old bed, // and setting medical to true removes all owners // That process could probably be made better by saving settings between spawned/not spawned but it hasn't been a problem elswhere. var placedBeds = map.GetComponent <PlacedBedsMapComponent>().placedBeds; foreach (KeyValuePair <Pawn, Building_Bed> kvp in placedBeds) { if (kvp.Value == __instance) { placedBeds.Remove(kvp.Key); return; } } }
public void Notify_TuckedIntoBed(Building_Bed bed) { pawn.Position = RestUtility.GetBedSleepingSlotPosFor(pawn, bed); pawn.Notify_Teleported(endCurrentJob: false); pawn.stances.CancelBusyStanceHard(); StartJob(JobMaker.MakeJob(JobDefOf.LayDown, bed), JobCondition.InterruptForced, null, resumeCurJobAfterwards: false, cancelBusyStances: true, null, JobTag.TuckedIntoBed); }
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 IEnumerable <Toil> AnimateLovin(Pawn pawn, Pawn mate, Building_Bed bed, Action finishAction = null, int len = 250) { if (bed == null) { yield break; } Toil t; yield return(t = ToilerHelper.GotoThing(pawn, bed)); t.AddFinishAction(delegate { Log.Message("Got To Bed for woohooing"); }); var layDown = new Toil() { initAction = delegate { pawn?.pather?.StopDead(); if (pawn?.jobs != null) { pawn.jobs.posture = PawnPosture.LayingInBed; } }, tickAction = delegate { pawn?.GainComfortFromCellIfPossible(); }, }; layDown.AddFinishAction(delegate { pawn?.needs?.joy?.GainJoy(Rand.Value * .15f, Constants.Joy_Woohoo); mate?.needs?.joy?.GainJoy(Rand.Value * .15f, Constants.Joy_Woohoo); /* Log.Message("[woohoo] animating done, woohoo joy between 0 and 5% added"); */ }); // Toils_LayDown.LayDown(TargetIndex.B, true, false, false, false); layDown.AddPreTickAction(delegate() { if (pawn.IsHashIntervalTick(100)) { /* Log.Message("Making Noises"); */ MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); } }); if (finishAction != null) { layDown.AddFinishAction(finishAction); } layDown.defaultCompleteMode = ToilCompleteMode.Delay; layDown.defaultDuration = len; yield return(layDown); }
private static Building_Bed GetGuestBed(object __instance, Pawn pawn) { var comp = getCompGuestInfo.Invoke(pawn, new object[] { }); Building_Bed bed = (Building_Bed)getCompGuestBed(comp); //Log.Message("Calculated GetGuestBed is " + bed.ToString()); return((comp != null) ? bed : null); }
//Don't try to take wounded to unreachable bed static Building_Bed Postfix(Building_Bed __result, Pawn sleeper, Pawn traveler, bool checkSocialProperness, bool ignoreOtherReservations, GuestStatus?guestStatus) { if (__result != null && traveler.IsPrisonerOfColony && !traveler.CanReach(__result, PathEndMode.ClosestTouch, traveler.NormalMaxDanger())) { return(null); } return(__result); }
public static Thing MakeBed(Building_Bed bed, string defName) { Log.Message("1"); ThingDef newDef = DefDatabase <ThingDef> .GetNamed(defName); Log.Message("2"); return(ThingMaker.MakeThing(newDef, bed.Stuff)); }