Exemple #1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompMeeseeksMemory compMeeseeksMemory = pawn.GetComp <CompMeeseeksMemory>();

            if (compMeeseeksMemory == null)
            {
                yield return(Toils_General.Do(delegate { }));
            }
            else
            {
                yield return(Toils_General.Do(delegate
                {
                    MeeseeksUtility.PlayFinishTaskSound(pawn, compMeeseeksMemory.Voice);
                }));

                int waitTime = Rand.RangeInclusive(60, 180);

                Toil            wait       = Toils_General.Wait(waitTime, 0);
                LocalTargetInfo faceCamera = new LocalTargetInfo(pawn.Position + IntVec3.South);
                pawn.rotationTracker.FaceTarget(faceCamera);
                yield return(wait);

                yield return(Toils_General.Do(delegate
                {
                    Logger.MessageFormat(this, "Meeseeks task completed. Vanishing.");
                    MeeseeksUtility.DespawnMeeseeks(pawn);
                }));
            }
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil checkDuration = new Toil();

            checkDuration.initAction = delegate
            {
                this.SetDuration();
            };

            Toil startLabel = Toils_General.Label();

            yield return(startLabel);

            this.FailOnBurningImmobile(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.A));

            Toil unequip = new Toil();

            unequip.tickAction = delegate
            {
                TryUnequipSomething();
            };
            unequip.WithProgressBarToilDelay(TargetIndex.A);
            unequip.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            unequip.defaultCompleteMode = ToilCompleteMode.Delay;
            unequip.defaultDuration     = this.Duration;
            yield return(unequip);

            yield return(Toils_General.Do(delegate
            {
                Equip();
            }));


            Toil findEquipment = new Toil();

            findEquipment.initAction = delegate
            {
                //Logger.MessageFormat(this, "Searching for equipment...");
                Thing foundEquipment = FindEquipment(pawn);
                if (foundEquipment != null && pawn.Reserve(foundEquipment, job, 1, -1, null, false))
                {
                    job.targetA = new LocalTargetInfo(foundEquipment);

                    this.SetDuration();
                    unequip.defaultDuration = this.Duration;
                    pawn.jobs.curDriver.JumpToToil(startLabel);
                }
            };
            yield return(findEquipment);

            yield return(Toils_General.Do(delegate
            {
                CompMeeseeksMemory compMeeseeksMemory = pawn.GetComp <CompMeeseeksMemory>();
                if (compMeeseeksMemory != null)
                {
                    compMeeseeksMemory.acquiredEquipmentTick = Find.TickManager.TicksGame;
                }
            }));
        }
Exemple #3
0
        public override bool StateCanOccur(Pawn pawn)
        {
            if (!base.StateCanOccur(pawn))
            {
                return(false);
            }

            if (!pawn.SpawnedOrAnyParentSpawned)
            {
                return(false);
            }

            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                return(false);
            }

            CompMeeseeksMemory memory = pawn.GetComp <CompMeeseeksMemory>();

            if (memory == null)
            {
                return(false);
            }

            Map map = pawn.MapHeld;

            List <Thing> meeseeksBoxes = map.listerThings.AllThings.Where(thing => (thing.def == MeeseeksDefOf.CM_Meeseeks_Box_Thing_Meeseeks_Box)).ToList();

            return(meeseeksBoxes.Count > 0);
        }
Exemple #4
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);
        }
