Example #1
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     if (this.Props.destroyOnNoFuel)
     {
         this.fuel = this.Props.fuelCapacity;
     }
     this.flickComp = this.parent.GetComp <CompFlickable>();
 }
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     flickableComp = parent.GetComp <CompFlickable>();
     if (PowerOn)
     {
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             StartSustainerPoweredIfInactive();
         });
     }
 }
Example #3
0
        public static bool WantsToBeOn(Thing t)
        {
            CompFlickable compFlickable = t.TryGetComp <CompFlickable>();

            if (compFlickable != null && !compFlickable.SwitchIsOn)
            {
                return(false);
            }
            CompSchedule compSchedule = t.TryGetComp <CompSchedule>();

            return(compSchedule == null || compSchedule.Allowed);
        }
 public override void ExposeData()
 {
     base.ExposeData();
     if (Scribe.mode == LoadSaveMode.PostLoadInit)
     {
         if (this.flickableComp == null)
         {
             this.flickableComp = base.GetComp <CompFlickable>();
         }
         this.wantsOnOld = !FlickUtility.WantsToBeOn(this);
         this.UpdatePowerGrid();
     }
 }
Example #5
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOnDespawnedOrNull(TargetIndex.A);
                    this.FailOn(delegate()
                    {
                        Designation designation = this.Map.designationManager.DesignationOn(this.TargetThingA, DesignationDefOf.Flick);
                        return(designation == null);
                    });
                    this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$current = Toils_General.Wait(15, TargetIndex.None).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                    < MakeNewToils > c__AnonStorey.finalize            = new Toil();
                    < MakeNewToils > c__AnonStorey.finalize.initAction = delegate()
                    {
                        Pawn           actor          = < MakeNewToils > c__AnonStorey.finalize.actor;
                        ThingWithComps thingWithComps = (ThingWithComps)actor.CurJob.targetA.Thing;
                        for (int i = 0; i < thingWithComps.AllComps.Count; i++)
                        {
                            CompFlickable compFlickable = thingWithComps.AllComps[i] as CompFlickable;
                            if (compFlickable != null && compFlickable.WantsFlick())
                            {
                                compFlickable.DoFlick();
                            }
                        }
                        actor.records.Increment(RecordDefOf.SwitchesFlicked);
                        Designation designation = < MakeNewToils > c__AnonStorey.< > f__ref$0.$this.Map.designationManager.DesignationOn(thingWithComps, DesignationDefOf.Flick);
                        if (designation != null)
                        {
                            designation.Delete();
                        }
                    };
        public static bool WantsToBeOn(Thing t)
        {
            CompFlickable compFlickable = t.TryGetComp <CompFlickable>();
            bool          result;

            if (compFlickable != null && !compFlickable.SwitchIsOn)
            {
                result = false;
            }
            else
            {
                CompSchedule compSchedule = t.TryGetComp <CompSchedule>();
                result = (compSchedule == null || compSchedule.Allowed);
            }
            return(result);
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompRefuelable compRefuelable = t.TryGetComp <CompRefuelable>();

            if (compRefuelable != null && !compRefuelable.IsFull)
            {
                if (!forced && !compRefuelable.ShouldAutoRefuelNow)
                {
                    return(false);
                }
                if (!t.IsForbidden(pawn))
                {
                    LocalTargetInfo target = t;
                    if (!pawn.CanReserve(target, 1, -1, null, forced))
                    {
                        goto IL_005b;
                    }
                    if (t.Faction != pawn.Faction)
                    {
                        return(false);
                    }
                    ThingWithComps thingWithComps = t as ThingWithComps;
                    if (thingWithComps != null)
                    {
                        CompFlickable comp = thingWithComps.GetComp <CompFlickable>();
                        if (comp != null && !comp.SwitchIsOn)
                        {
                            return(false);
                        }
                    }
                    Thing thing = this.FindBestFuel(pawn, t);
                    if (thing == null)
                    {
                        ThingFilter fuelFilter = t.TryGetComp <CompRefuelable>().Props.fuelFilter;
                        JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter.Summary));
                        return(false);
                    }
                    return(true);
                }
                goto IL_005b;
            }
            return(false);

