コード例 #1
0
 public new void MyUpdate()
 {
     if (ModEvents.PlayerInputUpdate(this))
     {
         orig_MyUpdate();
     }
 }
コード例 #2
0
        public static void LoadMods()
        {
            var owmlGo = new GameObject();

            owmlGo.AddComponent <OwmlBehaviour>();
            var owmlConfig        = JsonHelper.LoadJsonObject <OwmlConfig>(ConfigPath);
            var owmlDefaultConfig = JsonHelper.LoadJsonObject <OwmlConfig>(DefaultConfigPath);
            var owmlManifest      = JsonHelper.LoadJsonObject <ModManifest>(ManifestPath);

            if (owmlConfig == null || owmlManifest == null)
            {
                // Everything is wrong and can't write to console...
                return;
            }
            var logger = new ModLogger(owmlConfig, owmlManifest);

            logger.Log("Got config!");
            var console = OutputFactory.CreateOutput(owmlConfig, logger, owmlManifest);

            console.WriteLine("Mod loader has been initialized.");
            var modSorter     = new ModSorter(console);
            var modFinder     = new ModFinder(owmlConfig, console);
            var harmonyHelper = new HarmonyHelper(logger, console);
            var events        = new ModEvents(logger, console, harmonyHelper);
            var inputHandler  = new ModInputHandler(logger, console, harmonyHelper, owmlConfig, events);
            var menus         = new ModMenus(console, events, inputHandler, owmlManifest, owmlConfig, owmlDefaultConfig);
            var owo           = new Owo(modFinder, logger, console, owmlConfig, menus, harmonyHelper, inputHandler, modSorter);

            owo.LoadMods();
        }
コード例 #3
0
ファイル: ModLoader.cs プロジェクト: kaikecarlos/owml
        public static void LoadMods()
        {
            SecondaryLog($"In {nameof(ModLoader)}.{nameof(LoadMods)}!");
            SecondaryLog("Getting config...");
            var config = GetConfig();

            if (config == null)
            {
                SecondaryLog("Config is null");
                return;
            }
            SecondaryLog("Got config!");
            SecondaryLog("Loading mods...");
            try
            {
                var logger        = new ModLogger(config);
                var console       = new ModConsole(config);
                var harmonyHelper = new HarmonyHelper(logger, console);
                var events        = new ModEvents(harmonyHelper);
                var assets        = new ModAssets(console);
                var helper        = new ModHelper(config, logger, console, events, harmonyHelper, assets);
                var modFinder     = new ModFinder(config);
                var owo           = new Owo(helper, modFinder);
                owo.LoadMods();
                SecondaryLog("Loaded mods");
            }
            catch (Exception ex)
            {
                SecondaryLog("Error while loading mods: " + ex);
            }
        }
コード例 #4
0
        private void OnMailCleanup(object sender, EventArgs e)
        {
            DeleteFutureComposedMail();
            UnreadFutureReadMail();

            ModEvents.RaiseOnMailDelivery(this, EventArgs.Empty);
        }
コード例 #5
0
        /// <summary>Raised after the in-game clock time changes.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnTimeChanged(object sender, TimeChangedEventArgs e)
        {
            // Deliver mail every 30 mins
            var timeString  = e.NewTime.ToString();
            var correctTime = timeString.EndsWith("30") || timeString.EndsWith("00");

            if (_configService.InDebugMode() && e.NewTime != 600 && correctTime)
            {
                ModEvents.RaiseOnMailCleanup(this, EventArgs.Empty);
            }
        }
コード例 #6
0
 private async Task DeliverPostedMail()
 {
     _mod.Monitor.Log($"{logPrefix}Delivering mail...", LogLevel.Debug);
     DeliverLocalMail();
     if (!_configService.InLocalOnlyMode())
     {
         await DeliverLocalMailToCloud();
         await DeliverCloudMailLocally();
     }
     DeliverMailToLetterBox();
     _mod.Monitor.Log($"{logPrefix}.mail delivered, done!", LogLevel.Debug);
     ModEvents.RaiseMailDelivered(this, EventArgs.Empty);
 }
コード例 #7
0
ファイル: Owo.cs プロジェクト: misternebula/owml
        private IModHelper CreateModHelper(IModData modData)
        {
            var logger      = new ModLogger(_owmlConfig, modData.Manifest);
            var console     = OutputFactory.CreateOutput(_owmlConfig, _logger, modData.Manifest);
            var assets      = new ModAssets(console, modData.Manifest);
            var storage     = new ModStorage(console, modData.Manifest);
            var events      = new ModEvents(logger, console, _harmonyHelper);
            var interaction = new ModInteraction(_modList, new InterfaceProxyFactory(), modData.Manifest);

            return(new ModHelper.ModHelper(logger, console, _harmonyHelper,
                                           events, assets, storage, _menus, modData.Manifest, modData.Config,
                                           _owmlConfig, interaction));
        }
