Пример #1
0
        /// <summary>
        /// Registers a new weapon
        /// </summary>
        /// <param name="weapon">Information of weapon to register</param>
        public static void RegisterWeapon <T>(WeaponInformation weapon)
        {
            if (StardewValley.Tool.weaponsTexture == null)
            {
                throw new Exception("objectInformation is null! This likely occurs if you try to register an item before AfterContentLoaded");
            }

            weapon.Id = IdManager.AssignNewIdSequential(Game1.content.Load <Dictionary <int, string> >("Data\\weapons"));
            Weapons.Add(weapon);
            TextureUtility.AddSpriteToSpritesheet(ref StardewValley.Tool.weaponsTexture, weapon.Texture, weapon.Id, 16, 16);
        }
Пример #2
0
        /// <summary>
        /// Registers a new crop
        /// </summary>
        /// <param name="crop">Information of crop to register</param>
        public static void RegisterCrop <T>(CropInformation crop)
        {
            if (Game1.cropSpriteSheet == null)
            {
                throw new Exception("objectInformation is null! This likely occurs if you try to register a crop before AfterContentLoaded");
            }

            crop.Id = StardewValley.Game1.content.Load <Dictionary <int, string> >("Data\\Crops").Count() + 1;

            Crops.Add(crop.Seed, crop);
            TextureUtility.AddSpriteToSpritesheet(ref Game1.cropSpriteSheet, crop.Texture, crop.Id, 128, 32);
        }
Пример #3
0
        /// <summary>
        /// Registers a new item
        /// </summary>
        /// <param name="item">Information of item to register</param>
        public static void RegisterItem <T>(ItemInformation item)
        {
            if (Game1.objectSpriteSheet == null)
            {
                throw new Exception("objectInformation is null! This likely occurs if you try to register an item before AfterContentLoaded");
            }

            item.Id = IdManager.AssignNewIdSequential(Game1.objectInformation);
            Items.Add(item);
            TextureUtility.AddSpriteToSpritesheet(ref Game1.objectSpriteSheet, TextureRegistry.GetItem(item.Texture)?.Texture, item.Id, 16, 16);
            Game1.objectInformation[item.Id] = item.ToString();
        }
Пример #4
0
        /// <summary>
        /// Registers a new tool
        /// </summary>
        /// <param name="tool">Information of tool to register</param>
        public static void RegisterTool <T>(ToolInformation tool)
        {
            if (Game1.toolSpriteSheet == null)
            {
                throw new Exception("objectInformation is null! This likely occurs if you try to register an item before AfterContentLoaded");
            }

            tool.Id = NextAvailableIndex;
            NextAvailableIndex++;

            Tools.Add(tool.Name, tool);
            TextureUtility.AddSpriteToSpritesheet(ref Game1.toolSpriteSheet, tool.Texture, InitialTools + tool.Id, 112, 32);
        }
Пример #5
0
        /// <summary>
        /// Registers a new big craftable
        /// </summary>
        /// <param name="bigCraftable">Information of big craftable to register</param>
        public static void RegisterBigCraftable <T>(BigCraftableInformation bigCraftable)
        {
            if (Game1.bigCraftableSpriteSheet == null)
            {
                throw new Exception("objectInformation is null! This likely occurs if you try to register a big craftable before AfterContentLoaded");
            }

            bigCraftable.Id = IdManager.AssignNewIdSequential(Game1.bigCraftablesInformation);

            BigCraftables.Add(bigCraftable);
            RegisteredTypeInformation[typeof(T)] = bigCraftable;
            RegisteredIdType[bigCraftable.Id]    = typeof(T);
            TextureUtility.AddSpriteToSpritesheet(ref Game1.bigCraftableSpriteSheet, bigCraftable.Texture, bigCraftable.Id, 16, 32);
            // Reload big craftable information with the newly injected information
            StardewValley.Game1.bigCraftablesInformation = StardewValley.Game1.content.Load <Dictionary <int, string> >("Data\\BigCraftablesInformation");
        }