Пример #1
0
 public AdventureBegins(ISpecialModEvents modEvents, IModEvents gameEvents, IContentLoader contentLoader, IMonitor monitor) : base()
 {
     this.modEvents     = modEvents;
     this.gameEvents    = gameEvents;
     this.contentLoader = contentLoader;
     this.monitor       = monitor;
 }
Пример #2
0
 public AdventureBegins(ISpecialModEvents modEvents, IQuestFrameworkEvents questEvents, IModEvents gameEvents, IContentLoader contentLoader, Config config, IMonitor monitor) : base()
 {
     this.modEvents     = modEvents;
     this.questEvents   = questEvents;
     this.gameEvents    = gameEvents;
     this.contentLoader = contentLoader;
     this.config        = config;
     this.monitor       = monitor;
 }
Пример #3
0
        internal static void Setup(HarmonyInstance harmony, ISpecialModEvents events)
        {
            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), "draw"),
                postfix: new HarmonyMethod(typeof(GameLocationDrawPatch), nameof(GameLocationDrawPatch.Postfix))
                );

            GameLocationDrawPatch.events = events as SpecialModEvents;
        }
Пример #4
0
        private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
        {
            // Setup third party mod compatibility bridge
            TPMC.Setup(this.Helper.ModRegistry);

            // Mod's services and drivers
            this.SpecialEvents    = new SpecialModEvents();
            this.DialogueDriver   = new DialogueDriver(this.Helper.Events);
            this.HintDriver       = new HintDriver(this.Helper.Events);
            this.StuffDriver      = new StuffDriver(this.Helper.Data, this.Monitor);
            this.contentLoader    = new ContentLoader(this.Helper.Content, this.Helper.ContentPacks, this.ModManifest.UniqueID, "assets", this.Helper.DirectoryPath, this.Monitor);
            this.companionHud     = new CompanionDisplay(this.config, this.contentLoader);
            this.companionManager = new CompanionManager(this.DialogueDriver, this.HintDriver, this.companionHud, this.config, this.Monitor);
            this.StuffDriver.RegisterEvents(this.Helper.Events);

            // Harmony
            HarmonyInstance harmony = HarmonyInstance.Create("Purrplingcat.NpcAdventure");

            Patches.SpouseReturnHomePatch.Setup(harmony);
            Patches.CompanionSayHiPatch.Setup(harmony, this.companionManager);
            Patches.GameLocationDrawPatch.Setup(harmony, this.SpecialEvents);
        }
Пример #5
0
 public RecruitedState(CompanionStateMachine stateMachine, IModEvents events, ISpecialModEvents specialEvents, IMonitor monitor) : base(stateMachine, events, monitor)
 {
     this.BuffManager   = new BuffManager(stateMachine.Companion, stateMachine.CompanionManager.Farmer, stateMachine.ContentLoader, this.monitor);
     this.SpecialEvents = specialEvents;
 }
Пример #6
0
        /// <summary>
        /// Companion initializator. Call it after saved game is loaded
        /// </summary>
        /// <param name="loader"></param>
        /// <param name="gameEvents"></param>
        /// <param name="reflection"></param>
        public void InitializeCompanions(IContentLoader loader, IModEvents gameEvents, ISpecialModEvents specialEvents, IReflectionHelper reflection)
        {
            Dictionary <string, string> dispositions = loader.Load <Dictionary <string, string> >("Data/CompanionDispositions");

            foreach (string npcName in dispositions.Keys)
            {
                NPC companion = Game1.getCharacterFromName(npcName, true);

                if (companion == null)
                {
                    throw new Exception($"Can't find NPC with name '{npcName}'");
                }

                CompanionStateMachine csm = new CompanionStateMachine(this, companion, new CompanionMetaData(dispositions[npcName]), loader, reflection, this.monitor);
                Dictionary <StateFlag, ICompanionState> stateHandlers = new Dictionary <StateFlag, ICompanionState>()
                {
                    [StateFlag.RESET]       = new ResetState(csm, gameEvents, this.monitor),
                    [StateFlag.AVAILABLE]   = new AvailableState(csm, gameEvents, this.monitor),
                    [StateFlag.RECRUITED]   = new RecruitedState(csm, gameEvents, specialEvents, this.monitor),
                    [StateFlag.UNAVAILABLE] = new UnavailableState(csm, gameEvents, this.monitor),
                };

                csm.Setup(stateHandlers);
                this.PossibleCompanions.Add(npcName, csm);
            }

            this.monitor.Log($"Initalized {this.PossibleCompanions.Count} companions.", LogLevel.Info);
        }
