角色控制和房间进入推送

This commit is contained in:
2025-09-07 23:51:17 +08:00
parent 61d20b5729
commit 7dad49bf5f
28 changed files with 432 additions and 221 deletions

View File

@@ -4,5 +4,4 @@
(ë" MultiThread*Gate2KCP8 ś@ŤVH
ě" MultiThread*Game@—VH
î" MultiThread*Chat@«VH
ď" MultiThread*Map@µVH
đ" MultiThread*Map@¶VH
ď" MultiThread*Map@µVH

Binary file not shown.

View File

@@ -1 +1 @@
{"WorksheetNames":[-8419147776733210060,-3495952183970875596,1720330851179383898,3730651590607244245],"Tables":{"-3495952183970875596":1756269765285,"-1088042625810372120":1748918712210,"1720330851179383898":1753770985781,"3730651590607244245":1748918712210,"5812538452563588342":1751250727840}}
{"WorksheetNames":[-8419147776733210060,-3495952183970875596,-1088042625810372120,1720330851179383898],"Tables":{"-3495952183970875596":1757242691062,"-1088042625810372120":1753532052628,"1720330851179383898":1753711757684,"3730651590607244245":1753532052629,"5812538452563588342":1753532052630}}

View File

@@ -4,6 +4,5 @@
{"Id":1003,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Gate","NetworkProtocol":"KCP","OuterPort":20000,"InnerPort":11021,"SceneType":3},
{"Id":1004,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Game","NetworkProtocol":null,"OuterPort":0,"InnerPort":11031,"SceneType":4},
{"Id":1006,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Chat","NetworkProtocol":null,"OuterPort":0,"InnerPort":11051,"SceneType":8},
{"Id":1007,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Map","NetworkProtocol":null,"OuterPort":0,"InnerPort":11061,"SceneType":5},
{"Id":1008,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Map","NetworkProtocol":null,"OuterPort":0,"InnerPort":11062,"SceneType":5}
{"Id":1007,"ProcessConfigId":1,"WorldConfigId":1,"SceneRuntimeMode":"MultiThread","SceneTypeString":"Map","NetworkProtocol":null,"OuterPort":0,"InnerPort":11061,"SceneType":5}
]}

View File

@@ -42,7 +42,7 @@ message G2C_ExitRoomResponse // IResponse
message C2Map_EnterMapRequest // ICustomRouteRequest,Map2C_EnterMapResponse,MapRoute
{
int32 MapId = 1;//地图id
int64 RoomId = 2;//房间id如果联机则有
string RoomId = 2;//房间id如果联机则有
}
message Map2C_EnterMapResponse // ICustomRouteResponse

View File

@@ -47,6 +47,6 @@ message C2Game_GetRoleInfoRequest // ICustomRouteRequest,Game2C_GetRoleInfoRespo
message Game2C_GetRoleInfoResponse // ICustomRouteResponse
{
RoleInfo RoleInfo = 1; //账号信息
int64 RoomId = 2; //所在房间
RoleInfo RoleInfo = 1; //账号信息
string RoomCode = 2; //所在房间
}

View File

@@ -2,36 +2,15 @@ syntax = "proto3";
package Fantasy.Network.Message;
message C2Map_EnterRoomRequest // ICustomRouteRequest,Map2C_EnterRoomResponse,MapRoute
{
int32 MapId = 1;//房间id
string Password = 2;//进入密码
}
message Map2C_EnterRoomResponse // ICustomRouteResponse
{
int32 MapId = 1;//地图id
int64 RoomId = 2;//房间id
}
message C2Map_Move // ICustomRouteMessage,MapRoute
{
MapUnitPositionInfo Location = 1;
bool IsStop = 2;
}
///用户进入地图
message Map2C_RoleEnterMapNotify // ICustomRouteMessage,MapRoute
message Map2C_RoleEnterRoomNotify // ICustomRouteMessage,MapRoute
{
MapUnitInfo Info = 1;
}
///用户离开地图
message Map2C_RoleExitMapNotify // ICustomRouteMessage,MapRoute
message Map2C_RoleExitRoomNotify // ICustomRouteMessage,MapRoute
{
int64 Id = 1;//离开人员
}
@@ -57,9 +36,39 @@ message Map2C_RoleGearChangeNotify // ICustomRouteMessage,MapRoute
GearInfo Gears = 2; //钓组数据
}
///玩家位置变化
message Map2C_MoveNotify
//************** 移动 旋转 **********************
// 角色移动
message C2Map_Move // ICustomRouteMessage,MapRoute
{
int64 Id = 1;
MapUnitPositionInfo Location = 2;
Vector3Info Position = 1; //当前位置
Vector3Info Rotation = 2; //角色方向
Vector3Info Direction = 3; // 移动方向
bool IsStop = 4; // 是否是停止移动
int64 Timestamp = 5; // 时间点
}
// 角色朝向变化
message C2Map_Look // ICustomRouteMessage,MapRoute
{
Vector3Info Rotation = 1; //角色方向
int64 Timestamp = 2; // 时间点
}
///玩家移动推送
message Map2C_MoveNotify // ICustomRouteMessage,MapRoute
{
int64 Id = 1; // id
Vector3Info Position = 2; //当前位置
Vector3Info Rotation = 3; //角色方向
Vector3Info Direction = 4; // 移动方向
bool IsStop = 5; // 是否停止移动
int64 Timestamp = 6; // 时间点
}
///玩家旋转推送
message Map2C_LookeNotify // ICustomRouteMessage,MapRoute
{
int64 Id = 1; // id
Vector3Info Rotation = 2; //角色方向
int64 Timestamp = 3; // 时间点
}

View File

@@ -4,6 +4,13 @@ message Vector3Info
float y = 2;
float z = 3;
}
message Vector2Info
{
float x = 1;
float y = 2;
}
message QuaternionInfo
{
float x = 1;
@@ -30,15 +37,11 @@ message MapUnitInfo
{
int64 Id = 1; //用户id
RoleSimpleInfo RoleInfo = 2; //基础信息
MapUnitPositionInfo Location = 3; //位置信息
UnitStateInfo State = 4; //状态信息
GearInfo Gears = 5; //钓组数据
UnitFishingInfo FishingInfo = 6; //钓鱼状态信息
repeated KeyValueInt32 KV = 7; //属性信息
Vector3Info Position = 3; //当前位置
Vector3Info Rotation = 4; //角色方向
UnitStateInfo State = 5; //状态信息
GearInfo Gears = 6; //钓组数据
UnitFishingInfo FishingInfo = 7; //钓鱼状态信息
repeated KeyValueInt32 KV = 8; //属性信息
}
message MapUnitPositionInfo
{
Vector3Info Position = 1;
QuaternionInfo Rotation = 2;
}

View File

@@ -189,7 +189,7 @@ namespace Fantasy
[ProtoMember(1)]
public int MapId { get; set; }
[ProtoMember(2)]
public long RoomId { get; set; }
public string RoomId { get; set; }
}
[ProtoContract]
public partial class Map2C_EnterMapResponse : AMessage, ICustomRouteResponse, IProto

View File

@@ -41,6 +41,26 @@ namespace Fantasy
public float z { get; set; }
}
[ProtoContract]
public partial class Vector2Info : AMessage, IProto
{
public static Vector2Info Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Vector2Info>();
}
public override void Dispose()
{
x = default;
y = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Vector2Info>(this);
#endif
}
[ProtoMember(1)]
public float x { get; set; }
[ProtoMember(2)]
public float y { get; set; }
}
[ProtoContract]
public partial class QuaternionInfo : AMessage, IProto
{
public static QuaternionInfo Create(Scene scene)
@@ -123,7 +143,8 @@ namespace Fantasy
{
Id = default;
RoleInfo = default;
Location = default;
Position = default;
Rotation = default;
State = default;
Gears = default;
FishingInfo = default;
@@ -137,34 +158,16 @@ namespace Fantasy
[ProtoMember(2)]
public RoleSimpleInfo RoleInfo { get; set; }
[ProtoMember(3)]
public MapUnitPositionInfo Location { get; set; }
public Vector3Info Position { get; set; }
[ProtoMember(4)]
public UnitStateInfo State { get; set; }
public Vector3Info Rotation { get; set; }
[ProtoMember(5)]
public GearInfo Gears { get; set; }
public UnitStateInfo State { get; set; }
[ProtoMember(6)]
public UnitFishingInfo FishingInfo { get; set; }
public GearInfo Gears { get; set; }
[ProtoMember(7)]
public UnitFishingInfo FishingInfo { get; set; }
[ProtoMember(8)]
public List<KeyValueInt32> KV = new List<KeyValueInt32>();
}
[ProtoContract]
public partial class MapUnitPositionInfo : AMessage, IProto
{
public static MapUnitPositionInfo Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<MapUnitPositionInfo>();
}
public override void Dispose()
{
Position = default;
Rotation = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<MapUnitPositionInfo>(this);
#endif
}
[ProtoMember(1)]
public Vector3Info Position { get; set; }
[ProtoMember(2)]
public QuaternionInfo Rotation { get; set; }
}
}

