diff --git a/ReallifeGamemode.Client/Gui/cityhall.ts b/ReallifeGamemode.Client/Gui/cityhall.ts index 94cbe225..85fb08e2 100644 --- a/ReallifeGamemode.Client/Gui/cityhall.ts +++ b/ReallifeGamemode.Client/Gui/cityhall.ts @@ -15,11 +15,14 @@ export default function (globalData: GlobalData) { var keyBound = false; var menu: NativeUI.Menu = null; + var joblist: string[] = []; - mp.events.add("SERVER:CityHall_ShowHelpText", () => { + mp.events.add("SERVER:CityHall_ShowHelpText", (joblista) => { mp.game.ui.setTextComponentFormat('STRING'); mp.game.ui.addTextComponentSubstringPlayerName('Drücke ~INPUT_CONTEXT~, um das Stadthallen-Menü zu öffnen'); mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1); + + joblist = JSON.parse(joblista); if (!keyBound) { keyBound = true; @@ -29,6 +32,7 @@ export default function (globalData: GlobalData) { mp.events.add("SERVER:CityHall_ClearHelpText", () => { mp.game.ui.clearHelp(false); + if (menu) menu.Close(); if (keyBound) { mp.keys.unbind(0x45, false, keyPressHandler); keyBound = false; @@ -45,11 +49,32 @@ export default function (globalData: GlobalData) { var jobItem = new UIMenuItem("Jobs", "Jobcenter"); menu.AddItem(jobItem); - var jobMenu = new Menu("Jobcenter", "Hartz 4 und der Tag gehoert dir.", new Point(50, 50), null, null); - jobMenu.Visible = false; + var jobMenu = new Menu("Jobcenter", "Suche dir einen neuen Job aus", new Point(50, 50), null, null); + + for (var i = 0; i < joblist.length; i++) { + var job = joblist[i]; + jobMenu.AddItem(new UIMenuItem(job)); + } + + var cancelJobItem = new UIMenuItem("Job kuendigen"); + cancelJobItem.BackColor = new Color(213, 0, 0); + cancelJobItem.HighlightedBackColor = new Color(229, 57, 53); + jobMenu.AddItem(cancelJobItem); menu.BindMenuToItem(jobMenu, jobItem); + jobMenu.ItemSelect.on((item: NativeUI.UIMenuItem, index: number) => { + if (item === cancelJobItem) { // Job kündigen + mp.events.callRemote("CLIENT:JobCenter_CancelJob"); + } else { + mp.events.callRemote("CLIENT:JobCenter_AcceptJob", index + 1); + } + + menu.Close(); + }); + + jobMenu.Visible = false; + var groupCreateItem = new UIMenuItem("Gruppe erstellen", "Erstelle eine neue Gruppe"); groupCreateItem.SetRightLabel("~g~50.000$"); menu.AddItem(groupCreateItem); @@ -59,6 +84,8 @@ export default function (globalData: GlobalData) { cancelItem.HighlightedBackColor = new Color(229, 57, 53); menu.AddItem(cancelItem); + menu.Open(); + menu.ItemSelect.on((item: NativeUI.UIMenuItem, index) => { if (item === groupCreateItem) { // Gruppe var input = new InputHelper("Wie soll die Gruppe heißen?", globalData); diff --git a/ReallifeGamemode.Server/Business/BusinessBase.cs b/ReallifeGamemode.Server/Business/BusinessBase.cs index 1e613207..34328daf 100644 --- a/ReallifeGamemode.Server/Business/BusinessBase.cs +++ b/ReallifeGamemode.Server/Business/BusinessBase.cs @@ -10,7 +10,6 @@ namespace ReallifeGamemode.Server.Business public abstract class BusinessBase : IBankAccountOwner { private TextLabel _informationLabel; - private Marker _marker; private ColShape _colShape; public abstract int Id { get; } @@ -36,7 +35,7 @@ namespace ReallifeGamemode.Server.Business public void Setup() { _informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255)); - _marker = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255)); + NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255)); _colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f); _colShape.OnEntityEnterColShape += EntityEnterBusinessColShape; diff --git a/ReallifeGamemode.Server/Entities/Job.cs b/ReallifeGamemode.Server/Entities/Job.cs deleted file mode 100644 index 8d64331c..00000000 --- a/ReallifeGamemode.Server/Entities/Job.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Text; - -namespace ReallifeGamemode.Server.Entities -{ - public class Job - { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int Id { get; set; } - - public string Name { get; set; } - } -} diff --git a/ReallifeGamemode.Server/Entities/JobVehicle.cs b/ReallifeGamemode.Server/Entities/JobVehicle.cs index ce93899d..75d8bec2 100644 --- a/ReallifeGamemode.Server/Entities/JobVehicle.cs +++ b/ReallifeGamemode.Server/Entities/JobVehicle.cs @@ -1,4 +1,6 @@ using Microsoft.EntityFrameworkCore; +using ReallifeGamemode.Server.Job; +using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Models; using System; using System.Collections.Generic; @@ -9,11 +11,14 @@ namespace ReallifeGamemode.Server.Entities { public class JobVehicle : ServerVehicle { - public virtual Job Job { get; set; } + public int JobId { get; set; } + + public JobBase GetJob() => JobManager.GetJob(JobId); + public override string ToString() { using (var dbContext = new DatabaseContext()) - return "Job Fahrzeug | Job: " + dbContext.JobVehicles.Include(j => j.Job).First(j => j.Id == this.Id).Job.Name; + return "Job Fahrzeug | Job: " + this.GetJob().Name; } } } diff --git a/ReallifeGamemode.Server/Entities/ShopVehicles.cs b/ReallifeGamemode.Server/Entities/ShopVehicles.cs index 4bf2f1b8..ade17fb1 100644 --- a/ReallifeGamemode.Server/Entities/ShopVehicles.cs +++ b/ReallifeGamemode.Server/Entities/ShopVehicles.cs @@ -1,5 +1,6 @@ using GTANetworkAPI; using ReallifeGamemode.Server.Business; +using ReallifeGamemode.Server.Managers; using ReallifeGamemode.Server.Util; using System; using System.Collections.Generic; @@ -23,7 +24,7 @@ namespace ReallifeGamemode.Server.Entities public override string ToString() { - return "ShopVehicle"; + return "ShopVehicle | Shop: " + BusinessManager.GetBusiness(BusinessId).Name; } } } diff --git a/ReallifeGamemode.Server/Entities/User.cs b/ReallifeGamemode.Server/Entities/User.cs index 5c9f63c2..857e4f91 100644 --- a/ReallifeGamemode.Server/Entities/User.cs +++ b/ReallifeGamemode.Server/Entities/User.cs @@ -62,7 +62,7 @@ namespace ReallifeGamemode.Server.Entities public GroupRank GroupRank { get; set; } - public Job Job { get; set; } + public int? JobId { get; set; } public FactionRank GetFactionRank() { diff --git a/ReallifeGamemode.Server/Extensions/ClientExtension.cs b/ReallifeGamemode.Server/Extensions/ClientExtension.cs index 7434e2ff..aca50c9e 100644 --- a/ReallifeGamemode.Server/Extensions/ClientExtension.cs +++ b/ReallifeGamemode.Server/Extensions/ClientExtension.cs @@ -31,7 +31,6 @@ namespace ReallifeGamemode.Server.Extensions .Include(u => u.Faction) .Include(u => u.FactionRank) .Include(u => u.Group) - .Include(u => u.Job) .Where(u => u.Name == client.Name) .FirstOrDefault(); } diff --git a/ReallifeGamemode.Server/Job/JobBase.cs b/ReallifeGamemode.Server/Job/JobBase.cs new file mode 100644 index 00000000..7aa07d89 --- /dev/null +++ b/ReallifeGamemode.Server/Job/JobBase.cs @@ -0,0 +1,47 @@ +using GTANetworkAPI; +using ReallifeGamemode.Server.Entities; +using ReallifeGamemode.Server.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace ReallifeGamemode.Server.Job +{ + public abstract class JobBase + { + protected delegate void JobStartHandler(); + protected delegate void JobStopHandler(); + + protected event JobStartHandler JobStart; + protected event JobStopHandler JobStop; + + private readonly List _inJob = new List(); + + public abstract int Id { get; } + + public abstract string Name { get; } + + public void StartJob(Client player) + { + _inJob.Add(player); + JobStart(); + } + + public void StopJob(Client player) + { + _inJob.Remove(player); + JobStop(); + } + + public List GetJobVehicles() + { + using(var dbContext = new DatabaseContext()) + { + return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList(); + } + } + + public List GetUsersInJob() => _inJob; + } +} diff --git a/ReallifeGamemode.Server/Job/PilotJob.cs b/ReallifeGamemode.Server/Job/PilotJob.cs new file mode 100644 index 00000000..edece552 --- /dev/null +++ b/ReallifeGamemode.Server/Job/PilotJob.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ReallifeGamemode.Server.Job +{ + class PilotJob : JobBase + { + public override int Id => 3; + + public override string Name => "Pilot"; + } +} diff --git a/ReallifeGamemode.Server/Job/RefuseCollectorJob.cs b/ReallifeGamemode.Server/Job/RefuseCollectorJob.cs new file mode 100644 index 00000000..a00cfe91 --- /dev/null +++ b/ReallifeGamemode.Server/Job/RefuseCollectorJob.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ReallifeGamemode.Server.Job +{ + public class RefuseCollectorJob : JobBase + { + public override int Id => 2; + + public override string Name => "Müllmann"; + } +} diff --git a/ReallifeGamemode.Server/Job/TaxiDriverJob.cs b/ReallifeGamemode.Server/Job/TaxiDriverJob.cs new file mode 100644 index 00000000..ea548d35 --- /dev/null +++ b/ReallifeGamemode.Server/Job/TaxiDriverJob.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using GTANetworkAPI; + +namespace ReallifeGamemode.Server.Job +{ + class TaxiDriverJob : JobBase + { + public override int Id => 1; + + public override string Name => "Taxifahrer"; + } +} diff --git a/ReallifeGamemode.Server/Main.cs b/ReallifeGamemode.Server/Main.cs index 58f40e53..ac0af4b8 100644 --- a/ReallifeGamemode.Server/Main.cs +++ b/ReallifeGamemode.Server/Main.cs @@ -47,6 +47,7 @@ namespace ReallifeGamemode.Server DoorManager.LoadDoors(); ATMManager.InitATMs(); CityHallManager.LoadCityHall(); + JobManager.LoadJobs(); TempBlip tempBlip = new TempBlip() diff --git a/ReallifeGamemode.Server/Managers/CityHallManager.cs b/ReallifeGamemode.Server/Managers/CityHallManager.cs index 56be6fbe..c598190d 100644 --- a/ReallifeGamemode.Server/Managers/CityHallManager.cs +++ b/ReallifeGamemode.Server/Managers/CityHallManager.cs @@ -1,4 +1,5 @@ using GTANetworkAPI; +using Newtonsoft.Json; using ReallifeGamemode.Server.Entities; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Models; @@ -22,7 +23,8 @@ namespace ReallifeGamemode.Server.Managers var colShape = NAPI.ColShape.CreateSphereColShape(_cityHallPosition, 1.0f); colShape.OnEntityEnterColShape += (s, c) => { - c.TriggerEvent("SERVER:CityHall_ShowHelpText"); + var jobs = JobManager.GetJobs().Select(j => j.Name).ToArray(); + c.TriggerEvent("SERVER:CityHall_ShowHelpText", JsonConvert.SerializeObject(jobs)); }; colShape.OnEntityExitColShape += (s, c) => diff --git a/ReallifeGamemode.Server/Managers/JobManager.cs b/ReallifeGamemode.Server/Managers/JobManager.cs new file mode 100644 index 00000000..bfde7267 --- /dev/null +++ b/ReallifeGamemode.Server/Managers/JobManager.cs @@ -0,0 +1,100 @@ +using GTANetworkAPI; +using ReallifeGamemode.Server.Entities; +using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Job; +using ReallifeGamemode.Server.Models; +using ReallifeGamemode.Server.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace ReallifeGamemode.Server.Managers +{ + class JobManager : Script + { + private static List _jobs = new List(); + + public static void LoadJobs() + { + IEnumerable jobTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(JobBase)) && !t.IsAbstract); + + foreach (var type in jobTypes) + { + var instance = Activator.CreateInstance(type) as JobBase; + if (GetJob(instance.Id) != null) + { + throw new InvalidOperationException($"Double Job ID found: {instance.Id} | {instance.Name}"); + } + _jobs.Add(instance); + NAPI.Util.ConsoleOutput($"Loading job {instance.Name}"); + } + + NAPI.Util.ConsoleOutput($"Loaded {_jobs.Count} jobs"); + } + + public static JobBase GetJob(int id) => _jobs.Where(j => j.Id == id).FirstOrDefault(); + + public static T GetJob() where T : JobBase + { + return _jobs.Where(j => j.GetType() == typeof(T)).FirstOrDefault() as T; + } + + public static List GetJobs() => _jobs.OrderBy(j => j.Id).ToList(); + + [RemoteEvent("CLIENT:JobCenter_CancelJob")] + public void CancelJobEvent(Client player) + { + using(var dbContext = new DatabaseContext()) + { + User u = player.GetUser(dbContext); + + if (u == null) return; + + if(u.JobId == null) + { + ChatService.Error(player, "Du hast momentan keinen Job, den du kündigen könntest."); + return; + } + + u.JobId = null; + + player.SendChatMessage("~y~[JOBCENTER]~s~ Du hast deinen Job erfolgreich gekündigt."); + + dbContext.SaveChanges(); + } + } + + [RemoteEvent("CLIENT:JobCenter_AcceptJob")] + public void AcceptJobEvent(Client player, int jobId) + { + using (var dbContext = new DatabaseContext()) + { + User u = player.GetUser(dbContext); + + if (u == null) return; + + if (u.JobId != null) + { + ChatService.Error(player, "Du musst deinen alten Job kündigen, bevor du einen neuen ausüben kannst"); + return; + } + + JobBase job = JobManager.GetJob(jobId); + + if(job == null) + { + ChatService.Error(player, "Bei der Job-Annahme ist ein Fehler aufgetretet: Dieser Job wurde nicht gefunden"); + return; + } + + player.SendChatMessage($"~y~[JOBCENTER]~s~ Du hast erfolgreich deinen neuen Job: ~o~{job.Name}~s~ angenommen."); + + u.JobId = jobId; + + dbContext.SaveChanges(); + } + } + } +} diff --git a/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.Designer.cs b/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.Designer.cs new file mode 100644 index 00000000..b6390e3c --- /dev/null +++ b/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.Designer.cs @@ -0,0 +1,1116 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using ReallifeGamemode.Server.Models; + +namespace ReallifeGamemode.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20190516094446_JobFix")] + partial class JobFix + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.ATM", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Balance"); + + b.Property("Faulty"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("ATMs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Ban", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Applied"); + + b.Property("BannedBy"); + + b.Property("Reason"); + + b.Property("UntilDateTime"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Bans"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.BusinessBankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Balance"); + + b.Property("BusinessId"); + + b.HasKey("Id"); + + b.HasIndex("BusinessId") + .IsUnique(); + + b.ToTable("BusinessBankAccounts"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Character", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Ageing"); + + b.Property("AgeingOpacity"); + + b.Property("BeardColor"); + + b.Property("Blemishes"); + + b.Property("BlemishesOpacity"); + + b.Property("Blush"); + + b.Property("BlushColor"); + + b.Property("BlushOpacity"); + + b.Property("BrowDepth"); + + b.Property("BrowHeight"); + + b.Property("CheekDepth"); + + b.Property("CheekboneHeight"); + + b.Property("CheekboneWidth"); + + b.Property("ChestHair"); + + b.Property("ChestHairColor"); + + b.Property("ChestHairOpacity"); + + b.Property("ChinDepth"); + + b.Property("ChinHeight"); + + b.Property("ChinIndent"); + + b.Property("ChinWidth"); + + b.Property("Complexion"); + + b.Property("ComplexionOpacity"); + + b.Property("EyeColor"); + + b.Property("EyeSize"); + + b.Property("EyebrowColor"); + + b.Property("Eyebrows"); + + b.Property("EyebrowsOpacity"); + + b.Property("FacialHair"); + + b.Property("FacialHairOpacity"); + + b.Property("Father"); + + b.Property("Freckles"); + + b.Property("FrecklesOpacity"); + + b.Property("Gender"); + + b.Property("Hair"); + + b.Property("HairColor"); + + b.Property("HairHighlightColor"); + + b.Property("JawShape"); + + b.Property("JawWidth"); + + b.Property("LipThickness"); + + b.Property("Lipstick"); + + b.Property("LipstickColor"); + + b.Property("LipstickOpacity"); + + b.Property("Makeup"); + + b.Property("MakeupOpacity"); + + b.Property("Mother"); + + b.Property("NeckWidth"); + + b.Property("NoseBottomHeight"); + + b.Property("NoseBridgeDepth"); + + b.Property("NoseBroken"); + + b.Property("NoseTipHeight"); + + b.Property("NoseTipLength"); + + b.Property("NoseWidth"); + + b.Property("Similarity"); + + b.Property("SkinSimilarity"); + + b.Property("SunDamage"); + + b.Property("SunDamageOpacity"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Characters"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.CharacterCloth", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClothId"); + + b.Property("Duty"); + + b.Property("SlotId"); + + b.Property("SlotType"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("CharacterClothes"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.ClothCombination", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Gender"); + + b.Property("Top"); + + b.Property("Torso"); + + b.Property("Undershirt"); + + b.HasKey("Id"); + + b.ToTable("ClothCombinations"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Door", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Category"); + + b.Property("FactionId"); + + b.Property("Locked"); + + b.Property("Model"); + + b.Property("Name"); + + b.Property("Radius"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("Doors"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.DutyCloth", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClothId"); + + b.Property("FactionId"); + + b.Property("Gender"); + + b.Property("SlotId"); + + b.Property("SlotType"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("DutyClothes"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Faction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .HasMaxLength(32); + + b.Property("StateOwned"); + + b.HasKey("Id"); + + b.ToTable("Factions"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Balance"); + + b.Property("Bic") + .HasMaxLength(12); + + b.Property("FactionId"); + + b.Property("Iban") + .HasMaxLength(32); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("FactionBankAccounts"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionRank", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("FactionId"); + + b.Property("Order"); + + b.Property("RankName"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("FactionRanks"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GotoPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Description") + .HasMaxLength(32); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("GotoPoints"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Balance"); + + b.Property("GroupId"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupBankAccounts"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EnterPositionStr") + .HasColumnName("EnterPosition"); + + b.Property("ExitPositionStr") + .HasColumnName("ExitPosition"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Interiors"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.BankAccountTransactionHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Fee"); + + b.Property("MoneySent"); + + b.Property("NewReceiverBalance"); + + b.Property("NewSenderBalance"); + + b.Property("Origin") + .HasMaxLength(32); + + b.Property("Receiver") + .HasMaxLength(32); + + b.Property("ReceiverBalance"); + + b.Property("Sender") + .HasMaxLength(32); + + b.Property("SenderBalance"); + + b.Property("Timestamp") + .ValueGeneratedOnAdd(); + + b.HasKey("Id"); + + b.ToTable("BankAccountTransactionLogs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.Death", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CauseOfDeath") + .HasMaxLength(64); + + b.Property("KillerHeading"); + + b.Property("KillerId"); + + b.Property("KillerPositionX"); + + b.Property("KillerPositionY"); + + b.Property("KillerPositionZ"); + + b.Property("Timestamp") + .ValueGeneratedOnAdd(); + + b.Property("VictimHeading"); + + b.Property("VictimId"); + + b.Property("VictimPositionX"); + + b.Property("VictimPositionY"); + + b.Property("VictimPositionZ"); + + b.HasKey("Id"); + + b.HasIndex("KillerId"); + + b.HasIndex("VictimId"); + + b.ToTable("DeathLogs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.News", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Caption"); + + b.Property("Content"); + + b.Property("Timestamp"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("News"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedBlip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Alpha"); + + b.Property("Color"); + + b.Property("Dimension"); + + b.Property("DrawDistance"); + + b.Property("Name"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("Rotation"); + + b.Property("Scale"); + + b.Property("ShortRange"); + + b.Property("Sprite"); + + b.HasKey("Id"); + + b.ToTable("Blips"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedMarker", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("ColorA"); + + b.Property("ColorB"); + + b.Property("ColorG"); + + b.Property("ColorR"); + + b.Property("Dimension"); + + b.Property("DirectionX"); + + b.Property("DirectionY"); + + b.Property("DirectionZ"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("RotationX"); + + b.Property("RotationY"); + + b.Property("RotationZ"); + + b.Property("Scale"); + + b.Property("Type"); + + b.Property("Visible"); + + b.HasKey("Id"); + + b.ToTable("Markers"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedPed", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Dimension"); + + b.Property("HashModel"); + + b.Property("Heading"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.HasKey("Id"); + + b.ToTable("Peds"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedPickup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Dimension"); + + b.Property("PositionX") + .HasMaxLength(128); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("RespawnTime"); + + b.Property("RotationX"); + + b.Property("RotationY"); + + b.Property("RotationZ"); + + b.Property("Vehicle"); + + b.HasKey("Id"); + + b.ToTable("Pickups"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedTextLabel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("ColorA"); + + b.Property("ColorB"); + + b.Property("ColorG"); + + b.Property("ColorR"); + + b.Property("Dimension"); + + b.Property("DrawDistance"); + + b.Property("Font"); + + b.Property("LOS"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("Text") + .IsRequired(); + + b.HasKey("Id"); + + b.ToTable("TextLabels"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.ServerVehicle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active") + .ValueGeneratedOnAdd() + .HasDefaultValue(true); + + b.Property("Discriminator") + .IsRequired(); + + b.Property("DistanceDriven"); + + b.Property("Heading"); + + b.Property("Locked"); + + b.Property("Model"); + + b.Property("NumberPlate") + .HasMaxLength(8); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("PrimaryColor"); + + b.Property("SecondaryColor"); + + b.Property("TankAmount"); + + b.HasKey("Id"); + + b.ToTable("ServerVehicles"); + + b.HasDiscriminator("Discriminator").HasValue("ServerVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.TuningGarage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("TuningGarages"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AdminLevel"); + + b.Property("BanId"); + + b.Property("BusinessId"); + + b.Property("CharacterId"); + + b.Property("Dead"); + + b.Property("Email") + .HasMaxLength(64); + + b.Property("FactionId"); + + b.Property("FactionLeader"); + + b.Property("FactionRankId"); + + b.Property("GroupId"); + + b.Property("GroupRank"); + + b.Property("Handmoney"); + + b.Property("JobId"); + + b.Property("LogUserId"); + + b.Property("Name") + .HasMaxLength(32); + + b.Property("Password") + .HasMaxLength(64); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("RegistrationDate") + .ValueGeneratedOnAdd(); + + b.Property("SocialClubName") + .HasMaxLength(32); + + b.HasKey("Id"); + + b.HasIndex("BanId"); + + b.HasIndex("BusinessId") + .IsUnique(); + + b.HasIndex("CharacterId"); + + b.HasIndex("FactionId"); + + b.HasIndex("FactionRankId"); + + b.HasIndex("GroupId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Balance"); + + b.Property("Bic") + .HasMaxLength(12); + + b.Property("Iban") + .HasMaxLength(32); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserBankAccounts"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("ItemId"); + + b.Property("Slot"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserItems"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.VehicleMod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ModId"); + + b.Property("ServerVehicleId"); + + b.Property("Slot"); + + b.HasKey("Id"); + + b.HasIndex("ServerVehicleId", "Slot") + .IsUnique(); + + b.ToTable("VehicleMods"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Whitelist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("SocialClubName"); + + b.HasKey("Id"); + + b.ToTable("WhitelistEntries"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("FactionId"); + + b.HasIndex("FactionId"); + + b.ToTable("FactionVehicles"); + + b.HasDiscriminator().HasValue("FactionVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("GroupId"); + + b.HasIndex("GroupId"); + + b.HasDiscriminator().HasValue("GroupVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.JobVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("JobId"); + + b.HasDiscriminator().HasValue("JobVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.HasDiscriminator().HasValue("SavedVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.ShopVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("BusinessId"); + + b.Property("Price"); + + b.ToTable("ShopVehicles"); + + b.HasDiscriminator().HasValue("ShopVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("UserId"); + + b.HasIndex("UserId"); + + b.ToTable("UserVehicles"); + + b.HasDiscriminator().HasValue("UserVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Ban", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Character", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.CharacterCloth", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Door", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.DutyCloth", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionRank", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.Death", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "Killer") + .WithMany() + .HasForeignKey("KillerId"); + + b.HasOne("ReallifeGamemode.Server.Entities.User", "Victim") + .WithMany() + .HasForeignKey("VictimId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.News", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.User", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Ban", "Ban") + .WithMany() + .HasForeignKey("BanId"); + + b.HasOne("ReallifeGamemode.Server.Entities.Character", "Character") + .WithMany() + .HasForeignKey("CharacterId"); + + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + + b.HasOne("ReallifeGamemode.Server.Entities.FactionRank", "FactionRank") + .WithMany() + .HasForeignKey("FactionRankId"); + + b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserItem", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.VehicleMod", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.ServerVehicle", "Vehicle") + .WithMany() + .HasForeignKey("ServerVehicleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionVehicle", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupVehicle", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserVehicle", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.cs b/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.cs new file mode 100644 index 00000000..36f075e2 --- /dev/null +++ b/ReallifeGamemode.Server/Migrations/20190516094446_JobFix.cs @@ -0,0 +1,73 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace ReallifeGamemode.Migrations +{ + public partial class JobFix : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ServerVehicles_Jobs_JobId", + table: "ServerVehicles"); + + migrationBuilder.DropForeignKey( + name: "FK_Users_Jobs_JobId", + table: "Users"); + + migrationBuilder.DropTable( + name: "Jobs"); + + migrationBuilder.DropIndex( + name: "IX_Users_JobId", + table: "Users"); + + migrationBuilder.DropIndex( + name: "IX_ServerVehicles_JobId", + table: "ServerVehicles"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + migrationBuilder.CreateTable( + name: "Jobs", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Name = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Jobs", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Users_JobId", + table: "Users", + column: "JobId"); + + migrationBuilder.CreateIndex( + name: "IX_ServerVehicles_JobId", + table: "ServerVehicles", + column: "JobId"); + + migrationBuilder.AddForeignKey( + name: "FK_ServerVehicles_Jobs_JobId", + table: "ServerVehicles", + column: "JobId", + principalTable: "Jobs", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Users_Jobs_JobId", + table: "Users", + column: "JobId", + principalTable: "Jobs", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs b/ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs index 5b97fa67..6e3852e7 100644 --- a/ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs +++ b/ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs @@ -420,18 +420,6 @@ namespace ReallifeGamemode.Migrations b.ToTable("Interiors"); }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.Job", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Name"); - - b.HasKey("Id"); - - b.ToTable("Jobs"); - }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.BankAccountTransactionHistory", b => { b.Property("Id") @@ -827,8 +815,6 @@ namespace ReallifeGamemode.Migrations b.HasIndex("GroupId"); - b.HasIndex("JobId"); - b.ToTable("Users"); }); @@ -935,9 +921,7 @@ namespace ReallifeGamemode.Migrations { b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); - b.Property("JobId"); - - b.HasIndex("JobId"); + b.Property("JobId"); b.HasDiscriminator().HasValue("JobVehicle"); }); @@ -957,8 +941,6 @@ namespace ReallifeGamemode.Migrations b.Property("Price"); - b.Property("ShopId"); - b.ToTable("ShopVehicles"); b.HasDiscriminator().HasValue("ShopVehicle"); @@ -1079,10 +1061,6 @@ namespace ReallifeGamemode.Migrations b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group") .WithMany() .HasForeignKey("GroupId"); - - b.HasOne("ReallifeGamemode.Server.Entities.Job", "Job") - .WithMany() - .HasForeignKey("JobId"); }); modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b => @@ -1123,13 +1101,6 @@ namespace ReallifeGamemode.Migrations .HasForeignKey("GroupId"); }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.JobVehicle", b => - { - b.HasOne("ReallifeGamemode.Server.Entities.Job", "Job") - .WithMany() - .HasForeignKey("JobId"); - }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserVehicle", b => { b.HasOne("ReallifeGamemode.Server.Entities.User", "User") diff --git a/ReallifeGamemode.Server/Models/DatabaseContext.cs b/ReallifeGamemode.Server/Models/DatabaseContext.cs index 502279c7..dbe3171e 100644 --- a/ReallifeGamemode.Server/Models/DatabaseContext.cs +++ b/ReallifeGamemode.Server/Models/DatabaseContext.cs @@ -101,7 +101,6 @@ namespace ReallifeGamemode.Server.Models public DbSet GroupVehicles { get; set; } // Jobs - public DbSet Jobs { get; set; } public DbSet JobVehicles { get; set; } } }