Merging into feature/inventory-system

This commit is contained in:
VegaZ
2018-12-08 23:17:28 +01:00
35 changed files with 848 additions and 168 deletions

View File

@@ -30,5 +30,10 @@ namespace reallife_gamemode.Server.Entities
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
}
}
public override string ToString()
{
return "Fraktions Fahrzeug | Fraktion: " + GetFaction().Name;
}
}
}

View File

@@ -36,11 +36,20 @@ namespace reallife_gamemode.Server.Entities
Vehicle veh = NAPI.Vehicle.CreateVehicle(this.Model, this.Position, this.Heading, this.PrimaryColor, this.SecondaryColor, this.NumberPlate, locked: this.Locked, engine: false);
VehicleManager.AddVehicle(this, veh);
string numberplate = $"{this.Id}";
if(this is FactionVehicle fV)
{
veh.NumberPlate = fV.GetFaction().Name;
numberplate = $"F{fV.FactionId} " + numberplate;
}
if (this is UserVehicle uV)
{
numberplate = $"U{uV.UserId} " + numberplate;
}
veh.NumberPlate = numberplate;
return veh;
}
}

View File

@@ -1,9 +1,11 @@
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;
/**
@@ -20,5 +22,25 @@ namespace reallife_gamemode.Server.Entities
[ForeignKey("User")]
public int UserId { get; set; }
public User User { get; set; }
public override string ToString()
{
return "Spieler Fahrzeug | Besitzer: " + GetOwner().Name;
}
public User GetOwner(DatabaseContext dbContext = null)
{
if (dbContext == null)
{
using (dbContext = new DatabaseContext())
{
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
}
}
else
{
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
}
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace reallife_gamemode.Server.Entities
{
public class Whitelist
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string SocialClubName { get; set; }
}
}