Unite Male/Female-Combinations to ClothCombination

This commit is contained in:
VegaZ
2018-11-22 20:10:38 +01:00
parent ad6e5a13f5
commit 2b8e9cce00
4 changed files with 15 additions and 105 deletions

View File

@@ -35,8 +35,7 @@ namespace reallife_gamemode.Model
public DbSet<Server.Entities.Character> Characters { get; set; } public DbSet<Server.Entities.Character> Characters { get; set; }
public DbSet<Server.Entities.CharacterCloth> CharacterClothes { get; set; } public DbSet<Server.Entities.CharacterCloth> CharacterClothes { get; set; }
public DbSet<Server.Entities.DutyCloth> DutyClothes { get; set; } public DbSet<Server.Entities.DutyCloth> DutyClothes { get; set; }
public DbSet<Server.Entities.MaleCombination> MaleCombinations { get; set; } public DbSet<Server.Entities.ClothCombination> ClothCombinations { get; set; }
public DbSet<Server.Entities.FemaleCombination> FemaleCombinations { get; set; }
public DbSet<Server.Entities.User> Users { get; set; } public DbSet<Server.Entities.User> Users { get; set; }
public DbSet<Server.Entities.UserVehicle> UserVehicles { get; set; } public DbSet<Server.Entities.UserVehicle> UserVehicles { get; set; }
public DbSet<Server.Entities.UserBankAccount> UserBankAccounts { get; set; } public DbSet<Server.Entities.UserBankAccount> UserBankAccounts { get; set; }

View File

@@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Numerics;
using System.Text;
/**
* @overview Life of German Reallife - Entities FemaleCombination (FemaleCombination.cs)
* @author VegaZ
* @copyright (c) 2008 - 2018 Life of German
*/
namespace reallife_gamemode.Server.Entities
{
public class FemaleCombination
{
[Key]
public int Id { get; set; }
public int Top { get; set; }
public int Torso { get; set; }
public int Undershirt { get; set; }
}
}

View File

@@ -1,24 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Numerics;
using System.Text;
/**
* @overview Life of German Reallife - Entities MaleCombination (MaleCombination.cs)
* @author VegaZ
* @copyright (c) 2008 - 2018 Life of German
*/
namespace reallife_gamemode.Server.Entities
{
public class MaleCombination
{
[Key]
public int Id { get; set; }
public int Top { get; set; }
public int Torso { get; set; }
public int Undershirt { get; set; }
}
}

View File

@@ -34,25 +34,14 @@ namespace reallife_gamemode.Server.Events
//TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL) //TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL)
using (var context = new DatabaseContext()) using (var context = new DatabaseContext())
{ {
if (player.GetUser().GetCharacter().Gender == false) var character = player.GetUser().GetCharacter();
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
player.SetClothes(11, componentVariation, 0);
if (combination != null)
{ {
var combination = context.MaleCombinations.FirstOrDefault(c => c.Top == componentVariation); player.SetClothes(3, combination.Torso, 0);
player.SetClothes(11, componentVariation, 0); player.SetClothes(8, combination.Undershirt, 0);
if (combination != null)
{
player.SetClothes(3, combination.Torso, 0);
player.SetClothes(8, combination.Undershirt, 0);
}
}
else
{
var combination = context.FemaleCombinations.FirstOrDefault(c => c.Top == componentVariation);
player.SetClothes(11, componentVariation, 0);
if (combination != null)
{
player.SetClothes(3, combination.Torso, 0);
player.SetClothes(8, combination.Undershirt, 0);
}
} }
} }
} }
@@ -74,6 +63,8 @@ namespace reallife_gamemode.Server.Events
User user = client.GetUser(); User user = client.GetUser();
user = context.Users.FirstOrDefault(u => u.Id == user.Id); user = context.Users.FirstOrDefault(u => u.Id == user.Id);
var character = client.GetUser().GetCharacter();
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id); var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
if (charClothes == null) if (charClothes == null)
{ {
@@ -101,7 +92,7 @@ namespace reallife_gamemode.Server.Events
SlotType = 0, SlotType = 0,
SlotId = 3, SlotId = 3,
ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
}; };
CharacterCloth newUndershirt = new CharacterCloth CharacterCloth newUndershirt = new CharacterCloth
{ {
@@ -111,32 +102,7 @@ namespace reallife_gamemode.Server.Events
SlotType = 0, SlotType = 0,
SlotId = 8, SlotId = 8,
ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
};
context.CharacterClothes.Add(newTorso);
context.CharacterClothes.Add(newUndershirt);
}
else
{
CharacterCloth newTorso = new CharacterCloth
{
UserId = user.Id,
Duty = true,
SlotType = 0,
SlotId = 3,
ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso
};
CharacterCloth newUndershirt = new CharacterCloth
{
UserId = user.Id,
Duty = true,
SlotType = 0,
SlotId = 8,
ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt
}; };
context.CharacterClothes.Add(newTorso); context.CharacterClothes.Add(newTorso);
context.CharacterClothes.Add(newUndershirt); context.CharacterClothes.Add(newUndershirt);
@@ -151,16 +117,9 @@ namespace reallife_gamemode.Server.Events
} }
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3); CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8); CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
if (user.GetCharacter().Gender == false)
{ torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
torso.ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso; undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
undershirt.ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt;
}
else
{
torso.ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso;
undershirt.ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt;
}
} }
context.SaveChanges(); context.SaveChanges();
} }