View File

@@ -159,7 +159,7 @@ namespace Fantasy
{
ErrorCode = default;
RoleInfo = default;
RoomId = default;
RoomCode = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Game2C_GetRoleInfoResponse>(this);
#endif
@@ -168,7 +168,7 @@ namespace Fantasy
[ProtoMember(1)]
public RoleInfo RoleInfo { get; set; }
[ProtoMember(2)]
public long RoomId { get; set; }
public string RoomCode { get; set; }
[ProtoMember(3)]
public uint ErrorCode { get; set; }
}

View File

@@ -18,45 +18,46 @@ namespace Fantasy
public const uint G2C_RepeatLogin = 134227729;
public const uint C2Game_GetRoleInfoRequest = 2281711379;
public const uint Game2C_GetRoleInfoResponse = 2415929107;
public const uint C2Map_EnterRoomRequest = 2281711380;
public const uint Map2C_EnterRoomResponse = 2415929108;
public const uint C2Map_Move = 2147493650;
public const uint Map2C_RoleEnterMapNotify = 2147493651;
public const uint Map2C_RoleExitMapNotify = 2147493652;
public const uint Map2C_RoleStateNotify = 2147493653;
public const uint Map2C_RoleGearStateNotify = 2147493654;
public const uint Map2C_RoleGearChangeNotify = 2147493655;
public const uint C2S_GetConversationsRequest = 2281711381;
public const uint S2C_GetConversationsResponse = 2415929109;
public const uint C2S_SendMailRequest = 2281711382;
public const uint S2C_SendMailResponse = 2415929110;
public const uint C2S_DeleteMailRequest = 2281711383;
public const uint S2C_DeleteMailResponse = 2415929111;
public const uint S2C_HaveMail = 2147493656;
public const uint S2C_MailState = 2147493657;
public const uint C2S_CreateChannelRequest = 2281711384;
public const uint S2C_CreateChannelResponse = 2415929112;
public const uint C2S_JoinChannelRequest = 2281711385;
public const uint S2C_JoinChannelResponse = 2415929113;
public const uint C2S_SendMessageRequest = 2281711386;
public const uint S2C_SendMessageResponse = 2415929114;
public const uint S2C_Message = 2147493658;
public const uint C2S_CreateClubRequest = 2281711387;
public const uint S2C_CreateClubResponse = 2415929115;
public const uint C2S_GetClubInfoRequest = 2281711388;
public const uint S2C_GetClubInfoResponse = 2415929116;
public const uint C2S_GetMemberListRequest = 2281711389;
public const uint S2C_GetMemberListResponse = 2415929117;
public const uint C2S_GetClubListRequest = 2281711390;
public const uint S2C_GetClubListResponse = 2415929118;
public const uint C2S_JoinClubRequest = 2281711391;
public const uint S2C_JoinClubResponse = 2415929119;
public const uint C2S_LeaveClubRequest = 2281711392;
public const uint S2C_LeaveClubResponse = 2415929120;
public const uint C2S_DissolveClubRequest = 2281711393;
public const uint S2C_DissolveClubResponse = 2415929121;
public const uint C2S_DisposeJoinRequest = 2281711394;
public const uint S2C_DisposeJoinResponse = 2415929122;
public const uint S2C_ClubChange = 2147493659;
public const uint Map2C_RoleEnterRoomNotify = 2147493650;
public const uint Map2C_RoleExitRoomNotify = 2147493651;
public const uint Map2C_RoleStateNotify = 2147493652;
public const uint Map2C_RoleGearStateNotify = 2147493653;
public const uint Map2C_RoleGearChangeNotify = 2147493654;
public const uint C2Map_Move = 2147493655;
public const uint C2Map_Look = 2147493656;
public const uint Map2C_MoveNotify = 2147493657;
public const uint Map2C_LookeNotify = 2147493658;
public const uint C2S_GetConversationsRequest = 2281711380;
public const uint S2C_GetConversationsResponse = 2415929108;
public const uint C2S_SendMailRequest = 2281711381;
public const uint S2C_SendMailResponse = 2415929109;
public const uint C2S_DeleteMailRequest = 2281711382;
public const uint S2C_DeleteMailResponse = 2415929110;
public const uint S2C_HaveMail = 2147493659;
public const uint S2C_MailState = 2147493660;
public const uint C2S_CreateChannelRequest = 2281711383;
public const uint S2C_CreateChannelResponse = 2415929111;
public const uint C2S_JoinChannelRequest = 2281711384;
public const uint S2C_JoinChannelResponse = 2415929112;
public const uint C2S_SendMessageRequest = 2281711385;
public const uint S2C_SendMessageResponse = 2415929113;
public const uint S2C_Message = 2147493661;
public const uint C2S_CreateClubRequest = 2281711386;
public const uint S2C_CreateClubResponse = 2415929114;
public const uint C2S_GetClubInfoRequest = 2281711387;
public const uint S2C_GetClubInfoResponse = 2415929115;
public const uint C2S_GetMemberListRequest = 2281711388;
public const uint S2C_GetMemberListResponse = 2415929116;
public const uint C2S_GetClubListRequest = 2281711389;
public const uint S2C_GetClubListResponse = 2415929117;
public const uint C2S_JoinClubRequest = 2281711390;
public const uint S2C_JoinClubResponse = 2415929118;
public const uint C2S_LeaveClubRequest = 2281711391;
public const uint S2C_LeaveClubResponse = 2415929119;
public const uint C2S_DissolveClubRequest = 2281711392;
public const uint S2C_DissolveClubResponse = 2415929120;
public const uint C2S_DisposeJoinRequest = 2281711393;
public const uint S2C_DisposeJoinResponse = 2415929121;
public const uint S2C_ClubChange = 2147493662;
}
}

