From 8919e76b75ea9b5d12506a2e592c5762f471646c Mon Sep 17 00:00:00 2001 From: VegaZ Date: Wed, 21 Nov 2018 17:20:53 +0100 Subject: [PATCH] Finish Duty-System (Clothing) --- Model/DatabaseContext.cs | 1 - Server/Entities/DutyCloth.cs | 7 ++- Server/Entities/DutyProp.cs | 28 ------------ Server/Events/Key.cs | 65 ++++++++++++++++----------- Server/Events/UpdateCharacterCloth.cs | 2 +- 5 files changed, 44 insertions(+), 59 deletions(-) delete mode 100644 Server/Entities/DutyProp.cs diff --git a/Model/DatabaseContext.cs b/Model/DatabaseContext.cs index 2d1edddf..79250b55 100644 --- a/Model/DatabaseContext.cs +++ b/Model/DatabaseContext.cs @@ -35,7 +35,6 @@ namespace reallife_gamemode.Model public DbSet Characters { get; set; } public DbSet CharacterClothes { get; set; } public DbSet DutyClothes { get; set; } - public DbSet DutyProps { get; set; } public DbSet MaleCombinations { get; set; } public DbSet FemaleCombinations { get; set; } public DbSet Users { get; set; } diff --git a/Server/Entities/DutyCloth.cs b/Server/Entities/DutyCloth.cs index 2f391875..dd3a875d 100644 --- a/Server/Entities/DutyCloth.cs +++ b/Server/Entities/DutyCloth.cs @@ -22,7 +22,10 @@ namespace reallife_gamemode.Server.Entities public int FactionId { get; set; } public Faction Faction { get; set; } - public int ComponentId { get; set; } - public int Drawable { get; set; } + public bool Gender { get; set; } + + public byte SlotType { get; set; } + public int SlotId { get; set; } + public int ClothId { get; set; } } } diff --git a/Server/Entities/DutyProp.cs b/Server/Entities/DutyProp.cs deleted file mode 100644 index 0de732c3..00000000 --- a/Server/Entities/DutyProp.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Text; - -/** - * @overview Life of German Reallife - Entities DutyProp DutyProp.cs - * @author VegaZ - * @copyright (c) 2008 - 2018 Life of German - */ - -namespace reallife_gamemode.Server.Entities -{ - public class DutyProp - { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int Id { get; set; } - - [ForeignKey("Faction")] - public int FactionId { get; set; } - public Faction Faction { get; set; } - - public int PropId { get; set; } - public int Drawable { get; set; } - } -} diff --git a/Server/Events/Key.cs b/Server/Events/Key.cs index fc4ccda4..7d3a56c6 100644 --- a/Server/Events/Key.cs +++ b/Server/Events/Key.cs @@ -63,7 +63,7 @@ namespace reallife_gamemode.Server.Events player.NametagColor = nameTagColor; using (var context = new DatabaseContext()) { - List clothes = context.CharacterClothes.ToList().FindAll(u => u.UserId == user.Id); + List clothes = context.CharacterClothes.ToList().FindAll(u => u.UserId == user.Id && u.Duty == true); foreach(var cloth in clothes) { @@ -80,8 +80,7 @@ namespace reallife_gamemode.Server.Events else { player.ClearAccessory(cloth.SlotId); - } - + } } } } @@ -92,11 +91,7 @@ namespace reallife_gamemode.Server.Events player.SendNotification("Du bist nun ~r~außer Dienst."); NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false); player.NametagColor = new Color(255, 255, 255); - - player.ClearAccessory(0); - //Gespeicherte Props laden lassen - player.SetDefaultClothes(); - //Gespeicherte Klamotten laden lassen + UpdateCharacterCloth.LoadCharacterDefaults(player); } } } @@ -128,28 +123,44 @@ namespace reallife_gamemode.Server.Events if (nearest == null) return; if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId) { - string[] hats; - string[] tops; - string[] legs; - string[] shoes; + List hats = new List(); + List tops = new List(); + List legs = new List(); + List shoes = new List(); - //TODO in Datenbank auslagern - if(user.GetCharacter().Gender == false) //Wenn männlich - { - hats = new string[] { "Keinen", "5", "12", "39", "46", "123", "124", "125"}; - tops = new string[] { "55", "26"}; - legs = new string[] { "24", "28" }; - shoes = new string[] { "24", "25"}; - } - else + using (var context = new DatabaseContext()) { - hats = new string[] { "Keinen", "12", "38", "45", "122", "123", "124" }; - tops = new string[] { "48", "43" }; - legs = new string[] { "34", "37", "102" }; - shoes = new string[] { "24", "25" }; - } + List clothes = context.DutyClothes.ToList().FindAll(c => c.FactionId == user.FactionId && c.Gender == user.GetCharacter().Gender); + foreach(var cloth in clothes) + { + if(cloth.SlotType == 1) + { + if (cloth.ClothId != -1) + { + hats.Add(cloth.ClothId.ToString()); + } + else + { + hats.Add("Keinen"); + } + continue; + } - player.TriggerEvent("showDutyClothMenu", hats, tops, legs, shoes); + switch (cloth.SlotId) + { + case 11: + tops.Add(cloth.ClothId.ToString()); + break; + case 4: + legs.Add(cloth.ClothId.ToString()); + break; + case 6: + shoes.Add(cloth.ClothId.ToString()); + break; + } + } + } + player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray()); } } diff --git a/Server/Events/UpdateCharacterCloth.cs b/Server/Events/UpdateCharacterCloth.cs index 2c0006cd..dba839a6 100644 --- a/Server/Events/UpdateCharacterCloth.cs +++ b/Server/Events/UpdateCharacterCloth.cs @@ -177,7 +177,7 @@ namespace reallife_gamemode.Server.Events foreach(var cloth in charClothes) { - if(cloth.SlotType == 0) + if(cloth.SlotType == 1) { if (cloth.ClothId == -1) {