Skip to content

Commit

Permalink
No breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Jan 19, 2025
1 parent d0a5ac7 commit c6ae353
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public static T Get<T>(ushort serial)
/// <param name="owner">The <see cref="Player"/> who owns the item by default.</param>
/// <typeparam name="T">The specified <see cref="Item"/> type.</typeparam>
/// <returns>The <see cref="Item"/> created. This can be cast as a subclass.</returns>
public static Item Create<T>(ItemType type, Player owner = null)
public static Item Create<T>(ItemType type, Player owner = null) // TODO modify return type to "T"
where T : Item => Create(type, owner) as T;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Pickups/Pickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ public static IEnumerable<T> Get<T>(IEnumerable<GameObject> gameObjects)
/// <typeparam name="T">The specified <see cref="Pickup"/> type.</typeparam>
/// <returns>The created <see cref="Pickup"/>.</returns>
/// <seealso cref="Projectile.Create(Enums.ProjectileType)"/>
public static Pickup Create<T>(ItemType type)
public static Pickup Create<T>(ItemType type) // TODO modify return type to "T"
where T : Pickup => Create(type) as T;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ internal Projectile(ItemType type)
/// <param name="projectiletype">The <see cref="Enums.ProjectileType"/> of the projectile.</param>
/// <typeparam name="T">The specified <see cref="Projectile"/> type.</typeparam>
/// <returns>The created <see cref="Projectile"/>.</returns>
public static Projectile Create<T>(ProjectileType projectiletype)
public static Projectile Create<T>(ProjectileType projectiletype) // TODO modify return type to "T"
where T : Projectile => Create(projectiletype) as T;

/// <summary>
Expand Down
19 changes: 17 additions & 2 deletions EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2203,13 +2203,28 @@ public void Heal(float amount, bool overrideMaxHealth = false)
/// Forces the player to use an item.
/// </summary>
/// <param name="usableItem">The ItemType to be used.</param>
public void UseItem(ItemType usableItem) => UseItem(Item.Create<Usable>(usableItem));
/// <returns><see langword="true"/> if item was used successfully. Otherwise, <see langword="false"/>.</returns>
public bool UseItem(ItemType usableItem) => UseItem(Item.Create(usableItem));

/// <summary>
/// Forces the player to use an item.
/// </summary>
/// <param name="usable">The item to be used.</param>
public void UseItem(Usable usable) => usable?.Use(this);

/// <summary>
/// Forces the player to use an item.
/// </summary>
/// <param name="item">The item to be used.</param>
public void UseItem(Usable item) => item.Use(this);
/// <returns><see langword="true"/> if item was used successfully. Otherwise, <see langword="false"/>.</returns>
public bool UseItem(Item item)
{
if (item is not Usable usableItem)
return false;

UseItem(usableItem);
return true;
}

/// <summary>
/// Kills the player.
Expand Down

0 comments on commit c6ae353

Please sign in to comment.