View File

@@ -17,96 +17,24 @@ using Fantasy.Serialize;
namespace Fantasy
{
[ProtoContract]
public partial class C2Map_EnterRoomRequest : AMessage, ICustomRouteRequest, IProto
{
public static C2Map_EnterRoomRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Map_EnterRoomRequest>();
}
public override void Dispose()
{
MapId = default;
Password = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Map_EnterRoomRequest>(this);
#endif
}
[ProtoIgnore]
public Map2C_EnterRoomResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Map_EnterRoomRequest; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.MapRoute;
[ProtoMember(1)]
public int MapId { get; set; }
[ProtoMember(2)]
public string Password { get; set; }
}
[ProtoContract]
public partial class Map2C_EnterRoomResponse : AMessage, ICustomRouteResponse, IProto
{
public static Map2C_EnterRoomResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Map2C_EnterRoomResponse>();
}
public override void Dispose()
{
ErrorCode = default;
MapId = default;
RoomId = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Map2C_EnterRoomResponse>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Map2C_EnterRoomResponse; }
[ProtoMember(1)]
public int MapId { get; set; }
[ProtoMember(2)]
public long RoomId { get; set; }
[ProtoMember(3)]
public uint ErrorCode { get; set; }
}
[ProtoContract]
public partial class C2Map_Move : AMessage, ICustomRouteMessage, IProto
{
public static C2Map_Move Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Map_Move>();
}
public override void Dispose()
{
Location = default;
IsStop = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Map_Move>(this);
#endif
}
public uint OpCode() { return OuterOpcode.C2Map_Move; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.MapRoute;
[ProtoMember(1)]
public MapUnitPositionInfo Location { get; set; }
[ProtoMember(2)]
public bool IsStop { get; set; }
}
/// <summary>
/// 用户进入地图
/// </summary>
[ProtoContract]
public partial class Map2C_RoleEnterMapNotify : AMessage, ICustomRouteMessage, IProto
public partial class Map2C_RoleEnterRoomNotify : AMessage, ICustomRouteMessage, IProto
{
public static Map2C_RoleEnterMapNotify Create(Scene scene)
public static Map2C_RoleEnterRoomNotify Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Map2C_RoleEnterMapNotify>();
return scene.MessagePoolComponent.Rent<Map2C_RoleEnterRoomNotify>();
}
public override void Dispose()
{
Info = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Map2C_RoleEnterMapNotify>(this);
GetScene().MessagePoolComponent.Return<Map2C_RoleEnterRoomNotify>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Map2C_RoleEnterMapNotify; }
public uint OpCode() { return OuterOpcode.Map2C_RoleEnterRoomNotify; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.MapRoute;
[ProtoMember(1)]
@@ -116,20 +44,20 @@ namespace Fantasy
/// 用户离开地图
/// </summary>
[ProtoContract]
public partial class Map2C_RoleExitMapNotify : AMessage, ICustomRouteMessage, IProto
public partial class Map2C_RoleExitRoomNotify : AMessage, ICustomRouteMessage, IProto
{
public static Map2C_RoleExitMapNotify Create(Scene scene)
public static Map2C_RoleExitRoomNotify Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Map2C_RoleExitMapNotify>();
return scene.MessagePoolComponent.Rent<Map2C_RoleExitRoomNotify>();
}
public override void Dispose()
{
Id = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Map2C_RoleExitMapNotify>(this);
GetScene().MessagePoolComponent.Return<Map2C_RoleExitRoomNotify>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Map2C_RoleExitMapNotify; }
public uint OpCode() { return OuterOpcode.Map2C_RoleExitRoomNotify; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.MapRoute;
[ProtoMember(1)]
@@ -213,11 +141,66 @@ namespace Fantasy
[ProtoMember(2)]
public GearInfo Gears { get; set; }
}
[ProtoContract]
public partial class C2Map_Move : AMessage, ICustomRouteMessage, IProto
{
public static C2Map_Move Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Map_Move>();
}
public override void Dispose()
{
Position = default;
Rotation = default;
Direction = default;
IsStop = default;
Timestamp = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Map_Move>(this);
#endif
}
public uint OpCode() { return OuterOpcode.C2Map_Move; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.MapRoute;
[ProtoMember(1)]
public Vector3Info Position { get; set; }
[ProtoMember(2)]
public Vector3Info Rotation { get; set; }
[ProtoMember(3)]
public Vector3Info Direction { get; set; }
[ProtoMember(4)]
public bool IsStop { get; set; }
[ProtoMember(5)]
public long Timestamp { get; set; }
}
[ProtoContract]
public partial class C2Map_Look : AMessage, ICustomRouteMessage, IProto
{
public static C2Map_Look Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<C2Map_Look>();
}
public override void Dispose()
{
Rotation = default;
Timestamp = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2Map_Look>(this);
#endif
}
public uint OpCode() { return OuterOpcode.C2Map_Look; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.MapRoute;
[ProtoMember(1)]
public Vector3Info Rotation { get; set; }
[ProtoMember(2)]
public long Timestamp { get; set; }
}
/// <summary>
/// 玩家位置变化
/// 玩家移动推送
/// </summary>
[ProtoContract]
public partial class Map2C_MoveNotify : AMessage, IProto
public partial class Map2C_MoveNotify : AMessage, ICustomRouteMessage, IProto
{
public static Map2C_MoveNotify Create(Scene scene)
{
@@ -226,14 +209,58 @@ namespace Fantasy
public override void Dispose()
{
Id = default;
Location = default;
Position = default;
Rotation = default;
Direction = default;
IsStop = default;
Timestamp = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Map2C_MoveNotify>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Map2C_MoveNotify; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.MapRoute;
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public MapUnitPositionInfo Location { get; set; }
public Vector3Info Position { get; set; }
[ProtoMember(3)]
public Vector3Info Rotation { get; set; }
[ProtoMember(4)]
public Vector3Info Direction { get; set; }
[ProtoMember(5)]
public bool IsStop { get; set; }
[ProtoMember(6)]
public long Timestamp { get; set; }
}
/// <summary>
/// 玩家旋转推送
/// </summary>
[ProtoContract]
public partial class Map2C_LookeNotify : AMessage, ICustomRouteMessage, IProto
{
public static Map2C_LookeNotify Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Map2C_LookeNotify>();
}
public override void Dispose()
{
Id = default;
Rotation = default;
Timestamp = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Map2C_LookeNotify>(this);
#endif
}
public uint OpCode() { return OuterOpcode.Map2C_LookeNotify; }
[ProtoIgnore]
public int RouteType => Fantasy.RouteType.MapRoute;
[ProtoMember(1)]
public long Id { get; set; }
[ProtoMember(2)]
public Vector3Info Rotation { get; set; }
[ProtoMember(3)]
public long Timestamp { get; set; }
}
}

View File

@@ -8,4 +8,6 @@ public class RoomManageComponent : Entity
public readonly PriorityQueue<int, int> FreeIds = new();
public readonly HashSet<int> InUseID = new();
public string TestRoomCode;
}

