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();
            }
        }
예제 #2
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);
                }));
            }
        }
        private void SpawnMeeseeks(Pawn creator)
        {
            if (!Prefs.DevMode || !MeeseeksMod.settings.screenShotDebug)
            {
                cooldownTicksRemaining = cooldownTicksTotal;
            }

            MeeseeksUtility.SpawnMeeseeks(creator, parent, creator.MapHeld);
        }
        public override void PostDestroy(DestroyMode mode, Map previousMap)
        {
            base.PostDestroy(mode, previousMap);

            if (Meeseeks.Dead && !destroyed)
            {
                destroyed = true;
                Logger.MessageFormat(this, "Meeseeks dead. Vanishing.");
                MeeseeksUtility.DespawnMeeseeks(Meeseeks);
            }
        }
        public override void CompTick()
        {
            base.CompTick();

            if (Meeseeks.Downed && !destroyed)
            {
                destroyed = true;
                Logger.MessageFormat(this, "Meeseeks downed. Vanishing.");
                MeeseeksUtility.DespawnMeeseeks(Meeseeks);
            }
        }
        private void JobStarted(Job job)
        {
            if (givenTask || !job.playerForced || freeJobs.Contains(job.def))
            {
                return;
            }


            givenTask     = true;
            startedTask   = true;
            givenTaskTick = Find.TickManager.TicksGame;

            if (!playedAcceptSound)
            {
                MeeseeksUtility.PlayAcceptTaskSound(this.parent, voice);
                playedAcceptSound = true;
            }

            savedJob = new SavedJob(job);

            if (job.workGiverDef != null && job.workGiverDef.Worker != null && potentialTargetCache.ContainsKey(job.workGiverDef.Worker))
            {
                AddJobTarget(new SavedTargetInfo(potentialTargetCache[job.workGiverDef.Worker]), true);
            }
            else
            {
                TargetIndex targetIndex = GetJobPrimaryTarget(job);

                if (targetIndex != TargetIndex.None)
                {
                    AddJobTarget(new SavedTargetInfo(job.GetTarget(targetIndex)), true);
                }
                else
                {
                    Logger.MessageFormat(this, "No target found for {0}", job.def.defName);
                }
            }

            potentialTargetCache.Clear();
        }
        public void CopyJobDataFrom(CompMeeseeksMemory otherMemory)
        {
            if (otherMemory.givenTask)
            {
                jobTargets = new List <SavedTargetInfo>(otherMemory.jobTargets);

                givenTask     = otherMemory.givenTask;
                startedTask   = otherMemory.startedTask;
                taskCompleted = otherMemory.taskCompleted;

                savedJob = new SavedJob(otherMemory.savedJob.MakeJob());

                givenTaskTick = Find.TickManager.TicksGame;

                guardPosition = otherMemory.guardPosition;
                if (guardPosition.IsValid)
                {
                    ((Pawn)parent).drafter.Drafted = true;
                }

                MeeseeksUtility.PlayAcceptTaskSound(this.parent, voice);
            }
        }
        public override void PostStart(string reason)
        {
            base.PostStart(reason);

            Logger.MessageFormat(this, "Meeseeks attempting to incite other Meeseeks to join in killing the creator.");

            Faction meeseeksFaction = FactionUtility.DefaultFactionFrom(MeeseeksDefOf.CM_Meeseeks_Box_Faction_Hostile_Meeseeks);

            if (meeseeksFaction == null)
            {
                meeseeksFaction = Faction.OfAncientsHostile;
            }

            Lord lord = LordMaker.MakeNewLord(meeseeksFaction, new LordJob_MeeseeksKillCreator(target), pawn.MapHeld);

            // Now add all the meeseeks in this tree to the list
            List <Pawn> foundMeeseeks = new List <Pawn> {
                grandCreatorMeeseeks
            };
            List <Pawn> accumulatedMeeseeks = new List <Pawn>();

            while (foundMeeseeks.Count > 0)
            {
                foreach (Pawn meeseeks in foundMeeseeks)
                {
                    meeseeks.SetFaction(meeseeksFaction);

                    CompMeeseeksMemory meeseeksMemory = meeseeks.GetComp <CompMeeseeksMemory>();

                    // Set job memory, wont be using it in this lord, but set it anyway for debugging purposes
                    Job newJob = JobMaker.MakeJob(MeeseeksDefOf.CM_Meeseeks_Box_Job_Kill, target);
                    newJob.workGiverDef = MeeseeksDefOf.CM_Meeseeks_Box_WorkGiver_Kill;
                    meeseeksMemory.ForceNewJob(newJob, target);

                    // Put in new lrd
                    meeseeks.GetLord()?.Notify_PawnLost(meeseeks, PawnLostCondition.ChangedFaction);
                    lord.AddPawn(meeseeks);

                    accumulatedMeeseeks.AddRange(meeseeks.GetComp <CompMeeseeksMemory>().CreatedMeeseeks);
                }

                foundMeeseeks = new List <Pawn>(accumulatedMeeseeks);
                accumulatedMeeseeks.Clear();
            }

            CompMeeseeksMemory grandCreatorMeeseeksMemory = grandCreatorMeeseeks.GetComp <CompMeeseeksMemory>();

            MeeseeksUtility.PlayCriticalBreakSound(grandCreatorMeeseeks, grandCreatorMeeseeksMemory.Voice);

            // Since we changed the Meeseeks' faction, we need to make our own letter
            string letterText = this.GetBeginLetterText();

            if (!letterText.NullOrEmpty())
            {
                string letterLabel = (def.beginLetterLabel ?? ((string)def.LabelCap)).CapitalizeFirst();
                if (!reason.NullOrEmpty())
                {
                    letterText = letterText + "\n\n" + reason;
                }
                Find.LetterStack.ReceiveLetter(letterLabel, letterText, def.beginLetterDef, grandCreatorMeeseeks);
            }
        }
        public static void SpawnMeeseeks(Pawn creator, ThingWithComps creatingThing, Map map)
        {
            PawnKindDef pawnKindDef = MeeseeksDefOf.MeeseeksKind;

            Pawn mrMeeseeksLookAtMe = PawnGenerator.GeneratePawn(pawnKindDef, Faction.OfPlayer);

            lastCreatedMeeseeks = mrMeeseeksLookAtMe;

            QualityCategory boxQuality = QualityCategory.Normal;

            creatingThing.TryGetQuality(out boxQuality);

            int qualityInt = (int)boxQuality;

            float multiplier = ((float)qualityInt + 1.0f) / ((int)QualityCategory.Legendary + 1);
            int   skillLevel = Mathf.RoundToInt(multiplier * multiplier * 20.0f);

            // Enable all work types
            foreach (WorkTypeDef item in from w in DefDatabase <WorkTypeDef> .AllDefs
                     where !w.alwaysStartActive && !mrMeeseeksLookAtMe.WorkTypeIsDisabled(w)
                     select w)
            {
                // Our patch overrides the priority, but we need to make sure they are all on
                mrMeeseeksLookAtMe.workSettings.SetPriority(item, 3);
            }

            foreach (SkillRecord skill in mrMeeseeksLookAtMe.skills.skills)
            {
                skill.Level   = skillLevel;
                skill.passion = Passion.None;
            }

            // Max out needs
            foreach (Need need in mrMeeseeksLookAtMe.needs.AllNeeds)
            {
                if (need.def.defName != "Mood")
                {
                    need.CurLevelPercentage = 1.0f;
                }
            }

            IntVec3 summonPosition = MeeseeksUtility.FindSpawnPosition(creatingThing);

            GenSpawn.Spawn(mrMeeseeksLookAtMe, summonPosition, map);
            mrMeeseeksLookAtMe.Rotation = Rot4.South;

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

            compMeeseeksMemory.SetQuality(boxQuality);
            compMeeseeksMemory.SetCreator(creator);

            // The voices for greeting and task acceptance can overlap depending on the speed the game is running,
            //   especially if another Meeseeks created us, so just don't do it in that case
            CompMeeseeksMemory creatorMemory = creator.GetComp <CompMeeseeksMemory>();
            bool creatorIsMeeseeks           = creatorMemory != null;

            if (!creatorIsMeeseeks)
            {
                MeeseeksUtility.PlayGreetingSound(mrMeeseeksLookAtMe, compMeeseeksMemory.Voice);
            }
            else
            {
                compMeeseeksMemory.temporarilyBlockTask = true;
            }

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

            GenSpawn.Spawn(smoke, summonPosition, map);
            MeeseeksUtility.PlayPoofInSound(smoke);

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

            //GenExplosion.DoExplosion(mrMeeseeksLookAtMe.PositionHeld, mrMeeseeksLookAtMe.MapHeld, 1.0f, DamageDefOf.Smoke, null, -1, -1f, MeeseeksDefOf.CM_Meeseeks_Box_Poof_In, null, null, null, ThingDefOf.Gas_Smoke, 1f);

            GlobalTargetInfo meeseeksGlobalTarget = new GlobalTargetInfo(mrMeeseeksLookAtMe);

            if (!creatorIsMeeseeks && creator.IsColonistPlayerControlled && MeeseeksMod.settings.cameraJumpOnCreation)
            {
                CameraJumper.TryJump(meeseeksGlobalTarget);
            }

            if (!creatorIsMeeseeks && MeeseeksMod.settings.autoSelectOnCreation)
            {
                CameraJumper.TrySelect(meeseeksGlobalTarget);
            }

            if (!creatorIsMeeseeks && MeeseeksMod.settings.autoPauseOnCreation)
            {
                Find.TickManager.Pause();
            }
        }