Exemplo n.º 1
0
        public static Building_MAD FindMADFor(Pawn sleeper, Pawn traveler, bool sleeperWillBePrisoner, bool checkSocialProperness, bool forceCheckMedBed = false)
        {
            Predicate <Thing> MADValidator = delegate(Thing t)
            {
                if (!traveler.CanReserveAndReach(t, PathEndMode.OnCell, Danger.Some, 1))
                {
                    return(false);
                }

                Building_MAD Building_MAD3 = (Building_MAD)t;

                if (Building_MAD3.HasAnyContents)
                {
                    return(false);
                }
                else
                {
                    if (Building_MAD3.Faction != traveler.Faction)
                    {
                        return(false);
                    }
                }
                return(!Building_MAD3.IsForbidden(traveler) && !Building_MAD3.IsBurning());
            };
            Predicate <Thing> validator = (Thing b) => MADValidator(b);

            Building_MAD building_MAD = (Building_MAD)GenClosest.ClosestThingReachable(sleeper.Position, ThingRequest.ForDef(DefDatabase <ThingDef> .GetNamed("MindAlteringDevice")), PathEndMode.OnCell, TraverseParms.For(traveler, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, null, -1, false);

            if (building_MAD != null)
            {
                return(building_MAD);
            }

            return(null);
        }
        // TargetIndex.A   => VICTIM
        // TargetIndex.B   => MAD

        protected override IEnumerable <Toil> MakeNewToils()
        {
            Pawn         Warden = this.pawn;
            Pawn         Victim = (Pawn)base.TargetA.Thing;
            Building_MAD MAD    = (Building_MAD)base.TargetB.Thing;


            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_Reserve.Reserve(TargetIndex.B, 1));

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(100));

            //yield return Toils_Haul.StartCarryThing(TargetIndex.A, false, false);
            //yield return Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.InteractionCell);
            yield return(new Toil
            {
                initAction = delegate
                {
                    //Warden.carrier.TryStartCarry(Victim);
                    Warden.carryTracker.TryStartCarry(Victim);
                },
            });

            yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.InteractionCell));

            yield return(Toils_General.Wait(250));

            yield return(new Toil
            {
                initAction = delegate
                {
                    if (MAD.PowerOn)
                    {
                        MAD.TryAcceptThing(Victim);

                        //Warden.carrier.container.Clear();
                        //Warden.carryTracker.
                    }
                    else
                    {
                        //Warden.carrier.container.TryDropAll(Warden.Position, ThingPlaceMode.Near);
                        Thing thing;
                        Warden.carryTracker.TryDropCarriedThing(Warden.Position, ThingPlaceMode.Near, out thing);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Delay
            });

            yield break;
        }
Exemplo n.º 3
0
        // TargetIndex.A   => VICTIM
        // TargetIndex.B   => MAD

        protected override IEnumerable <Toil> MakeNewToils()
        {
            Pawn         Warden = this.pawn;
            Pawn         Victim = (Pawn)base.TargetA.Thing;
            Building_MAD MAD    = (Building_MAD)base.TargetB.Thing;


            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_Reserve.Reserve(TargetIndex.B, 1));

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(100));

            yield return(new Toil
            {
                initAction = delegate
                {
                    Warden.carrier.TryStartCarry(Victim);
                },
            });

            yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.InteractionCell));

            yield return(Toils_General.Wait(250));

            yield return(new Toil
            {
                initAction = delegate
                {
                    MAD.TryAcceptThing(Victim);
                    Warden.carrier.container.Clear();
                },
                defaultCompleteMode = ToilCompleteMode.Delay
            });

            yield break;
        }