protected virtual Weapon SpawnWeapon(WeaponData data) { if (data.Prefab == null) { throw new ArgumentException("Cannot Spawn Weapon From " + data.name + " Data, Because The Prefab Has Not Been Set"); } if (data.Prefab.GetComponent <Weapon>() == null) { throw new ArgumentException("Cannot Spawn Weapon From " + data.name + " Data, Because The Prefab Has No Type of Weapon Component"); } var instance = Instantiate(data.Prefab, transform, false); instance.gameObject.name = data.name; return(instance.GetComponent <Weapon>()); }
public virtual void Swap(KitSlot newSlot, WeaponData weapon) { Swap(newSlot, SpawnWeapon(weapon)); }
public virtual void Swap(WeaponData weapon) { Swap(slot, weapon); }