角色控制和房间进入推送
This commit is contained in:
@@ -18,9 +18,34 @@ public class MapRoomDestroySystem : DestroySystem<MapRoom>
|
||||
|
||||
public static class MapRoomSystem
|
||||
{
|
||||
public static async FTask<uint> Enter(this MapRoom self, long unitId)
|
||||
public static async FTask<uint> Enter(this MapRoom self, MapUnit unit)
|
||||
{
|
||||
self.Units.TryAdd(unit.Id, unit);
|
||||
|
||||
var notifyMessage = new Map2C_RoleEnterRoomNotify()
|
||||
{
|
||||
Info = unit.ToMapUnitInfo(),
|
||||
};
|
||||
|
||||
foreach (var (_, roomUnit) in self.Units)
|
||||
{
|
||||
// if (roomUnit.Id == unit.Id) continue;
|
||||
// 同步其他客户端
|
||||
self.Scene.NetworkMessagingComponent.SendInnerRoute(roomUnit.GateRouteId, notifyMessage);
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
return ErrorCode.Successful;
|
||||
}
|
||||
|
||||
public static List<MapUnitInfo> ToMapUnitInfo(this MapRoom self)
|
||||
{
|
||||
List<MapUnitInfo> ret = new List<MapUnitInfo>();
|
||||
foreach (var (_, unit) in self.Units)
|
||||
{
|
||||
ret.Add(unit.ToMapUnitInfo());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public class MapUnitSystemDestroySystem : DestroySystem<MapUnit>
|
||||
{
|
||||
self.MapId = 0;
|
||||
self.Position = float3.zero;
|
||||
self.Rotation = float4.zero;
|
||||
self.Rotation = float3.zero;
|
||||
self.GateRouteId = 0L;
|
||||
}
|
||||
}
|
||||
@@ -40,4 +40,25 @@ public static class MapUnitSystem
|
||||
|
||||
return ErrorCode.Successful;
|
||||
}
|
||||
|
||||
|
||||
public static MapUnitInfo ToMapUnitInfo(this MapUnit self)
|
||||
{
|
||||
var ret = new MapUnitInfo()
|
||||
{
|
||||
Id = self.Id,
|
||||
Position = Vector3Info.Create(self.Scene),
|
||||
Rotation = Vector3Info.Create(self.Scene),
|
||||
};
|
||||
|
||||
ret.Position.x = self.Position.x;
|
||||
ret.Position.y = self.Position.y;
|
||||
ret.Position.z = self.Position.z;
|
||||
|
||||
ret.Rotation.x = self.Rotation.x;
|
||||
ret.Rotation.y = self.Rotation.y;
|
||||
ret.Rotation.z = self.Rotation.z;
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
@@ -31,6 +32,24 @@ public static class RoomManageComponentSystem
|
||||
{
|
||||
#region 增删
|
||||
|
||||
public static MapRoom? Create(this RoomManageComponent self, long ownerId)
|
||||
{
|
||||
var roomId = self.AllocateId();
|
||||
if (roomId < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// roomManageComponent.on
|
||||
var room = Entity.Create<MapRoom>(self.Scene, true, true);
|
||||
room.Owner = ownerId;
|
||||
room.RoomId = roomId;
|
||||
room.Code = RoomHelper.GenerateCode(self.Scene.SceneConfigId, roomId);
|
||||
self.Add(room);
|
||||
|
||||
return room;
|
||||
}
|
||||
|
||||
public static void Add(this RoomManageComponent self, MapRoom room)
|
||||
{
|
||||
self.Rooms[room.RoomId] = room;
|
||||
@@ -46,10 +65,12 @@ public static class RoomManageComponentSystem
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static MapRoom? Get(this RoomManageComponent self, int roomId)
|
||||
{
|
||||
return self.Rooms.GetValueOrDefault(roomId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 房间Id
|
||||
@@ -81,6 +102,4 @@ public static class RoomManageComponentSystem
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user