Exemple #5
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            Logger.MessageFormat(this, "Checking for saved job on Meeseeks.");

            CompMeeseeksMemory compMeeseeksMemory = pawn.GetComp <CompMeeseeksMemory>();

            if (compMeeseeksMemory != null && compMeeseeksMemory.GivenTask)
            {
                SavedJob savedJob = compMeeseeksMemory.savedJob;

                if (savedJob == null || CompMeeseeksMemory.noContinueJobs.Contains(savedJob.def))
                {
                    return(ThinkResult.NoJob);
                }

                Job nextJob = GetNextJob(pawn, compMeeseeksMemory);

                if (nextJob == null && compMeeseeksMemory.jobTargets.Count == 0)
                {
                    nextJob = JobMaker.MakeJob(MeeseeksDefOf.CM_Meeseeks_Box_Job_EmbraceTheVoid);
                }

                if (nextJob != null)
                {
                    return(new ThinkResult(nextJob, this, JobTag.MiscWork, fromQueue: false));
                }
            }

            return(ThinkResult.NoJob);
        }
        private static bool CanEquipThis(bool combat, Pawn pawn, CompMeeseeksMemory compMeeseeksMemory, Thing weapon, List <SkillDef> relevantSkills)
        {
            if (weapon.IsForbidden(pawn))
            {
                AddDebugLine("Forbidden: " + weapon.GetUniqueLoadID());
                return(false);
            }
            if (weapon.IsBurning())
            {
                AddDebugLine("Burning: " + weapon.GetUniqueLoadID());
                return(false);
            }
            if (EquipmentUtility.IsBiocoded(weapon))
            {
                AddDebugLine("Biocoded: " + weapon.GetUniqueLoadID());
                return(false);
            }
            if (!pawn.CanReserveAndReach(weapon, PathEndMode.OnCell, pawn.NormalMaxDanger()))
            {
                AddDebugLine("Can't touch this: " + weapon.GetUniqueLoadID());
                return(false);
            }
            if (!combat && !HasReleventStatModifiers(weapon, relevantSkills))
            {
                AddDebugLine("Irrelevant: " + weapon.GetUniqueLoadID());
                return(false);
            }

            return(true);
        }
            public static bool Prefix(Pawn_JobTracker __instance, Job job, ref bool __result, Pawn ___pawn)
            {
                //Logger.MessageFormat(__instance, "TryTakeOrderedJob Prefix");

                if (___pawn != null)
                {
                    CompMeeseeksMemory compMeeseeksMemory = ___pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        bool canTakeJob = compMeeseeksMemory.CanTakeOrderedJob(job);

                        //Logger.MessageFormat(__instance, "TryTakeOrderedJob Meeseeks canTakeJob: {0}", canTakeJob.ToString());

                        if (!canTakeJob)
                        {
                            __result = false;
                            return(false);
                        }
                        else
                        {
                            compMeeseeksMemory.PreTryTakeOrderedJob(job);
                        }
                    }
                }

                return(true);
            }
        public static void DespawnMeeseeks(Pawn mrMeeseeksLookAtMe)
        {
            CompMeeseeksMemory compMeeseeksMemory = mrMeeseeksLookAtMe.GetComp <CompMeeseeksMemory>();

            compMeeseeksMemory.CleanupMemory();

            Thing smoke = ThingMaker.MakeThing(ThingDefOf.Gas_Smoke);

            GenSpawn.Spawn(smoke, mrMeeseeksLookAtMe.PositionHeld, mrMeeseeksLookAtMe.MapHeld);
            MeeseeksUtility.PlayPoofOutSound(mrMeeseeksLookAtMe);

            if (mrMeeseeksLookAtMe.carryTracker.CarriedThing != null)
            {
                mrMeeseeksLookAtMe.carryTracker.TryDropCarriedThing(mrMeeseeksLookAtMe.PositionHeld, ThingPlaceMode.Near, out Thing thing);
            }
            mrMeeseeksLookAtMe.Strip();

            //ThingDef moteDef = DefDatabase<ThingDef>.GetNamedSilentFail("Mote_PsycastSkipOuterRingExit");
            //if (moteDef != null)
            //    MoteMaker.MakeAttachedOverlay(pawn, moteDef, Vector3.zero, 1.0f);

            //GenExplosion.DoExplosion(pawn.PositionHeld, pawn.MapHeld, 1.0f, DamageDefOf.Smoke, null, -1, -1f, MeeseeksDefOf.CM_Meeseeks_Box_Poof_Out, null, null, null, ThingDefOf.Gas_Smoke, 1f);
            if (mrMeeseeksLookAtMe.Corpse != null)
            {
                mrMeeseeksLookAtMe.Corpse.Destroy();
            }
            else
            {
                mrMeeseeksLookAtMe.Destroy();
            }
        }
        public override Job GetJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty)
        {
            bool wait = true;

            IntVec3 guardPosition = memory.guardPosition;

            if (memory.guardPosition.IsValid && meeseeks.Position != guardPosition)
            {
                guardPosition = RCellFinder.BestOrderedGotoDestNear(memory.guardPosition, meeseeks);
                if (guardPosition.IsValid && meeseeks.Position != guardPosition)
                {
                    wait = false;
                }
            }

            Job job = null;

            if (wait)
            {
                Logger.MessageFormat(this, "Wait");
                job = JobMaker.MakeJob(JobDefOf.Wait_Combat, memory.guardPosition);
                job.expiryInterval = 600;
            }
            else
            {
                Logger.MessageFormat(this, "Goto spot");
                job = JobMaker.MakeJob(JobDefOf.Goto, guardPosition);
                job.expiryInterval = 120;
            }

            return(job);
        }
        public override Job GetJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty)
        {
            Bill bill = jobTarget.bill;

            Logger.MessageFormat(this, "Checking for bill job...");

            if (bill == null)
            {
                return(ScanForJob(meeseeks, memory, savedJob, jobTarget, ref jobAvailabilty));
            }

            if (bill.deleted)
            {
                jobAvailabilty = JobAvailability.Complete;
                return(null);
            }

            if (bill is Bill_Medical)
            {
                return(GetMedicalBillJob(meeseeks, memory, savedJob, jobTarget, ref jobAvailabilty));
            }
            else if (bill is Bill_Production)
            {
                return(GetProductionBillJob(meeseeks, memory, savedJob, jobTarget, ref jobAvailabilty));
            }

            return(null);
        }
        public override Job GetJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty)
        {
            Job job = null;

            WorkGiver_Scanner scanner = savedJob.WorkGiverScanner;

            if (scanner != null && jobTarget != null && jobTarget.HasThing && !jobTarget.ThingDestroyed && jobTarget.Thing is Pawn)
            {
                Pawn targetPawn = jobTarget.Thing as Pawn;

                if (targetPawn.Dead)
                {
                    Logger.MessageFormat(this, "{0} dead.", targetPawn);
                    jobAvailabilty = JobAvailability.Complete;
                }
                else if (this.TrainingCompleted(meeseeks, targetPawn, jobTarget))
                {
                    jobAvailabilty = JobAvailability.Complete;
                }
                else if (targetPawn.RaceProps.EatsFood && !HasFoodToInteractAnimal(meeseeks, targetPawn))
                {
                    job = TakeFoodForAnimalInteractJob(meeseeks, targetPawn);
                }
                else if (TrainableUtility.TrainedTooRecently(targetPawn))
                {
                    jobAvailabilty = JobAvailability.Delayed;
                }
                else if (targetPawn.MapHeld != meeseeks.MapHeld)
                {
                    Logger.MessageFormat(this, "{0} not on map with {1}.", targetPawn);
                    job = ExitMapJob(meeseeks);
                }
                else if (targetPawn.Spawned)
                {
                    job = this.GetJobOnTarget(meeseeks, jobTarget, scanner);

                    if (job == null)
                    {
                        jobAvailabilty = JobAvailability.Delayed;
                    }
                }
                else
                {
                    Logger.WarningFormat(this, "Could not get handling job for {0}.", targetPawn);
                    jobAvailabilty = JobAvailability.Delayed;
                }
            }
            else
            {
                Logger.WarningFormat(this, "Unable to get scanner or target for job.");
            }

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

            return(job);
        }
