54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using Fantasy;
|
|
using Fantasy.Async;
|
|
using Fantasy.Helper;
|
|
using Fantasy.Network.Interface;
|
|
|
|
namespace NB.Game;
|
|
|
|
public class C2Map_MoveHandler : Address<Player, C2Game_Move>
|
|
{
|
|
protected override async FTask Run(Player entity, C2Game_Move message)
|
|
{
|
|
var mapUnit = entity.GetComponent<MapUnitComponent>();
|
|
if (mapUnit == null)
|
|
{
|
|
// response.ErrorCode = ErrorCode.ErrServer;
|
|
return;
|
|
}
|
|
|
|
var roomManageComponent = entity.Scene.GetComponent<RoomManageComponent>();
|
|
var roomId = mapUnit.RoomId;
|
|
var room = roomManageComponent.Get(roomId);
|
|
if (room == null)
|
|
{
|
|
return;
|
|
}
|
|
// var mapUnitManageComponent = entity.Scene.GetComponent<MapUnitManageComponent>();
|
|
var notifyMessage = new Game2C_MoveNotify()
|
|
{
|
|
Id = entity.Id,
|
|
Position = message.Position,
|
|
Rotation = message.Rotation,
|
|
IsStop = message.IsStop,
|
|
Direction = message.Direction,
|
|
Timestamp = TimeHelper.Now
|
|
};
|
|
|
|
// entity.Position.x = message.Position.x;
|
|
// entity.Position.y = message.Position.y;
|
|
// entity.Position.z = message.Position.z;
|
|
//
|
|
// entity.Rotation.x = message.Rotation.x;
|
|
// entity.Rotation.y = message.Rotation.y;
|
|
// entity.Rotation.z = message.Rotation.z;
|
|
|
|
foreach (var (_, unit) in room.Units)
|
|
{
|
|
// if (unit.Id == entity.Id) continue;
|
|
entity.Scene.NetworkMessagingComponent.Send(unit.SessionRunTimeId, notifyMessage);
|
|
}
|
|
|
|
|
|
await FTask.CompletedTask;
|
|
}
|
|
} |