From 0dc123590904e45de89afd8467a28a1fb86c709a Mon Sep 17 00:00:00 2001 From: hydrant Date: Sun, 29 Mar 2020 17:40:35 +0200 Subject: [PATCH] improve house --- ReallifeGamemode.Database/Entities/House.cs | 11 +---------- ReallifeGamemode.Server.Core/Managers/HouseManager.cs | 6 +++--- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/ReallifeGamemode.Database/Entities/House.cs b/ReallifeGamemode.Database/Entities/House.cs index c4e8258c..666d74f1 100644 --- a/ReallifeGamemode.Database/Entities/House.cs +++ b/ReallifeGamemode.Database/Entities/House.cs @@ -28,19 +28,10 @@ namespace ReallifeGamemode.Database.Entities public DateTime LastRentSetTime { get; set; } [NotMapped] - public Vector3 Position => new Vector3(X, Y, Z); - - [NotMapped] - public Position NewPosition => new Position(X, Y, Z); + public Position Position => new Position(X, Y, Z); [ForeignKey("Owner")] public int? OwnerId { get; set; } public User Owner { get; set; } - - [NotMapped] - public Player User => Owner?.Player; - - [NotMapped] - public IPlayer OwnerPlayer => new RagePlayer(User); } } diff --git a/ReallifeGamemode.Server.Core/Managers/HouseManager.cs b/ReallifeGamemode.Server.Core/Managers/HouseManager.cs index 0f4afc02..a1cfada1 100644 --- a/ReallifeGamemode.Server.Core/Managers/HouseManager.cs +++ b/ReallifeGamemode.Server.Core/Managers/HouseManager.cs @@ -176,7 +176,7 @@ namespace ReallifeGamemode.Server.Core.Managers public House GetNearHouse(Position position, DatabaseContext dbContext) { - return dbContext.Houses.Where(h => h.NewPosition.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.NewPosition.DistanceTo(position)).FirstOrDefault(); + return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).Include(h => h.Owner).OrderBy(h => h.Position.DistanceTo(position)).FirstOrDefault(); } public void ReloadAllHouses() @@ -337,7 +337,7 @@ namespace ReallifeGamemode.Server.Core.Managers player.SendNotification("~g~Du hast dich in das Haus eingemietet"); - house.OwnerPlayer?.SendNotification($"~y~{player.Name}~s~ hat sich in dein Haus eingemietet."); + house.Owner?.NewPlayer?.SendNotification($"~y~{player.Name}~s~ hat sich in dein Haus eingemietet."); SendPlayerHouseData(player, house); } @@ -366,7 +366,7 @@ namespace ReallifeGamemode.Server.Core.Managers dbContext.SaveChanges(); player.SendNotification("~g~Du hast den Mietvertrag gekündigt."); - house.OwnerPlayer?.SendNotification($"~y~{player.Name}~s~ hat seinen Mietvertrag gekündigt."); + house.Owner?.NewPlayer?.SendNotification($"~y~{player.Name}~s~ hat seinen Mietvertrag gekündigt."); RemoveHouse(house); LoadHouse(house);