Ejemplo n.º 1
0
 public CustomItem(string name, string nameToken,
                   string descriptionToken, string loreToken,
                   string pickupToken,
                   Sprite pickupIconSprite, GameObject pickupModelPrefab,
                   ItemTier tier, ItemTag[] tags,
                   bool canRemove,
                   bool hidden,
                   UnlockableDef unlockableDef          = null,
                   ItemDisplayRuleDict?itemDisplayRules = null,
                   ItemTierDef itemTierDef = null)
 {
     SetupItem(name, nameToken, descriptionToken, loreToken, pickupToken, pickupIconSprite, pickupModelPrefab, tier, tags, canRemove, hidden, unlockableDef, itemDisplayRules, itemTierDef);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds an ItemTierDef to your Mod's ContentPack
        /// </summary>
        /// <param name="itemTierDef">The ItemTierDef to add</param>
        /// <returns>True if valid and added, false if one of the requirements is not met</returns>
        public static bool AddItemTierDef(ItemTierDef itemTierDef)
        {
            //Todo: finds what makes an itemTierDef invalid
            var asm = Assembly.GetCallingAssembly();

            if (CatalogBlockers.GetAvailability <ItemTierDef>())
            {
                R2APIContentManager.HandleContentAddition(asm, itemTierDef);
                return(true);
            }
            RejectContent(itemTierDef, asm, "ItemTierDef", "but the ItemTierCatalog has already initialized!");
            return(false);
        }
Ejemplo n.º 3
0
        private void SetupItem(string name, string nameToken,
                               string descriptionToken, string loreToken,
                               string pickupToken,
                               Sprite pickupIconSprite, GameObject pickupModelPrefab,
                               ItemTier tier, ItemTag[] tags,
                               bool canRemove,
                               bool hidden,
                               UnlockableDef unlockableDef          = null,
                               ItemDisplayRuleDict?itemDisplayRules = null,
                               ItemTierDef itemTierDef = null)
        {
            ItemDef                   = ScriptableObject.CreateInstance <ItemDef>();
            ItemDef.canRemove         = canRemove;
            ItemDef.descriptionToken  = descriptionToken;
            ItemDef.hidden            = hidden;
            ItemDef.loreToken         = loreToken;
            ItemDef.name              = name;
            ItemDef.nameToken         = nameToken;
            ItemDef.pickupIconSprite  = pickupIconSprite;
            ItemDef.pickupModelPrefab = pickupModelPrefab;
            ItemDef.pickupToken       = pickupToken;
            ItemDef.tags              = tags;
            ItemDef.unlockableDef     = unlockableDef;
            ItemDisplayRules          = itemDisplayRules;

            //If the tier isnt assigned at runtime, load tier from addressables, this should make it so mods that add items dont break.
            //We dont want to set the .tier directly, because that'll attempt to load the itemTierDef via the itemTierCatalog, and we cant
            //Guarantee said catalog has been initialized at that point
            if (tier != ItemTier.AssignedAtRuntime)
            {
                ItemDef._itemTierDef = LoadTierFromAddress(tier);
                return;
            }
            else
            {
                //If the itemTier is AssignedAtRuntime, but an itemTierDef is not assigned, default to noTier and warn the user
                if (!itemTierDef)
                {
                    ItemDef._itemTierDef = null;
                    R2API.Logger.LogWarning($"Trying to create an itemDef ({name}), but the \"tier\" argument is set to {nameof(ItemTier.AssignedAtRuntime)}" +
                                            $"And the argument \"itemTierDef\" is null! Resorting to setting tier to NoTier");
                }
                else
                {
                    ItemDef._itemTierDef = itemTierDef;
                }
            }
        }