Start work on Inventory System
This commit is contained in:
@@ -43,6 +43,9 @@ namespace reallife_gamemode.Model
|
|||||||
public DbSet<Server.Entities.Ban> Bans { get; set; }
|
public DbSet<Server.Entities.Ban> Bans { get; set; }
|
||||||
public DbSet<Server.Entities.Character> Characters { get; set; }
|
public DbSet<Server.Entities.Character> Characters { get; set; }
|
||||||
|
|
||||||
|
//Inventar
|
||||||
|
public DbSet<Server.Entities.UserItem> UserItems { get; set; }
|
||||||
|
|
||||||
//Faction
|
//Faction
|
||||||
public DbSet<Server.Entities.Faction> Factions { get; set; }
|
public DbSet<Server.Entities.Faction> Factions { get; set; }
|
||||||
public DbSet<Server.Entities.FactionBankAccount> FactionBankAccounts { get; set; }
|
public DbSet<Server.Entities.FactionBankAccount> FactionBankAccounts { get; set; }
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ using reallife_gamemode.Server.Extensions;
|
|||||||
using reallife_gamemode.Server.Services;
|
using reallife_gamemode.Server.Services;
|
||||||
using reallife_gamemode.Server.Util;
|
using reallife_gamemode.Server.Util;
|
||||||
using reallife_gamemode.Server.Managers;
|
using reallife_gamemode.Server.Managers;
|
||||||
|
using reallife_gamemode.Server.Inventory.Items;
|
||||||
|
using reallife_gamemode.Server.Inventory.Interfaces;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Admin Commands (Admin.cs)
|
* @overview Life of German Reallife - Admin Commands (Admin.cs)
|
||||||
@@ -25,6 +27,22 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
{
|
{
|
||||||
public class Admin : Script
|
public class Admin : Script
|
||||||
{
|
{
|
||||||
|
[Command("eat")]
|
||||||
|
public void CmdAdminEat(Client player)
|
||||||
|
{
|
||||||
|
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Hamburger hamburger = new Hamburger();
|
||||||
|
if(hamburger is IUsableItem)
|
||||||
|
{
|
||||||
|
var usableItemObj = hamburger as IUsableItem;
|
||||||
|
usableItemObj.Use(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
[Command("vmod", "~m~Benutzung: ~s~/vmod [Slot] [Mod ID]")]
|
[Command("vmod", "~m~Benutzung: ~s~/vmod [Slot] [Mod ID]")]
|
||||||
public void CmdAdminVmod(Client player, int slot, int mod)
|
public void CmdAdminVmod(Client player, int slot, int mod)
|
||||||
{
|
{
|
||||||
|
|||||||
34
Server/Entities/UserItem.cs
Normal file
34
Server/Entities/UserItem.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using GTANetworkAPI;
|
||||||
|
using reallife_gamemode.Model;
|
||||||
|
using reallife_gamemode.Server.Util;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Entities UserItem (UserItem.cs)
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class UserItem
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int ItemId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("User")]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public User User { get; set; }
|
||||||
|
|
||||||
|
public float Amount { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Server/Inventory/Interfaces/IDroppableItem.cs
Normal file
18
Server/Inventory/Interfaces/IDroppableItem.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using GTANetworkAPI;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Inventory Interfaces DroppableItem (IDroppableItem.cs)
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Inventory.Interfaces
|
||||||
|
{
|
||||||
|
public interface IDroppableItem
|
||||||
|
{
|
||||||
|
void Drop(Client player);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Server/Inventory/Interfaces/IItem.cs
Normal file
21
Server/Inventory/Interfaces/IItem.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Inventory Interfaces Item (IItem.cs)
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Inventory.Interfaces
|
||||||
|
{
|
||||||
|
public interface IItem
|
||||||
|
{
|
||||||
|
int Id { get; }
|
||||||
|
string Name { get; }
|
||||||
|
string Description { get; }
|
||||||
|
int Gewicht { get; }
|
||||||
|
string Einheit { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Server/Inventory/Interfaces/IUsableItem.cs
Normal file
18
Server/Inventory/Interfaces/IUsableItem.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using GTANetworkAPI;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Inventory Interfaces UsableItem (IUsableItem.cs)
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Inventory.Interfaces
|
||||||
|
{
|
||||||
|
public interface IUsableItem
|
||||||
|
{
|
||||||
|
void Use(Client player);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Server/Inventory/Items/FoodItem.cs
Normal file
18
Server/Inventory/Items/FoodItem.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using GTANetworkAPI;
|
||||||
|
using reallife_gamemode.Server.Inventory.Interfaces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Inventory.Items
|
||||||
|
{
|
||||||
|
public abstract class FoodItem : IUsableItem
|
||||||
|
{
|
||||||
|
public abstract int HpAmount { get; }
|
||||||
|
|
||||||
|
public void Use(Client player)
|
||||||
|
{
|
||||||
|
player.Health += HpAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
Server/Inventory/Items/Hamburger.cs
Normal file
23
Server/Inventory/Items/Hamburger.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using reallife_gamemode.Server.Inventory.Interfaces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Inventory Items Hamburger (Hamburger.cs)
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Inventory.Items
|
||||||
|
{
|
||||||
|
public class Hamburger : FoodItem, IItem
|
||||||
|
{
|
||||||
|
public int Id => 1;
|
||||||
|
public string Name => "Hamburger";
|
||||||
|
public string Description => "Ein leckerer Hamburger.";
|
||||||
|
public int Gewicht => 300;
|
||||||
|
public string Einheit => "g";
|
||||||
|
public override int HpAmount => 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user