Example #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);
        }
Example #2
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();
        }
Example #3
0
        /// <summary>
        ///     Registers a quest to be inserted into the game.
        /// </summary>
        /// <param name="questInformation">
        ///     The information on the quest to insert.
        /// </param>
        public static void RegisterQuest(QuestInformation questInformation)
        {
            if (Quests.ContainsKey(questInformation.Id) && Quests[questInformation.Id] != questInformation)
            {
                Log.Warning(
                    $"Potential conflict registering new quest. Quest {questInformation.Id} has been registered by two separate mods."
                    + "Only the last registered one will be used.");
            }

            questInformation.Id =
                IdManager.AssignNewIdSequential(Game1.content.Load <Dictionary <int, string> >("Data\\Quests"));
            Quests[questInformation.Id] = questInformation;
        }
        /// <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");
        }