コード例 #1
0
 public static void AddItemToInventoryPrefix(StardewValley.Item item)
 {
     if (item is StardewValley.Object)
     {
         ((StardewValley.Object)item).quality.Value = 4;
     }
 }
コード例 #2
0
ファイル: ModEntry.cs プロジェクト: viteook/smapi-mod-dump
 public static void GetCookedCounter(StardewValley.CraftingRecipe recipe, StardewValley.Item item)
 {
     if (recipe.isCookingRecipe)
     {
         var item_key = item.ParentSheetIndex;
         recipe.timesCrafted = StardewValley.Game1.player.recipesCooked.ContainsKey(item_key) ? StardewValley.Game1.player.recipesCooked[item_key] : 0;
     }
 }
コード例 #3
0
        /// <summary>
        /// Stores the gift giving event described by the NPC receiving and the gift given.
        /// </summary>
        /// <param name="npc">The NPC receiving the gift</param>
        /// <param name="gift">The Gift being given</param>
        public void AddGift(StardewValley.NPC npc, StardewValley.Item gift)
        {
            NPCGift equivalent = new NPCGift(npc.name, gift.Name);

            if (!giftsMade.Contains(equivalent))
            {
                giftsMade.Add(equivalent);
            }
        }
コード例 #4
0
        public int HarvestContents(StardewValley.Farmer player)
        {
            int numItemsHarvested = 0;

            //Harvest items into inventory
            foreach (var container in _buildingInfo.ReadyToHarvestContainers)
            {
                //Get the item stored in the container
                StardewValley.Item item = null;
                if (container.name.Equals("Crystalarium"))
                {
                    item = (StardewValley.Item)container.heldObject.Value.getOne();
                }
                else
                {
                    item = (StardewValley.Item)container.heldObject.Value;
                }

                //Make sure player can collect item and inventory is not already full
                if (player.couldInventoryAcceptThisItem(item))
                {
                    //this.Monitor.Log($"  Harvesting item {item.Name} from container {container.Name} and placing in {player.Name}'s inventory.");
                    if (!player.addItemToInventoryBool(item, false))
                    {
                        //Inventory was full - throw exception so we can show a message
                        Utility.Log($"  {player.Name} has run out of inventory space. Stopping harvest.");
                        throw new InventoryFullException();
                    }
                    numItemsHarvested++;

                    //Remove this item permanently from the container (except Crystalarium).
                    if (container.name.Equals("Crystalarium"))
                    {
                        container.MinutesUntilReady = this.getMinutesForCrystalarium(item.ParentSheetIndex);
                    }
                    else
                    {
                        container.heldObject.Value = (StardewValley.Object)null;
                    }

                    container.readyForHarvest.Value = false;
                    container.showNextIndex.Value   = false;
                }
                else
                {
                    //Inventory was full - throw exception so we can show a message
                    Utility.Log($"  {player.Name} has run out of inventory space. Stopping harvest.");
                    throw new InventoryFullException();
                }
            }

            return(numItemsHarvested);
        }
コード例 #5
0
                    public SVObjectEx(StardewValley.Item item) : base()
                    {
                        orgCall = new drawInMenuDelegate(item.drawInMenu);

                        this.Category           = item.Category;
                        this.DisplayName        = item.DisplayName;
                        this.HasBeenInInventory = item.HasBeenInInventory;
                        this.Name             = item.Name;
                        this.ParentSheetIndex = item.ParentSheetIndex;
                        this.Price            = Math.Max(1, item.salePrice());
                        this.specialItem      = item.specialItem;
                        this.SpecialVariable  = item.SpecialVariable;
                    }
コード例 #6
0
        public static void SetIdentifier(StardewValley.Item item, Type type)
        {
#if ANDROID
            item.netName.Value = item.GetType().Name;
#else
            if (item.modDataForSerialization.ContainsKey(IdentifierKey))
            {
                item.modDataForSerialization[IdentifierKey] = type.FullName;
            }
            else
            {
                item.modDataForSerialization.Add(IdentifierKey, type.FullName);
            }
#endif
        }
コード例 #7
0
        public static bool CanLinkWith(StardewValley.Item linkedObject, object platoObject)
        {
#if ANDROID
            if (linkedObject is TLink && linkedObject.netName.Value == platoObject.GetType().Name)
            {
                return(true);
            }
#else
            if (linkedObject is TLink && linkedObject.modDataForSerialization.ContainsKey(IdentifierKey) && linkedObject.modDataForSerialization[IdentifierKey] == platoObject.GetType().FullName)
            {
                return(true);
            }
#endif

            return(false);
        }
コード例 #8
0
 public static string ItemToSpeech(StardewValley.Item item)
 {
     if (item != null)
     {
         if (item.Stack > 1)
         {
             return(item.Stack + " " + item.DisplayName);
         }
         else
         {
             return(item.DisplayName);
         }
     }
     else
     {
         return("none");
     }
 }
