add house reload command
This commit is contained in:
@@ -14,6 +14,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
private static readonly Dictionary<int, NetHandle> houseMarkers = new Dictionary<int, NetHandle>();
|
||||
private static readonly Dictionary<int, NetHandle> houseLabels = new Dictionary<int, NetHandle>();
|
||||
private static readonly Dictionary<int, NetHandle> houseColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static void LoadHouses()
|
||||
{
|
||||
@@ -21,7 +22,19 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
foreach (House house in dbContext.Houses.Include(h => h.User))
|
||||
{
|
||||
LoadHouse(house);
|
||||
LoadHouse(house, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async static void ReloadAllHouses()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach(House house in await dbContext.Houses.Include(h => h.User).ToListAsync())
|
||||
{
|
||||
RemoveHouse(house);
|
||||
LoadHouse(house, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,8 +74,10 @@ namespace ReallifeGamemode.Server.Managers
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadHouse(House house)
|
||||
public static void LoadHouse(House house, bool loadUser = true)
|
||||
{
|
||||
if (loadUser) house = house.Refresh();
|
||||
|
||||
houseMarkers[house.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, house.Position.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255));
|
||||
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{house.Price.ToMoneyString()}";
|
||||
if(house.User != null)
|
||||
@@ -74,11 +89,17 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
public static void RemoveHouse(House house)
|
||||
{
|
||||
houseMarkers[house.Id].Entity<Marker>().Delete();
|
||||
houseLabels[house.Id].Entity<TextLabel>().Delete();
|
||||
if (houseMarkers.ContainsKey(house.Id))
|
||||
{
|
||||
houseMarkers[house.Id].Entity<Marker>().Delete();
|
||||
houseMarkers.Remove(house.Id);
|
||||
}
|
||||
|
||||
houseMarkers.Remove(house.Id);
|
||||
houseLabels.Remove(house.Id);
|
||||
if(houseLabels.ContainsKey(house.Id))
|
||||
{
|
||||
houseLabels[house.Id].Entity<TextLabel>().Delete();
|
||||
houseLabels.Remove(house.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user