Exemplo n.º 1
0
        /*********
        ** Public methods
        *********/

        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            // Read config.
            this.config = new ConfigManager(this.Helper).GetConfig();

            // Create helper classes that make the mod work.
            ErrorQueue        errorQueue = new ErrorQueue(this.Monitor);
            ContentPackLoader packLoader = new ContentPackLoader(this.Helper, this.Monitor, errorQueue);

            this.serializer          = new DoorPositionSerializer(this.Helper.Data);
            this.timer               = new CallbackTimer();
            this.doorTileInfoManager = new GeneratedDoorTileInfoManager();
            this.generator           = new DoorSpriteGenerator(this.doorTileInfoManager, packLoader.LoadContentPacks(), this.Helper.Multiplayer.ModID, this.Monitor, Game1.graphics.GraphicsDevice);
            this.creator             = new DoorCreator(this.doorTileInfoManager, this.timer, errorQueue, this.Helper.ModRegistry.Get(this.Helper.ModRegistry.ModID).Manifest.Version);
            this.assetLoader         = new DoorAssetLoader(this.Helper.Content);
            this.mapTileSheetManager = new MapTileSheetManager();
            this.manager             = new DoorManager(this.config, this.OnDoorToggled);

            // Apply Harmony patches.
            BetterDoorsMod.Instance = this;
            HarmonyInstance harmony = HarmonyInstance.Create(this.Helper.ModRegistry.ModID);

            harmony.PatchAll(Assembly.GetExecutingAssembly());

            // Attach events.
            this.Enable();
            this.Helper.Events.Multiplayer.PeerContextReceived += this.Multiplayer_PeerContextReceived;
            this.Helper.Events.GameLoop.ReturnedToTitle        += this.GameLoop_ReturnedToTitle;
        }
Exemplo n.º 2
0
        /*********
        ** Public methods
        *********/

        /// <summary>Constructs an instance.</summary>
        /// <param name="config">Mod configuration.</param>
        /// <param name="onToggledDoor">The action to take when a door is toggled.</param>
        public DoorManager(BetterDoorsModConfig config, Action <Door> onToggledDoor)
        {
            this.config        = config;
            this.onToggledDoor = onToggledDoor;
        }