Refactored inventory system

This commit is contained in:
hydrant
2018-12-19 21:14:36 +01:00
parent 98d6ecb01a
commit b16ed270c2
11 changed files with 43 additions and 29 deletions

View File

@@ -12,8 +12,8 @@ using System.Text;
namespace reallife_gamemode.Server.Inventory.Interfaces
{
public interface IDroppableItem : IUsableItem
public interface IDroppableItem : IItem
{
void Drop(UserItem uItem, Client player, int amount);
uint Object { get; }
}
}

View File

@@ -17,6 +17,5 @@ namespace reallife_gamemode.Server.Inventory.Interfaces
string Description { get; }
int Gewicht { get; }
string Einheit { get; }
uint Object { get; }
}
}

View File

@@ -14,6 +14,6 @@ namespace reallife_gamemode.Server.Inventory.Interfaces
{
public interface IUsableItem : IItem
{
void Use(UserItem uItem, Client player);
void Use(UserItem uItem);
}
}

View File

@@ -11,7 +11,7 @@ using System.Text;
namespace reallife_gamemode.Server.Inventory.Items
{
public class Cheeseburger : DropItem
public class Cheeseburger : FoodItem
{
public override int Id => 2;
public override string Name => "Cheeseburger";

View File

@@ -11,7 +11,7 @@ using System.Text;
namespace reallife_gamemode.Server.Inventory.Items
{
public class Chickenburger : DropItem, FoodItem
public class Chickenburger : FoodItem
{
public override int Id => 3;
public override string Name => "Chickenburger";

View File

@@ -19,9 +19,17 @@ namespace reallife_gamemode.Server.Inventory.Items
public abstract string Einheit { get; }
public abstract uint Object { get; }
public void Use(UserItem uItem, Client player)
public void Use(UserItem uItem)
{
player.Health += HpAmount;
Client player = uItem.GetUser().GetClient();
int amountToAdd = HpAmount;
if(player.Health + amountToAdd > 100)
{
amountToAdd = 100 - player.Health;
}
player.Health += amountToAdd;
player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false);
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
}

View File

@@ -11,7 +11,7 @@ using System.Text;
namespace reallife_gamemode.Server.Inventory.Items
{
public class Hamburger : DropItem
public class Hamburger : FoodItem
{
public override int Id => 1;
public override string Name => "Hamburger";

View File

@@ -11,14 +11,13 @@ using System.Text;
namespace reallife_gamemode.Server.Inventory.Items
{
public class Holz : DropItem
public class Holz : IDroppableItem
{
public override int Id => 4;
public override string Name => "Holz";
public override string Description => "Ich und mein Holz.";
public override int Gewicht => 1000;
public override string Einheit => "g";
public override int HpAmount => 20;
public override uint Object => 1805779401;
public int Id => 4;
public string Name => "Holz";
public string Description => "Ich und mein Holz.";
public int Gewicht => 1000;
public string Einheit => "g";
public uint Object => 1805779401;
}
}