示例#1
0
        public override void Entry(IModHelper helper)
        {
            // Initialize the helper
            bdHelper = new BirthdayHelper(Monitor, Helper.ModRegistry, Helper.GameContent);

            helper.Events.Content.AssetRequested      += OnAssetRequested;
            helper.Events.Display.MenuChanged         += OnMenuChanged;
            helper.Events.Display.RenderingActiveMenu += OnRenderingActiveMenu;
            helper.Events.Display.RenderedActiveMenu  += OnRenderedActiveMenu;
            helper.Events.GameLoop.GameLaunched       += OnGameLaunched;
            helper.Events.GameLoop.SaveLoaded         += OnSaveLoaded;
            helper.Events.GameLoop.ReturnedToTitle    += OnReturnedToTitle;
        }
示例#2
0
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            // Initialize the helper
            bdHelper = new BirthdayHelper(Monitor);
            // Refresh the config
            config = Helper.ReadConfig <ModConfig>();

            // Subscribe to the correct events to prevent unnecessary event checks
            switch (cycleType)
            {
            case CycleType.Always:
                break;

            case CycleType.Hover:
                Helper.Events.Input.CursorMoved += OnCursorMoved;
                break;

            case CycleType.Click:
                Helper.Events.Input.ButtonPressed += OnButtonPressed;
                break;

            default:
                break;
            }

            // Read the config options and fix the values if needed
            switch (config.cycleType)
            {
            case "Always":
                cycleType = CycleType.Always;
                break;

            case "Hover":
                cycleType = CycleType.Hover;
                break;

            case "Click":
                cycleType = CycleType.Click;
                break;

            default:
                Monitor.Log("The only accepted cycle types are Always, Hover and Click. Defaulting to Always.", LogLevel.Error);
                cycleType = CycleType.Always;
                break;
            }

            spriteCycleTicks = config.cycleDuration;
            if (spriteCycleTicks < 1)
            {
                Monitor.Log("Cycle duration can't be less than 1", LogLevel.Error);
                spriteCycleTicks = 1;
            }

            foreach (NPC n in Utility.getAllCharacters())
            {
                // Checking for 0 should eliminate a lot of the non-friendable NPCs, needs verification
                if (n.isVillager() && n.Birthday_Day > 0)
                {
                    bdHelper.AddBirthday(n.Birthday_Season, n.Birthday_Day, n);
                }
            }
        }