diff --git a/Entity/Map/Component/RoomManageComponent.cs b/Entity/Map/Component/RoomManageComponent.cs index 5583847..4d193a5 100644 --- a/Entity/Map/Component/RoomManageComponent.cs +++ b/Entity/Map/Component/RoomManageComponent.cs @@ -4,7 +4,7 @@ namespace NB.Map; public class RoomManageComponent : Entity { - public readonly Dictionary Rooms = new(); + public readonly Dictionary Rooms = new(); public readonly PriorityQueue FreeIds = new(); public readonly HashSet InUseID = new(); diff --git a/Entity/Map/Entity/MapUnit.cs b/Entity/Map/Entity/MapUnit.cs index 35e53c6..a453728 100644 --- a/Entity/Map/Entity/MapUnit.cs +++ b/Entity/Map/Entity/MapUnit.cs @@ -32,7 +32,7 @@ public class MapUnit : Entity /// /// 当前所在的房间id /// - public long RoomId; + public int RoomId; public long GateRouteId; diff --git a/Hotfix/Map/Handler/C2Map_LookHandler.cs b/Hotfix/Map/Handler/C2Map_LookHandler.cs index 4278f25..a905d91 100644 --- a/Hotfix/Map/Handler/C2Map_LookHandler.cs +++ b/Hotfix/Map/Handler/C2Map_LookHandler.cs @@ -9,6 +9,13 @@ public class C2Map_LookHandler : Route protected override async FTask Run(MapUnit entity, C2Map_Look message) { var roomManageComponent = entity.Scene.GetComponent(); + var roomId = entity.RoomId; + var room = roomManageComponent.Get(roomId); + if (room == null) + { + return; + } + var notifyMessage = new Map2C_LookeNotify() { Id = entity.Id, @@ -19,14 +26,11 @@ public class C2Map_LookHandler : Route entity.Rotation.x = message.Rotation.x; entity.Rotation.y = message.Rotation.y; entity.Rotation.z = message.Rotation.z; - - var room = roomManageComponent.Get(entity.MapId); - - // foreach (var (_, unit) in mapUnitManageComponent.Units) - // { - // entity.Scene.NetworkMessagingComponent.SendInnerRoute(unit.GateRouteId, notifyMessage); - // } + foreach (var (_, unit) in room.Units) + { + entity.Scene.NetworkMessagingComponent.SendInnerRoute(unit.GateRouteId, notifyMessage); + } await FTask.CompletedTask; } diff --git a/Hotfix/Map/Handler/C2Map_MoveHandler.cs b/Hotfix/Map/Handler/C2Map_MoveHandler.cs index d465648..60151a5 100644 --- a/Hotfix/Map/Handler/C2Map_MoveHandler.cs +++ b/Hotfix/Map/Handler/C2Map_MoveHandler.cs @@ -9,7 +9,14 @@ public class C2Map_MoveHandler : Route { protected override async FTask Run(MapUnit entity, C2Map_Move message) { - var mapUnitManageComponent = entity.Scene.GetComponent(); + var roomManageComponent = entity.Scene.GetComponent(); + var roomId = entity.RoomId; + var room = roomManageComponent.Get(roomId); + if (room == null) + { + return; + } + // var mapUnitManageComponent = entity.Scene.GetComponent(); var notifyMessage = new Map2C_MoveNotify() { Id = entity.Id, @@ -28,10 +35,11 @@ public class C2Map_MoveHandler : Route entity.Rotation.y = message.Rotation.y; entity.Rotation.z = message.Rotation.z; - foreach (var (_, unit) in mapUnitManageComponent.Units) + foreach (var (_, unit) in room.Units) { entity.Scene.NetworkMessagingComponent.SendInnerRoute(unit.GateRouteId, notifyMessage); } + await FTask.CompletedTask; } diff --git a/Hotfix/Map/Handler/Inner/G2Map_EnterMapRequestHandler.cs b/Hotfix/Map/Handler/Inner/G2Map_EnterMapRequestHandler.cs index e0d1692..d256b14 100644 --- a/Hotfix/Map/Handler/Inner/G2Map_EnterMapRequestHandler.cs +++ b/Hotfix/Map/Handler/Inner/G2Map_EnterMapRequestHandler.cs @@ -64,7 +64,7 @@ public class G2Map_EnterMapRequestHandler : RouteRPCForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded