移动同步相关
This commit is contained in:
@@ -9,6 +9,13 @@ public class C2Map_LookHandler : Route<MapUnit, C2Map_Look>
|
||||
protected override async FTask Run(MapUnit entity, C2Map_Look message)
|
||||
{
|
||||
var roomManageComponent = entity.Scene.GetComponent<RoomManageComponent>();
|
||||
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<MapUnit, C2Map_Look>
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,14 @@ public class C2Map_MoveHandler : Route<MapUnit, C2Map_Move>
|
||||
{
|
||||
protected override async FTask Run(MapUnit entity, C2Map_Move message)
|
||||
{
|
||||
var mapUnitManageComponent = entity.Scene.GetComponent<MapUnitManageComponent>();
|
||||
var roomManageComponent = entity.Scene.GetComponent<RoomManageComponent>();
|
||||
var roomId = entity.RoomId;
|
||||
var room = roomManageComponent.Get(roomId);
|
||||
if (room == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// var mapUnitManageComponent = entity.Scene.GetComponent<MapUnitManageComponent>();
|
||||
var notifyMessage = new Map2C_MoveNotify()
|
||||
{
|
||||
Id = entity.Id,
|
||||
@@ -28,10 +35,11 @@ public class C2Map_MoveHandler : Route<MapUnit, C2Map_Move>
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class G2Map_EnterMapRequestHandler : RouteRPC<Scene, G2Map_EnterMapReques
|
||||
response.RoomCode = room.Code;
|
||||
if (response.ErrorCode == ErrorCode.Successful)
|
||||
{
|
||||
mapUnit.RoomId = room.Id;
|
||||
mapUnit.RoomId = room.RoomId;
|
||||
response.Units = room.ToMapUnitInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,11 @@ public static class RoomManageComponentSystem
|
||||
{
|
||||
return self.Rooms.GetValueOrDefault(roomId);
|
||||
}
|
||||
|
||||
// public static MapRoom? Get(this RoomManageComponent self, long roomId)
|
||||
// {
|
||||
// return self.Rooms.GetValueOrDefault(roomId);
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user