public override IEnumerable <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > GetFloatMenus() { List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > > floatMenus = new List <KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > >(); _Condition zombieCondition = new _Condition(_ConditionType.IsType, typeof(Zombie)); Func <Vector3, Pawn, Thing, List <FloatMenuOption> > zombieFunc = delegate(Vector3 clickPos, Pawn pawn, Thing curThing) { List <FloatMenuOption> opts = null; if (curThing is Zombie target && target.Downed) { if (REDataCache.GetFirstBrainChip(pawn.MapHeld) is Thing brainChip) { opts = new List <FloatMenuOption>(); if (target.installedBrainChip) { //Do nothing } else if (!pawn.CanReach(target, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("RE_CannotInstallBrainchip".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(target, 1)) { opts.Add(new FloatMenuOption("RE_CannotInstallBrainchip".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReach(brainChip, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("RE_CannotInstallBrainchip".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(brainChip, 1)) { opts.Add(new FloatMenuOption("RE_CannotInstallBrainchip".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Action action = delegate { Job job = new Job(DefDatabase <JobDef> .GetNamed("RE_InstallBrainChip"), target, brainChip); job.count = 1; pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("RE_InstallBrainChip".Translate( brainChip.LabelCap, target.LabelShortCap ), action, MenuOptionPriority.High, null, target, 0f, null, null)); } return(opts); } } return(null); }; KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > > curSec = new KeyValuePair <_Condition, Func <Vector3, Pawn, Thing, List <FloatMenuOption> > >(zombieCondition, zombieFunc); floatMenus.Add(curSec); return(floatMenus); }
protected override IEnumerable <Toil> MakeNewToils() { //Commence fail checks! this.FailOnDestroyedOrNull(TargetIndex.A); this.FailOnDestroyedOrNull(TargetIndex.B); yield return(Toils_Reserve.Reserve(ZombieIndex, 1)); yield return(Toils_Reserve.Reserve(BrainChipIndex, 1)); yield return(new Toil { initAction = delegate { REDataCache.ClearBrainChipCache(this.GetActor().Map); //this.customString = "ChthonianPitSacrificeGathering".Translate(); } }); yield return(Toils_Goto.GotoThing(BrainChipIndex, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(BrainChipIndex)); yield return(Toils_Construct.UninstallIfMinifiable(BrainChipIndex).FailOnSomeonePhysicallyInteracting(BrainChipIndex)); yield return(Toils_Haul.StartCarryThing(BrainChipIndex, false, true)); yield return(Toils_Goto.GotoThing(ZombieIndex, PathEndMode.Touch)); Toil chantingTime = new Toil() { defaultCompleteMode = ToilCompleteMode.Delay, defaultDuration = 1200 }; chantingTime.WithProgressBarToilDelay(ZombieIndex, false, -0.5f); chantingTime.initAction = delegate { //this.customString = "ChthonianPitSacrificeDropping".Translate(new object[] // { // this.Zombie.LabelShort // }); }; yield return(chantingTime); yield return(new Toil { initAction = delegate { //this.customString = "ChthonianPitSacrificeFinished".Translate(); IntVec3 position = this.Zombie.Position; this.pawn.carryTracker.TryDropCarriedThing(position, ThingPlaceMode.Near, out Thing thing, null); InstallBrainChip(thing, Zombie); },