IL_005b:
            return(false);
        }
Example #8
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            this.FailOn(delegate()
            {
                Designation designation = this.Map.designationManager.DesignationOn(this.TargetThingA, DesignationDefOf.Flick);
                return(designation == null);
            });
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(15, TargetIndex.None).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch));

            Toil finalize = new Toil();

            finalize.initAction = delegate()
            {
                Pawn           actor          = finalize.actor;
                ThingWithComps thingWithComps = (ThingWithComps)actor.CurJob.targetA.Thing;
                for (int i = 0; i < thingWithComps.AllComps.Count; i++)
                {
                    CompFlickable compFlickable = thingWithComps.AllComps[i] as CompFlickable;
                    if (compFlickable != null && compFlickable.WantsFlick())
                    {
                        compFlickable.DoFlick();
                    }
                }
                actor.records.Increment(RecordDefOf.SwitchesFlicked);
                Designation designation = this.Map.designationManager.DesignationOn(thingWithComps, DesignationDefOf.Flick);
                if (designation != null)
                {
                    designation.Delete();
                }
            };
            finalize.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(finalize);

            yield break;
        }
Example #9
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOn(delegate
            {
                ThingWithComps thingWithComps = this.$this.job.GetTarget(TargetIndex.A).Thing as ThingWithComps;
                if (thingWithComps != null)
                {
                    CompFlickable comp = thingWithComps.GetComp <CompFlickable>();
                    if (comp != null && !comp.SwitchIsOn)
                    {
                        return(true);
                    }
                }
                return(false);
            });
            base.AddEndCondition(() => (!this.$this.RefuelableComp.IsFull) ? JobCondition.Ongoing : JobCondition.Succeeded);
            yield return(Toils_General.DoAtomic(delegate
            {
                this.$this.job.count = this.$this.RefuelableComp.GetFuelCountToFullyRefuel();
            }));

            Toil reserveFuel = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null);

            yield return(reserveFuel);

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, true, false).FailOnDestroyedNullOrForbidden(TargetIndex.B));

            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveFuel, TargetIndex.B, TargetIndex.None, true, null));

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

            yield return(Toils_General.Wait(240).FailOnDestroyedNullOrForbidden(TargetIndex.B).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f));

            yield return(Toils_Refuel.FinalizeRefueling(TargetIndex.A, TargetIndex.B));
        }
Example #10
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOn(delegate
            {
                ThingWithComps thingWithComps = ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0050: stateMachine*/)._0024this.job.GetTarget(TargetIndex.A).Thing as ThingWithComps;
                if (thingWithComps != null)
                {
                    CompFlickable comp = thingWithComps.GetComp <CompFlickable>();
                    if (comp != null && !comp.SwitchIsOn)
                    {
                        return(true);
                    }
                }
                return(false);
            });
            base.AddEndCondition(() => (JobCondition)((!((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0068: stateMachine*/)._0024this.RefuelableComp.IsFull) ? 1 : 2));
            yield return(Toils_General.DoAtomic(delegate
            {
                ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_007a: stateMachine*/)._0024this.job.count = ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_007a: stateMachine*/)._0024this.RefuelableComp.GetFuelCountToFullyRefuel();
            }));

            /*Error: Unable to find new state assignment for yield return*/;
        }
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     this.flickableComp = base.GetComp <CompFlickable>();
 }
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     this.flickableComp = this.parent.GetComp <CompFlickable>();
 }
Example #13
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     this.fuel      = this.Props.fuelCapacity * this.Props.initialFuelPercent;
     this.flickComp = this.parent.GetComp <CompFlickable>();
 }