Exemple #12
0
 private void CollectNewTargets(Pawn meeseeks, CompMeeseeksMemory memory, IntVec3 cell, Map map)
 {
     foreach (IntVec3 nearCell in GenAdjFast.AdjacentCellsCardinal(cell))
     {
         if (nearCell.InBounds(map) && nearCell.Roofed(map) && map.areaManager.NoRoof[nearCell])
         {
             memory.AddJobTarget(nearCell);
         }
     }
 }
        public void SetCreator(Pawn creatingPawn)
        {
            CompMeeseeksMemory creatorMemory = creatingPawn.GetComp <CompMeeseeksMemory>();

            if (creatorMemory != null)
            {
                creatorMemory.AddChildMeeseeks(Meeseeks);
            }

            creator = creatingPawn;
        }
        public override Job GetJobDelayed(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget)
        {
            Pawn targetPawn = jobTarget.Thing as Pawn;

            Job job = JobMaker.MakeJob(MeeseeksDefOf.CM_Meeseeks_Box_Job_WaitNear, targetPawn);

            job.locomotionUrgency     = LocomotionUrgency.Walk;
            job.checkOverrideOnExpire = true;
            job.expiryInterval        = 120;
            return(job);
        }
Exemple #15
0
            public static void Postfix(WorkGiver_Train __instance, Pawn pawn, Thing t, bool forced, Job __result)
            {
                if (__result != null && forced)
                {
                    CompMeeseeksMemory memory = pawn.GetComp <CompMeeseeksMemory>();

                    if (memory != null)
                    {
                        memory.AddToPotentialTargetCache(__instance, t);
                    }
                }
            }
        private Job GetMedicalBillJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty)
        {
            Bill_Medical bill = jobTarget.bill as Bill_Medical;
            Job          job  = null;

            if (jobTarget != null && jobTarget.HasThing && !jobTarget.ThingDestroyed && jobTarget.Thing is Pawn && !(jobTarget.Thing as Pawn).Dead)
            {
                Pawn targetPawn = jobTarget.Thing as Pawn;
                if (targetPawn == null || targetPawn.Dead || !bill.CompletableEver)
                {
                    bill.deleted   = true;
                    jobAvailabilty = JobAvailability.Complete;
                }
                else
                {
                    MeeseeksBillStorage billStorage = Current.Game.World.GetComponent <MeeseeksBillStorage>();
                    BillStack           billStack   = targetPawn.BillStack;

                    jobAvailabilty = JobAvailability.Delayed;

                    if (targetPawn.UsableForBillsAfterFueling() && meeseeks.CanReserve(targetPawn, 1, -1, null, true))
                    {
                        List <ThingCount> chosenIngredients = new List <ThingCount>();
                        // Screw you I need this function
                        bool result = (bool)typeof(WorkGiver_DoBill).GetMethod("TryFindBestBillIngredients", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, new object[] { bill, meeseeks, targetPawn, chosenIngredients });

                        if (result)
                        {
                            Job haulOffJob;
                            job = WorkGiver_DoBill.TryStartNewDoBillJob(meeseeks, bill, targetPawn, chosenIngredients, out haulOffJob);
                            bill.billStack.billGiver = targetPawn as IBillGiver;
                        }

                        if (job == null)
                        {
                            jobAvailabilty = JobAvailability.Delayed;
                        }
                        else
                        {
                            jobAvailabilty = JobAvailability.Available;
                        }
                    }
                }
            }
            else
            {
                bill.deleted   = true;
                jobAvailabilty = JobAvailability.Complete;
            }

            return(job);
        }
            public static void Prefix(Pawn_JobTracker __instance, JobCondition condition, Pawn ___pawn)
            {
                //Logger.MessageFormat(__instance, "EndCurrentJob Prefix");

                if (___pawn != null)
                {
                    CompMeeseeksMemory compMeeseeksMemory = ___pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        compMeeseeksMemory.EndCurrentJob(__instance.curJob, __instance.curDriver, condition);
                    }
                }
            }
            public static void Finalizer(Pawn_JobTracker __instance, Job newJob, Pawn ___pawn)
            {
                //Logger.MessageFormat(__instance, "StartJob Postfix");

                if (___pawn != null)
                {
                    CompMeeseeksMemory compMeeseeksMemory = ___pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        compMeeseeksMemory.PostStartJob(newJob, __instance.curDriver);
                    }
                }
            }
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                return(null);
            }
            if (pawn.GetRegion() == null)
            {
                return(null);
            }

            CompMeeseeksMemory memory = pawn.GetComp <CompMeeseeksMemory>();

            if (memory == null || !memory.guardPosition.IsValid)
            {
                return(null);
            }

            Job job = null;

            Thing target = this.FindAttackTarget(pawn);

            if (target == null)
            {
                return(null);
            }

            // Melee attack if it is adjacent
            job = TryMeleeAttackTargetJob(pawn, target);

            // Shoot it if we can
            if (job == null)
            {
                job = TryRangedAttackTargetJob(pawn, target);
            }

            // Otherwise approach
            if (job == null)
            {
                job = GoNearTarget(pawn, target);
            }

            if (job != null)
            {
                job.locomotionUrgency = PawnUtility.ResolveLocomotion(pawn, LocomotionUrgency.Sprint, LocomotionUrgency.Walk);
            }

            return(job);
        }
        public override Job GetJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty)
        {
            Job job = null;

            ConstructionStatus status = jobTarget.TargetConstructionStatus(meeseeks.MapHeld);

            Logger.MessageFormat(this, "Checking for blocker, construction status: {0}", status);

            if (status == ConstructionStatus.None)
            {
                BuildableDef buildableDef = jobTarget.BuildableDef;

                if (buildableDef != null && GenConstruct.PlaceBlueprintForBuild(buildableDef, jobTarget.Cell, meeseeks.MapHeld, jobTarget.blueprintRotation, meeseeks.Faction, jobTarget.blueprintStuff) != null)
                {
                    status = ConstructionStatus.InProgress;
                }
            }

            if (status == ConstructionStatus.Blocked)
            {
                job = GetDeconstructingJob(meeseeks, jobTarget, meeseeks.MapHeld);
                if (job == null)
                {
                    jobAvailabilty = JobAvailability.Delayed;
                }
                else
                {
                    jobAvailabilty = JobAvailability.Available;
                }
            }
            else if (status == ConstructionStatus.InProgress)
            {
                job = ScanForJob(meeseeks, memory, savedJob, jobTarget, ref jobAvailabilty, true);
                if (job == null)
                {
                    jobAvailabilty = JobAvailability.Delayed;
                }
                else
                {
                    jobAvailabilty = JobAvailability.Available;
                }
            }
            else if (status == ConstructionStatus.Complete)
            {
                jobAvailabilty = JobAvailability.Complete;
            }

            return(job);
        }
        public override Job GetJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty)
        {
            Map map = meeseeks.MapHeld;
            Job job = ScanForJob(meeseeks, memory, savedJob, jobTarget, ref jobAvailabilty);

            // Mark them now because building a roof will cover most if them, and we will need a chance to check their neighbors
            CollectNewTargets(meeseeks, memory, jobTarget.Cell, map);

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

            return(job);
        }
            public static void Postfix(Pawn_JobTracker __instance, Job job, ref bool __result, Pawn ___pawn)
            {
                //Logger.MessageFormat(__instance, "TryTakeOrderedJob Postfix");

                if (___pawn != null)
                {
                    CompMeeseeksMemory compMeeseeksMemory = ___pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        //Logger.MessageFormat(__instance, "Meeseeks TookOrderedJob");
                        compMeeseeksMemory.PostTryTakeOrderedJob(__result, job);
                    }
                }
            }
            public static bool Prefix(Pawn_DraftController __instance, bool ___draftedInt)
            {
                //Logger.MessageFormat(__instance, "Drafted Prefix");

                if (__instance.pawn != null && ___draftedInt)
                {
                    CompMeeseeksMemory compMeeseeksMemory = __instance.pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        return(false);
                    }
                }

                return(true);
            }
            static Exception Finalizer(Exception __exception, Vector3 clickPos, Pawn pawn)
            {
                // Time to clean up our mess
                if (pawn != null)
                {
                    CompMeeseeksMemory compMeeseeksMemory = pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        IntVec3 cell = IntVec3.FromVector3(clickPos);
                        DesignatorUtility.RestoreDesignationsOnCell(cell, pawn.MapHeld);
                    }
                }

                return(__exception);
            }
            public static void Prefix(Pawn_JobTracker __instance, ref Job job, WorkGiver giver, Pawn ___pawn)
            {
                //Logger.MessageFormat(__instance, "TryTakeOrderedJobPrioritizedWork Prefix");

                if (___pawn != null)
                {
                    CompMeeseeksMemory compMeeseeksMemory = ___pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        // I don't see any reason why this shouldn't always be the case, but we'll only do it for Meeseeks just to minimize potential impact
                        job.workGiverDef = giver.def;
                        //Logger.MessageFormat(__instance, "Assigned workgiver def");
                    }
                }
            }
            public static IEnumerable <Gizmo> Postfix(IEnumerable <Gizmo> gizmos, Pawn __instance)
            {
                List <Gizmo> gizmoList = gizmos.ToList();

                //Logger.MessageFormat(__instance, "GetGizmos Postfix");

                CompMeeseeksMemory compMeeseeksMemory = __instance.GetComp <CompMeeseeksMemory>();

                if (__instance.IsColonistPlayerControlled && compMeeseeksMemory != null)
                {
                    gizmoList.Clear();

                    if (compMeeseeksMemory.HasTimeToQueueNewJob())
                    {
                        // First add our own gizmo for queueing jobs in an area - IF the job's workgiver is a scanner type
                        if (compMeeseeksMemory.savedJob != null && compMeeseeksMemory.savedJob.workGiverDef != null && compMeeseeksMemory.savedJob.workGiverDef.Worker as WorkGiver_Scanner != null)
                        {
                            yield return(new Designator_AreaWorkMeeseeks(__instance));
                        }

                        string clearCommandLabel = "CommandClearPrioritizedWork".Translate();

                        List <Gizmo> priorityGizmos = __instance.mindState.priorityWork.GetGizmos().ToList();
                        //Logger.MessageFormat(__instance, "Meeseeks GetGizmos, priority gizmo count: {0}", priorityGizmos.Count);

                        // This is specifically to allow Achtung's increase/decrease priority gizmos
                        // TODO: Check for Achtung and do this more on purpose
                        foreach (Gizmo gizmo in priorityGizmos)
                        {
                            Command_Action commandAction = gizmo as Command_Action;
                            if (commandAction == null || commandAction.defaultLabel != clearCommandLabel)
                            {
                                yield return(gizmo);
                            }
                            else
                            {
                                //Logger.MessageFormat(__instance, "Meeseeks GetGizmos - Skipping gizmo");
                            }
                        }
                    }
                }

                foreach (Gizmo gizmo in gizmoList)
                {
                    yield return(gizmo);
                }
            }