コード例 #8
0
        private void MouseChanged(object sender, EventArgsMouseStateChanged e)
        {
            if (e.NewState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                // Check if the click is on the letterbox tile or the one above it
                Location tileLocation = new Location((int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y);

                if (tileLocation.X == 68 && (tileLocation.Y >= 15 && tileLocation.Y <= 16))
                {
                    if (CanUseLetterbox())
                    {
                        ModEvents.RaisePlayerUsingLetterbox(this, EventArgs.Empty);
                    }
                }
            }
        }
コード例 #9
0
        /// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            if (e.Button == SButton.MouseRight)
            {
                // Check if the click is on the letterbox tile or the one above it
                Location tileLocation = new Location((int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y);

                if (tileLocation.X == 68 && (tileLocation.Y >= 15 && tileLocation.Y <= 16))
                {
                    if (CanUsePostbox())
                    {
                        ModEvents.RaisePlayerUsingPostbox(this, EventArgs.Empty);
                    }
                }
            }
        }
コード例 #10
0
        private void DeliverLocalMail()
        {
            var localMail        = GetLocallyComposedMail();
            var localFarmers     = _farmerService.GetFarmers();
            var updatedLocalMail = new List <Mail>();

            foreach (var mail in localMail)
            {
                if (localFarmers.Any(x => x.Id == mail.ToFarmerId))
                {
                    mail.Status = MailStatus.Delivered;
                    updatedLocalMail.Add(mail);
                }
            }

            UpdateLocalMail(updatedLocalMail);
            ModEvents.RaiseMailDelivered(this, EventArgs.Empty);
        }
コード例 #11
0
        private void ShowLetter(Mail mail)
        {
            if (Game1.mailbox == null || !Game1.mailbox.Any())
            {
                return;
            }

            if (Game1.mailbox.First() == ModConstants.PlayerMailKey)
            {
                Game1.activeClickableMenu = new LetterViewerMenu(mail.Text, ModConstants.PlayerMailTitle);
                if (Game1.mailbox.Any())
                {
                    Game1.mailbox.RemoveAt(0);
                }
                ModEvents.RaiseMailRead(this, new MailReadEventArgs {
                    Id = mail.Id
                });
            }
        }
コード例 #12
0
 /// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnDayStarted(object sender, DayStartedEventArgs e)
 {
     // Deliver mail each morning
     ModEvents.RaiseOnMailCleanup(this, EventArgs.Empty);
 }
コード例 #13
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            this.okClicked = false;
            Item heldItem = this.heldItem;
            int  num      = heldItem != null ? heldItem.Stack : -1;

            if (this.isWithinBounds(x, y))
            {
                base.receiveLeftClick(x, y, true);
                if (this.itemChangeBehavior == null && heldItem == null && (this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift)))
                {
                    this.heldItem = this.ItemsToGrabMenu.tryToAddItem(this.heldItem, "Ship");
                }
            }
            bool flag = true;

            if (this.ItemsToGrabMenu.isWithinBounds(x, y))
            {
                this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                if (this.heldItem != null && heldItem == null || this.heldItem != null && heldItem != null && !this.heldItem.Equals((object)heldItem))
                {
                    if (this.itemChangeBehavior != null)
                    {
                        flag = this.itemChangeBehavior(this.heldItem, this.ItemsToGrabMenu.getInventoryPositionOfClick(x, y), heldItem, this, true);
                    }
                    if (flag)
                    {
                        Game1.playSound("dwop");
                    }
                }
                if (this.heldItem == null && heldItem != null || this.heldItem != null && heldItem != null && !this.heldItem.Equals((object)heldItem))
                {
                    Item old = this.heldItem;
                    if (this.heldItem == null && this.ItemsToGrabMenu.getItemAt(x, y) != null && num < this.ItemsToGrabMenu.getItemAt(x, y).Stack)
                    {
                        old       = heldItem.getOne();
                        old.Stack = num;
                    }
                    if (this.itemChangeBehavior != null)
                    {
                        flag = this.itemChangeBehavior(heldItem, this.ItemsToGrabMenu.getInventoryPositionOfClick(x, y), old, this, false);
                    }
                    if (flag)
                    {
                        Game1.playSound("Ship");
                    }
                }
                if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).IsRecipe)
                {
                    string key = this.heldItem.Name.Substring(0, this.heldItem.Name.IndexOf("Recipe") - 1);
                    try
                    {
                        if ((this.heldItem as StardewValley.Object).Category == -7)
                        {
                            Game1.player.cookingRecipes.Add(key, 0);
                        }
                        else
                        {
                            Game1.player.craftingRecipes.Add(key, 0);
                        }
                        this.poof = new TemporaryAnimatedSprite(Game1.animationsName, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
                        Game1.playSound("newRecipe");
                    }
                    catch
                    {
                    }
                    this.heldItem = (Item)null;
                }
                else if (Game1.oldKBState.IsKeyDown(Keys.LeftShift) && Game1.player.addItemToInventoryBool(this.heldItem, false))
                {
                    this.heldItem = (Item)null;
                    if (this.itemChangeBehavior != null)
                    {
                        flag = this.itemChangeBehavior(this.heldItem, this.ItemsToGrabMenu.getInventoryPositionOfClick(x, y), heldItem, this, true);
                    }
                    if (flag)
                    {
                        Game1.playSound("coin");
                    }
                }
            }
            if (okButton.containsPoint(x, y))
            {
                okClicked = true;
                if (readyToClose())
                {
                    Game1.playSound("bigDeSelect");
                    Game1.exitActiveMenu();
                    if (ItemsToGrabMenu.inventory.Any())
                    {
                        ModEvents.RaiseMailComposed(this, new MailComposedEventArgs()
                        {
                            ToFarmerId = toFarmerId,
                            Item       = ItemsToGrabMenu.actualInventory[0]
                        });
                    }
                }
            }
        }
コード例 #14
0
ファイル: TextManager.cs プロジェクト: YLMAPI/YLMAPI
    // new as we're hiding TextManager's LoadTables.
    public new void LoadTables()
    {
        orig_LoadTables();

        ModEvents.TextsLoaded(this, tables, stringData);
    }
コード例 #15
0
ファイル: SavegameManager.cs プロジェクト: YLMAPI/YLMAPI
 public new IEnumerator LoadSceneControl(string sceneName, LoadingScreenFade fadeMask)
 => ModEvents.LoadSceneControl(orig_LoadSceneControl(sceneName, fadeMask), sceneName, fadeMask);