コード例 #1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            //this.FailOn(() => (base.Map.designationManager.DesignationOn(base.TargetThingA, MeeseeksDefOf.CM_Meeseeks_Box_Designation_PressButton) == null) ? true : false);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            Toil toil = Toils_General.Wait(useDuration);

            toil.WithProgressBarToilDelay(TargetIndex.A);
            toil.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            toil.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
            yield return(toil);

            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++)
                {
                    CompHasButton compHasButton = thingWithComps.AllComps[i] as CompHasButton;
                    if (compHasButton != null)// && compHasButton.WantsPress)
                    {
                        compHasButton.DoPress(finalize.actor);
                    }
                }
                // Don't want to add a bunch of these, one day they will exist in a core mod
                //actor.records.Increment(PocketDimensionDefOf.CM_PocketDimension_Record_ButtonsPressed);
            };
            finalize.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(finalize);
        }
コード例 #2
0
        public override Job GetJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty)
        {
            Job job = null;

            if (jobTarget != null && jobTarget.HasThing && !jobTarget.ThingDestroyed)
            {
                CompHasButton hasButton = jobTarget.Thing.TryGetComp <CompHasButton>();

                if (!hasButton.WantsPress)
                {
                    jobAvailabilty = JobAvailability.Complete;
                }
            }
            else
            {
                Logger.WarningFormat(this, "Unable to get scanner or target for job.");
            }

            if (job != null)
            {
                jobAvailabilty = JobAvailability.Available;
            }

            return(job);
        }