예제 #1
0
        public override void Entry()
        {
            this.ai            = new AI_StateMachine(this.StateMachine, this.StateMachine.CompanionManager.Hud, this.Events, this.monitor);
            this.timeOfRecruit = Game1.timeOfDay;

            if (this.StateMachine.Companion.doingEndOfRouteAnimation.Value)
            {
                this.FinishScheduleAnimation();
            }

            this.StateMachine.Companion.faceTowardFarmerTimer = 0;
            this.StateMachine.Companion.movementPause         = 0;
            this.StateMachine.Companion.followSchedule        = false;
            this.StateMachine.Companion.Schedule            = null;
            this.StateMachine.Companion.controller          = null;
            this.StateMachine.Companion.temporaryController = null;
            this.StateMachine.Companion.eventActor          = true;
            this.StateMachine.Companion.farmerPassesThrough = true;

            this.Events.GameLoop.UpdateTicked   += this.GameLoop_UpdateTicked;
            this.Events.GameLoop.TimeChanged    += this.GameLoop_TimeChanged;
            this.Events.Player.Warped           += this.Player_Warped;
            this.Events.Input.ButtonPressed     += this.Input_ButtonPressed;
            this.SpecialEvents.RenderedLocation += this.SpecialEvents_RenderedLocation;

            this.recruitedDialogue = DialogueHelper.GenerateDialogue(this.StateMachine.Companion, "companionRecruited");
            this.CanPerformAction  = true;

            if (this.recruitedDialogue != null)
            {
                this.StateMachine.Companion.CurrentDialogue.Push(this.recruitedDialogue);
            }

            foreach (string skill in this.StateMachine.Metadata.PersonalSkills)
            {
                string text = this.StateMachine.ContentLoader.LoadString($"Strings/Strings:skill.{skill}", this.StateMachine.Companion.displayName)
                              + Environment.NewLine
                              + this.StateMachine.ContentLoader.LoadString($"Strings/Strings:skillDescription.{skill}").Replace("#", Environment.NewLine);
                this.StateMachine.CompanionManager.Hud.AddSkill(skill, text);
            }

            this.StateMachine.CompanionManager.Hud.AssignCompanion(this.StateMachine.Companion);
            this.BuffManager.AssignBuffs();
            this.ai.Setup();

            if (this.BuffManager.HasProsthetics())
            {
                var key  = this.StateMachine.CompanionManager.Config.ChangeBuffButton;
                var desc = this.StateMachine.ContentLoader.LoadString("Strings/Strings:prosteticsChangeButton", key, this.StateMachine.Companion.displayName);
                this.StateMachine.CompanionManager.Hud.AddKey(key, desc);
            }
        }
예제 #2
0
        private Dialogue GenerateLocationDialogue(GameLocation location, NPC companion)
        {
            if (DialogueHelper.GenerateStaticDialogue(companion, location, "companionOnce") is CompanionDialogue dialogueOnce &&
                !this.StateMachine.CompanionManager.Farmer.hasOrWillReceiveMail(dialogueOnce.Tag))
            {
                // Remember only once spoken dialogue
                dialogueOnce.Remember = true;
                return(dialogueOnce);
            }

            // Generate standard companion various dialogue if no once dialogue defined or once dialogue spoken
            return(DialogueHelper.GenerateDialogue(companion, location, "companion"));
        }
예제 #3
0
        public Dialogue GenerateLocationDialogue(GameLocation location, string suffix = "")
        {
            NPC companion = this.Companion;

            // Try generate only once spoken dialogue in game save
            if (DialogueHelper.GenerateStaticDialogue(companion, location, $"companionOnce{suffix}") is CompanionDialogue dialogueOnce &&
                !this.CompanionManager.Farmer.hasOrWillReceiveMail(dialogueOnce.Tag))
            {
                // Remember only once spoken dialogue (as received mail. Keep it forever in loaded game after game saved)
                dialogueOnce.Remember = true;
                return(dialogueOnce);
            }

            // Try generate standard companion various dialogue. This dialogue can be shown only once per day (per recruited companion session)
            if (DialogueHelper.GenerateDialogue(companion, location, $"companion{suffix}") is CompanionDialogue dialogue && !this.SpokenDialogues.Contains(dialogue.Tag))
            {
                dialogue.SpecialAttributes.Add("session"); // Remember this dialogue in this companion session when will be spoken
                return(dialogue);
            }

            // Try generate dialogue which can be shown repeately in day (current companion session). If none defined, returns null
            return(DialogueHelper.GenerateDialogue(companion, location, "companionRepeat"));
        }
예제 #4
0
        private bool TryPushLocationDialogue(GameLocation location)
        {
            NPC              companion   = this.StateMachine.Companion;
            Dialogue         newDialogue = DialogueHelper.GenerateDialogue(companion, location, "companion");
            Stack <Dialogue> temp        = new Stack <Dialogue>(this.StateMachine.Companion.CurrentDialogue.Count);

            if ((newDialogue == null && this.currentLocationDialogue == null) || (newDialogue != null && newDialogue.Equals(this.currentLocationDialogue)))
            {
                return(false);
            }

            // Remove old location dialogue
            while (this.StateMachine.Companion.CurrentDialogue.Count > 0)
            {
                Dialogue d = this.StateMachine.Companion.CurrentDialogue.Pop();

                if (!d.Equals(this.currentLocationDialogue))
                {
                    temp.Push(d);
                }
            }

            while (temp.Count > 0)
            {
                this.StateMachine.Companion.CurrentDialogue.Push(temp.Pop());
            }

            this.currentLocationDialogue = newDialogue;

            if (newDialogue != null)
            {
                this.StateMachine.Companion.CurrentDialogue.Push(newDialogue); // Push new location dialogue
                return(true);
            }

            return(false);
        }