Пример #7
0
 public RecruitedState(CompanionStateMachine stateMachine, IModEvents events, ISpecialModEvents specialEvents, IMonitor monitor) : base(stateMachine, events, monitor)
 {
     this.BuffManager   = new BuffManager(stateMachine.Companion, stateMachine.CompanionManager.Farmer, stateMachine.ContentLoader, this.monitor);
     this.SpecialEvents = specialEvents;
     this.TimeToBye     = 2200; // Companions auto-dismiss at 10pm, except married (see end of Entry() method)
 }
Пример #8
0
 internal void RegisterEvents(ISpecialModEvents events)
 {
     events.MailboxOpen += this.Events_MailboxOpen;
 }
Пример #9
0
        /// <summary>
        /// Companion initializator. Call it after saved game is loaded
        /// </summary>
        /// <param name="loader"></param>
        /// <param name="gameEvents"></param>
        /// <param name="reflection"></param>
        public void InitializeCompanions(IContentLoader loader, IModEvents gameEvents, ISpecialModEvents specialEvents, IReflectionHelper reflection)
        {
            Dictionary <string, string> dispositions = loader.LoadData <string, string>("Data/CompanionDispositions");

            foreach (string npcName in dispositions.Keys)
            {
                NPC companion = Game1.getCharacterFromName(npcName, true);

                if (companion == null)
                {
                    this.monitor.Log($"Unable to initialize companion `{npcName}`, because this NPC cannot be found in the game. " +
                                     "Are you trying to add a custom NPC as a companion? Check the mod which adds this NPC into the game. " +
                                     "Don't report this as a bug to NPC Adventures unless it's a vanilla game NPC.", LogLevel.Error);
                    continue;
                }

                CompanionStateMachine csm = new CompanionStateMachine(this, companion, new CompanionMetaData(dispositions[npcName]), loader, reflection, this.monitor);
                Dictionary <StateFlag, ICompanionState> stateHandlers = new Dictionary <StateFlag, ICompanionState>()
                {
                    [StateFlag.RESET]       = new ResetState(csm, gameEvents, this.monitor),
                    [StateFlag.AVAILABLE]   = new AvailableState(csm, gameEvents, this.monitor),
                    [StateFlag.RECRUITED]   = new RecruitedState(csm, gameEvents, specialEvents, this.monitor),
                    [StateFlag.UNAVAILABLE] = new UnavailableState(csm, gameEvents, this.monitor),
                };

                csm.Setup(stateHandlers);
                this.PossibleCompanions.Add(npcName, csm);
            }

            this.monitor.Log($"Initalized {this.PossibleCompanions.Count} companions.", LogLevel.Info);
        }
Пример #10
0
        /// <summary>
        /// Companion initializator. Call it after saved game is loaded
        /// </summary>
        /// <param name="loader"></param>
        /// <param name="gameEvents"></param>
        /// <param name="reflection"></param>
        public void InitializeCompanions(IContentLoader loader, IModEvents gameEvents, ISpecialModEvents specialEvents, IReflectionHelper reflection)
        {
            Dictionary <string, string> dispositions = loader.LoadData <string, string>("Data/CompanionDispositions");

            foreach (string npcName in dispositions.Keys)
            {
                CompanionStateMachine csm = new CompanionStateMachine(npcName, this, new CompanionMetaData(dispositions[npcName]), loader, reflection, this.monitor);
                Dictionary <StateFlag, ICompanionState> stateHandlers = new Dictionary <StateFlag, ICompanionState>()
                {
                    [StateFlag.RESET]       = new ResetState(csm, gameEvents, this.monitor),
                    [StateFlag.AVAILABLE]   = new AvailableState(csm, gameEvents, this.monitor),
                    [StateFlag.RECRUITED]   = new RecruitedState(csm, gameEvents, specialEvents, this.monitor),
                    [StateFlag.UNAVAILABLE] = new UnavailableState(csm, gameEvents, this.monitor),
                };

                csm.Setup(stateHandlers);
                this.PossibleCompanions.Add(npcName, csm);
            }

            this.monitor.Log($"Initalized {this.PossibleCompanions.Count} companions.", LogLevel.Info);
        }
Пример #11
0
 public QuestScenario(ISpecialModEvents events, IContentLoader contentLoader, IMonitor monitor)
 {
     this.events        = events;
     this.contentLoader = contentLoader;
     this.monitor       = monitor;
 }