private static void Input_ButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            // In-game interactions
            if (!Game1.game1.IsActive || Game1.currentLocation == null || !Context.IsWorldReady)
            {
                return;
            }

            // . . .

            // World interactions
            if (!Context.CanPlayerMove)
            {
                return;
            }

            if (e.Button.IsActionButton())
            {
                // Object actions
                Game1.currentLocation.Objects.TryGetValue(e.Cursor.GrabTile, out StardewValley.Object o);
                if (o != null)
                {
                    // Open Saloon delivery giftbox chests
                    if (o is Chest c)
                    {
                        GusDeliveryService.TryOpenDeliveryChest(location: Game1.currentLocation, chest: c, button: e.Button);
                    }
                }
            }
        }
        private static void Display_MenuChanged(object sender, MenuChangedEventArgs e)
        {
            if (e.OldMenu is TitleMenu || e.NewMenu is TitleMenu || Game1.currentLocation == null || Game1.player == null)
            {
                return;
            }

            // Handle Saloon Delivery telephone dialogue menu
            const string questionKey = "telephone";

            if (e.NewMenu is DialogueBox dialogueBox &&
                Game1.currentLocation.lastQuestionKey == questionKey &&
                dialogueBox.characterDialogue?.speaker?.Name == GusDeliveryService.ShopOwner &&
                (Kitchen.HasOrWillReceiveKitchenCompletedMail() || Kitchen.IsKitchenComplete(Bundles.CC)))
            {
                if ((e.OldMenu == null || !(e.OldMenu is CommunityKitchen.ShopMenuNoInventory)) &&
                    (GusOnABike.IsGusOnFarm() || GusOnABike.WhereGus() != GusDeliveryService.ShopLocation))
                {
                    // Replace phonecall with dummy dialogue if Gus is already delivering food
                    Game1.activeClickableMenu = new DialogueBox(ModEntry.i18n.Get("dialogue.phone.invalid"));
                }
                else
                {
                    // Add delivery menu option to phonecall
                    GusDeliveryService.TryOpenDeliveryMenu();
                }
                return;
            }
        }
Example #3
0
        private void RegisterEvents()
        {
            this.Helper.Events.GameLoop.GameLaunched += this.GameLoop_GameLaunched;
            this.Helper.Events.GameLoop.SaveLoaded   += this.GameLoop_SaveLoaded;
            this.Helper.Events.GameLoop.DayStarted   += this.GameLoop_DayStarted;

            Kitchen.RegisterEvents();
            GusDeliveryService.RegisterEvents();
        }
Example #4
0
        public override void Entry(IModHelper helper)
        {
            ModEntry.Instance = this;

            this.RegisterEvents();
            Kitchen.AddConsoleCommands(cmd: ModEntry.CommandPrefix);
            GusDeliveryService.AddConsoleCommands(cmd: ModEntry.CommandPrefix);

            AssetManager assetManager = new();

            helper.Content.AssetLoaders.Add(assetManager);
            helper.Content.AssetEditors.Add(assetManager);
        }
 internal static void AddConsoleCommands(string cmd)
 {
     Helper.ConsoleCommands.Add(
         name: cmd + "delivery",
         documentation: $"Open a new Saloon delivery menu.",
         callback: (string s, string[] args) =>
     {
         GusDeliveryService.OpenDeliveryMenu();
     });
     Helper.ConsoleCommands.Add(
         name: cmd + "gus",
         documentation: $"Create a new {nameof(GusOnABike)} on the farm.",
         callback: (string s, string[] args) =>
     {
         GusOnABike.Create();
     });
 }
 private static void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e)
 {
     if (GusDeliveryService.ItemDeliveryChest.IsValueCreated &&
         GusDeliveryService.ItemDeliveryChest.Value.items.Any() &&
         !(Game1.activeClickableMenu is CommunityKitchen.ShopMenuNoInventory) &&
         (e.NewTime < GusDeliveryService.SaloonOpeningTime ||
          e.NewTime > GusDeliveryService.SaloonClosingTime ||
          e.NewTime >= GusDeliveryService.DeliveryEndTime))
     {
         if (!GusOnABike.IsGusOnFarm())
         {
             if (Game1.currentLocation is Farm)
             {
                 GusOnABike.Create();
             }
             else
             {
                 GusOnABike.Honk(isOnFarm: false);
                 GusDeliveryService.AddDeliveryChests();
             }
         }
     }
 }
 internal static void SaveLoadedBehaviours()
 {
     // Reload lazy assets per save
     GusDeliveryService.ResetDeliveryTexture();
     GusDeliveryService.ResetDeliveryChest();
 }
Example #8
0
 private void DayStartedBehaviours()
 {
     Kitchen.DayStartedBehaviours();
     GusDeliveryService.DayStartedBehaviours();
 }
Example #9
0
 private void SaveLoadedBehaviours()
 {
     Kitchen.SaveLoadedBehaviours();
     GusDeliveryService.SaveLoadedBehaviours();
 }