Exemple #27
0
        protected Job ScanForJob(Pawn meeseeks, CompMeeseeksMemory memory, SavedJob savedJob, SavedTargetInfo jobTarget, ref JobAvailability jobAvailabilty, bool scanAllThingsOnCell = false)
        {
            Job job = null;

            if (savedJob.workGiverDef != null && savedJob.workGiverDef.Worker != null)
            {
                WorkGiver_Scanner workGiverScanner = savedJob.workGiverDef.Worker as WorkGiver_Scanner;
                if (workGiverScanner != null)
                {
                    List <WorkGiver_Scanner> workGivers = WorkerDefUtility.GetCombinedWorkGiverScanners(workGiverScanner);

                    foreach (WorkGiver_Scanner scanner in workGivers)
                    {
                        job = this.GetJobOnTarget(meeseeks, jobTarget, scanner, scanAllThingsOnCell);

                        if (job != null)
                        {
                            if (memory.JobStuckRepeat(job))
                            {
                                Logger.ErrorFormat(this, "Stuck job detected and removed on {0}.", jobTarget);
                                jobAvailabilty = JobAvailability.Delayed;
                                job            = null;
                            }
                            else
                            {
                                //Logger.MessageFormat(this, "Job WAS found for {0}.", scanner.def.defName);
                                jobAvailabilty = JobAvailability.Available;
                                return(job);
                            }
                        }

                        //Logger.MessageFormat(this, "No {0} job found.", scanner.def.defName);
                    }
                }
                else
                {
                    Logger.WarningFormat(this, "No work scanner");
                }
            }
            else
            {
                Logger.WarningFormat(this, "Missing saved job workGiverDef or Worker for savedJob: {0}", savedJob.def.defName);
            }

            return(job);
        }
            public static bool Prefix(WorkGiver_HunterHunt __instance, Pawn pawn, ref bool __result)
            {
                //Logger.MessageFormat(__instance, "Prefix");

                if (pawn != null)
                {
                    CompMeeseeksMemory compMeeseeksMemory = pawn.GetComp <CompMeeseeksMemory>();

                    if (compMeeseeksMemory != null)
                    {
                        __result = false;
                        return(false);
                    }
                }

                return(true);
            }