コード例 #9
0
        // Constructors:

        // TODO: Add custom menu background colour support
        public MainMenu(IList <StardewValley.Item> inventory,
                        Boolean reverseGrab,
                        Boolean showReceivingMenu,
                        InventoryMenu.highlightThisItem highlightFunction,
                        ItemGrabMenu.behaviorOnItemSelect behaviorOnItemSelectFunction,
                        String message,
                        ItemGrabMenu.behaviorOnItemSelect behaviorOnItemGrab = null,
                        Boolean snapToBottom        = false,
                        Boolean canBeExitedWithKey  = false,
                        Boolean playRightClickSound = true,
                        Boolean allowRightClick     = true,
                        Boolean showOrganizeButton  = false,
                        Int32 source = 0,
                        StardewValley.Item sourceItem = null,
                        Int32 whichSpecialButton      = -1,
                        Object context = null)
            : base(inventory, reverseGrab, showReceivingMenu, highlightFunction, behaviorOnItemSelectFunction, message, behaviorOnItemGrab, snapToBottom, canBeExitedWithKey, playRightClickSound, allowRightClick, showOrganizeButton, source, sourceItem, whichSpecialButton, context)
        {
            // recreate menu
            {
                var game_viewport = GlobalVars.GameViewport;

                this.inventory = new InventoryMenu(
                    game_viewport.Width - this.inventory.width - Convert.ToInt32(game_viewport.Width / (12.0f * StardewValley.Game1.options.zoomLevel)),
                    game_viewport.Height - this.inventory.height - (game_viewport.Height / Convert.ToInt32(8.0f * StardewValley.Game1.options.zoomLevel)),
                    false, null,
                    this.inventory.highlightMethod, this.inventory.capacity, this.inventory.rows,
                    this.inventory.horizontalGap, this.inventory.verticalGap, this.inventory.drawSlots);

                this.ItemsToGrabMenu = new InventoryMenu(
                    game_viewport.Width - this.ItemsToGrabMenu.width - Convert.ToInt32(game_viewport.Width / (12.0f * StardewValley.Game1.options.zoomLevel)),
                    game_viewport.Height / Convert.ToInt32(8.0f * StardewValley.Game1.options.zoomLevel),
                    false, this.ItemsToGrabMenu.actualInventory,
                    this.ItemsToGrabMenu.highlightMethod, this.ItemsToGrabMenu.capacity, this.ItemsToGrabMenu.rows,
                    this.ItemsToGrabMenu.horizontalGap, this.ItemsToGrabMenu.verticalGap, this.ItemsToGrabMenu.drawSlots);

                this.ItemsToGrabMenu.populateClickableComponentList();
                for (Int32 i = 0; i < this.ItemsToGrabMenu.inventory.Count; i++)
                {
                    if (this.ItemsToGrabMenu.inventory[i] != null)
                    {
                        this.ItemsToGrabMenu.inventory[i].myID            += ItemGrabMenu.region_itemsToGrabMenuModifier;
                        this.ItemsToGrabMenu.inventory[i].upNeighborID    += ItemGrabMenu.region_itemsToGrabMenuModifier;
                        this.ItemsToGrabMenu.inventory[i].rightNeighborID += ItemGrabMenu.region_itemsToGrabMenuModifier;
                        this.ItemsToGrabMenu.inventory[i].downNeighborID   = ClickableComponent.CUSTOM_SNAP_BEHAVIOR;
                        this.ItemsToGrabMenu.inventory[i].leftNeighborID  += ItemGrabMenu.region_itemsToGrabMenuModifier;
                        this.ItemsToGrabMenu.inventory[i].fullyImmutable   = true;
                    }
                }

                this.PlayerInventoryOptions.Bounds = this.inventory.GetRectangleForDialogueBox();
                this.SourceInventoryOptions.Bounds = this.ItemsToGrabMenu.GetRectangleForDialogueBox();

                this.SetBounds(
                    this.SourceInventoryOptions.Bounds.X,
                    this.SourceInventoryOptions.Bounds.Y,
                    this.SourceInventoryOptions.Bounds.Width,
                    this.SourceInventoryOptions.Bounds.Height
                    + (this.PlayerInventoryOptions.Bounds.Y - (this.SourceInventoryOptions.Bounds.Y + this.SourceInventoryOptions.Bounds.Height))
                    + this.PlayerInventoryOptions.Bounds.Height);

                // handle organization buttons
                {
                    this.createOrganizationButtons(false, false, false);
                    this.okButton = this.trashCan = null;
                    if (!(this.dropItemInvisibleButton is null))
                    {
                        this.dropItemInvisibleButton.bounds = new Rectangle(
                            this.PlayerInventoryOptions.Bounds.X + (this.PlayerInventoryOptions.Bounds.Width / 2),
                            this.PlayerInventoryOptions.Bounds.Y - ((this.PlayerInventoryOptions.Bounds.Y - (this.SourceInventoryOptions.Bounds.Y + this.SourceInventoryOptions.Bounds.Height)) / 2),
                            64, 64);
                    }
                }

                this.populateClickableComponentList();
                if (StardewValley.Game1.options.SnappyMenus)
                {
                    this.snapToDefaultClickableComponent();
                }
                this.SetupBorderNeighbors();
            }

            this.MenuItems.Add(new ConfigPanel(this));
            this.MenuItems.Add(new ChestColouringPanel(this));
        }
コード例 #10
0
 public GiftLikes GetGiftTasteForItem(StardewValley.Item item)
 {
     return((GiftLikes)Char.getGiftTasteForThisItem(item));
 }
コード例 #11
0
 public bool CanReceiveItemAsGift(StardewValley.Item item)
 {
     return(item is StardewValley.Object || item is StardewValley.Objects.Ring || item is StardewValley.Objects.Hat || item is StardewValley.Objects.Boots || item is StardewValley.Tools.MeleeWeapon);
 }
コード例 #12
0
        // Constructors:
        #region Constructors

        public ICustomItemGrabMenuItem(ICustomItemGrabMenu hostMenu, Rectangle bounds, Boolean raiseMouseClickEventOnRelease, Colours colours, StardewValley.Item svItem) : base(null, bounds, raiseMouseClickEventOnRelease, colours, svItem)
        {
            this.HostMenu = hostMenu;
        }