protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Reserve.Reserve(TargetIndex.A)); if (TargetLocA != pawn.PositionHeld) { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch)); } Toil doWork = new Toil(); doWork.initAction = delegate { if (WorkLeft < -500f) { WorkLeft = BaseWorkAmount; } job.SetTarget(TargetIndex.B, pawn); }; doWork.tickAction = delegate { if (GetActor().Downed || GetActor().Dead || GetActor().pather.MovingNow) { EndJobWith(JobCondition.Incompletable); return; } WorkLeft -= pawn.skills.GetSkill(SkillDefOf.Melee).Level;// (StatDefOf.ConstructionSpeed, true); if (WorkLeft <= 0f) { WorkLeft = BaseWorkAmount; Thing thing = ThingMaker.MakeThing(VampDefOf.ROMV_HideyHole); thing.SetFaction(pawn.Faction); GenSpawn.Spawn(thing, TargetLocA, Map); Pawn actor = pawn; Building_Casket pod = (Building_Casket)thing; actor.DeSpawn(); pod.GetDirectlyHeldThings().TryAdd(actor); ReadyForNextToil(); return; } //JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 1f); }; doWork.WithProgressBar(TargetIndex.B, () => 1f - (float)WorkLeft / (float)BaseWorkAmount); doWork.defaultCompleteMode = ToilCompleteMode.Never; //doWork.FailOn(() => !JoyUtility.EnjoyableOutsideNow(this.pawn, null)); //doWork.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(doWork); }
/// <summary>Called after the parent's graphic is drawn.</summary> public override void PostDraw() { Building_Casket chamber = (Building_Casket)parent; if (chamber.HasAnyContents) { foreach (Pawn pawn in chamber.GetDirectlyHeldThings().OfType <Pawn>()) { if (pawn != null) { pawn.Rotation = Rot4.South; pawn.DrawAt(GenThing.TrueCenter(parent.Position, Rot4.South, parent.def.size, Props.Altitude) + Offset); } } } }
public static void Ressurrect(Pawn pawn, Thing thing) { if (thing is HoloEmitter) { if (pawn.Corpse.holdingOwner != null) { pawn.Corpse.GetDirectlyHeldThings().TryTransferToContainer(pawn, pawn.Corpse.holdingOwner, true); } else if (pawn.Corpse.Spawned) { ResurrectionUtility.Resurrect(pawn); PawnDiedOrDownedThoughtsUtility.RemoveDiedThoughts(pawn); PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn, false); CompOsiris.FixPawnRelationships(pawn); pawn.health.Reset(); if (pawn.Corpse != null && pawn.Corpse.Spawned) { pawn.Corpse.DeSpawn(); } GenSpawn.Spawn(pawn, pawn.Corpse.Position, pawn.Corpse.Map); GiveSideEffects(pawn); } if (pawn.Corpse != null) { pawn.Corpse.Destroy(DestroyMode.Vanish); } } else { ResurrectionUtility.Resurrect(pawn); PawnDiedOrDownedThoughtsUtility.RemoveDiedThoughts(pawn); CompOsiris.FixPawnRelationships(pawn); pawn.health.Reset(); if (pawn.Corpse != null && pawn.Corpse.Spawned) { pawn.Corpse.DeSpawn(); } GenSpawn.Spawn(pawn, thing.Position, thing.Map); GiveSideEffects(pawn); Building_Casket building_Casket = thing as Building_Casket; if (building_Casket != null) { building_Casket.GetDirectlyHeldThings().Clear(); } } }
public override void PostMapGenerate(Map map) { if (Find.GameInitData == null) { return; } if (spawnInCoffins) { bool usingDropPods = Find.Scenario.AllParts.Any(x => x is ScenPart_PlayerPawnsArriveMethod s && (PlayerPawnsArriveMethod)AccessTools.Field(typeof(ScenPart_PlayerPawnsArriveMethod), "method").GetValue(s) == PlayerPawnsArriveMethod.DropPods); List <List <Thing> > list = new List <List <Thing> >(); foreach (Pawn current in Find.GameInitData.startingPawns) { if (current.RaceProps.Humanlike && current?.health?.hediffSet?.hediffs.FirstOrDefault(y => y.def.defName.Contains("Vampirism")) != null) { IntVec3 loc = current.PositionHeld; Building_Casket casket = (Building_Casket)ThingMaker.MakeThing(VampDefOf.ROMV_RoyalCoffin, ThingDefOf.WoodLog); casket.SetFaction(Faction.OfPlayer); if (current.Spawned) { current.DeSpawn(); } if (current.holdingOwner != null) { current.holdingOwner.Take(current); } if (!usingDropPods) { GenPlace.TryPlaceThing(casket, loc, map, ThingPlaceMode.Near); } casket.GetDirectlyHeldThings().TryAdd(current); if (usingDropPods) { list.Add(new List <Thing> { casket }); } } } bool instaDrop = Find.GameInitData.QuickStarted; if (usingDropPods) { DropPodUtility.DropThingGroupsNear(MapGenerator.PlayerStartSpot, map, list, 110, instaDrop, true); } } }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); yield return(Toils_Reserve.Reserve(TargetIndex.A)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil prepare = Toils_General.Wait(500); prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); prepare.WithProgressBarToilDelay(TargetIndex.A); yield return(prepare); yield return(new Toil { initAction = delegate { Pawn actor = pawn; Building_Casket pod = (Building_Casket)actor.CurJob.targetA.Thing; actor.DeSpawn(); pod.GetDirectlyHeldThings().TryAdd(actor); //pod.TryAcceptThing(actor, true); //if (!pod.def.building.isPlayerEjectable) //{ // int freeColonistsSpawnedOrInPlayerEjectablePodsCount = this.Map.mapPawns.FreeColonistsSpawnedOrInPlayerEjectablePodsCount; // if (freeColonistsSpawnedOrInPlayerEjectablePodsCount <= 1) // { // Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CasketWarning".Translate().AdjustedFor(actor), action, false, null)); // } // else // { // action(); // } //} //else //{ // action(); //} }, defaultCompleteMode = ToilCompleteMode.Instant }); }
protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null)); if (TargetLocA != pawn.PositionHeld) { yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch)); } Toil doWork = new Toil(); doWork.initAction = delegate { this.workLeft = BaseWorkAmount; this.CurJob.SetTarget(TargetIndex.B, this.pawn); }; doWork.tickAction = delegate { this.workLeft -= this.pawn.GetStatValue(StatDefOf.ConstructionSpeed, true); if (this.workLeft <= 0f) { Thing thing = ThingMaker.MakeThing(VampDefOf.ROMV_HideyHole, null); thing.SetFaction(this.pawn.Faction, null); GenSpawn.Spawn(thing, this.TargetLocA, this.Map); Pawn actor = this.pawn; Building_Casket pod = (Building_Casket)thing; actor.DeSpawn(); pod.GetDirectlyHeldThings().TryAdd(actor); this.ReadyForNextToil(); return; } //JoyUtility.JoyTickCheckEnd(this.pawn, JoyTickFullJoyAction.EndJob, 1f); }; doWork.WithProgressBar(TargetIndex.B, () => 1f - (float)this.workLeft / (float)BaseWorkAmount); doWork.defaultCompleteMode = ToilCompleteMode.Never; //doWork.FailOn(() => !JoyUtility.EnjoyableOutsideNow(this.pawn, null)); //doWork.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); yield return(doWork); }
// Token: 0x060000FF RID: 255 RVA: 0x0000A24C File Offset: 0x0000864C public static void Ressurrect(Pawn pawn, Thing thing) { pawn.health.Reset(); if (pawn.Corpse != null && pawn.Corpse.Spawned) { pawn.Corpse.DeSpawn(); } CompOsiris.AddComponentsForResurrection(pawn); Type typeFromHandle = typeof(Thing); FieldInfo field = typeFromHandle.GetField("mapIndexOrState", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(pawn, (SByte)(-1)); CompOsiris.FixPawnRelationships(pawn); if (thing is HoloEmitter) { if (!pawn.Dead) { } if (pawn.Corpse.holdingOwner != null) { pawn.Corpse.GetDirectlyHeldThings().TryTransferToContainer(pawn, pawn.Corpse.holdingOwner, true); } else if (pawn.Corpse.Spawned) { GenSpawn.Spawn(pawn, pawn.Corpse.Position, pawn.Corpse.Map); } if (pawn.Corpse != null) { pawn.Corpse.Destroy(0); } } else { GenSpawn.Spawn(pawn, thing.Position, thing.Map); Building_Casket building_Casket = thing as Building_Casket; if (building_Casket != null) { building_Casket.GetDirectlyHeldThings().Clear(); } } }