Exemple #29
0
        public Designator_AreaWorkMeeseeks(Pawn mrMeeseeksLookAtMe)
        {
            defaultLabel = "CM_Meeseeks_Box_SelectJobAreaLabel".Translate();
            defaultDesc  = "CM_Meeseeks_Box_SelectJobAreaDescription".Translate();
            icon         = ContentFinder <Texture2D> .Get("Icons/SelectTargets");

            soundDragSustain = SoundDefOf.Designate_DragStandard;
            soundDragChanged = SoundDefOf.Designate_DragStandard_Changed;
            useMouseIcon     = true;
            soundSucceeded   = SoundDefOf.Designate_Harvest;
            Meeseeks         = mrMeeseeksLookAtMe;
            Memory           = Meeseeks.GetComp <CompMeeseeksMemory>();

            hasDesignateAllFloatMenuOption = true;
            designateAllLabel      = "CM_Meeseeks_Box_Select_All_Additional_Targets".Translate();
            designateAllOnMapLabel = "CM_Meeseeks_Box_Select_All_Additional_Targets_In_Home".Translate();
        }
        public override bool StateCanOccur(Pawn pawn)
        {
            if (!base.StateCanOccur(pawn))
            {
                return(false);
            }

            if (!pawn.SpawnedOrAnyParentSpawned)
            {
                return(false);
            }

            CompMeeseeksMemory memory = pawn.GetComp <CompMeeseeksMemory>();

            if (memory == null)
            {
                return(false);
            }

            // If our creator is a Meeseeks, try his creator and so on until we get a target
            Pawn creator = memory.Creator;

            // If we have no creator, um, just go ahead and we'll figure this out later
            if (!TargetIsValid(pawn, creator))
            {
                return(true);
            }

            CompMeeseeksMemory creatorMemory = creator.GetComp <CompMeeseeksMemory>();

            while (creator != null && creatorMemory != null)
            {
                creator = creatorMemory.Creator;
                if (creator == null)
                {
                    creatorMemory = null;
                }
                else
                {
                    creatorMemory = creator.GetComp <CompMeeseeksMemory>();
                }
            }

            return(this.TargetIsValid(pawn, creator));
        }