93 lines
2.9 KiB
C#
93 lines
2.9 KiB
C#
using GTANetworkAPI;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using ReallifeGamemode.Database.Entities;
|
|
using ReallifeGamemode.Database.Models;
|
|
using System.Linq;
|
|
using Newtonsoft.Json;
|
|
using ReallifeGamemode.Server.Extensions;
|
|
|
|
namespace ReallifeGamemode.Server.Shop.Clothing
|
|
{
|
|
public class ClotheShop
|
|
{
|
|
public int category { get; set; } = 1;
|
|
public List<ShopClothe> clotheList = new List<ShopClothe>();
|
|
|
|
|
|
public ClotheShop(int category)
|
|
{
|
|
this.category = category;
|
|
LoadClothes();
|
|
}
|
|
|
|
public void LoadClothes()
|
|
{
|
|
|
|
using (var dbContext = new DatabaseContext())
|
|
{
|
|
clotheList = dbContext.ShopClothes.ToList().FindAll(c => c.Category == category);
|
|
}
|
|
|
|
}
|
|
|
|
[Command("buyclothes")]
|
|
public void LoadShopNUI(Client client)
|
|
{
|
|
LoadClothes();
|
|
|
|
using (var dbContext = new DatabaseContext())
|
|
{
|
|
List<Clothe> clothes = new List<Clothe>();
|
|
bool gender = client.GetUser().Character.Gender;
|
|
foreach (var clothe in clotheList)
|
|
{
|
|
if(clothe.TypeId == "clothes" )
|
|
{
|
|
switch (clothe.ComponentId)
|
|
{
|
|
case 11: //tops
|
|
List<ClothCombination> combinations = dbContext.ClothCombinations.Where(c => c.Top == clothe.ClotheId && c.Gender == gender).ToList();
|
|
foreach (var combination in combinations)
|
|
{
|
|
var top = new Clothe
|
|
{
|
|
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
|
|
ClotheId = clothe.ClotheId,
|
|
Gender = gender,
|
|
TypeId = "clothes",
|
|
clothe = "clothes",
|
|
Category = category,
|
|
Price = clothe.Price,
|
|
undershirtId = combination.Undershirt,
|
|
torsoId = combination.Torso
|
|
};
|
|
clothes.Add(top);
|
|
}
|
|
break;
|
|
default: //everything else
|
|
var garment = new Clothe
|
|
{
|
|
ComponentId = clothe.ComponentId, //needs to be fist bc it acts like an identifier in JS
|
|
ClotheId = clothe.ClotheId,
|
|
Gender = gender,
|
|
TypeId = "clothes",
|
|
clothe = "clothes",
|
|
Category = category,
|
|
Price = clothe.Price,
|
|
undershirtId = -1, //will not be used unless top
|
|
torsoId = -1 //will not be used unless top
|
|
};
|
|
clothes.Add(garment);
|
|
break;
|
|
|
|
}
|
|
}
|
|
}
|
|
client.TriggerEvent("clothesMenu:updateData", JsonConvert.SerializeObject(category), JsonConvert.SerializeObject(clothes.ToArray()));
|
|
}
|
|
}
|
|
}
|
|
}
|