View File

@@ -16,12 +16,17 @@ public class MapUnit : Entity
/// <summary>
/// 旋转
/// </summary>
public float4 Rotation;
public float3 Rotation;
/// <summary>
/// 当前所在地图id
/// </summary>
public int MapId;
/// <summary>
/// 当前所在的房间id
/// </summary>
public long RoomId;
public long GateRouteId;
}

View File

@@ -11,7 +11,7 @@ public class C2Game_GetRoleInfoRequestHandler : RouteRPC<Player, C2Game_GetRoleI
protected override async FTask Run(Player entity, C2Game_GetRoleInfoRequest request,
Game2C_GetRoleInfoResponse response, Action reply)
{
response.RoomId = 0;
response.RoomCode = "13AHVL";
response.RoleInfo = entity.GetRoleInfo();
await FTask.CompletedTask;

View File

@@ -97,7 +97,8 @@ public class C2G_EnterRoomRequestHandler : MessageRPC<C2G_EnterRoomRequest, G2C_
}
gateUnit.RoomCode = request.RoomCode;
response.Units = roomResponse.Units;
response.RoomCode = request.RoomCode;
response.ErrorCode = ErrorCode.Successful;
}

View File

@@ -39,7 +39,7 @@ public sealed class C2G_LoginRequestHandler : MessageRPC<C2G_LoginRequest, G2C_L
return;
}
response.RoleId = gateUnit.AccountID;
response.ErrorCode = await GateLoginHelper.Online(gateUnit);
Log.Debug($"当前的Gate服务器:{session.Scene.SceneConfigId} accountId:{accountId}");
}

