Split handlers to multiple classes
This commit is contained in:
parent
e50312938b
commit
9419cab81c
20 changed files with 448 additions and 233 deletions
18
GameServer/Handlers/AchievementMessageHandler.cs
Normal file
18
GameServer/Handlers/AchievementMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class AchievementMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public AchievementMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// AchievementMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.AchievementInfoRequest)]
|
||||
public async Task OnAchievementInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.AchievementInfoResponse, new AchievementInfoResponse());
|
||||
}
|
||||
}
|
|
@ -1,23 +1,22 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Models;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class AuthMessageHandler : MessageHandlerBase
|
||||
{
|
||||
private const int CharacterId = 1601;
|
||||
private readonly ModelManager _modelManager;
|
||||
|
||||
public AuthMessageHandler(KcpSession session) : base(session)
|
||||
public AuthMessageHandler(KcpSession session, ModelManager modelManager) : base(session)
|
||||
{
|
||||
// AuthMessageHandler.
|
||||
_modelManager = modelManager;
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.LoginRequest)]
|
||||
public async Task OnLoginRequest(ReadOnlyMemory<byte> data)
|
||||
public async Task OnLoginRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
LoginRequest request = LoginRequest.Parser.ParseFrom(data.Span);
|
||||
|
||||
Console.WriteLine(request);
|
||||
_modelManager.OnLogin();
|
||||
|
||||
await Session.Rpc.ReturnAsync(MessageId.LoginResponse, new LoginResponse
|
||||
{
|
||||
|
@ -31,12 +30,11 @@ internal class AuthMessageHandler : MessageHandlerBase
|
|||
public async Task OnEnterGameRequest(ReadOnlyMemory<byte> data)
|
||||
{
|
||||
EnterGameRequest request = EnterGameRequest.Parser.ParseFrom(data.Span);
|
||||
Console.WriteLine(request);
|
||||
|
||||
await Session.PushMessage(MessageId.BasicInfoNotify, new BasicInfoNotify
|
||||
{
|
||||
RandomSeed = 1337,
|
||||
Id = 1337,
|
||||
Id = _modelManager.Player.Id,
|
||||
Birthday = 0,
|
||||
Attributes =
|
||||
{
|
||||
|
@ -44,7 +42,7 @@ internal class AuthMessageHandler : MessageHandlerBase
|
|||
{
|
||||
Key = (int)PlayerAttrKey.Name,
|
||||
ValueType = (int)PlayerAttrType.String,
|
||||
StringValue = "ReversedRooms"
|
||||
StringValue = _modelManager.Player.Name
|
||||
},
|
||||
new PlayerAttr
|
||||
{
|
||||
|
@ -58,7 +56,7 @@ internal class AuthMessageHandler : MessageHandlerBase
|
|||
new RoleShowEntry
|
||||
{
|
||||
Level = 1,
|
||||
RoleId = CharacterId
|
||||
RoleId = _modelManager.Player.CharacterId
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -97,7 +95,7 @@ internal class AuthMessageHandler : MessageHandlerBase
|
|||
{
|
||||
new roleInfo
|
||||
{
|
||||
RoleId = 1601,
|
||||
RoleId = _modelManager.Player.CharacterId,
|
||||
Level = 1,
|
||||
}
|
||||
}
|
||||
|
@ -124,9 +122,9 @@ internal class AuthMessageHandler : MessageHandlerBase
|
|||
{
|
||||
EntityState = (int)EntityState.Born,
|
||||
EntityType = (int)EEntityType.Player,
|
||||
PlayerId = 1337,
|
||||
PlayerId = _modelManager.Player.Id,
|
||||
LivingStatus = (int)LivingStatus.Alive,
|
||||
ConfigId = CharacterId,
|
||||
ConfigId = _modelManager.Player.CharacterId,
|
||||
ConfigType = (int)EntityConfigType.Character,
|
||||
Id = 1,
|
||||
IsVisible = true,
|
||||
|
@ -250,7 +248,7 @@ internal class AuthMessageHandler : MessageHandlerBase
|
|||
{
|
||||
new ScenePlayerInformation
|
||||
{
|
||||
PlayerId = 1337,
|
||||
PlayerId = _modelManager.Player.Id,
|
||||
Level = 1,
|
||||
IsOffline = false,
|
||||
Location = new()
|
||||
|
@ -267,14 +265,14 @@ internal class AuthMessageHandler : MessageHandlerBase
|
|||
CurHp = 1000,
|
||||
MaxHp = 1000,
|
||||
IsControl = true,
|
||||
RoleId = CharacterId,
|
||||
RoleId = _modelManager.Player.CharacterId,
|
||||
RoleLevel = 1,
|
||||
}
|
||||
},
|
||||
PlayerName = "ReversedRooms"
|
||||
}
|
||||
},
|
||||
CurContextId = 1337
|
||||
CurContextId = _modelManager.Player.Id
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -283,225 +281,9 @@ internal class AuthMessageHandler : MessageHandlerBase
|
|||
await Session.Rpc.ReturnAsync(MessageId.EnterGameResponse, new EnterGameResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.TutorialInfoRequest)]
|
||||
public async Task OnTutorialInfoRequest(ReadOnlyMemory<byte> data)
|
||||
{
|
||||
int[] tutorials = [30001, 30002, 30003, 30004, 30005, 30006, 30007, 30011, 30012, 30008, 30009, 30010, 30013, 30014, 30015, 30016, 30017, 30018, 30019, 30020, 30021, 30022, 30023, 30024, 40001, 30025, 30026, 30027, 30028, 30029, 30030, 30031, 30032, 30033, 30034, 30035, 30036, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009, 50010, 50011, 33001, 34017, 34018, 32001, 32002, 32003, 32004, 32005, 32006, 32007, 32008, 32009, 32010, 32011, 32012, 32013, 32014, 32015, 32016, 32017, 32018, 32019, 32020, 32021, 33002, 33003, 33004, 33005, 34001, 34002, 34003, 34004, 34005, 34006, 34007, 34008, 34009, 34010, 34011, 34012, 34013, 34014, 34015, 34016, 34019, 34020, 34021, 34022, 34023, 34024, 34025, 34027, 34028, 34029, 34030, 34031, 34032, 34033];
|
||||
TutorialInfoResponse rsp = new();
|
||||
foreach (int id in tutorials)
|
||||
{
|
||||
rsp.UnLockList.Add(new TutorialInfo
|
||||
{
|
||||
Id = id,
|
||||
GetAward = true,
|
||||
CreateTime = 1337
|
||||
});
|
||||
}
|
||||
|
||||
await Session.Rpc.ReturnAsync(MessageId.TutorialInfoResponse, rsp);
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.GetDetectionLabelInfoRequest)]
|
||||
public async Task OnGetDetectionLabelInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
int[] guides = [0, 1, 2, 3, 14, 15, 16, 4, 21, 22, 7, 5, 18, 6, 61, 8, 9, 10, 11, 12, 13, 17, 19];
|
||||
int[] detectionTexts = [1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 61];
|
||||
|
||||
GetDetectionLabelInfoResponse rsp = new() { UnlockLabelInfo = new() };
|
||||
rsp.UnlockLabelInfo.UnlockedGuideIds.AddRange(guides);
|
||||
rsp.UnlockLabelInfo.UnlockedDetectionTextIds.AddRange(detectionTexts);
|
||||
|
||||
await Session.Rpc.ReturnAsync(MessageId.GetDetectionLabelInfoResponse, rsp);
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.EntityOnLandedRequest)]
|
||||
public async Task OnEntityOnLandedRequest(ReadOnlyMemory<byte> data)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.EntityOnLandedResponse, new EntityOnLandedResponse
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.GachaInfoRequest)]
|
||||
public async Task OnGachaInfoRequest(ReadOnlyMemory<byte> data)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.GachaInfoResponse, new GachaInfoResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.RoleFavorListRequest)]
|
||||
public async Task OnRoleFavorListRequest(ReadOnlyMemory<byte> data)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.RoleFavorListResponse, new RoleFavorListResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.NormalItemRequest)]
|
||||
public async Task OnNormalItemRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.NormalItemResponse, new NormalItemResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.WeaponItemRequest)]
|
||||
public async Task OnWeaponItemRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.WeaponItemResponse, new WeaponItemResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.PhantomItemRequest)]
|
||||
public async Task OnPhantomItemRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.PhantomItemResponse, new PhantomItemResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.FriendAllRequest)]
|
||||
public async Task OnFriendAllRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.FriendAllResponse, new FriendAllResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.ItemExchangeInfoRequest)]
|
||||
public async Task OnItemExchangeInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.ItemExchangeInfoResponse, new ItemExchangeInfoResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.TowerChallengeRequest)]
|
||||
public async Task OnTowerChallengeRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.TowerChallengeResponse, new TowerChallengeResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.InfluenceInfoRequest)]
|
||||
public async Task OnInfluenceInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.InfluenceInfoResponse, new InfluenceInfoResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.CycleTowerChallengeRequest)]
|
||||
public async Task OnCycleTowerChallengeRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.CycleTowerChallengeResponse, new CycleTowerChallengeResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.AchievementInfoRequest)]
|
||||
public async Task OnAchievementInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.AchievementInfoResponse, new AchievementInfoResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.ActivityRequest)]
|
||||
public async Task OnActivityRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.ActivityResponse, new ActivityResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.ExchangeRewardInfoRequest)]
|
||||
public async Task OnExchangeRewardInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.ExchangeRewardInfoResponse, new ExchangeRewardInfoResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.RoguelikeSeasonDataRequest)]
|
||||
public async Task OnRoguelikeSeasonDataRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.RoguelikeSeasonDataResponse, new RoguelikeSeasonDataResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.MapTraceInfoRequest)]
|
||||
public async Task OnMapTraceInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.MapTraceInfoResponse, new MapTraceInfoResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.PayShopInfoRequest)]
|
||||
public async Task OnPayShopInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.PayShopInfoResponse, new PayShopInfoResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.LivenessRequest)]
|
||||
public async Task OnLivenessRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.LivenessResponse, new LivenessResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.LordGymInfoRequest)]
|
||||
public async Task OnLordGymInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.LordGymInfoResponse, new LordGymInfoResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.UpdateSceneDateRequest)]
|
||||
public async Task OnUpdateSceneDateRequest(ReadOnlyMemory<byte> data)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.UpdateSceneDateResponse, new UpdateSceneDateResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.PlayerMotionRequest)]
|
||||
public async Task OnPlayerMotionRequest(ReadOnlyMemory<byte> data)
|
||||
{
|
||||
PlayerMotionRequest request = PlayerMotionRequest.Parser.ParseFrom(data.Span);
|
||||
await Session.Rpc.ReturnAsync(MessageId.PlayerMotionResponse, new PlayerMotionResponse
|
||||
{
|
||||
ErrorId = 0
|
||||
});
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.EntityActiveRequest)]
|
||||
public async Task OnEntityActiveRequest(ReadOnlyMemory<byte> data)
|
||||
{
|
||||
EntityActiveRequest request = EntityActiveRequest.Parser.ParseFrom(data.Span);
|
||||
await Session.Rpc.ReturnAsync(MessageId.EntityActiveResponse, new EntityActiveResponse
|
||||
{
|
||||
ComponentPbs = { },
|
||||
});
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.GetFormationDataRequest)]
|
||||
public async Task OnGetFormationDataRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.GetFormationDataResponse, new GetFormationDataResponse
|
||||
{
|
||||
Formations =
|
||||
{
|
||||
new FightFormation
|
||||
{
|
||||
CurRole = CharacterId,
|
||||
FormationId = 1,
|
||||
IsCurrent = true,
|
||||
RoleIds = { CharacterId },
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.EntityLoadCompleteRequest)]
|
||||
public async Task OnEntityLoadCompleteRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.EntityLoadCompleteResponse, new EntityLoadCompleteResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.SceneLoadingFinishRequest)]
|
||||
public async Task OnSceneLoadingFinishRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.SceneLoadingFinishResponse, new SceneLoadingFinishResponse
|
||||
{
|
||||
ErrorCode = 0
|
||||
});
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.HeartbeatRequest)]
|
||||
public async Task OnHeartbeatRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.HeartbeatResponse, new HeartbeatResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.GuideInfoRequest)]
|
||||
public async Task OnGuideInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.GuideInfoResponse, new GuideInfoResponse()
|
||||
{
|
||||
GuideGroupFinishList = { 60001, 60002, 60003, 60004, 60005, 60006, 60007, 60008, 60009, 60010, 60011, 60012, 60013, 60014, 60015, 60016, 60017, 60018, 60019, 60020, 60021, 60101, 60102, 60103, 62002, 62004, 62005, 62006, 62007, 62009, 62010, 62011, 62012, 62013, 62014, 62015, 62016, 62017, 62022, 62027, 62028, 62029, 62030, 62031, 62032, 62033, 62034, 62036, 65001, 67001, 67002, 67003, 67004, 67005, 67006, 67007, 67008, 67009, 67010, 67011, 67012, 67013, 67014, 67015, 67016, 67017, 67018, 67019, 67022, 62001, 62008, 62018, 62019, 62020, 62021, 62023, 62024, 62025, 62026, 62035, 65002, 65003, 65004, 65005 }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
24
GameServer/Handlers/DailyActivityMessageHandler.cs
Normal file
24
GameServer/Handlers/DailyActivityMessageHandler.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class DailyActivityMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public DailyActivityMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// DailyActivityMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.ActivityRequest)]
|
||||
public async Task OnActivityRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.ActivityResponse, new ActivityResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.LivenessRequest)]
|
||||
public async Task OnLivenessRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.LivenessResponse, new LivenessResponse());
|
||||
}
|
||||
}
|
18
GameServer/Handlers/ExchangeRewardMessageHandler.cs
Normal file
18
GameServer/Handlers/ExchangeRewardMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class ExchangeRewardMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public ExchangeRewardMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// ExchangeRewardMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.ExchangeRewardInfoRequest)]
|
||||
public async Task OnExchangeRewardInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.ExchangeRewardInfoResponse, new ExchangeRewardInfoResponse());
|
||||
}
|
||||
}
|
33
GameServer/Handlers/FormationMessageHandler.cs
Normal file
33
GameServer/Handlers/FormationMessageHandler.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Models;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class FormationMessageHandler : MessageHandlerBase
|
||||
{
|
||||
private readonly ModelManager _modelManager;
|
||||
|
||||
public FormationMessageHandler(KcpSession session, ModelManager modelManager) : base(session)
|
||||
{
|
||||
_modelManager = modelManager;
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.GetFormationDataRequest)]
|
||||
public async Task OnGetFormationDataRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.GetFormationDataResponse, new GetFormationDataResponse
|
||||
{
|
||||
Formations =
|
||||
{
|
||||
new FightFormation
|
||||
{
|
||||
CurRole = _modelManager.Player.CharacterId,
|
||||
FormationId = 1,
|
||||
IsCurrent = true,
|
||||
RoleIds = { _modelManager.Player.CharacterId },
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
18
GameServer/Handlers/FriendMessageHandler.cs
Normal file
18
GameServer/Handlers/FriendMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class FriendMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public FriendMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// FriendMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.FriendAllRequest)]
|
||||
public async Task OnFriendAllRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.FriendAllResponse, new FriendAllResponse());
|
||||
}
|
||||
}
|
18
GameServer/Handlers/GachaMessageHandler.cs
Normal file
18
GameServer/Handlers/GachaMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class GachaMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public GachaMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// GachaMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.GachaInfoRequest)]
|
||||
public async Task OnGachaInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.GachaInfoResponse, new GachaInfoResponse());
|
||||
}
|
||||
}
|
18
GameServer/Handlers/InfluenceReputationMessageHandler.cs
Normal file
18
GameServer/Handlers/InfluenceReputationMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class InfluenceReputationMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public InfluenceReputationMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// InfluenceReputationMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.InfluenceInfoRequest)]
|
||||
public async Task OnInfluenceInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.InfluenceInfoResponse, new InfluenceInfoResponse());
|
||||
}
|
||||
}
|
36
GameServer/Handlers/InventoryMessageHandler.cs
Normal file
36
GameServer/Handlers/InventoryMessageHandler.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class InventoryMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public InventoryMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// InventoryMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.NormalItemRequest)]
|
||||
public async Task OnNormalItemRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.NormalItemResponse, new NormalItemResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.WeaponItemRequest)]
|
||||
public async Task OnWeaponItemRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.WeaponItemResponse, new WeaponItemResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.PhantomItemRequest)]
|
||||
public async Task OnPhantomItemRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.PhantomItemResponse, new PhantomItemResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.ItemExchangeInfoRequest)]
|
||||
public async Task OnItemExchangeInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.ItemExchangeInfoResponse, new ItemExchangeInfoResponse());
|
||||
}
|
||||
}
|
18
GameServer/Handlers/LordGymMessageHandler.cs
Normal file
18
GameServer/Handlers/LordGymMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class LordGymMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public LordGymMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// LordGymMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.LordGymInfoRequest)]
|
||||
public async Task OnLordGymInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.LordGymInfoResponse, new LordGymInfoResponse());
|
||||
}
|
||||
}
|
18
GameServer/Handlers/RoguelikeMessageHandler.cs
Normal file
18
GameServer/Handlers/RoguelikeMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class RoguelikeMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public RoguelikeMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// RoguelikeMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.RoguelikeSeasonDataRequest)]
|
||||
public async Task OnRoguelikeSeasonDataRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.RoguelikeSeasonDataResponse, new RoguelikeSeasonDataResponse());
|
||||
}
|
||||
}
|
18
GameServer/Handlers/RoleMessageHandler.cs
Normal file
18
GameServer/Handlers/RoleMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class RoleMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public RoleMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// RoleMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.RoleFavorListRequest)]
|
||||
public async Task OnRoleFavorListRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.RoleFavorListResponse, new RoleFavorListResponse());
|
||||
}
|
||||
}
|
18
GameServer/Handlers/ShopMessageHandler.cs
Normal file
18
GameServer/Handlers/ShopMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class ShopMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public ShopMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// ShopMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.PayShopInfoRequest)]
|
||||
public async Task OnPayShopInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.PayShopInfoResponse, new PayShopInfoResponse());
|
||||
}
|
||||
}
|
24
GameServer/Handlers/TowerMessageHandler.cs
Normal file
24
GameServer/Handlers/TowerMessageHandler.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class TowerMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public TowerMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// TowerMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.TowerChallengeRequest)]
|
||||
public async Task OnTowerChallengeRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.TowerChallengeResponse, new TowerChallengeResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.CycleTowerChallengeRequest)]
|
||||
public async Task OnCycleTowerChallengeRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.CycleTowerChallengeResponse, new CycleTowerChallengeResponse());
|
||||
}
|
||||
}
|
52
GameServer/Handlers/TutorialMessageHandler.cs
Normal file
52
GameServer/Handlers/TutorialMessageHandler.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class TutorialMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public TutorialMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// TutorialMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.TutorialInfoRequest)]
|
||||
public async Task OnTutorialInfoRequest(ReadOnlyMemory<byte> data)
|
||||
{
|
||||
int[] tutorials = [30001, 30002, 30003, 30004, 30005, 30006, 30007, 30011, 30012, 30008, 30009, 30010, 30013, 30014, 30015, 30016, 30017, 30018, 30019, 30020, 30021, 30022, 30023, 30024, 40001, 30025, 30026, 30027, 30028, 30029, 30030, 30031, 30032, 30033, 30034, 30035, 30036, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009, 50010, 50011, 33001, 34017, 34018, 32001, 32002, 32003, 32004, 32005, 32006, 32007, 32008, 32009, 32010, 32011, 32012, 32013, 32014, 32015, 32016, 32017, 32018, 32019, 32020, 32021, 33002, 33003, 33004, 33005, 34001, 34002, 34003, 34004, 34005, 34006, 34007, 34008, 34009, 34010, 34011, 34012, 34013, 34014, 34015, 34016, 34019, 34020, 34021, 34022, 34023, 34024, 34025, 34027, 34028, 34029, 34030, 34031, 34032, 34033];
|
||||
TutorialInfoResponse rsp = new();
|
||||
foreach (int id in tutorials)
|
||||
{
|
||||
rsp.UnLockList.Add(new TutorialInfo
|
||||
{
|
||||
Id = id,
|
||||
GetAward = true,
|
||||
CreateTime = 1337
|
||||
});
|
||||
}
|
||||
|
||||
await Session.Rpc.ReturnAsync(MessageId.TutorialInfoResponse, rsp);
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.GetDetectionLabelInfoRequest)]
|
||||
public async Task OnGetDetectionLabelInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
int[] guides = [0, 1, 2, 3, 14, 15, 16, 4, 21, 22, 7, 5, 18, 6, 61, 8, 9, 10, 11, 12, 13, 17, 19];
|
||||
int[] detectionTexts = [1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 61];
|
||||
|
||||
GetDetectionLabelInfoResponse rsp = new() { UnlockLabelInfo = new() };
|
||||
rsp.UnlockLabelInfo.UnlockedGuideIds.AddRange(guides);
|
||||
rsp.UnlockLabelInfo.UnlockedDetectionTextIds.AddRange(detectionTexts);
|
||||
|
||||
await Session.Rpc.ReturnAsync(MessageId.GetDetectionLabelInfoResponse, rsp);
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.GuideInfoRequest)]
|
||||
public async Task OnGuideInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.GuideInfoResponse, new GuideInfoResponse()
|
||||
{
|
||||
GuideGroupFinishList = { 60001, 60002, 60003, 60004, 60005, 60006, 60007, 60008, 60009, 60010, 60011, 60012, 60013, 60014, 60015, 60016, 60017, 60018, 60019, 60020, 60021, 60101, 60102, 60103, 62002, 62004, 62005, 62006, 62007, 62009, 62010, 62011, 62012, 62013, 62014, 62015, 62016, 62017, 62022, 62027, 62028, 62029, 62030, 62031, 62032, 62033, 62034, 62036, 65001, 67001, 67002, 67003, 67004, 67005, 67006, 67007, 67008, 67009, 67010, 67011, 67012, 67013, 67014, 67015, 67016, 67017, 67018, 67019, 67022, 62001, 62008, 62018, 62019, 62020, 62021, 62023, 62024, 62025, 62026, 62035, 65002, 65003, 65004, 65005 }
|
||||
});
|
||||
}
|
||||
}
|
18
GameServer/Handlers/WorldMapMessageHandler.cs
Normal file
18
GameServer/Handlers/WorldMapMessageHandler.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class WorldMapMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public WorldMapMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// WorldMapMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.MapTraceInfoRequest)]
|
||||
public async Task OnMapTraceInfoRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.MapTraceInfoResponse, new MapTraceInfoResponse());
|
||||
}
|
||||
}
|
48
GameServer/Handlers/WorldMessageHandler.cs
Normal file
48
GameServer/Handlers/WorldMessageHandler.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using GameServer.Handlers.Attributes;
|
||||
using GameServer.Network;
|
||||
using Protocol;
|
||||
|
||||
namespace GameServer.Handlers;
|
||||
internal class WorldMessageHandler : MessageHandlerBase
|
||||
{
|
||||
public WorldMessageHandler(KcpSession session) : base(session)
|
||||
{
|
||||
// WorldMessageHandler.
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.EntityActiveRequest)]
|
||||
public async Task OnEntityActiveRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.EntityActiveResponse, new EntityActiveResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.EntityOnLandedRequest)]
|
||||
public async Task OnEntityOnLandedRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.EntityOnLandedResponse, new EntityOnLandedResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.PlayerMotionRequest)]
|
||||
public async Task OnPlayerMotionRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.PlayerMotionResponse, new PlayerMotionResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.EntityLoadCompleteRequest)]
|
||||
public async Task OnEntityLoadCompleteRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.EntityLoadCompleteResponse, new EntityLoadCompleteResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.SceneLoadingFinishRequest)]
|
||||
public async Task OnSceneLoadingFinishRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.SceneLoadingFinishResponse, new SceneLoadingFinishResponse());
|
||||
}
|
||||
|
||||
[MessageHandler(MessageId.UpdateSceneDateRequest)]
|
||||
public async Task OnUpdateSceneDateRequest(ReadOnlyMemory<byte> _)
|
||||
{
|
||||
await Session.Rpc.ReturnAsync(MessageId.UpdateSceneDateResponse, new UpdateSceneDateResponse());
|
||||
}
|
||||
}
|
12
GameServer/Models/ModelManager.cs
Normal file
12
GameServer/Models/ModelManager.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace GameServer.Models;
|
||||
internal class ModelManager
|
||||
{
|
||||
private PlayerModel? _playerModel;
|
||||
|
||||
public void OnLogin()
|
||||
{
|
||||
_playerModel = PlayerModel.CreateDefaultPlayer();
|
||||
}
|
||||
|
||||
public PlayerModel Player => _playerModel ?? throw new InvalidOperationException($"Trying to access {nameof(PlayerModel)} instance before initialization!");
|
||||
}
|
22
GameServer/Models/PlayerModel.cs
Normal file
22
GameServer/Models/PlayerModel.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
namespace GameServer.Models;
|
||||
internal class PlayerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public int CharacterId { get; set; }
|
||||
|
||||
public PlayerModel()
|
||||
{
|
||||
Name = string.Empty;
|
||||
}
|
||||
|
||||
public static PlayerModel CreateDefaultPlayer()
|
||||
{
|
||||
return new PlayerModel
|
||||
{
|
||||
Id = 1337,
|
||||
Name = "ReversedRooms",
|
||||
CharacterId = 1601
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using GameServer.Extensions;
|
||||
using GameServer.Handlers;
|
||||
using GameServer.Handlers.Factory;
|
||||
using GameServer.Models;
|
||||
using GameServer.Network;
|
||||
using GameServer.Network.Rpc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
@ -21,6 +22,7 @@ internal static class Program
|
|||
.AddScoped<MessageManager>().AddSingleton<MessageHandlerFactory>()
|
||||
.AddScoped<RpcManager>().AddScoped<IRpcEndPoint, RpcSessionEndPoint>()
|
||||
.AddSingleton<SessionManager>()
|
||||
.AddScoped<ModelManager>()
|
||||
.AddHostedService<WWGameServer>();
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
|
|
Loading…
Reference in a new issue