Exemple #1
0
        /// <summary>
        /// Provides a wrapper for the given vanilla ID. If the given ID has already been wrapped before, it will return the same wrapper instance as was returned before. If register is true, then the wrapper will be registered to its ID in the appropriate registry.
        /// </summary>
        public static VanillaTileInfo Wrap(int ID, bool register)
        {
            VanillaTileInfo tileInfo = Wrappers.ContainsKey(ID) ? Wrappers[ID] : (Wrappers[ID] = new VanillaTileInfo(ID));

            if (register && tileInfo.RegistryName == null)
            {
                tileInfo.Register(tileInfo.Item.Name, ID, true);
            }
            return(tileInfo);
        }
Exemple #2
0
 /// <summary>
 /// Constructs a new VanillaItemInfo based upon the given ID. Do not try to call this yourself - use <see cref="Wrap"/>
 /// </summary>
 /// <param name="ID">The vanilla ID to be wrapped.</param>
 /// <param name="WrapForTile">If true, the Tile property should not be set by this constructor, as it will be set later as part of a TileInfo's constructor.</param>
 protected VanillaItemInfo(int ID, bool WrapForTile) : base(ItemRegistry.GetDefaultTypeByID(ID), GadgetCoreAPI.GetItemName(ID), GadgetCoreAPI.GetItemDesc(ID), GadgetCoreAPI.GetItemMaterial(ID), -1, GadgetCoreAPI.GetTrueGearBaseStats(ID), GadgetCoreAPI.GetWeaponMaterial(ID), ID >= 1000 && ID < 2000 ? GadgetCoreAPI.GetDroidHeadMaterial(ID) : GadgetCoreAPI.GetHeadMaterial(ID), ID >= 1000 && ID < 2000 ? GadgetCoreAPI.GetDroidBodyMaterial(ID) : GadgetCoreAPI.GetBodyMaterial(ID), GadgetCoreAPI.GetArmMaterial(ID))
 {
     this.ID = ID;
     if ((Type & ItemType.EQUIP_MASK) == (ItemType.WEAPON & ItemType.EQUIP_MASK))
     {
         SetWeaponInfo(ItemRegistry.GetDefaultWeaponScalingByID(ID), GadgetCoreAPI.GetAttackSound(ID), ItemRegistry.GetDefaultCritChanceBonus(ID), ItemRegistry.GetDefaultCritPowerBonus(ID), ID);
         OnAttack += (script) => { Attacking = true; IEnumerator ie = script.Attack(); Attacking = false; return(ie); };
     }
     else if ((Type & ItemType.USABLE) == ItemType.USABLE)
     {
         OnUse += (slot) => { Using = true; InstanceTracker.GameScript.StartCoroutine(InstanceTracker.GameScript.UseItemFinal(slot)); return(false); };
     }
     if (!WrapForTile)
     {
         if (TileRegistry.Singleton.HasEntry(ID))
         {
             SetTile(TileRegistry.Singleton.GetEntry(ID));
         }
         else
         {
             SetTile(VanillaTileInfo.Wrap(ID, false));
         }
     }
 }
Exemple #3
0
 /// <summary>
 /// Gets the <see cref="TileInfo"/> for the given ID. Will return a <see cref="VanillaTileInfo"/> if the given ID is not in the registry, but is within the vanilla ID range. Otherwise, returns null.
 /// </summary>
 public static TileInfo GetTile(int ID)
 {
     return(GetSingleton().HasEntry(ID) ? GetSingleton().GetEntry(ID) : ID > 0 && ID < GetSingleton().GetIDStart() ? VanillaTileInfo.Wrap(ID) : null);
 }