View File

@@ -24,19 +24,14 @@ public class C2Map_CreateRoomRequestHandler : RouteRPC<MapUnit, C2Map_CreateRoom
return;
}
var roomId = roomManageComponent.AllocateId();
if (roomId < 1)
var room = roomManageComponent.Create(entity.Id);
if (room == null)
{
response.ErrorCode = ErrorCode.MapCreateRoomMax;
return;
}
// roomManageComponent.on
var room = Entity.Create<MapRoom>(entity.Scene, true, true);
room.Owner = entity.Id;
room.RoomId = roomId;
room.Code = RoomHelper.GenerateCode(entity.Scene.SceneConfigId, roomId);
roomManageComponent.Add(room);
Log.Info(
$"创建房间=== sId={entity.Scene.SceneConfigId} map:{request.MapId} id={room.RoomId} code={room.Code}");

View File

@@ -0,0 +1,33 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Network.Interface;
namespace NB.Map;
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 notifyMessage = new Map2C_LookeNotify()
{
Id = entity.Id,
Rotation = message.Rotation,
Timestamp = message.Timestamp
};
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);
// }
await FTask.CompletedTask;
}
}

View File

@@ -0,0 +1,38 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Helper;
using Fantasy.Network.Interface;
namespace NB.Map;
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 notifyMessage = new Map2C_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 mapUnitManageComponent.Units)
{
entity.Scene.NetworkMessagingComponent.SendInnerRoute(unit.GateRouteId, notifyMessage);
}
await FTask.CompletedTask;
}
}

