private void AddNuzzledThought(Pawn initiator, Pawn recipient) { Thought_Memory newThought = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDef.Named("AA_BeenPsionicallyNuzzled")); recipient.needs.mood.thoughts.memories.TryGainMemory(newThought, null); recipient.health.AddHediff(HediffDef.Named("AA_PsionicallyNuzzled")); }
public override void PostIngested(Pawn ingester) { base.PostIngested(ingester); if (ingester.needs.mood != null) { var memories = ingester.needs.mood.thoughts.memories; var curIngestedMemory = memories.GetFirstMemoryOfDef(Props.ingestedThought); int quality = (int)parent.GetComp <CompQuality>().Quality; // Modify the existing memory if it exists if (curIngestedMemory != null) { float averageIndex = (float)(curIngestedMemory.CurStageIndex + quality) / 2; curIngestedMemory.SetForcedStage((quality > curIngestedMemory.CurStageIndex) ? Mathf.RoundToInt(averageIndex) : Mathf.FloorToInt(averageIndex)); curIngestedMemory.Renew(); } // Otherwise create a new one else { var ingestedMemory = ThoughtMaker.MakeThought(Props.ingestedThought, quality); ingester.needs.mood.thoughts.memories.TryGainMemory(ingestedMemory); } } }
public static void GiveThoughtsForPawnExecuted(Pawn victim, PawnExecutionKind kind) { if (!victim.RaceProps.Humanlike) { return; } int forcedStage = 1; if (victim.guilt.IsGuilty) { forcedStage = 0; } ThoughtDef def; if (victim.IsColonist) { def = YunoThoughtDefOf.YunoMod_KnowColonistExecuted; } else { def = YunoThoughtDefOf.YunoMod_KnowGuestExecuted; } foreach (Pawn pawn in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoners) { if (pawn.IsColonist && pawn.needs.mood != null) { pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(def, forcedStage), null); } } }
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); }
public static void TryGainTempleRoomThought(Pawn pawn) { var room = pawn.GetRoom(); var def = ReligionDefOf.PrayedInImpressiveTemple; if (pawn == null) { return; } if (room?.Role == null) { return; } if (def == null) { return; } if (room.Role != ReligionDefOf.Church) { return; } var scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(room.GetStat(RoomStatDefOf.Impressiveness)); if (def.stages[scoreStageIndex] == null) { return; } pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(def, scoreStageIndex)); }
/// <summary> /// Creates the new thought from the original pawn to transfer to the target pawn. /// </summary> /// <param name="original">The original.</param> /// <param name="target">The target.</param> /// <param name="originalThought">The original thought.</param> /// <returns></returns> public Thought_Memory CreateNewThought(Pawn original, Pawn target, Thought_Memory originalThought) { if (original == null) { throw new ArgumentNullException(nameof(original)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } if (originalThought == null) { throw new ArgumentNullException(nameof(originalThought)); } try { var harmonizerThought = (Thought_PsychicHarmonizer)originalThought; var newHarmonizerThought = (Thought_PsychicHarmonizer)ThoughtMaker.MakeThought(originalThought.def, originalThought.CurStageIndex); newHarmonizerThought.harmonizer = harmonizerThought.harmonizer; return(newHarmonizerThought); } catch (System.Exception e) { Log.Error($"unable to transfer thought {original?.def?.label} onto {target?.Label}! caught {e.GetType().Name}!"); throw; } }
public static void GiveThoughtsForPawnDiedOfBloodLoss(Pawn victim, Pawn drainer = null) { if (!victim.RaceProps.Humanlike) { return; } int thoughtIndex = 1; if (victim.guilt.IsGuilty || drainer == null) { thoughtIndex = 0; } ThoughtDef def; if (victim.IsColonist) { def = VampDefOf.ROMV_KnowColonistDiedOfBloodLoss; } else { def = VampDefOf.ROMV_KnowGuestDiedOfBloodLoss; } foreach (Pawn current in from x in PawnsFinder.AllMapsCaravansAndTravelingTransportPods where x.IsColonist || x.IsPrisonerOfColony select x) { current.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(def, thoughtIndex)); } }
public static Thought_Memory GetSubstitute([NotNull] this Thought_Memory memory, [NotNull] Pawn pawn) { IEnumerable <ThoughtGroupDefExtension> tGroups = memory.def.modExtensions.MakeSafe().OfType <ThoughtGroupDefExtension>(); foreach (ThoughtDef thoughtDef in tGroups.SelectMany(g => g.thoughts)) { if (ThoughtUtility.CanGetThought(pawn, thoughtDef)) { int forcedStage = Mathf.Min(memory.CurStageIndex, thoughtDef.stages.Count - 1); if (forcedStage != memory.CurStageIndex) { Log.Warning($"in memory {memory.def.defName}, substituted thought {thoughtDef.defName} does not the same number of stages\noriginal:{memory.def.stages.Count} sub:{thoughtDef.stages.Count}"); } Thought_Memory newMemory = ThoughtMaker.MakeThought(thoughtDef, forcedStage); if (newMemory == null) { Log.Error($"in thought {memory.def.defName} group, thought {thoughtDef.defName} is not a memory"); continue; } return(newMemory); } } return(memory); }
private void ApplyOutcome(LordToil_Disco toil) { List <Pawn> ownedPawns = this.lord.ownedPawns; LordToilData_Disco data = (LordToilData_Disco)toil.data; int given = 0; for (int index = 0; index < ownedPawns.Count; ++index) { Pawn key = ownedPawns[index]; bool flag = key == organizer; if (data.wasPresent.Contains(key)) { if (ownedPawns[index].needs.mood != null) { ThoughtDef def = flag ? OrganizerThought : AttendeeThought; Thought_Memory newThought = (Thought_Memory)ThoughtMaker.MakeThought(def); newThought.moodPowerFactor = 1; ownedPawns[index].needs.mood.thoughts.memories.TryGainMemory(newThought); given++; } TaleRecorder.RecordTale(flag ? OrganizerTale : AttendeeTale, ownedPawns[index], organizer); } } Core.Log($"Gave positive vibes to {given} pawns."); }
public Thought_Memory GiveObservedThought() { if (this.StoringThing() != null) { return(null); } var thought_MemoryObservation = (Thought_MemoryObservation)ThoughtMaker.MakeThought( DefDatabase <ThoughtDef> .GetNamed("Cults_ObservedNightmareTree")); thought_MemoryObservation.Target = this; var Dave = thought_MemoryObservation.pawn; if (Dave == null) { return(null); } if (!Dave.IsColonist) { return(thought_MemoryObservation); } if (Dave.needs.TryGetNeed <Need_CultMindedness>().CurLevel > 0.7) { thought_MemoryObservation = (Thought_MemoryObservation)ThoughtMaker.MakeThought( DefDatabase <ThoughtDef> .GetNamed("Cults_ObservedNightmareTreeCultist")); } return(thought_MemoryObservation); }
private static bool Prefix(MemoryThoughtHandler __instance, ref Thought_Memory newThought, Pawn otherPawn) { if (__instance.pawn.HasTrait(VTEDefOf.VTE_AnimalHater) && animalThoughtDefs.Contains(newThought.def)) { newThought = (Thought_Memory)ThoughtMaker.MakeThought(inverseAnimalThoughDefs[newThought.def]); } if (__instance.pawn.HasTrait(VTEDefOf.VTE_Squeamish) && newThought.def == VTEDefOf.ObservedLayingRottingCorpse) { var comp = Current.Game.GetComponent <TraitsManager>(); if ((!comp.squeamishWithLastVomitedTick.ContainsKey(__instance.pawn) || GenTicks.TicksAbs >= comp.squeamishWithLastVomitedTick[__instance.pawn] + (30 * 60)) && Rand.Chance(0.5f)) { Job vomit = JobMaker.MakeJob(JobDefOf.Vomit); __instance.pawn.jobs.TryTakeOrderedJob(vomit); comp.squeamishWithLastVomitedTick[__instance.pawn] = GenTicks.TicksAbs; } } if (__instance.pawn.HasTrait(VTEDefOf.VTE_Desensitized) && horribleThoughts.Contains(newThought.def.defName)) { return(false); } if (__instance.pawn.HasTrait(VTEDefOf.VTE_ColdInclined) && (newThought.CurStageIndex < 1 && newThought.def == ThoughtDef.Named("EnvironmentCold") || newThought.def == ThoughtDefOf.SleptInCold)) { return(false); } if (__instance.pawn.HasTrait(VTEDefOf.VTE_HeatInclined) && (newThought.CurStageIndex < 1 && newThought.def == ThoughtDef.Named("EnvironmentHot") || newThought.def == ThoughtDefOf.SleptInHeat)) { return(false); } if (__instance.pawn.HasTrait(VTEDefOf.VTE_ChildOfMountain) && newThought.def == ThoughtDef.Named("EnvironmentDark")) { return(false); } if (__instance.pawn.HasTrait(VTEDefOf.VTE_ChildOfSea) && newThought.def == ThoughtDef.Named("SoakingWet")) { __instance.pawn.TryGiveThought(VTEDefOf.VTE_SoakingWetChildOfTheSea); return(false); } if (__instance.pawn.HasTrait(VTEDefOf.VTE_HeavySleeper) && newThought.def == ThoughtDefOf.SleepDisturbed) { return(false); } if (__instance.pawn.HasTrait(VTEDefOf.VTE_MadSurgeon) && (newThought.def == ThoughtDefOf.KnowColonistOrganHarvested || newThought.def == ThoughtDefOf.KnowGuestOrganHarvested || newThought.def == ThoughtDefOf.ButcheredHumanlikeCorpse || newThought.def == ThoughtDefOf.KnowButcheredHumanlikeCorpse || newThought.def == VTEDefOf.ObservedLayingCorpse || newThought.def == VTEDefOf.ObservedLayingRottingCorpse || newThought.def == ThoughtDefOf.KnowPrisonerDiedInnocent || newThought.def == ThoughtDefOf.KnowColonistExecuted && newThought.CurStageIndex == 3 )) { return(false); } return(true); }
//public new Pawn_HealthTracker_CantHeal health; public Thought_Memory GiveObservedThought() { Thought_MemoryObservation thought = ((Thought_MemoryObservation)ThoughtMaker.MakeThought(D9HDefOf.ObservedSpookySkeleton)); thought.Target = this; return(thought); }
public Thought_Memory GiveObservedThought() { Thought_Memory result; if (!this.InnerPawn.RaceProps.Humanlike) { result = null; } else if (this.StoringThing() == null) { Thought_MemoryObservation thought_MemoryObservation; if (this.IsNotFresh()) { thought_MemoryObservation = (Thought_MemoryObservation)ThoughtMaker.MakeThought(ThoughtDefOf.ObservedLayingRottingCorpse); } else { thought_MemoryObservation = (Thought_MemoryObservation)ThoughtMaker.MakeThought(ThoughtDefOf.ObservedLayingCorpse); } thought_MemoryObservation.Target = this; result = thought_MemoryObservation; } else { result = null; } return(result); }
public static void GiveThoughtsForTakeBlood(Pawn donor, bool isViolation, bool tookWhenLow) { if (donor.NonHumanlikeOrWildMan()) { return; } if (!isViolation) { if (tookWhenLow) { donor.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(GiveBloodNegativeThoughtDef, 0)); } else { donor.needs.mood.thoughts.memories.TryGainMemory(GiveBloodPositiveThoughtDef); } return; } //is a violation donor.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(GiveBloodNegativeThoughtDef, 1)); PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoners.ForEach(cap => { cap.needs.mood.thoughts.memories.TryGainMemory(StealBloodThoughDef); }); }
/// <summary> /// add the correct reversion thought at the correct stage /// </summary> /// <param name="spawned">The spawned.</param> private void AddReversionThought(Pawn spawned) { TraitSet traits = spawned.story.traits; ThoughtDef thoughtDef; var hasPrimalWish = spawned.GetAspectTracker()?.Contains(AspectDefOf.PrimalWish) == true; if (hasPrimalWish) { thoughtDef = def.revertedPrimalWish ?? def.revertedThoughtBad; //substitute with the bad thought if null } else if (traits.HasTrait(PMTraitDefOf.MutationAffinity)) { thoughtDef = def.revertedThoughtGood; } else if (traits.HasTrait(TraitDefOf.BodyPurist)) { thoughtDef = def.revertedThoughtBad; } else { thoughtDef = Rand.Value > 0.5f ? def.revertedThoughtGood : def.revertedThoughtBad; } if (thoughtDef != null) { //TODO fix this with special memory for animalistic pawns Thought_Memory mem = ThoughtMaker.MakeThought(thoughtDef, 0); spawned.TryGainMemory(mem); } }
public Thought_Memory GiveObservedThought() { //Non-humanlike corpses never give thoughts if (!InnerPawn.RaceProps.Humanlike) { return(null); } var storingBuilding = this.StoringThing(); if (storingBuilding == null) { //Laying on the ground Thought_MemoryObservation obs; if (this.IsNotFresh()) { obs = (Thought_MemoryObservation)ThoughtMaker.MakeThought(ThoughtDefOf.ObservedLayingRottingCorpse); } else { obs = (Thought_MemoryObservation)ThoughtMaker.MakeThought(ThoughtDefOf.ObservedLayingCorpse); } obs.Target = this; return(obs); } return(null); }
public override bool TryExecute(IncidentParms parms) { var memoDef = (AncestorMemoDef)this.def; Pawn target; Find.MapPawns.FreeColonistsSpawned.TryRandomElement(out target); if (target != null) { var thoughtDef = DefDatabase <ThoughtDef> .GetNamed(memoDef.thoughtDef); var thought = (Thought_Memory)ThoughtMaker.MakeThought(thoughtDef); target.needs.mood.thoughts.memories.TryGainMemoryThought(thought); var letterText = String.Format(this.def.letterText, target.LabelShort); Find.LetterStack.ReceiveLetter(this.def.letterLabel, letterText, this.def.letterType); return(true); } else { return(false); } }
/// <summary> /// add the correct reversion thought at the correct stage /// </summary> /// <param name="spawned"></param> /// <param name="curStageIndex"></param> private void AddReversionThought(Pawn spawned, int curStageIndex) { TraitSet traits = spawned.story.traits; ThoughtDef thoughtDef; var hasPrimalWish = spawned.GetAspectTracker()?.Contains(AspectDefOf.PrimalWish) == true; if (hasPrimalWish) { thoughtDef = def.revertedPrimalWish ?? def.revertedThoughtBad; //substitute with the bad thought if null } else if (traits.HasTrait(PMTraitDefOf.MutationAffinity)) { thoughtDef = def.revertedThoughtGood; } else if (traits.HasTrait(TraitDefOf.BodyPurist)) { thoughtDef = def.revertedThoughtBad; } else { thoughtDef = Rand.Value > 0.5f ? def.revertedThoughtGood : def.revertedThoughtBad; } if (thoughtDef != null) { curStageIndex = Mathf.Min(curStageIndex, thoughtDef.stages.Count - 1); //avoid index out of bounds issues Thought_Memory mem = ThoughtMaker.MakeThought(thoughtDef, curStageIndex); spawned.TryGainMemory(mem); } }
public static void ThoughtWithStage(Pawn pawn, ThoughtDef thought, int stage) { Thought_Memory thought1 = (Thought_Memory)ThoughtMaker.MakeThought(thought); pawn.needs.mood.thoughts.memories.TryGainMemory(thought1, null); pawn.needs.mood.thoughts.memories.OldestMemoryOfDef(thought).SetForcedStage(stage); }
/// <summary> /// Transfers thoughts from pawn1 onto pawn2. /// </summary> /// <param name="pawn1">The pawn to transfer thoughts from.</param> /// <param name="pawn2">The pawn to transfer thoughts onto.</param> /// <param name="selector">The selector function. default just checks that the memory is valid for pawn2</param> /// <exception cref="ArgumentNullException"> /// pawn1 /// or /// pawn2 /// </exception> public static void TransferThoughts([NotNull] Pawn pawn1, [NotNull] Pawn pawn2, [CanBeNull] Func <Thought_Memory, bool> selector = null) { if (pawn1 == null) { throw new ArgumentNullException(nameof(pawn1)); } if (pawn2 == null) { throw new ArgumentNullException(nameof(pawn2)); } selector = selector ?? (t => DefaultThoughtSelector(pawn2, t)); var thoughtHandler1 = pawn1.needs?.mood?.thoughts; var thoughtHandler2 = pawn2.needs?.mood?.thoughts; if (thoughtHandler2?.memories == null || thoughtHandler1?.memories == null) { return; } foreach (Thought_Memory memory in thoughtHandler1.memories.Memories.MakeSafe()) { if (!selector(memory)) { continue; } var sameMemory = thoughtHandler2.memories.Memories.MakeSafe().FirstOrDefault(m => m.def == memory.def); if (sameMemory != null) { continue; } var worker = memory.def?.modExtensions?.OfType <IThoughtTransferWorker>().FirstOrDefault(); Thought_Memory newMemory; if (worker != null) { if (!worker.ShouldTransfer(pawn1, pawn2, memory)) { continue; } newMemory = worker.CreateNewThought(pawn1, pawn2, memory); } else { newMemory = ThoughtMaker.MakeThought(memory.def, memory.CurStageIndex); } if (memory.otherPawn == null) { thoughtHandler2.memories.TryGainMemory(newMemory, memory.otherPawn); } newMemory.age = memory.age; newMemory.moodPowerFactor = memory.moodPowerFactor; } }
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); } } } }
protected override IEnumerable <Toil> MakeNewToils() { // TargetIndex.A is the window glower // TargetIndex.B is the window Building_Window window = TargetB.Thing as Building_Window; // Set fail conditions this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOnDestroyedOrNull(TargetIndex.B); // Reserve the window glower yield return(Toils_Reserve.Reserve(TargetIndex.A)); // Go to the window yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell)); // Look out the window Toil low = new Toil(); JoyKindDef joyKind = LocalDefOf.WIN_LookOutWindow.joyKind; low.socialMode = RandomSocialMode.Normal; low.initAction = () => { low.handlingFacing = true; }; low.tickAction = () => { base.WatchTickAction(); pawn.needs.joy.GainJoy(Mathf.Max(window.WindowViewBeauty, 0.1f) * 0.000576f, joyKind); pawn.rotationTracker.FaceCell(TargetB.Cell); }; low.defaultCompleteMode = ToilCompleteMode.Delay; low.defaultDuration = job.def.joyDuration; low.AddFinishAction(() => { // Create the basic memory Thought_Memory thought_Memory = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.WIN_LookedOutWindowRegular); // Create a temp list of thoughts the pawn has List <Thought> tmpThoughts = new List <Thought>();; pawn.needs.mood.thoughts.GetAllMoodThoughts(tmpThoughts); // Scan through the thoughts for (int t = 0; t < tmpThoughts.Count; t++) { // If the pawn has cabin fever, change the memory if (tmpThoughts[t].def.defName == "CabinFever") { thought_Memory = (Thought_Memory)ThoughtMaker.MakeThought(LocalDefOf.WIN_LookedOutWindowCabinFever); // If the pawn has serious cabin fever, give a better memory if (tmpThoughts[t].CurStageIndex == 1) { thought_Memory.moodPowerFactor = 1.5f; } } } // Try to add the memory pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory); }); yield return(low); }
public static void GiveThoughtsForDrinkingBlood(Pawn drainer) { if (!drainer.RaceProps.Humanlike) { return; } drainer.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(VampDefOf.ROMV_IGaveTheKiss, 0), null); }
public static void GiveThoughtsAboutExecutionToPawn(Pawn receipient, Pawn victim, ThoughtDef def, int stage) { // FileLog.Log("Victim's corpse: " + victim.Corpse + "; the corps is inside map " + victim.Corpse.Map); if (true) { receipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(def, stage), null); } }
public static void GiveThoughtsForDiablerie(Pawn drainer) { if (!drainer.RaceProps.Humanlike) { return; } drainer.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(VampDefOf.ROMV_IConsumedASoul, 0), null); }
public override void MakeIngestMemory(ThoughtDef memory, Pawn ingester) { Thought_MealTemp foodMem = (Thought_MealTemp)ThoughtMaker.MakeThought(memory); foodMem.createdTemp = curTemp; foodMem.comp = this; ingester.needs.mood.thoughts.memories.TryGainMemory(foodMem, 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); }
protected override IEnumerable <Toil> MakeNewToils() { IntVec3 cell = RCellFinder.RandomWanderDestFor(pawn, pawn.Position, 5f, null, Danger.Deadly); pawn.rotationTracker.Face(cell.ToVector3()); yield return(Toils_General.ClearTarget(TargetIndex.A)); yield return(Toils_General.Wait(500)); yield return(Toils_General.Do(delegate { //this.ReportStringProcessed("laying egg."); Thing egg = GenSpawn.Spawn(ThingDefOf.AvaliEgg, pawn.Position, Map); //FilthMaker.MakeFilth(pawn.Position, pawn.Map, ThingDefOf.FilthAmnioticFluid, pawn.LabelIndefinite(), 1); egg.SetForbidden(true, true); CompHatcherAvali compHatcher = egg.TryGetComp <CompHatcherAvali>(); if (compHatcher != null) { //Log.Message("mother = " + pawn); Hediff hediff_HasEgg = pawn.health.hediffSet.hediffs.Find((Hediff x) => x.def == HediffDefOf.AvaliHasEgg); if (hediff_HasEgg != null) { pawn.health.RemoveHediff(hediff_HasEgg); } //Log.Message(pawn + " removed hediff: " + hediff_HasEgg); Thought_Memory newThought = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDefOf.AvaliCaresOfEgg); compHatcher.hatcheeFaction = pawn.Faction; compHatcher.hatcheeParent = pawn; pawn.health.AddHediff(HediffDefOf.AvaliCaresOfEgg, null, null); pawn.needs.mood.thoughts.memories.TryGainMemory(newThought, pawn); if (father != null) { compHatcher.otherParent = father; if (!father.Dead) { father.health.AddHediff(HediffDefOf.AvaliCaresOfEgg, null, null); father.needs.mood.thoughts.memories.TryGainMemory(newThought, father); } } //Log.Message(pawn + " egg.hatcheeFaction = " + compHatcher.hatcheeFaction); //Log.Message(pawn + " egg.hatcheeMother = " + pawn); //Log.Message(pawn + " egg.hatcheeFather = " + father); } else { Log.Error(egg + " not have CompHatcherAvali."); } })); yield break; }
public override void Tick() { if (pawn.IsFighting() && pawn.equipment.AllEquipmentListForReading.Any(t => t.def == RWBYDefOf.RWBY_Crescent_Rose_Rifle || t.def == RWBYDefOf.RWBY_Crescent_Rose_Scythe)) { Thought_Memory thought_Memory = (Thought_Memory)ThoughtMaker.MakeThought(RWBYDefOf.RWBY_RubyUsedCrescentRose); pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory); } base.Tick(); }
public override void Notify_OtherWeaponWielded(CompBladelinkWeapon weapon) { if (weapon.bondedPawn != null && !weapon.bondedPawn.Dead && weapon.bondedPawn.needs.mood != null) { Thought_WeaponTrait thought_WeaponTrait = (Thought_WeaponTrait)ThoughtMaker.MakeThought(ThoughtDefOf.JealousRage); thought_WeaponTrait.weapon = weapon.parent; weapon.bondedPawn.needs.mood.thoughts.memories.TryGainMemory(thought_WeaponTrait); } }