Finish Duty-System (Clothing)

This commit is contained in:
VegaZ
2018-11-21 17:20:53 +01:00
parent 5e7a8ac0ae
commit 8919e76b75
5 changed files with 44 additions and 59 deletions

View File

@@ -35,7 +35,6 @@ namespace reallife_gamemode.Model
public DbSet<Server.Entities.Character> Characters { get; set; }
public DbSet<Server.Entities.CharacterCloth> CharacterClothes { get; set; }
public DbSet<Server.Entities.DutyCloth> DutyClothes { get; set; }
public DbSet<Server.Entities.DutyProp> DutyProps { get; set; }
public DbSet<Server.Entities.MaleCombination> MaleCombinations { get; set; }
public DbSet<Server.Entities.FemaleCombination> FemaleCombinations { get; set; }
public DbSet<Server.Entities.User> Users { get; set; }

View File

@@ -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; }
}
}

View File

@@ -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; }
}
}

View File

@@ -63,7 +63,7 @@ namespace reallife_gamemode.Server.Events
player.NametagColor = nameTagColor;
using (var context = new DatabaseContext())
{
List<CharacterCloth> clothes = context.CharacterClothes.ToList().FindAll(u => u.UserId == user.Id);
List<CharacterCloth> clothes = context.CharacterClothes.ToList().FindAll(u => u.UserId == user.Id && u.Duty == true);
foreach(var cloth in clothes)
{
@@ -81,7 +81,6 @@ namespace reallife_gamemode.Server.Events
{
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<string> hats = new List<string>();
List<string> tops = new List<string>();
List<string> legs = new List<string>();
List<string> shoes = new List<string>();
//TODO in Datenbank auslagern
if(user.GetCharacter().Gender == false) //Wenn männlich
using (var context = new DatabaseContext())
{
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
{
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<DutyCloth> 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());
}
}

View File

@@ -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)
{