View File

@@ -4,7 +4,7 @@ using Fantasy.Network.Interface;
namespace NB.Map.Inner;
public class G2Map_EnterRequestHandler : RouteRPC<Scene, G2Map_EnterRoomRequest, Map2G_EnterRoomResponse>
public class G2Map_EnterRoomRequestHandler : RouteRPC<Scene, G2Map_EnterRoomRequest, Map2G_EnterRoomResponse>
{
protected override async FTask Run(Scene entity, G2Map_EnterRoomRequest request, Map2G_EnterRoomResponse response,
Action reply)
@@ -54,9 +54,16 @@ public class G2Map_EnterRequestHandler : RouteRPC<Scene, G2Map_EnterRoomRequest,
return;
}
}
response.ErrorCode = await room.Enter(request.AccountId);
response.ErrorCode = await room.Enter(mapUnit);
response.RoomCode = room.Code;
if (response.ErrorCode == ErrorCode.Successful)
{
mapUnit.RoomId = room.Id;
response.Units = room.ToMapUnitInfo();
}
}
}

View File

@@ -0,0 +1,13 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Network.Interface;
namespace NB.Map.Inner;
public class G2Map_ExitRoomRequestHandler : RouteRPC<Scene, G2Map_ExitRoomRequest, Map2G_ExiRoomResponse>
{
protected override async FTask Run(Scene entity, G2Map_ExitRoomRequest request, Map2G_ExiRoomResponse response,
Action reply)
{
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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
}

View File

@@ -67,6 +67,9 @@ public sealed class OnCreateSceneEvent : AsyncEventSystem<OnCreateScene>
case SceneType.Map:
{
Log.Debug($"Map Scene SceneRuntimeId:{scene.RuntimeId}");
var roomCode = RoomHelper.GenerateCode(scene.SceneConfigId, 1);
Log.Info($"测试 roomCode{roomCode}");
// uint serverId = 25255;
// for (int i = 1; i < 65535; i++)
// {

View File

@@ -52,8 +52,16 @@ public class OnSceneCreate_Init : AsyncEventSystem<OnCreateScene>
{
Log.Info("创建地图场景===");
scene.AddComponent<MapUnitManageComponent>();
scene.AddComponent<RoomManageComponent>();
var roomManageComponent = scene.AddComponent<RoomManageComponent>();
scene.AddComponent<MapManageComponent>();
var room = roomManageComponent.Create(361499030775398402);
if (room != null)
{
roomManageComponent.TestRoomCode = room.Code;
Log.Info($"测试房间代码 = {room.Code}");
}
break;
}
}