新增逻辑
This commit is contained in:
@@ -18,4 +18,8 @@
|
||||
<ProjectReference Include="..\ThirdParty\ThirdParty.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Game\Map\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -65,13 +65,13 @@
|
||||
networkProtocol=""
|
||||
outerPort="0" innerPort="11051" />
|
||||
|
||||
<scene id="1007"
|
||||
processConfigId="1"
|
||||
worldConfigId="1"
|
||||
sceneRuntimeMode="MultiThread"
|
||||
sceneTypeString="Map"
|
||||
networkProtocol=""
|
||||
outerPort="0" innerPort="11061" />
|
||||
<!-- <scene id="1007" -->
|
||||
<!-- processConfigId="1" -->
|
||||
<!-- worldConfigId="1" -->
|
||||
<!-- sceneRuntimeMode="MultiThread" -->
|
||||
<!-- sceneTypeString="Map" -->
|
||||
<!-- networkProtocol="" -->
|
||||
<!-- outerPort="0" innerPort="11061" /> -->
|
||||
</scenes>
|
||||
</server>
|
||||
</fantasy>
|
||||
@@ -8,7 +8,15 @@ public enum ItemBasicType
|
||||
None,
|
||||
Currency = 1,
|
||||
Item = 2,
|
||||
Fish = 3,
|
||||
Rod = 3,
|
||||
Reel =4,
|
||||
Bobber = 5,
|
||||
Line = 6,
|
||||
Bait = 7,
|
||||
Lure = 8,
|
||||
Hook = 9,
|
||||
Weight = 10,
|
||||
Feeder = 11,
|
||||
}
|
||||
|
||||
public class Item : Entity
|
||||
@@ -47,4 +55,9 @@ public class Item : Entity
|
||||
/// 物品所属的容器
|
||||
/// </summary>
|
||||
[BsonIgnore] PlayerItemContainerComponent Container;
|
||||
|
||||
/// <summary>
|
||||
/// 正则使用中
|
||||
/// </summary>
|
||||
[BsonIgnore] public bool InUse;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class MapManageComponent: Entity
|
||||
public class MapManageComponent : Entity
|
||||
{
|
||||
public readonly Dictionary<long, Map> Maps = new();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class RoomManageComponent : Entity
|
||||
{
|
||||
@@ -8,6 +8,4 @@ public class RoomManageComponent : Entity
|
||||
|
||||
public readonly PriorityQueue<int, int> FreeIds = new();
|
||||
public readonly HashSet<int> InUseID = new();
|
||||
|
||||
public string TestRoomCode;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class Map : Entity
|
||||
{
|
||||
@@ -12,5 +12,5 @@ public class Map : Entity
|
||||
/// <summary>
|
||||
/// 地图玩家
|
||||
/// </summary>
|
||||
public Dictionary<long, MapUnit> Units = new Dictionary<long, MapUnit>();
|
||||
public Dictionary<long, Player> Units = new Dictionary<long, Player>();
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using Fantasy.Entitas;
|
||||
using NB.Map;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
/// <summary>
|
||||
/// 地图房间
|
||||
@@ -26,7 +25,7 @@ public class MapRoom : Entity
|
||||
/// <summary>
|
||||
/// 房间玩家
|
||||
/// </summary>
|
||||
public Dictionary<long, MapUnit> Units = new Dictionary<long, MapUnit>();
|
||||
public Dictionary<long, Player> Units = new Dictionary<long, Player>();
|
||||
|
||||
/// <summary>
|
||||
/// 房主
|
||||
@@ -1,19 +1,13 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
/// <summary>
|
||||
/// 地图玩家单元
|
||||
///
|
||||
/// </summary>
|
||||
public class MapUnit : Entity
|
||||
public class MapUnitComponent : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色基础信息
|
||||
/// </summary>
|
||||
public RoleSimpleInfo Info;
|
||||
|
||||
/// <summary>
|
||||
/// 位置
|
||||
/// </summary>
|
||||
@@ -24,20 +18,18 @@ public class MapUnit : Entity
|
||||
/// </summary>
|
||||
public float3 Rotation;
|
||||
|
||||
/// <summary>
|
||||
/// 当前所在地图id
|
||||
/// </summary>
|
||||
public int MapId;
|
||||
|
||||
/// <summary>
|
||||
/// 当前所在的房间id
|
||||
/// </summary>
|
||||
public int RoomId;
|
||||
|
||||
public long GateRouteId;
|
||||
|
||||
/// <summary>
|
||||
/// 钓组信息
|
||||
/// </summary>
|
||||
public List<MapUnitGear> Gears = new List<MapUnitGear>();
|
||||
|
||||
/// <summary>
|
||||
/// 房间Id
|
||||
/// </summary>
|
||||
public int RoomId;
|
||||
|
||||
/// <summary>
|
||||
/// 地图id
|
||||
/// </summary>
|
||||
public int MapId;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Fantasy.Entitas;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public enum MapGearState
|
||||
{
|
||||
@@ -18,7 +18,7 @@ public class MapUnitGear : Entity
|
||||
/// <summary>
|
||||
/// 杆子
|
||||
/// </summary>
|
||||
public long Rod;
|
||||
public long Item;
|
||||
|
||||
/// <summary>
|
||||
/// 杆子配件
|
||||
@@ -63,4 +63,5 @@ public sealed class Player : Entity
|
||||
|
||||
|
||||
[BsonIgnore] public long SessionRunTimeId;
|
||||
|
||||
}
|
||||
@@ -85,6 +85,7 @@ namespace Fantasy
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
ItemId = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2Game_UseItemRequest>(this);
|
||||
#endif
|
||||
@@ -94,6 +95,8 @@ namespace Fantasy
|
||||
public uint OpCode() { return OuterOpcode.C2Game_UseItemRequest; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public long ItemId { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 请求使用物品响应
|
||||
@@ -509,5 +512,57 @@ namespace Fantasy
|
||||
[ProtoMember(1)]
|
||||
public List<AwardInfo> Awards = new List<AwardInfo>();
|
||||
}
|
||||
/// <summary>
|
||||
/// /////////// ******** GM *******/////////////
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// 请求执行GM
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class C2Game_GMRequest : AMessage, ICustomRouteRequest
|
||||
{
|
||||
public static C2Game_GMRequest Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<C2Game_GMRequest>();
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
Cmd = default;
|
||||
Args = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2Game_GMRequest>(this);
|
||||
#endif
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public Game2C_GMResponse ResponseType { get; set; }
|
||||
public uint OpCode() { return OuterOpcode.C2Game_GMRequest; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public string Cmd { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public string Args { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 执行GM返回
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class Game2C_GMResponse : AMessage, ICustomRouteResponse
|
||||
{
|
||||
public static Game2C_GMResponse Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<Game2C_GMResponse>();
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<Game2C_GMResponse>(this);
|
||||
#endif
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Game2C_GMResponse; }
|
||||
[ProtoMember(1)]
|
||||
public uint ErrorCode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Fantasy
|
||||
public Map2C_CreateRoomResponse ResponseType { get; set; }
|
||||
public uint OpCode() { return OuterOpcode.C2Map_CreateRoomRequest; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public int MapId { get; set; }
|
||||
}
|
||||
@@ -193,7 +193,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Map2C_ChangeMap; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public int MapId { get; set; }
|
||||
[ProtoMember(2)]
|
||||
|
||||
@@ -99,25 +99,31 @@ namespace Fantasy
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
Rod = default;
|
||||
Rigs.Clear();
|
||||
Item = default;
|
||||
Binds.Clear();
|
||||
Position = default;
|
||||
Rotation = default;
|
||||
Propertys.Clear();
|
||||
InUse = default;
|
||||
InHand = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<GearInfo>(this);
|
||||
#endif
|
||||
}
|
||||
[ProtoMember(1)]
|
||||
public long Rod { get; set; }
|
||||
public ItemInfo Item { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public List<long> Rigs = new List<long>();
|
||||
public List<ItemInfo> Binds = new List<ItemInfo>();
|
||||
[ProtoMember(3)]
|
||||
public Vector3Info Position { get; set; }
|
||||
[ProtoMember(4)]
|
||||
public Vector3Info Rotation { get; set; }
|
||||
[ProtoMember(5)]
|
||||
public List<KeyValueInt64> Propertys = new List<KeyValueInt64>();
|
||||
[ProtoMember(6)]
|
||||
public bool InUse { get; set; }
|
||||
[ProtoMember(7)]
|
||||
public bool InHand { get; set; }
|
||||
}
|
||||
[ProtoContract]
|
||||
public partial class UnitStateInfo : AMessage
|
||||
|
||||
@@ -21,8 +21,10 @@ namespace Fantasy
|
||||
public const uint C2Game_BuyRequest = 2281711384;
|
||||
public const uint Game2C_BuyResponse = 2415929112;
|
||||
public const uint Game2C_RewardNotify = 2147493651;
|
||||
public const uint C2Map_CreateRoomRequest = 2281711385;
|
||||
public const uint Map2C_CreateRoomResponse = 2415929113;
|
||||
public const uint C2Game_GMRequest = 2281711385;
|
||||
public const uint Game2C_GMResponse = 2415929113;
|
||||
public const uint C2Map_CreateRoomRequest = 2281711386;
|
||||
public const uint Map2C_CreateRoomResponse = 2415929114;
|
||||
public const uint C2G_ExitRoomRequest = 268445457;
|
||||
public const uint G2C_ExitRoomResponse = 402663185;
|
||||
public const uint C2G_EnterMapRequest = 268445458;
|
||||
@@ -33,10 +35,12 @@ namespace Fantasy
|
||||
public const uint C2G_LoginRequest = 268445460;
|
||||
public const uint G2C_LoginResponse = 402663188;
|
||||
public const uint G2C_RepeatLogin = 134227729;
|
||||
public const uint C2Game_GetRoleInfoRequest = 2281711386;
|
||||
public const uint Game2C_GetRoleInfoResponse = 2415929114;
|
||||
public const uint C2Game_GetRoleInfoRequest = 2281711387;
|
||||
public const uint Game2C_GetRoleInfoResponse = 2415929115;
|
||||
public const uint Map2C_RoleEnterRoomNotify = 2147493653;
|
||||
public const uint Map2C_RoleExitRoomNotify = 2147493654;
|
||||
public const uint C2Map_TakeItemRequest = 2281711388;
|
||||
public const uint Map2C_TakeItemResponse = 2415929116;
|
||||
public const uint C2Map_RolePropertyChange = 2147493655;
|
||||
public const uint Map2C_RoleStateNotify = 2147493656;
|
||||
public const uint Map2C_RoleGearChangeNotify = 2147493657;
|
||||
@@ -45,37 +49,37 @@ namespace Fantasy
|
||||
public const uint C2Map_Look = 2147493660;
|
||||
public const uint Map2C_MoveNotify = 2147493661;
|
||||
public const uint Map2C_LookeNotify = 2147493662;
|
||||
public const uint C2S_GetConversationsRequest = 2281711387;
|
||||
public const uint S2C_GetConversationsResponse = 2415929115;
|
||||
public const uint C2S_SendMailRequest = 2281711388;
|
||||
public const uint S2C_SendMailResponse = 2415929116;
|
||||
public const uint C2S_DeleteMailRequest = 2281711389;
|
||||
public const uint S2C_DeleteMailResponse = 2415929117;
|
||||
public const uint C2S_GetConversationsRequest = 2281711389;
|
||||
public const uint S2C_GetConversationsResponse = 2415929117;
|
||||
public const uint C2S_SendMailRequest = 2281711390;
|
||||
public const uint S2C_SendMailResponse = 2415929118;
|
||||
public const uint C2S_DeleteMailRequest = 2281711391;
|
||||
public const uint S2C_DeleteMailResponse = 2415929119;
|
||||
public const uint S2C_HaveMail = 2147493663;
|
||||
public const uint S2C_MailState = 2147493664;
|
||||
public const uint C2S_CreateChannelRequest = 2281711390;
|
||||
public const uint S2C_CreateChannelResponse = 2415929118;
|
||||
public const uint C2S_JoinChannelRequest = 2281711391;
|
||||
public const uint S2C_JoinChannelResponse = 2415929119;
|
||||
public const uint C2S_SendMessageRequest = 2281711392;
|
||||
public const uint S2C_SendMessageResponse = 2415929120;
|
||||
public const uint C2S_CreateChannelRequest = 2281711392;
|
||||
public const uint S2C_CreateChannelResponse = 2415929120;
|
||||
public const uint C2S_JoinChannelRequest = 2281711393;
|
||||
public const uint S2C_JoinChannelResponse = 2415929121;
|
||||
public const uint C2S_SendMessageRequest = 2281711394;
|
||||
public const uint S2C_SendMessageResponse = 2415929122;
|
||||
public const uint S2C_Message = 2147493665;
|
||||
public const uint C2S_CreateClubRequest = 2281711393;
|
||||
public const uint S2C_CreateClubResponse = 2415929121;
|
||||
public const uint C2S_GetClubInfoRequest = 2281711394;
|
||||
public const uint S2C_GetClubInfoResponse = 2415929122;
|
||||
public const uint C2S_GetMemberListRequest = 2281711395;
|
||||
public const uint S2C_GetMemberListResponse = 2415929123;
|
||||
public const uint C2S_GetClubListRequest = 2281711396;
|
||||
public const uint S2C_GetClubListResponse = 2415929124;
|
||||
public const uint C2S_JoinClubRequest = 2281711397;
|
||||
public const uint S2C_JoinClubResponse = 2415929125;
|
||||
public const uint C2S_LeaveClubRequest = 2281711398;
|
||||
public const uint S2C_LeaveClubResponse = 2415929126;
|
||||
public const uint C2S_DissolveClubRequest = 2281711399;
|
||||
public const uint S2C_DissolveClubResponse = 2415929127;
|
||||
public const uint C2S_DisposeJoinRequest = 2281711400;
|
||||
public const uint S2C_DisposeJoinResponse = 2415929128;
|
||||
public const uint C2S_CreateClubRequest = 2281711395;
|
||||
public const uint S2C_CreateClubResponse = 2415929123;
|
||||
public const uint C2S_GetClubInfoRequest = 2281711396;
|
||||
public const uint S2C_GetClubInfoResponse = 2415929124;
|
||||
public const uint C2S_GetMemberListRequest = 2281711397;
|
||||
public const uint S2C_GetMemberListResponse = 2415929125;
|
||||
public const uint C2S_GetClubListRequest = 2281711398;
|
||||
public const uint S2C_GetClubListResponse = 2415929126;
|
||||
public const uint C2S_JoinClubRequest = 2281711399;
|
||||
public const uint S2C_JoinClubResponse = 2415929127;
|
||||
public const uint C2S_LeaveClubRequest = 2281711400;
|
||||
public const uint S2C_LeaveClubResponse = 2415929128;
|
||||
public const uint C2S_DissolveClubRequest = 2281711401;
|
||||
public const uint S2C_DissolveClubResponse = 2415929129;
|
||||
public const uint C2S_DisposeJoinRequest = 2281711402;
|
||||
public const uint S2C_DisposeJoinResponse = 2415929130;
|
||||
public const uint S2C_ClubChange = 2147493666;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Map2C_RoleEnterRoomNotify; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public MapUnitInfo Info { get; set; }
|
||||
}
|
||||
@@ -60,10 +60,65 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Map2C_RoleExitRoomNotify; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public long Id { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 请求拿起物品
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class C2Map_TakeItemRequest : AMessage, ICustomRouteRequest
|
||||
{
|
||||
public static C2Map_TakeItemRequest Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<C2Map_TakeItemRequest>();
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
Id = default;
|
||||
Task = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2Map_TakeItemRequest>(this);
|
||||
#endif
|
||||
}
|
||||
[ProtoIgnore]
|
||||
public Map2C_TakeItemResponse ResponseType { get; set; }
|
||||
public uint OpCode() { return OuterOpcode.C2Map_TakeItemRequest; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public int Id { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public bool Task { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 请求拿起物品响应
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class Map2C_TakeItemResponse : AMessage, ICustomRouteResponse
|
||||
{
|
||||
public static Map2C_TakeItemResponse Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<Map2C_TakeItemResponse>();
|
||||
}
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
Id = default;
|
||||
Task = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<Map2C_TakeItemResponse>(this);
|
||||
#endif
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Map2C_TakeItemResponse; }
|
||||
[ProtoMember(1)]
|
||||
public int Id { get; set; }
|
||||
[ProtoMember(2)]
|
||||
public bool Task { get; set; }
|
||||
[ProtoMember(3)]
|
||||
public uint ErrorCode { get; set; }
|
||||
}
|
||||
[ProtoContract]
|
||||
public partial class C2Map_RolePropertyChange : AMessage, ICustomRouteMessage
|
||||
{
|
||||
@@ -80,7 +135,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.C2Map_RolePropertyChange; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public List<KeyValueInt64> Propertys = new List<KeyValueInt64>();
|
||||
}
|
||||
@@ -104,7 +159,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Map2C_RoleStateNotify; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public long Id { get; set; }
|
||||
[ProtoMember(2)]
|
||||
@@ -130,7 +185,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Map2C_RoleGearChangeNotify; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public long Id { get; set; }
|
||||
[ProtoMember(2)]
|
||||
@@ -153,7 +208,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Map2C_RolePropertyChangeNotify; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public long Id { get; set; }
|
||||
[ProtoMember(2)]
|
||||
@@ -180,7 +235,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.C2Map_Move; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public Vector3Info Position { get; set; }
|
||||
[ProtoMember(2)]
|
||||
@@ -211,7 +266,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.C2Map_Look; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public Vector3Info Rotation { get; set; }
|
||||
[ProtoMember(2)]
|
||||
@@ -242,7 +297,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Map2C_MoveNotify; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public long Id { get; set; }
|
||||
[ProtoMember(2)]
|
||||
@@ -279,7 +334,7 @@ namespace Fantasy
|
||||
}
|
||||
public uint OpCode() { return OuterOpcode.Map2C_LookeNotify; }
|
||||
[ProtoIgnore]
|
||||
public int RouteType => Fantasy.RouteType.MapRoute;
|
||||
public int RouteType => Fantasy.RouteType.GameRoute;
|
||||
[ProtoMember(1)]
|
||||
public long Id { get; set; }
|
||||
[ProtoMember(2)]
|
||||
|
||||
@@ -6,6 +6,5 @@ namespace Fantasy
|
||||
public const int GateRoute = 1001; // Gate
|
||||
public const int SocialRoute = 1002; // Social
|
||||
public const int GameRoute = 1003; // Game
|
||||
public const int MapRoute = 1004; // 地图
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Map;
|
||||
|
||||
public class MapUnitManageComponent : Entity
|
||||
{
|
||||
public readonly Dictionary<long, MapUnit> Units = new();
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
using NB.Chat;
|
||||
using NB.Game;
|
||||
using NB.Map;
|
||||
|
||||
namespace NB.Common;
|
||||
|
||||
@@ -27,11 +26,11 @@ public class G2Common_EnterRequestHandler : RouteRPC<Scene, G2Common_EnterReques
|
||||
await RunSocial(scene, request, response);
|
||||
break;
|
||||
}
|
||||
case SceneType.Map:
|
||||
{
|
||||
await RunMap(scene, request, response);
|
||||
break;
|
||||
}
|
||||
// case SceneType.Map:
|
||||
// {
|
||||
// await RunMap(scene, request, response);
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
@@ -68,19 +67,19 @@ public class G2Common_EnterRequestHandler : RouteRPC<Scene, G2Common_EnterReques
|
||||
Log.Info($"登录到社交服成功,id={response.UnitRouteId}");
|
||||
}
|
||||
|
||||
private async FTask RunMap(Scene scene, G2Common_EnterRequest request, G2Common_EnterResponse response)
|
||||
{
|
||||
// 在缓存中检查该账号是否存在
|
||||
var chatUnitManageComponent = scene.GetComponent<MapUnitManageComponent>();
|
||||
var account = await chatUnitManageComponent.Online(scene, request.AccountId, request.GateRouteId);
|
||||
|
||||
if (account == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
response.UnitRouteId = account.RuntimeId;
|
||||
Log.Info($"登录到地图服成功,id={response.UnitRouteId}");
|
||||
}
|
||||
// private async FTask RunMap(Scene scene, G2Common_EnterRequest request, G2Common_EnterResponse response)
|
||||
// {
|
||||
// // 在缓存中检查该账号是否存在
|
||||
// var chatUnitManageComponent = scene.GetComponent<MapUnitManageComponent>();
|
||||
// var account = await chatUnitManageComponent.Online(scene, request.AccountId, request.GateRouteId);
|
||||
//
|
||||
// if (account == null)
|
||||
// {
|
||||
// response.ErrorCode = ErrorCode.ErrServer;
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// response.UnitRouteId = account.RuntimeId;
|
||||
// Log.Info($"登录到地图服成功,id={response.UnitRouteId}");
|
||||
// }
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
using NB.Chat;
|
||||
using NB.Game;
|
||||
using NB.Map;
|
||||
|
||||
namespace NB.Common;
|
||||
|
||||
@@ -25,11 +24,11 @@ public class G2Common_ExitRequestHandler : RouteRPC<Scene, G2Common_ExitRequest,
|
||||
await RunSocial(scene, request, response);
|
||||
break;
|
||||
}
|
||||
case SceneType.Map:
|
||||
{
|
||||
await RunMap(scene, request, response);
|
||||
break;
|
||||
}
|
||||
// case SceneType.Map:
|
||||
// {
|
||||
// await RunMap(scene, request, response);
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
@@ -51,9 +50,9 @@ public class G2Common_ExitRequestHandler : RouteRPC<Scene, G2Common_ExitRequest,
|
||||
Log.Info("退出聊天服成功==");
|
||||
}
|
||||
|
||||
private async FTask RunMap(Scene scene, G2Common_ExitRequest request, Common2G_ExitResponse response)
|
||||
{
|
||||
await MapHelper.Offline(scene, request.AccountId, request.GateRouteId);
|
||||
Log.Info("退出房间服成功==");
|
||||
}
|
||||
// private async FTask RunMap(Scene scene, G2Common_ExitRequest request, Common2G_ExitResponse response)
|
||||
// {
|
||||
// await MapHelper.Offline(scene, request.AccountId, request.GateRouteId);
|
||||
// Log.Info("退出房间服成功==");
|
||||
// }
|
||||
}
|
||||
@@ -16,10 +16,6 @@ public static class SceneConfigHelper
|
||||
{
|
||||
sceneType = SceneType.Social;
|
||||
}
|
||||
else if (routeType == RouteType.MapRoute)
|
||||
{
|
||||
sceneType = SceneType.Map;
|
||||
}
|
||||
else if (routeType == RouteType.GateRoute)
|
||||
{
|
||||
sceneType = SceneType.Gate;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Network.Interface;
|
||||
using NB.Map;
|
||||
|
||||
namespace NB.Game;
|
||||
|
||||
@@ -11,7 +10,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.RoomCode = "13AHVL";
|
||||
response.RoomCode = "136A69";
|
||||
response.RoleInfo = entity.GetRoleInfo();
|
||||
|
||||
await FTask.CompletedTask;
|
||||
|
||||
@@ -22,6 +22,12 @@ public class C2Game_RigChangeRequestHandler : RouteRPC<Player, C2Game_RigChangeR
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.InUse)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs; //已使用的
|
||||
return;
|
||||
}
|
||||
|
||||
if (request.IsAdd)
|
||||
{
|
||||
//安装配件需要检查配件是否已被使用
|
||||
|
||||
31
Hotfix/Game/Handler/C2Game_UseItemRequestHandler.cs
Normal file
31
Hotfix/Game/Handler/C2Game_UseItemRequestHandler.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Game;
|
||||
|
||||
public class C2Game_UseItemRequestHandler : RouteRPC<Player, C2Game_UseItemRequest, Game2C_UseItemResponse>
|
||||
{
|
||||
protected override async FTask Run(Player entity, C2Game_UseItemRequest request, Game2C_UseItemResponse response,
|
||||
Action reply)
|
||||
{
|
||||
var itemContainer = entity.GetComponent<PlayerItemContainerComponent>();
|
||||
if (itemContainer == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemContainer.Items.TryGetValue(request.ItemId, out var item))
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
var itemType = ItemHelper.GetType(item.ConfigId);
|
||||
if (itemType == ItemBasicType.Rod)
|
||||
{
|
||||
//鱼竿
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
using NB.Map;
|
||||
|
||||
namespace NB.Game;
|
||||
|
||||
|
||||
@@ -4,17 +4,22 @@ public static class ItemHelper
|
||||
{
|
||||
public static ItemBasicType GetType(uint id)
|
||||
{
|
||||
var type = (int)(id / 10000);
|
||||
if (type == 1)
|
||||
{
|
||||
return ItemBasicType.Currency;
|
||||
}
|
||||
|
||||
if (type == 21)
|
||||
{
|
||||
return ItemBasicType.Fish;
|
||||
}
|
||||
|
||||
return ItemBasicType.Item;
|
||||
return (ItemBasicType)(id / 10000);
|
||||
}
|
||||
|
||||
// public static ItemBasicType GetType(uint id)
|
||||
// {
|
||||
// var type = (int)(id / 10000);
|
||||
// if (type == 1)
|
||||
// {
|
||||
// return ItemBasicType.Currency;
|
||||
// }
|
||||
//
|
||||
// if (type == 21)
|
||||
// {
|
||||
// return ItemBasicType.Fish;
|
||||
// }
|
||||
//
|
||||
// return ItemBasicType.Item;
|
||||
// }
|
||||
}
|
||||
@@ -18,6 +18,9 @@ public class ItemDestroySystem : DestroySystem<Item>
|
||||
|
||||
public static class ItemSystem
|
||||
{
|
||||
|
||||
|
||||
|
||||
public static ItemInfo ToItemInfo(this Item self)
|
||||
{
|
||||
return new ItemInfo()
|
||||
|
||||
@@ -3,15 +3,22 @@ using Fantasy.Async;
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class C2Map_CreateRoomRequestHandler : RouteRPC<MapUnit, C2Map_CreateRoomRequest, Map2C_CreateRoomResponse>
|
||||
public class C2Map_CreateRoomRequestHandler : RouteRPC<Player, C2Map_CreateRoomRequest, Map2C_CreateRoomResponse>
|
||||
{
|
||||
protected override async FTask Run(MapUnit entity, C2Map_CreateRoomRequest request,
|
||||
protected override async FTask Run(Player entity, C2Map_CreateRoomRequest request,
|
||||
Map2C_CreateRoomResponse response,
|
||||
Action reply)
|
||||
{
|
||||
if (entity.MapId != request.MapId)
|
||||
var mapUnit = entity.GetComponent<MapUnitComponent>();
|
||||
if (mapUnit == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mapUnit.MapId != request.MapId)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.MapCreateRoomNotEnter;
|
||||
return;
|
||||
@@ -31,12 +38,12 @@ public class C2Map_CreateRoomRequestHandler : RouteRPC<MapUnit, C2Map_CreateRoom
|
||||
response.ErrorCode = ErrorCode.MapCreateRoomMax;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Log.Info(
|
||||
$"创建房间=== sId={entity.Scene.SceneConfigId} map:{request.MapId} id={room.RoomId} code={room.Code}");
|
||||
|
||||
|
||||
response.RoomCode = room.Code;
|
||||
|
||||
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,21 @@
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class C2Map_LookHandler : Route<MapUnit, C2Map_Look>
|
||||
public class C2Map_LookHandler : Route<Player, C2Map_Look>
|
||||
{
|
||||
protected override async FTask Run(MapUnit entity, C2Map_Look message)
|
||||
protected override async FTask Run(Player entity, C2Map_Look message)
|
||||
{
|
||||
var mapUnit = entity.GetComponent<MapUnitComponent>();
|
||||
if (mapUnit == null)
|
||||
{
|
||||
// response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var roomId = mapUnit.RoomId;
|
||||
var roomManageComponent = entity.Scene.GetComponent<RoomManageComponent>();
|
||||
var roomId = entity.RoomId;
|
||||
var room = roomManageComponent.Get(roomId);
|
||||
if (room == null)
|
||||
{
|
||||
@@ -23,14 +30,14 @@ public class C2Map_LookHandler : Route<MapUnit, C2Map_Look>
|
||||
Timestamp = message.Timestamp
|
||||
};
|
||||
|
||||
entity.Rotation.x = message.Rotation.x;
|
||||
entity.Rotation.y = message.Rotation.y;
|
||||
entity.Rotation.z = message.Rotation.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.SendInnerRoute(unit.GateRouteId, notifyMessage);
|
||||
entity.Scene.NetworkMessagingComponent.SendInnerRoute(unit.SessionRunTimeId, notifyMessage);
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
@@ -3,14 +3,21 @@ using Fantasy.Async;
|
||||
using Fantasy.Helper;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class C2Map_MoveHandler : Route<MapUnit, C2Map_Move>
|
||||
public class C2Map_MoveHandler : Route<Player, C2Map_Move>
|
||||
{
|
||||
protected override async FTask Run(MapUnit entity, C2Map_Move message)
|
||||
protected override async FTask Run(Player entity, C2Map_Move message)
|
||||
{
|
||||
var mapUnit = entity.GetComponent<MapUnitComponent>();
|
||||
if (mapUnit == null)
|
||||
{
|
||||
// response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var roomManageComponent = entity.Scene.GetComponent<RoomManageComponent>();
|
||||
var roomId = entity.RoomId;
|
||||
var roomId = mapUnit.RoomId;
|
||||
var room = roomManageComponent.Get(roomId);
|
||||
if (room == null)
|
||||
{
|
||||
@@ -27,18 +34,18 @@ public class C2Map_MoveHandler : Route<MapUnit, C2Map_Move>
|
||||
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;
|
||||
// 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.SendInnerRoute(unit.GateRouteId, notifyMessage);
|
||||
entity.Scene.NetworkMessagingComponent.SendInnerRoute(unit.SessionRunTimeId, notifyMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,21 @@
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class C2Map_RolePropertyChangeHandler : Route<MapUnit, C2Map_RolePropertyChange>
|
||||
public class C2Map_RolePropertyChangeHandler : Route<Player, C2Map_RolePropertyChange>
|
||||
{
|
||||
protected override async FTask Run(MapUnit entity, C2Map_RolePropertyChange message)
|
||||
protected override async FTask Run(Player entity, C2Map_RolePropertyChange message)
|
||||
{
|
||||
var mapUnit = entity.GetComponent<MapUnitComponent>();
|
||||
if (mapUnit == null)
|
||||
{
|
||||
// response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var roomManageComponent = entity.Scene.GetComponent<RoomManageComponent>();
|
||||
var roomId = entity.RoomId;
|
||||
var roomId = mapUnit.RoomId;
|
||||
var room = roomManageComponent.Get(roomId);
|
||||
if (room == null)
|
||||
{
|
||||
@@ -26,7 +33,7 @@ public class C2Map_RolePropertyChangeHandler : Route<MapUnit, C2Map_RoleProperty
|
||||
foreach (var (_, unit) in room.Units)
|
||||
{
|
||||
if (unit.Id == entity.Id) continue;
|
||||
entity.Scene.NetworkMessagingComponent.SendInnerRoute(unit.GateRouteId, notifyMessage);
|
||||
entity.Scene.NetworkMessagingComponent.SendInnerRoute(unit.SessionRunTimeId, notifyMessage);
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
60
Hotfix/Game/Map/Handler/C2Map_TakeItemRequestHandler.cs
Normal file
60
Hotfix/Game/Map/Handler/C2Map_TakeItemRequestHandler.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Game;
|
||||
|
||||
public class C2Map_TakeItemRequestHandler : RouteRPC<Player, C2Map_TakeItemRequest, Map2C_TakeItemResponse>
|
||||
{
|
||||
protected override async FTask Run(Player entity, C2Map_TakeItemRequest request, Map2C_TakeItemResponse response,
|
||||
Action reply)
|
||||
{
|
||||
var itemContainer = entity.GetComponent<PlayerItemContainerComponent>();
|
||||
if (itemContainer == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemContainer.Items.TryGetValue(request.Id, out var item))
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
var mapUnit = entity.GetComponent<MapUnitComponent>();
|
||||
if (mapUnit == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrArgs;
|
||||
return;
|
||||
}
|
||||
|
||||
var itemType = ItemHelper.GetType(item.ConfigId);
|
||||
if (itemType == ItemBasicType.Rod)
|
||||
{
|
||||
itemContainer.Binding.TryGetValue(item.Id, out var itemRod);
|
||||
//鱼竿
|
||||
var itemGear = mapUnit.GetOrAddItemGear(item);
|
||||
if (itemRod != null)
|
||||
{
|
||||
itemGear.Rings.AddRange(itemRod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var roomManageComponent = entity.Scene.GetComponent<RoomManageComponent>();
|
||||
var roomId = mapUnit.RoomId;
|
||||
var room = roomManageComponent.Get(roomId);
|
||||
if (room != null)
|
||||
{
|
||||
var notifyMessage = new Map2C_RoleGearChangeNotify();
|
||||
// notifyMessage
|
||||
// return;
|
||||
foreach (var (_, unit) in room.Units)
|
||||
{
|
||||
// if (unit.Id == entity.Id) continue;
|
||||
entity.Scene.NetworkMessagingComponent.SendInnerRoute(unit.SessionRunTimeId, notifyMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
using NB.Game;
|
||||
|
||||
namespace NB.Map.Inner;
|
||||
namespace NB.Game.Inner;
|
||||
|
||||
/// <summary>
|
||||
/// 请求进入地图
|
||||
@@ -19,32 +20,43 @@ public class G2Map_EnterMapRequestHandler : RouteRPC<Scene, G2Map_EnterMapReques
|
||||
return;
|
||||
}
|
||||
|
||||
var mapUnitManage = entity.GetComponent<MapUnitManageComponent>();
|
||||
var mapUnitManage = entity.GetComponent<PlayerManageComponent>();
|
||||
if (mapUnitManage == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var mapUnit = mapUnitManage.Get(request.AccountId);
|
||||
var player = mapUnitManage.Get(request.AccountId);
|
||||
if (player == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var mapUnit = player.GetComponent<MapUnitComponent>();
|
||||
if (mapUnit == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//进入地图
|
||||
response.ErrorCode = await mapUnit.EnterMap(request.MapId);
|
||||
if (response.ErrorCode != 0)
|
||||
var mapManageComponent = entity.GetComponent<MapManageComponent>();
|
||||
var map = mapManageComponent.Get(request.MapId);
|
||||
if (map == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.MapIdError;
|
||||
return;
|
||||
}
|
||||
|
||||
mapUnit.MapId = request.MapId;
|
||||
|
||||
|
||||
// 如果没有房间代码,则只是进入地图,直接返回,不执行后续逻辑
|
||||
if (string.IsNullOrEmpty(request.RoomCode))
|
||||
{
|
||||
response.Units = [mapUnit.ToMapUnitInfo()];
|
||||
response.Units = [player.ToMapUnitInfo()];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,7 +72,7 @@ public class G2Map_EnterMapRequestHandler : RouteRPC<Scene, G2Map_EnterMapReques
|
||||
return;
|
||||
}
|
||||
|
||||
response.ErrorCode = await room.Enter(mapUnit);
|
||||
response.ErrorCode = await room.Enter(player);
|
||||
response.RoomCode = room.Code;
|
||||
if (response.ErrorCode == ErrorCode.Successful)
|
||||
{
|
||||
@@ -0,0 +1,51 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Network.Interface;
|
||||
|
||||
namespace NB.Game.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)
|
||||
{
|
||||
var roomManageComponent = entity.GetComponent<RoomManageComponent>();
|
||||
if (roomManageComponent == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var mapUnitManage = entity.GetComponent<PlayerManageComponent>();
|
||||
if (mapUnitManage == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var player = mapUnitManage.Get(request.AccountId);
|
||||
if (player == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var mapUnit = player.GetComponent<MapUnitComponent>();
|
||||
if (mapUnit == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
var room = roomManageComponent.Get(mapUnit.RoomId);
|
||||
if (room == null)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.ErrServer;
|
||||
return;
|
||||
}
|
||||
|
||||
player.RemoveComponent<MapUnitComponent>();
|
||||
response.ErrorCode = await room.Enter(player);
|
||||
// room.Units.Remove(mapUnit.Id);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class MapFactory
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Text;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public static class RoomHelper
|
||||
{
|
||||
@@ -65,5 +65,4 @@ public static class RoomHelper
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class MapManageComponentDestroySystem : DestroySystem<MapManageComponent>
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Entitas.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class MapRoomDestroySystem : DestroySystem<MapRoom>
|
||||
{
|
||||
@@ -18,21 +18,21 @@ public class MapRoomDestroySystem : DestroySystem<MapRoom>
|
||||
|
||||
public static class MapRoomSystem
|
||||
{
|
||||
public static async FTask<uint> Enter(this MapRoom self, MapUnit unit)
|
||||
public static async FTask<uint> Enter(this MapRoom self, Player 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);
|
||||
}
|
||||
// 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;
|
||||
@@ -1,6 +1,6 @@
|
||||
using Fantasy.Entitas.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class MapDestroySystem : DestroySystem<Map>
|
||||
{
|
||||
31
Hotfix/Game/Map/System/MapUnitSystem.cs
Normal file
31
Hotfix/Game/Map/System/MapUnitSystem.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
|
||||
namespace NB.Game;
|
||||
|
||||
public static class MapUnitComponentSystem
|
||||
{
|
||||
public static MapUnitGear GetOrAddItemGear(this MapUnitComponent self, Item item)
|
||||
{
|
||||
var mapItem = self.Gears.Find(t => t.Item == item.Id);
|
||||
if (mapItem == null)
|
||||
{
|
||||
mapItem = new MapUnitGear();
|
||||
mapItem.Item = item.Id;
|
||||
self.Gears.Add(mapItem);
|
||||
}
|
||||
|
||||
return mapItem;
|
||||
}
|
||||
|
||||
public static List<GearInfo> ToMapUnitInfo(this MapUnitComponent self)
|
||||
{
|
||||
List<GearInfo> ret = new List<GearInfo>();
|
||||
// foreach (var (_, unit) in self.Units)
|
||||
// {
|
||||
// // ret.Add(unit.ToMapUnitInfo());
|
||||
// }
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
namespace NB.Game;
|
||||
|
||||
public class RoomManageComponentAwakeSystem : AwakeSystem<RoomManageComponent>
|
||||
{
|
||||
@@ -62,6 +62,7 @@ public static class PlayerManageComponentSystem
|
||||
await account.TryComponent<PlayerItemContainerComponent>();
|
||||
await account.TryComponent<PlayerWalletComponent>();
|
||||
await account.TryComponent<FishContainer>();
|
||||
account.GetOrAddComponent<MapUnitComponent>();
|
||||
|
||||
if (needInit)
|
||||
{
|
||||
|
||||
@@ -63,45 +63,26 @@ public static class PlayerSystem
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 测试数据
|
||||
|
||||
public static void SetTestData(this Player player)
|
||||
|
||||
public static MapUnitInfo ToMapUnitInfo(this Player self)
|
||||
{
|
||||
var ret = new MapUnitInfo()
|
||||
{
|
||||
Id = self.Id,
|
||||
Position = Vector3Info.Create(self.Scene),
|
||||
Rotation = Vector3Info.Create(self.Scene),
|
||||
};
|
||||
|
||||
// Dictionary<int, List<int>> rigDic = new Dictionary<int, List<int>>()
|
||||
// {
|
||||
// { 30001, [50001, 60001, 70002, 90001, 100001] },
|
||||
// { 30002, [40001, 50001, 60001, 70002, 00001, 100001] },
|
||||
// { 30003, [40001, 60001, 80001] }
|
||||
// };
|
||||
//
|
||||
// var itemContainer = player.GetComponent<PlayerItemContainerComponent>();
|
||||
//
|
||||
// //添加测试数据
|
||||
// if (itemContainer != null && itemContainer.FishingRig.Count < 1)
|
||||
// {
|
||||
// foreach (var (rod, list) in rigDic)
|
||||
// {
|
||||
// if (itemContainer.GetFistItemByConfigId(rod, out var item) && item != null)
|
||||
// {
|
||||
// var childs = new List<long>();
|
||||
// foreach (var i in list)
|
||||
// {
|
||||
// if (itemContainer.GetFistItemByConfigId(i, out var itemChild) && itemChild != null)
|
||||
// {
|
||||
// childs.Add(itemChild.Id);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// itemContainer.FishingRig[item.Id] = childs;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// itemContainer.Save();
|
||||
// }
|
||||
var mapUnit = self.GetComponent<MapUnitComponent>();
|
||||
|
||||
ret.Position.x = mapUnit.Position.x;
|
||||
ret.Position.y = mapUnit.Position.y;
|
||||
ret.Position.z = mapUnit.Position.z;
|
||||
|
||||
ret.Rotation.x = mapUnit.Rotation.x;
|
||||
ret.Rotation.y = mapUnit.Rotation.y;
|
||||
ret.Rotation.z = mapUnit.Rotation.z;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Fantasy.Async;
|
||||
using Fantasy.Network;
|
||||
using Fantasy.Network.Interface;
|
||||
using Fantasy.Platform.Net;
|
||||
using NB.Map;
|
||||
using NB.Game;
|
||||
|
||||
namespace NB.Gate;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class C2G_EnterMapRequestHandler : MessageRPC<C2G_EnterMapRequest, G2C_En
|
||||
|
||||
if (serviceId == 0)
|
||||
{
|
||||
var mapScenes = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Map);
|
||||
var mapScenes = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Game);
|
||||
serviceId = mapScenes.First().Id;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class C2G_EnterMapRequestHandler : MessageRPC<C2G_EnterMapRequest, G2C_En
|
||||
if (oldServerRouteId != sceneConfig.RouteId)
|
||||
{
|
||||
//先退出旧的服务
|
||||
var ret = await gateUnit.Offline(session.RuntimeId, RouteType.MapRoute);
|
||||
var ret = await gateUnit.Offline(session.RuntimeId, RouteType.GameRoute);
|
||||
if (ret != 0)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.MapRoomIdError;
|
||||
@@ -79,7 +79,7 @@ public class C2G_EnterMapRequestHandler : MessageRPC<C2G_EnterMapRequest, G2C_En
|
||||
}
|
||||
|
||||
//再进入新的服务
|
||||
ret = await gateUnit.Online(RouteType.MapRoute, sceneConfig);
|
||||
ret = await gateUnit.Online(RouteType.GameRoute, sceneConfig);
|
||||
if (ret != 0)
|
||||
{
|
||||
response.ErrorCode = ErrorCode.MapRoomIdError;
|
||||
|
||||
@@ -3,7 +3,7 @@ using Fantasy.Async;
|
||||
using Fantasy.Network;
|
||||
using Fantasy.Network.Interface;
|
||||
using Fantasy.Platform.Net;
|
||||
using NB.Map;
|
||||
using NB.Game;
|
||||
|
||||
namespace NB.Gate;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public static class GateLoginHelper
|
||||
gateUnitSessionComponent.AccountID = gateUnit.AccountID;
|
||||
gateUnitSessionComponent.SessionId = session.RuntimeId;
|
||||
|
||||
return await gateUnit.Online(RouteType.GameRoute, RouteType.SocialRoute, RouteType.MapRoute);
|
||||
return await gateUnit.Online(RouteType.GameRoute, RouteType.SocialRoute);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -61,7 +61,7 @@ public static class GateLoginHelper
|
||||
{
|
||||
//通知服务器下线
|
||||
Log.Info($"断线的session id={sessionId}");
|
||||
var ret = await gateUnit.Offline(sessionId, RouteType.GameRoute, RouteType.SocialRoute, RouteType.MapRoute);
|
||||
var ret = await gateUnit.Offline(sessionId, RouteType.GameRoute, RouteType.SocialRoute);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
|
||||
namespace NB.Map;
|
||||
|
||||
public static class MapHelper
|
||||
{
|
||||
public static async FTask Offline(Scene scene, long accountId, long gateRouteId)
|
||||
{
|
||||
// 在缓存中检查该账号是否存在
|
||||
var chatUnitManageComponent = scene.GetComponent<MapUnitManageComponent>();
|
||||
if (chatUnitManageComponent == null) return;
|
||||
var mapUnit = chatUnitManageComponent.Get(accountId);
|
||||
if (mapUnit == null) return;
|
||||
|
||||
var roomManageComponent = scene.GetComponent<RoomManageComponent>();
|
||||
|
||||
if (mapUnit.RoomId > 0)
|
||||
{
|
||||
var room = roomManageComponent.Get(mapUnit.RoomId);
|
||||
if (room != null)
|
||||
{
|
||||
await room.Exit(accountId);
|
||||
roomManageComponent.Check(mapUnit.RoomId);
|
||||
}
|
||||
}
|
||||
|
||||
await chatUnitManageComponent.Offline(scene, accountId, gateRouteId);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Entitas;
|
||||
|
||||
namespace NB.Map;
|
||||
|
||||
public static class MapUnitFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建一个新的Player
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="aId">ToKen令牌传递过来的aId</param>
|
||||
/// <returns></returns>
|
||||
public static MapUnit Create(Scene scene, long aId)
|
||||
{
|
||||
var player = Entity.Create<MapUnit>(scene, aId, true, true);
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
|
||||
namespace NB.Map;
|
||||
|
||||
public static class MapUnitManageComponentSystem
|
||||
{
|
||||
#region 上线下线
|
||||
|
||||
/// <summary>
|
||||
/// 玩家上线
|
||||
/// </summary>
|
||||
/// <param name="self"></param>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="accountId"></param>
|
||||
/// <param name="gateRouteId"></param>
|
||||
public static async FTask<MapUnit?> Online(this MapUnitManageComponent self, Scene scene,
|
||||
long accountId,
|
||||
long gateRouteId)
|
||||
{
|
||||
if (!self.TryGet(accountId, out var unit))
|
||||
{
|
||||
unit = MapUnitFactory.Create(scene, accountId);
|
||||
self.Add(unit);
|
||||
}
|
||||
|
||||
if (unit != null)
|
||||
{
|
||||
unit.GateRouteId = gateRouteId;
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
return unit;
|
||||
}
|
||||
|
||||
public static async FTask Offline(this MapUnitManageComponent self, Scene scene, long accountId, long gateRouteId)
|
||||
{
|
||||
if (self.TryGet(accountId, out var unit) && unit != null)
|
||||
{
|
||||
if (unit.GateRouteId == gateRouteId)
|
||||
{
|
||||
self.Remove(accountId); //如果当前网关和下线的网关一致
|
||||
}
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 获取&移除
|
||||
|
||||
public static void Add(this MapUnitManageComponent self, MapUnit unit)
|
||||
{
|
||||
self.Units.Add(unit.Id, unit);
|
||||
}
|
||||
|
||||
public static MapUnit? Get(this MapUnitManageComponent self, long accountId)
|
||||
{
|
||||
return self.Units.GetValueOrDefault(accountId);
|
||||
}
|
||||
|
||||
public static bool TryGet(this MapUnitManageComponent self, long accountId, out MapUnit? unit)
|
||||
{
|
||||
return self.Units.TryGetValue(accountId, out unit);
|
||||
}
|
||||
|
||||
public static void Remove(this MapUnitManageComponent self, long accountId, bool isDispose = true)
|
||||
{
|
||||
if (!self.Units.Remove(accountId, out var account))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isDispose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
account.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Entitas.Interface;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace NB.Map;
|
||||
|
||||
public class MapUnitSystemDestroySystem : DestroySystem<MapUnit>
|
||||
{
|
||||
protected override void Destroy(MapUnit self)
|
||||
{
|
||||
self.MapId = 0;
|
||||
self.Position = float3.zero;
|
||||
self.Rotation = float3.zero;
|
||||
self.GateRouteId = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapUnitSystem
|
||||
{
|
||||
public static async FTask<uint> EnterMap(this MapUnit self, int mapId)
|
||||
{
|
||||
var mapManageComponent = self.Scene.GetComponent<MapManageComponent>();
|
||||
|
||||
var map = mapManageComponent.Get(mapId);
|
||||
if (map == null)
|
||||
{
|
||||
return ErrorCode.MapIdError;
|
||||
}
|
||||
|
||||
if (map.Units.TryAdd(self.Id, self))
|
||||
{
|
||||
// 同步客户端
|
||||
// self.Scene.NetworkMessagingComponent.SendInnerRoute(self.GateRouteId, new Map2C_ChangeMap()
|
||||
// {
|
||||
// Node = 1,
|
||||
// MapId = mapId
|
||||
// });
|
||||
}
|
||||
|
||||
self.MapId = mapId;
|
||||
|
||||
|
||||
await FTask.CompletedTask;
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ using NB.Authentication;
|
||||
using NB.Chat;
|
||||
using NB.Game;
|
||||
using NB.Gate;
|
||||
using NB.Map;
|
||||
|
||||
namespace NBF;
|
||||
|
||||
@@ -40,11 +39,11 @@ public sealed class OnCreateSceneEvent : AsyncEventSystem<OnCreateScene>
|
||||
await InitializeGateScene(scene);
|
||||
break;
|
||||
}
|
||||
case SceneType.Map:
|
||||
{
|
||||
await InitializeMapScene(scene);
|
||||
break;
|
||||
}
|
||||
// case SceneType.Map:
|
||||
// {
|
||||
// await InitializeMapScene(scene);
|
||||
// break;
|
||||
// }
|
||||
case SceneType.Social:
|
||||
{
|
||||
// Gate 场景初始化
|
||||
@@ -117,24 +116,24 @@ public sealed class OnCreateSceneEvent : AsyncEventSystem<OnCreateScene>
|
||||
// Log.Debug(instanceList[0].Dic[1]);
|
||||
}
|
||||
|
||||
private async FTask InitializeMapScene(Scene scene)
|
||||
{
|
||||
// Map 场景特定的初始化逻辑
|
||||
Log.Info($"初始化 Map 场景: {scene.Id}");
|
||||
Log.Info("创建地图场景===");
|
||||
scene.AddComponent<MapUnitManageComponent>();
|
||||
var roomManageComponent = scene.AddComponent<RoomManageComponent>();
|
||||
scene.AddComponent<MapManageComponent>();
|
||||
|
||||
var room = roomManageComponent.Create(361499030775398402);
|
||||
if (room != null)
|
||||
{
|
||||
roomManageComponent.TestRoomCode = room.Code;
|
||||
Log.Info($"测试房间代码 = {room.Code}");
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
// private async FTask InitializeMapScene(Scene scene)
|
||||
// {
|
||||
// // Map 场景特定的初始化逻辑
|
||||
// Log.Info($"初始化 Map 场景: {scene.Id}");
|
||||
// Log.Info("创建地图场景===");
|
||||
// scene.AddComponent<MapUnitManageComponent>();
|
||||
// var roomManageComponent = scene.AddComponent<RoomManageComponent>();
|
||||
// scene.AddComponent<MapManageComponent>();
|
||||
//
|
||||
// var room = roomManageComponent.Create(361499030775398402);
|
||||
// if (room != null)
|
||||
// {
|
||||
// roomManageComponent.TestRoomCode = room.Code;
|
||||
// Log.Info($"测试房间代码 = {room.Code}");
|
||||
// }
|
||||
//
|
||||
// await FTask.CompletedTask;
|
||||
// }
|
||||
|
||||
private async FTask InitializeSocialScene(Scene scene)
|
||||
{
|
||||
@@ -153,6 +152,19 @@ public sealed class OnCreateSceneEvent : AsyncEventSystem<OnCreateScene>
|
||||
//用于管理玩家的组件
|
||||
scene.AddComponent<PlayerManageComponent>();
|
||||
scene.AddComponent<PlayerBasicCacheManageComponent>();
|
||||
|
||||
|
||||
Log.Info("创建地图场景===");
|
||||
var roomManageComponent = scene.AddComponent<RoomManageComponent>();
|
||||
scene.AddComponent<MapManageComponent>();
|
||||
|
||||
var room = roomManageComponent.Create(361499030775398402);
|
||||
if (room != null)
|
||||
{
|
||||
// roomManageComponent.TestRoomCode = room.Code;
|
||||
Log.Info($"测试房间代码 = {room.Code}");
|
||||
}
|
||||
|
||||
await FTask.CompletedTask;
|
||||
|
||||
// var rod = RodConfig.Get(30001);
|
||||
|
||||
@@ -20,7 +20,7 @@ message Game2C_GetItemsResponse // ICustomRouteResponse
|
||||
///请求使用物品
|
||||
message C2Game_UseItemRequest // ICustomRouteRequest,Game2C_UseItemResponse,GameRoute
|
||||
{
|
||||
|
||||
int64 ItemId = 1;//主物体id
|
||||
}
|
||||
|
||||
///请求使用物品响应
|
||||
|
||||
@@ -2,7 +2,7 @@ syntax = "proto3";
|
||||
package Fantasy.Network.Message;
|
||||
|
||||
/// 请求创建房间
|
||||
message C2Map_CreateRoomRequest // ICustomRouteRequest,Map2C_CreateRoomResponse,MapRoute
|
||||
message C2Map_CreateRoomRequest // ICustomRouteRequest,Map2C_CreateRoomResponse,GameRoute
|
||||
{
|
||||
int32 MapId = 1;//地图id
|
||||
}
|
||||
@@ -43,22 +43,11 @@ message G2C_EnterMapResponse // IResponse
|
||||
}
|
||||
|
||||
|
||||
// // 请求进入地图
|
||||
// message C2Map_EnterMapRequest // ICustomRouteRequest,Map2C_EnterMapResponse,MapRoute
|
||||
// {
|
||||
// int32 MapId = 1;//地图id
|
||||
// string RoomCode = 2;//房间id,如果是进入房间
|
||||
// }
|
||||
|
||||
|
||||
// message Map2C_EnterMapResponse // ICustomRouteResponse
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
/// 通知客户端切换地图
|
||||
message Map2C_ChangeMap // ICustomRouteMessage,MapRoute
|
||||
message Map2C_ChangeMap // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
int32 MapId = 1; //地图id
|
||||
int32 Node = 2; //站位节点
|
||||
|
||||
@@ -4,39 +4,56 @@ package Fantasy.Network.Message;
|
||||
|
||||
//************** 进入 离开 **********************
|
||||
///用户进入地图
|
||||
message Map2C_RoleEnterRoomNotify // ICustomRouteMessage,MapRoute
|
||||
message Map2C_RoleEnterRoomNotify // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
MapUnitInfo Info = 2;
|
||||
}
|
||||
|
||||
///用户离开地图
|
||||
message Map2C_RoleExitRoomNotify // ICustomRouteMessage,MapRoute
|
||||
message Map2C_RoleExitRoomNotify // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
int64 Id = 1;//离开人员
|
||||
}
|
||||
|
||||
//************** 物品变化 **********************
|
||||
|
||||
/// 请求拿起物品
|
||||
message C2Map_TakeItemRequest // ICustomRouteRequest,Map2C_TakeItemResponse,GameRoute
|
||||
{
|
||||
int32 Id = 1; //物品id
|
||||
bool Task = 2; //拿起
|
||||
}
|
||||
|
||||
/// 请求拿起物品响应
|
||||
message Map2C_TakeItemResponse // ICustomRouteResponse
|
||||
{
|
||||
int32 Id = 1; //物品id
|
||||
bool Task = 2; //拿起
|
||||
}
|
||||
|
||||
|
||||
//************** 参数变化 **********************
|
||||
message C2Map_RolePropertyChange // ICustomRouteMessage,MapRoute
|
||||
message C2Map_RolePropertyChange // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
repeated KeyValueInt64 Propertys = 1; //变化的属性信息
|
||||
}
|
||||
|
||||
///玩家状态变化同步
|
||||
message Map2C_RoleStateNotify // ICustomRouteMessage,MapRoute
|
||||
message Map2C_RoleStateNotify // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
int64 Id = 1;
|
||||
UnitStateInfo State = 2;
|
||||
}
|
||||
|
||||
///玩家钓组变化
|
||||
message Map2C_RoleGearChangeNotify // ICustomRouteMessage,MapRoute
|
||||
message Map2C_RoleGearChangeNotify // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
int64 Id = 1;
|
||||
repeated GearInfo Gears = 2; //钓组数据
|
||||
}
|
||||
|
||||
//玩家属性值变化
|
||||
message Map2C_RolePropertyChangeNotify // ICustomRouteMessage,MapRoute
|
||||
message Map2C_RolePropertyChangeNotify // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
int64 Id = 1;
|
||||
repeated KeyValueInt64 Propertys = 2; //变化的属性信息
|
||||
@@ -47,7 +64,7 @@ message Map2C_RolePropertyChangeNotify // ICustomRouteMessage,MapRoute
|
||||
//************** 移动 旋转 **********************
|
||||
|
||||
// 角色移动
|
||||
message C2Map_Move // ICustomRouteMessage,MapRoute
|
||||
message C2Map_Move // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
Vector3Info Position = 1; //当前位置
|
||||
Vector3Info Rotation = 2; //角色方向
|
||||
@@ -58,14 +75,14 @@ message C2Map_Move // ICustomRouteMessage,MapRoute
|
||||
}
|
||||
|
||||
// 角色朝向变化
|
||||
message C2Map_Look // ICustomRouteMessage,MapRoute
|
||||
message C2Map_Look // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
Vector3Info Rotation = 1; //角色方向
|
||||
int64 Timestamp = 2; // 时间点
|
||||
}
|
||||
|
||||
///玩家移动推送
|
||||
message Map2C_MoveNotify // ICustomRouteMessage,MapRoute
|
||||
message Map2C_MoveNotify // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
int64 Id = 1; // id
|
||||
Vector3Info Position = 2; //当前位置
|
||||
@@ -77,9 +94,11 @@ message Map2C_MoveNotify // ICustomRouteMessage,MapRoute
|
||||
}
|
||||
|
||||
///玩家旋转推送
|
||||
message Map2C_LookeNotify // ICustomRouteMessage,MapRoute
|
||||
message Map2C_LookeNotify // ICustomRouteMessage,GameRoute
|
||||
{
|
||||
int64 Id = 1; // id
|
||||
Vector3Info Rotation = 2; //角色方向
|
||||
int64 Timestamp = 3; // 时间点
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,11 +22,13 @@ message QuaternionInfo
|
||||
///玩家当前使用钓组信息
|
||||
message GearInfo
|
||||
{
|
||||
int64 Rod = 1;
|
||||
repeated int64 Rigs = 2; //钓组配件
|
||||
Vector3Info Position = 3; //钓组当前位置
|
||||
Vector3Info Rotation = 4; //钓组方向
|
||||
repeated KeyValueInt64 Propertys = 5; //钓组参数信息
|
||||
ItemInfo Item = 1; //主物品id
|
||||
repeated ItemInfo Binds = 2; //物品配件
|
||||
Vector3Info Position = 3; //物品当前位置
|
||||
Vector3Info Rotation = 4; //物品方向
|
||||
repeated KeyValueInt64 Propertys = 5; //物品参数信息
|
||||
bool InUse = 6; //使用中
|
||||
bool InHand = 7; //在手中
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +45,7 @@ message MapUnitInfo
|
||||
Vector3Info Position = 3; //当前位置
|
||||
Vector3Info Rotation = 4; //角色方向
|
||||
UnitStateInfo State = 5; //状态信息
|
||||
repeated GearInfo Gears = 6; //钓组数据
|
||||
repeated GearInfo Gears = 6; //钓组数据
|
||||
repeated KeyValueInt64 Propertys = 7; //属性信息
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Route协议定义(需要定义1000以上、因为1000以内的框架预留)
|
||||
GateRoute = 1001 // Gate
|
||||
SocialRoute = 1002 // Social
|
||||
GameRoute = 1003 // Game
|
||||
MapRoute = 1004 // 地图
|
||||
GameRoute = 1003 // Game
|
||||
Reference in New Issue
Block a user