diff --git a/GameServer/Handlers/AchievementMessageHandler.cs b/GameServer/Handlers/AchievementMessageHandler.cs new file mode 100644 index 0000000..7dfac49 --- /dev/null +++ b/GameServer/Handlers/AchievementMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.AchievementInfoResponse, new AchievementInfoResponse()); + } +} diff --git a/GameServer/Handlers/AuthMessageHandler.cs b/GameServer/Handlers/AuthMessageHandler.cs index bafa9ee..1ab6bf4 100644 --- a/GameServer/Handlers/AuthMessageHandler.cs +++ b/GameServer/Handlers/AuthMessageHandler.cs @@ -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 data) + public async Task OnLoginRequest(ReadOnlyMemory _) { - 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 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 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 _) - { - 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 data) - { - await Session.Rpc.ReturnAsync(MessageId.EntityOnLandedResponse, new EntityOnLandedResponse - { - - }); - } - - [MessageHandler(MessageId.GachaInfoRequest)] - public async Task OnGachaInfoRequest(ReadOnlyMemory data) - { - await Session.Rpc.ReturnAsync(MessageId.GachaInfoResponse, new GachaInfoResponse()); - } - - [MessageHandler(MessageId.RoleFavorListRequest)] - public async Task OnRoleFavorListRequest(ReadOnlyMemory data) - { - await Session.Rpc.ReturnAsync(MessageId.RoleFavorListResponse, new RoleFavorListResponse()); - } - - [MessageHandler(MessageId.NormalItemRequest)] - public async Task OnNormalItemRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.NormalItemResponse, new NormalItemResponse()); - } - - [MessageHandler(MessageId.WeaponItemRequest)] - public async Task OnWeaponItemRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.WeaponItemResponse, new WeaponItemResponse()); - } - - [MessageHandler(MessageId.PhantomItemRequest)] - public async Task OnPhantomItemRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.PhantomItemResponse, new PhantomItemResponse()); - } - - [MessageHandler(MessageId.FriendAllRequest)] - public async Task OnFriendAllRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.FriendAllResponse, new FriendAllResponse()); - } - - [MessageHandler(MessageId.ItemExchangeInfoRequest)] - public async Task OnItemExchangeInfoRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.ItemExchangeInfoResponse, new ItemExchangeInfoResponse()); - } - - [MessageHandler(MessageId.TowerChallengeRequest)] - public async Task OnTowerChallengeRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.TowerChallengeResponse, new TowerChallengeResponse()); - } - - [MessageHandler(MessageId.InfluenceInfoRequest)] - public async Task OnInfluenceInfoRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.InfluenceInfoResponse, new InfluenceInfoResponse()); - } - - [MessageHandler(MessageId.CycleTowerChallengeRequest)] - public async Task OnCycleTowerChallengeRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.CycleTowerChallengeResponse, new CycleTowerChallengeResponse()); - } - - [MessageHandler(MessageId.AchievementInfoRequest)] - public async Task OnAchievementInfoRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.AchievementInfoResponse, new AchievementInfoResponse()); - } - - [MessageHandler(MessageId.ActivityRequest)] - public async Task OnActivityRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.ActivityResponse, new ActivityResponse()); - } - - [MessageHandler(MessageId.ExchangeRewardInfoRequest)] - public async Task OnExchangeRewardInfoRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.ExchangeRewardInfoResponse, new ExchangeRewardInfoResponse()); - } - - [MessageHandler(MessageId.RoguelikeSeasonDataRequest)] - public async Task OnRoguelikeSeasonDataRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.RoguelikeSeasonDataResponse, new RoguelikeSeasonDataResponse()); - } - - [MessageHandler(MessageId.MapTraceInfoRequest)] - public async Task OnMapTraceInfoRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.MapTraceInfoResponse, new MapTraceInfoResponse()); - } - - [MessageHandler(MessageId.PayShopInfoRequest)] - public async Task OnPayShopInfoRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.PayShopInfoResponse, new PayShopInfoResponse()); - } - - [MessageHandler(MessageId.LivenessRequest)] - public async Task OnLivenessRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.LivenessResponse, new LivenessResponse()); - } - - [MessageHandler(MessageId.LordGymInfoRequest)] - public async Task OnLordGymInfoRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.LordGymInfoResponse, new LordGymInfoResponse()); - } - - [MessageHandler(MessageId.UpdateSceneDateRequest)] - public async Task OnUpdateSceneDateRequest(ReadOnlyMemory data) - { - await Session.Rpc.ReturnAsync(MessageId.UpdateSceneDateResponse, new UpdateSceneDateResponse()); - } - - [MessageHandler(MessageId.PlayerMotionRequest)] - public async Task OnPlayerMotionRequest(ReadOnlyMemory 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 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 _) - { - 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 _) - { - await Session.Rpc.ReturnAsync(MessageId.EntityLoadCompleteResponse, new EntityLoadCompleteResponse()); - } - - [MessageHandler(MessageId.SceneLoadingFinishRequest)] - public async Task OnSceneLoadingFinishRequest(ReadOnlyMemory _) - { - await Session.Rpc.ReturnAsync(MessageId.SceneLoadingFinishResponse, new SceneLoadingFinishResponse - { - ErrorCode = 0 - }); - } - [MessageHandler(MessageId.HeartbeatRequest)] public async Task OnHeartbeatRequest(ReadOnlyMemory _) { await Session.Rpc.ReturnAsync(MessageId.HeartbeatResponse, new HeartbeatResponse()); } - - [MessageHandler(MessageId.GuideInfoRequest)] - public async Task OnGuideInfoRequest(ReadOnlyMemory _) - { - 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 } - }); - } } diff --git a/GameServer/Handlers/DailyActivityMessageHandler.cs b/GameServer/Handlers/DailyActivityMessageHandler.cs new file mode 100644 index 0000000..52202da --- /dev/null +++ b/GameServer/Handlers/DailyActivityMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.ActivityResponse, new ActivityResponse()); + } + + [MessageHandler(MessageId.LivenessRequest)] + public async Task OnLivenessRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.LivenessResponse, new LivenessResponse()); + } +} diff --git a/GameServer/Handlers/ExchangeRewardMessageHandler.cs b/GameServer/Handlers/ExchangeRewardMessageHandler.cs new file mode 100644 index 0000000..d559fe5 --- /dev/null +++ b/GameServer/Handlers/ExchangeRewardMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.ExchangeRewardInfoResponse, new ExchangeRewardInfoResponse()); + } +} diff --git a/GameServer/Handlers/FormationMessageHandler.cs b/GameServer/Handlers/FormationMessageHandler.cs new file mode 100644 index 0000000..ec0ee26 --- /dev/null +++ b/GameServer/Handlers/FormationMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.GetFormationDataResponse, new GetFormationDataResponse + { + Formations = + { + new FightFormation + { + CurRole = _modelManager.Player.CharacterId, + FormationId = 1, + IsCurrent = true, + RoleIds = { _modelManager.Player.CharacterId }, + } + }, + }); + } +} diff --git a/GameServer/Handlers/FriendMessageHandler.cs b/GameServer/Handlers/FriendMessageHandler.cs new file mode 100644 index 0000000..9cce4ad --- /dev/null +++ b/GameServer/Handlers/FriendMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.FriendAllResponse, new FriendAllResponse()); + } +} diff --git a/GameServer/Handlers/GachaMessageHandler.cs b/GameServer/Handlers/GachaMessageHandler.cs new file mode 100644 index 0000000..df52b03 --- /dev/null +++ b/GameServer/Handlers/GachaMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.GachaInfoResponse, new GachaInfoResponse()); + } +} diff --git a/GameServer/Handlers/InfluenceReputationMessageHandler.cs b/GameServer/Handlers/InfluenceReputationMessageHandler.cs new file mode 100644 index 0000000..f2f22d3 --- /dev/null +++ b/GameServer/Handlers/InfluenceReputationMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.InfluenceInfoResponse, new InfluenceInfoResponse()); + } +} diff --git a/GameServer/Handlers/InventoryMessageHandler.cs b/GameServer/Handlers/InventoryMessageHandler.cs new file mode 100644 index 0000000..459a6f4 --- /dev/null +++ b/GameServer/Handlers/InventoryMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.NormalItemResponse, new NormalItemResponse()); + } + + [MessageHandler(MessageId.WeaponItemRequest)] + public async Task OnWeaponItemRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.WeaponItemResponse, new WeaponItemResponse()); + } + + [MessageHandler(MessageId.PhantomItemRequest)] + public async Task OnPhantomItemRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.PhantomItemResponse, new PhantomItemResponse()); + } + + [MessageHandler(MessageId.ItemExchangeInfoRequest)] + public async Task OnItemExchangeInfoRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.ItemExchangeInfoResponse, new ItemExchangeInfoResponse()); + } +} diff --git a/GameServer/Handlers/LordGymMessageHandler.cs b/GameServer/Handlers/LordGymMessageHandler.cs new file mode 100644 index 0000000..3e365e5 --- /dev/null +++ b/GameServer/Handlers/LordGymMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.LordGymInfoResponse, new LordGymInfoResponse()); + } +} diff --git a/GameServer/Handlers/RoguelikeMessageHandler.cs b/GameServer/Handlers/RoguelikeMessageHandler.cs new file mode 100644 index 0000000..cc72fde --- /dev/null +++ b/GameServer/Handlers/RoguelikeMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.RoguelikeSeasonDataResponse, new RoguelikeSeasonDataResponse()); + } +} diff --git a/GameServer/Handlers/RoleMessageHandler.cs b/GameServer/Handlers/RoleMessageHandler.cs new file mode 100644 index 0000000..087acfa --- /dev/null +++ b/GameServer/Handlers/RoleMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.RoleFavorListResponse, new RoleFavorListResponse()); + } +} diff --git a/GameServer/Handlers/ShopMessageHandler.cs b/GameServer/Handlers/ShopMessageHandler.cs new file mode 100644 index 0000000..afa8753 --- /dev/null +++ b/GameServer/Handlers/ShopMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.PayShopInfoResponse, new PayShopInfoResponse()); + } +} diff --git a/GameServer/Handlers/TowerMessageHandler.cs b/GameServer/Handlers/TowerMessageHandler.cs new file mode 100644 index 0000000..4e15e07 --- /dev/null +++ b/GameServer/Handlers/TowerMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.TowerChallengeResponse, new TowerChallengeResponse()); + } + + [MessageHandler(MessageId.CycleTowerChallengeRequest)] + public async Task OnCycleTowerChallengeRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.CycleTowerChallengeResponse, new CycleTowerChallengeResponse()); + } +} diff --git a/GameServer/Handlers/TutorialMessageHandler.cs b/GameServer/Handlers/TutorialMessageHandler.cs new file mode 100644 index 0000000..bc73e81 --- /dev/null +++ b/GameServer/Handlers/TutorialMessageHandler.cs @@ -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 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 _) + { + 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 _) + { + 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 } + }); + } +} diff --git a/GameServer/Handlers/WorldMapMessageHandler.cs b/GameServer/Handlers/WorldMapMessageHandler.cs new file mode 100644 index 0000000..9529791 --- /dev/null +++ b/GameServer/Handlers/WorldMapMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.MapTraceInfoResponse, new MapTraceInfoResponse()); + } +} diff --git a/GameServer/Handlers/WorldMessageHandler.cs b/GameServer/Handlers/WorldMessageHandler.cs new file mode 100644 index 0000000..7967503 --- /dev/null +++ b/GameServer/Handlers/WorldMessageHandler.cs @@ -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 _) + { + await Session.Rpc.ReturnAsync(MessageId.EntityActiveResponse, new EntityActiveResponse()); + } + + [MessageHandler(MessageId.EntityOnLandedRequest)] + public async Task OnEntityOnLandedRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.EntityOnLandedResponse, new EntityOnLandedResponse()); + } + + [MessageHandler(MessageId.PlayerMotionRequest)] + public async Task OnPlayerMotionRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.PlayerMotionResponse, new PlayerMotionResponse()); + } + + [MessageHandler(MessageId.EntityLoadCompleteRequest)] + public async Task OnEntityLoadCompleteRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.EntityLoadCompleteResponse, new EntityLoadCompleteResponse()); + } + + [MessageHandler(MessageId.SceneLoadingFinishRequest)] + public async Task OnSceneLoadingFinishRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.SceneLoadingFinishResponse, new SceneLoadingFinishResponse()); + } + + [MessageHandler(MessageId.UpdateSceneDateRequest)] + public async Task OnUpdateSceneDateRequest(ReadOnlyMemory _) + { + await Session.Rpc.ReturnAsync(MessageId.UpdateSceneDateResponse, new UpdateSceneDateResponse()); + } +} diff --git a/GameServer/Models/ModelManager.cs b/GameServer/Models/ModelManager.cs new file mode 100644 index 0000000..2946d8f --- /dev/null +++ b/GameServer/Models/ModelManager.cs @@ -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!"); +} diff --git a/GameServer/Models/PlayerModel.cs b/GameServer/Models/PlayerModel.cs new file mode 100644 index 0000000..d453cec --- /dev/null +++ b/GameServer/Models/PlayerModel.cs @@ -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 + }; + } +} diff --git a/GameServer/Program.cs b/GameServer/Program.cs index c261490..4a886b6 100644 --- a/GameServer/Program.cs +++ b/GameServer/Program.cs @@ -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().AddSingleton() .AddScoped().AddScoped() .AddSingleton() + .AddScoped() .AddHostedService(); await builder.Build().RunAsync();