From e3c073b049ca3fe1425e8df6a97060369ede5361 Mon Sep 17 00:00:00 2001 From: StopWuyu Date: Fri, 30 May 2025 21:03:57 +0800 Subject: [PATCH] refactor: change entity interface to base class --- Command/Command/Cmd/CommandScene.cs | 6 +-- Common/Data/Config/Task/AdvModifyMaxMazeMP.cs | 2 +- .../Loaders/TrialActivityEntityLoader.cs | 4 +- GameServer/Game/Battle/BattleManager.cs | 2 +- GameServer/Game/Battle/SceneSkillManager.cs | 6 +-- .../Game/Challenge/ChallengeEntityLoader.cs | 4 +- .../ChessRogue/Cell/ChessRogueEntityLoader.cs | 4 +- GameServer/Game/Lobby/LobbyRoomInstance.cs | 1 + .../Handler/MissionHandlerKillMonster.cs | 2 +- .../Game/Mission/StoryLineEntityLoader.cs | 2 +- GameServer/Game/Player/PlayerInstance.cs | 22 ++++----- .../Game/Rogue/Scene/Entity/RogueProp.cs | 14 +++--- .../Game/Rogue/Scene/RogueEntityLoader.cs | 18 +++---- .../Scene/RogueMagicEntityLoader.cs | 12 ++--- .../Scene/RogueTournEntityLoader.cs | 12 ++--- .../Game/Scene/Entity/BaseGameEntity.cs | 25 ++++++++++ GameServer/Game/Scene/Entity/EntityMonster.cs | 31 ++++++------ GameServer/Game/Scene/Entity/EntityNpc.cs | 22 ++------- GameServer/Game/Scene/Entity/EntityProp.cs | 22 ++------- .../Game/Scene/Entity/EntitySummonUnit.cs | 22 ++------- GameServer/Game/Scene/Entity/IGameEntity.cs | 17 ------- GameServer/Game/Scene/SceneEntityLoader.cs | 24 ++++----- GameServer/Game/Scene/SceneInstance.cs | 49 +++++++++---------- .../Game/Task/AvatarTask/AbilityLevelTask.cs | 18 ++++--- .../Task/AvatarTask/SummonUnitLevelTask.cs | 16 +++--- GameServer/Game/Task/LevelTask.cs | 16 +++--- .../HandlerRogueWorkbenchGetInfoCsReq.cs | 2 +- .../HandlerRogueWorkbenchHandleFuncCsReq.cs | 2 +- .../Scene/PacketSceneGroupRefreshScNotify.cs | 20 ++++---- .../PacketSyncEntityBuffChangeListScNotify.cs | 4 +- 30 files changed, 186 insertions(+), 215 deletions(-) create mode 100644 GameServer/Game/Scene/Entity/BaseGameEntity.cs delete mode 100644 GameServer/Game/Scene/Entity/IGameEntity.cs diff --git a/Command/Command/Cmd/CommandScene.cs b/Command/Command/Cmd/CommandScene.cs index ba4aae05..e19aa959 100644 --- a/Command/Command/Cmd/CommandScene.cs +++ b/Command/Command/Cmd/CommandScene.cs @@ -19,8 +19,8 @@ public class CommandScene : ICommand var scene = arg.Target!.Player!.SceneInstance!; var loadedGroup = new List(); foreach (var group in scene.Entities) - if (!loadedGroup.Contains(group.Value.GroupID)) - loadedGroup.Add(group.Value.GroupID); + if (!loadedGroup.Contains(group.Value.GroupId)) + loadedGroup.Add(group.Value.GroupId); await arg.SendMsg(I18NManager.Translate("Game.Command.Scene.LoadedGroups", string.Join(", ", loadedGroup))); } @@ -190,6 +190,6 @@ public class CommandScene : ICommand if (nearest != null) await arg.SendMsg( - $"Nearest Prop {nearest.EntityId}: PropId {nearest.PropInfo.ID}, GroupId {nearest.GroupID}, State {nearest.State}"); + $"Nearest Prop {nearest.EntityId}: PropId {nearest.PropInfo.ID}, GroupId {nearest.GroupId}, State {nearest.State}"); } } \ No newline at end of file diff --git a/Common/Data/Config/Task/AdvModifyMaxMazeMP.cs b/Common/Data/Config/Task/AdvModifyMaxMazeMP.cs index 587a393c..7aa000b4 100644 --- a/Common/Data/Config/Task/AdvModifyMaxMazeMP.cs +++ b/Common/Data/Config/Task/AdvModifyMaxMazeMP.cs @@ -9,5 +9,5 @@ public class AdvModifyMaxMazeMP : TaskConfigInfo [JsonConverter(typeof(StringEnumConverter))] public PropertyModifyFunctionEnum ModifyFunction { get; set; } - public DynamicFloat ModifyValue { get; set; } + public DynamicFloat ModifyValue { get; set; } = new(); } \ No newline at end of file diff --git a/GameServer/Game/Activity/Loaders/TrialActivityEntityLoader.cs b/GameServer/Game/Activity/Loaders/TrialActivityEntityLoader.cs index edfbc242..77ad2a3e 100644 --- a/GameServer/Game/Activity/Loaders/TrialActivityEntityLoader.cs +++ b/GameServer/Game/Activity/Loaders/TrialActivityEntityLoader.cs @@ -68,8 +68,8 @@ public class TrialActivityEntityLoader(SceneInstance scene, PlayerInstance playe // Create monster from group monster info var entity = new EntityMonster(Scene, info.ToPositionProto(), info.ToRotationProto(), group.Id, info.ID, npcMonsterExcel, info); - entity.EventID = stageMonsterInfo.EventId; - entity.CustomStageID = stageMonsterInfo.EventId; + entity.EventId = stageMonsterInfo.EventId; + entity.CustomStageId = stageMonsterInfo.EventId; await Scene.AddEntity(entity, sendPacket); return entity; diff --git a/GameServer/Game/Battle/BattleManager.cs b/GameServer/Game/Battle/BattleManager.cs index 57b81053..357cedc3 100644 --- a/GameServer/Game/Battle/BattleManager.cs +++ b/GameServer/Game/Battle/BattleManager.cs @@ -19,7 +19,7 @@ public class BattleManager(PlayerInstance player) : BasePlayerManager(player) { public StageConfigExcel? NextBattleStageConfig { get; set; } - public async ValueTask StartBattle(IGameEntity attackEntity, List targetEntityList, + public async ValueTask StartBattle(BaseGameEntity attackEntity, List targetEntityList, bool isSkill) { if (Player.BattleInstance != null) return Player.BattleInstance; diff --git a/GameServer/Game/Battle/SceneSkillManager.cs b/GameServer/Game/Battle/SceneSkillManager.cs index bc7e388e..6e91340c 100644 --- a/GameServer/Game/Battle/SceneSkillManager.cs +++ b/GameServer/Game/Battle/SceneSkillManager.cs @@ -12,8 +12,8 @@ public class SceneSkillManager(PlayerInstance player) : BasePlayerManager(player public async ValueTask OnCast(SceneCastSkillCsReq req) { // get entities - List targetEntities = []; // enemy - IGameEntity? attackEntity; // caster + List targetEntities = []; // enemy + BaseGameEntity? attackEntity; // caster List addEntityIds = []; foreach (var id in req.AssistMonsterEntityIdList) if (Player.SceneInstance!.Entities.TryGetValue((int)id, out var v)) @@ -60,7 +60,7 @@ public class SceneSkillManager(PlayerInstance player) : BasePlayerManager(player return new SkillResultData(Retcode.RetSucc, res.Instance, res.BattleInfos); } - private AdventureAbilityConfigListInfo? GetAbilityConfig(IGameEntity entity) + private AdventureAbilityConfigListInfo? GetAbilityConfig(BaseGameEntity entity) { if (entity is EntityMonster monster) return GameData.AdventureAbilityConfigListData.GetValueOrDefault(monster.MonsterData.ID); diff --git a/GameServer/Game/Challenge/ChallengeEntityLoader.cs b/GameServer/Game/Challenge/ChallengeEntityLoader.cs index a96e4ab0..fb5c66a3 100644 --- a/GameServer/Game/Challenge/ChallengeEntityLoader.cs +++ b/GameServer/Game/Challenge/ChallengeEntityLoader.cs @@ -76,8 +76,8 @@ public class ChallengeEntityLoader(SceneInstance scene, PlayerInstance player) : var entity = new EntityMonster(Scene, info.ToPositionProto(), info.ToRotationProto(), group.Id, info.ID, npcMonsterExcel, info) { - EventID = challengeMonsterInfo.EventId, - CustomStageID = challengeMonsterInfo.EventId + EventId = challengeMonsterInfo.EventId, + CustomStageId = challengeMonsterInfo.EventId }; await Scene.AddEntity(entity, sendPacket); diff --git a/GameServer/Game/ChessRogue/Cell/ChessRogueEntityLoader.cs b/GameServer/Game/ChessRogue/Cell/ChessRogueEntityLoader.cs index 689ea261..e7772f51 100644 --- a/GameServer/Game/ChessRogue/Cell/ChessRogueEntityLoader.cs +++ b/GameServer/Game/ChessRogue/Cell/ChessRogueEntityLoader.cs @@ -96,8 +96,8 @@ public class ChessRogueEntityLoader(SceneInstance scene) : SceneEntityLoader(sce EntityMonster entity = new(Scene, info.ToPositionProto(), info.ToRotationProto(), group.Id, info.ID, excel, info) { - EventID = rogueMonster.EventID, - CustomStageID = rogueMonster.EventID + EventId = rogueMonster.EventID, + CustomStageId = rogueMonster.EventID }; await Scene.AddEntity(entity, sendPacket); diff --git a/GameServer/Game/Lobby/LobbyRoomInstance.cs b/GameServer/Game/Lobby/LobbyRoomInstance.cs index f9d6cf48..0b9c3371 100644 --- a/GameServer/Game/Lobby/LobbyRoomInstance.cs +++ b/GameServer/Game/Lobby/LobbyRoomInstance.cs @@ -10,6 +10,7 @@ namespace EggLink.DanhengServer.GameServer.Game.Lobby; public class LobbyRoomInstance(PlayerInstance owner, long roomId, FightGameMode gameMode, int lobbyMode) { + public PlayerInstance Owner { get; } = owner; public long RoomId { get; set; } = roomId; public FightGameMode GameMode { get; set; } = gameMode; public List Players { get; set; } = []; diff --git a/GameServer/Game/Mission/FinishType/Handler/MissionHandlerKillMonster.cs b/GameServer/Game/Mission/FinishType/Handler/MissionHandlerKillMonster.cs index 5c451b0f..4a9cc746 100644 --- a/GameServer/Game/Mission/FinishType/Handler/MissionHandlerKillMonster.cs +++ b/GameServer/Game/Mission/FinishType/Handler/MissionHandlerKillMonster.cs @@ -12,7 +12,7 @@ public class MissionHandlerKillMonster : MissionFinishTypeHandler public override async ValueTask HandleMissionFinishType(PlayerInstance player, SubMissionInfo info, object? arg) { if (arg is not EntityMonster monster) return; - if (monster.InstID == info.ParamInt2) + if (monster.InstId == info.ParamInt2) if (!monster.IsAlive) await player.MissionManager!.FinishSubMission(info.ID); } diff --git a/GameServer/Game/Mission/StoryLineEntityLoader.cs b/GameServer/Game/Mission/StoryLineEntityLoader.cs index 764b872e..d992c703 100644 --- a/GameServer/Game/Mission/StoryLineEntityLoader.cs +++ b/GameServer/Game/Mission/StoryLineEntityLoader.cs @@ -41,7 +41,7 @@ public class StoryLineEntityLoader(SceneInstance scene) : SceneEntityLoader(scen Scene.IsLoaded = true; } - public override async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) + public override async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) { if (!LoadGroups.Contains(info.Id)) return null; return await base.LoadGroup(info, forceLoad); diff --git a/GameServer/Game/Player/PlayerInstance.cs b/GameServer/Game/Player/PlayerInstance.cs index 78f02008..1cf3d4bd 100644 --- a/GameServer/Game/Player/PlayerInstance.cs +++ b/GameServer/Game/Player/PlayerInstance.cs @@ -494,7 +494,7 @@ public class PlayerInstance(PlayerData data) var oldState = prop.State; await prop.SetState(config.TargetState); var newState = prop.State; - await SendPacket(new PacketGroupStateChangeScNotify(Data.EntryId, prop.GroupID, prop.State)); + await SendPacket(new PacketGroupStateChangeScNotify(Data.EntryId, prop.GroupId, prop.State)); switch (prop.Excel.PropType) { @@ -510,7 +510,7 @@ public class PlayerInstance(PlayerData data) foreach (var markedChest in SceneData!.MarkedChestData.Values) { var chest = markedChest.Find(x => - x.FloorId == SceneInstance.FloorId && x.GroupId == prop.GroupID && + x.FloorId == SceneInstance.FloorId && x.GroupId == prop.GroupId && x.ConfigId == prop.PropInfo.ID); if (chest == null) continue; @@ -531,7 +531,7 @@ public class PlayerInstance(PlayerData data) { case PropStateEnum.Closed: { - foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupID)) + foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupId)) if (p.Excel.PropType == PropTypeEnum.PROP_TREASURE_CHEST) { await p.SetState(PropStateEnum.ChestClosed); @@ -549,7 +549,7 @@ public class PlayerInstance(PlayerData data) } case PropStateEnum.Open: { - foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupID).Where(p => + foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupId).Where(p => p.Excel.PropType is not PropTypeEnum.PROP_TREASURE_CHEST && p.Excel.PropType != prop.Excel.PropType)) await p.SetState(PropStateEnum.Open); @@ -561,7 +561,7 @@ public class PlayerInstance(PlayerData data) break; case PropTypeEnum.PROP_MAZE_PUZZLE: if (newState is PropStateEnum.Closed or PropStateEnum.Open) - foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupID)) + foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupId)) { if (p.Excel.PropType == PropTypeEnum.PROP_TREASURE_CHEST) { @@ -583,7 +583,7 @@ public class PlayerInstance(PlayerData data) case PropTypeEnum.PROP_ORDINARY: if (prop.PropInfo.CommonConsole) // set group - foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupID)) + foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupId)) { await p.SetState(newState); @@ -592,12 +592,12 @@ public class PlayerInstance(PlayerData data) if (prop.PropInfo.Name.Contains("Piece")) { - var pieceDone = SceneInstance.GetEntitiesInGroup(prop.GroupID) + var pieceDone = SceneInstance.GetEntitiesInGroup(prop.GroupId) .Where(p => p.PropInfo.Name.Contains("Piece")).All(p => p.State == PropStateEnum.Closed); if (pieceDone) // set JigsawSir to open - foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupID) + foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupId) .Where(p => p.PropInfo.Name.Contains("JigsawSir") && p.State != PropStateEnum.Closed)) await p.SetState(PropStateEnum.TriggerEnable); @@ -679,10 +679,10 @@ public class PlayerInstance(PlayerData data) SceneData.PropTimelineData[Data.FloorId] = floorData; } - if (!floorData.ContainsKey(prop.GroupID)) - floorData[prop.GroupID] = new Dictionary(); + if (!floorData.ContainsKey(prop.GroupId)) + floorData[prop.GroupId] = new Dictionary(); - floorData[prop.GroupID][prop.PropInfo.ID] = data; + floorData[prop.GroupId][prop.PropInfo.ID] = data; prop.PropTimelineData = data; diff --git a/GameServer/Game/Rogue/Scene/Entity/RogueProp.cs b/GameServer/Game/Rogue/Scene/Entity/RogueProp.cs index 2f54997f..61af8777 100644 --- a/GameServer/Game/Rogue/Scene/Entity/RogueProp.cs +++ b/GameServer/Game/Rogue/Scene/Entity/RogueProp.cs @@ -15,10 +15,10 @@ public class RogueProp(SceneInstance scene, MazePropExcel excel, GroupInfo group { } - public int NextRoomID { get; set; } - public int NextSiteID { get; set; } + public int NextRoomId { get; set; } + public int NextSiteId { get; set; } public int ChestCanUseTimes { get; set; } - public int CustomPropID { get; set; } + public int CustomPropId { get; set; } public bool IsChessRogue { get; set; } = false; public bool IsLastRoom { get; set; } = false; @@ -34,13 +34,13 @@ public class RogueProp(SceneInstance scene, MazePropExcel excel, GroupInfo group { var proto = base.ToProto(); - if (NextRoomID != 0 || NextSiteID != 0 || ChestCanUseTimes != 0) // do not set if all are 0 + if (NextRoomId != 0 || NextSiteId != 0 || ChestCanUseTimes != 0) // do not set if all are 0 proto.Prop.ExtraInfo = new PropExtraInfo { RogueInfo = new PropRogueInfo { - RoomId = (uint)NextRoomID, - SiteId = (uint)NextSiteID + RoomId = (uint)NextRoomId, + SiteId = (uint)NextSiteId } }; @@ -73,7 +73,7 @@ public class RogueProp(SceneInstance scene, MazePropExcel excel, GroupInfo group } }; - if (CustomPropID != 0) proto.Prop.PropId = (uint)CustomPropID; + if (CustomPropId != 0) proto.Prop.PropId = (uint)CustomPropId; return proto; } diff --git a/GameServer/Game/Rogue/Scene/RogueEntityLoader.cs b/GameServer/Game/Rogue/Scene/RogueEntityLoader.cs index be3008aa..83328cb7 100644 --- a/GameServer/Game/Rogue/Scene/RogueEntityLoader.cs +++ b/GameServer/Game/Rogue/Scene/RogueEntityLoader.cs @@ -35,9 +35,9 @@ public class RogueEntityLoader(SceneInstance scene, PlayerInstance player) : Sce Scene.IsLoaded = true; } - public override async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) + public override async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) { - var entityList = new List(); + var entityList = new List(); foreach (var npc in info.NPCList) try { @@ -113,8 +113,8 @@ public class RogueEntityLoader(SceneInstance scene, PlayerInstance player) : Sce EntityMonster entity = new(Scene, info.ToPositionProto(), info.ToRotationProto(), group.Id, info.ID, excel, info) { - EventID = rogueMonster.EventID, - CustomStageID = rogueMonster.EventID + EventId = rogueMonster.EventID, + CustomStageId = rogueMonster.EventID }; await Scene.AddEntity(entity, sendPacket); @@ -144,17 +144,17 @@ public class RogueEntityLoader(SceneInstance scene, PlayerInstance player) : Sce if (nextSiteIds.Count == 0) { // exit - prop.CustomPropID = 1000; + prop.CustomPropId = 1000; } else { index = Math.Min(index, nextSiteIds.Count - 1); // Sanity check var nextRoom = Player.RogueManager?.RogueInstance?.RogueRooms[nextSiteIds[index]]; - prop.NextSiteID = nextSiteIds[index]; - prop.NextRoomID = nextRoom!.Excel?.RogueRoomID ?? 0; - NextRoomIds.Add(prop.NextRoomID); + prop.NextSiteId = nextSiteIds[index]; + prop.NextRoomId = nextRoom!.Excel?.RogueRoomID ?? 0; + NextRoomIds.Add(prop.NextRoomId); - prop.CustomPropID = nextRoom!.Excel!.RogueRoomType switch // door style + prop.CustomPropId = nextRoom!.Excel!.RogueRoomType switch // door style { 3 => 1022, 8 => 1022, diff --git a/GameServer/Game/RogueMagic/Scene/RogueMagicEntityLoader.cs b/GameServer/Game/RogueMagic/Scene/RogueMagicEntityLoader.cs index 3c799d89..e40b2907 100644 --- a/GameServer/Game/RogueMagic/Scene/RogueMagicEntityLoader.cs +++ b/GameServer/Game/RogueMagic/Scene/RogueMagicEntityLoader.cs @@ -41,9 +41,9 @@ public class RogueMagicEntityLoader(SceneInstance scene, PlayerInstance player) Scene.IsLoaded = true; } - public override async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) + public override async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) { - var entityList = new List(); + var entityList = new List(); foreach (var npc in info.NPCList) try { @@ -165,8 +165,8 @@ public class RogueMagicEntityLoader(SceneInstance scene, PlayerInstance player) EntityMonster entity = new(Scene, info.ToPositionProto(), info.ToRotationProto(), group.Id, info.ID, excel, info) { - EventID = rogueMonster.EventID, - CustomStageID = rogueMonster.EventID, + EventId = rogueMonster.EventID, + CustomStageId = rogueMonster.EventID, RogueMonsterId = rogueMonster.RogueMonsterID }; @@ -197,7 +197,7 @@ public class RogueMagicEntityLoader(SceneInstance scene, PlayerInstance player) { // exit if (prop.InstId != 300002) return null; // not center door - prop.CustomPropID = 1053; + prop.CustomPropId = 1053; } else { @@ -226,7 +226,7 @@ public class RogueMagicEntityLoader(SceneInstance scene, PlayerInstance player) ExistTypes.Add(nextRoom); } - prop.CustomPropID = nextRoom switch // door style + prop.CustomPropId = nextRoom switch // door style { RogueMagicRoomTypeEnum.Event => 1055, RogueMagicRoomTypeEnum.Wealth => 1055, diff --git a/GameServer/Game/RogueTourn/Scene/RogueTournEntityLoader.cs b/GameServer/Game/RogueTourn/Scene/RogueTournEntityLoader.cs index a9e12242..5de60a78 100644 --- a/GameServer/Game/RogueTourn/Scene/RogueTournEntityLoader.cs +++ b/GameServer/Game/RogueTourn/Scene/RogueTournEntityLoader.cs @@ -38,9 +38,9 @@ public class RogueTournEntityLoader(SceneInstance scene, PlayerInstance player) Scene.IsLoaded = true; } - public override async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) + public override async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) { - var entityList = new List(); + var entityList = new List(); foreach (var npc in info.NPCList) try { @@ -140,8 +140,8 @@ public class RogueTournEntityLoader(SceneInstance scene, PlayerInstance player) EntityMonster entity = new(Scene, info.ToPositionProto(), info.ToRotationProto(), group.Id, info.ID, excel, info) { - EventID = rogueMonster.EventID, - CustomStageID = rogueMonster.EventID, + EventId = rogueMonster.EventID, + CustomStageId = rogueMonster.EventID, RogueMonsterId = rogueMonster.RogueMonsterID }; @@ -166,7 +166,7 @@ public class RogueTournEntityLoader(SceneInstance scene, PlayerInstance player) { if (room is { RoomIndex: 4, LevelInstance.LevelIndex: 3 }) // last room // exit - prop.CustomPropID = 1033; + prop.CustomPropId = 1033; else do // find next room { @@ -193,7 +193,7 @@ public class RogueTournEntityLoader(SceneInstance scene, PlayerInstance player) ExistTypes.Add(nextRoom); } - prop.CustomPropID = nextRoom switch // door style + prop.CustomPropId = nextRoom switch // door style { RogueTournRoomTypeEnum.Event => 1035, RogueTournRoomTypeEnum.Coin => 1035, diff --git a/GameServer/Game/Scene/Entity/BaseGameEntity.cs b/GameServer/Game/Scene/Entity/BaseGameEntity.cs new file mode 100644 index 00000000..ba04d4c3 --- /dev/null +++ b/GameServer/Game/Scene/Entity/BaseGameEntity.cs @@ -0,0 +1,25 @@ +using EggLink.DanhengServer.GameServer.Game.Battle; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Game.Scene.Entity; + +public abstract class BaseGameEntity +{ + public abstract int EntityId { get; set; } + public abstract int GroupId { get; set; } + + public List BuffList { get; set; } = []; + + public virtual ValueTask AddBuff(SceneBuff buff) + { + return ValueTask.CompletedTask; + } + + public virtual ValueTask ApplyBuff(BattleInstance instance) + { + return ValueTask.CompletedTask; + } + + + public abstract SceneEntityInfo ToProto(); +} \ No newline at end of file diff --git a/GameServer/Game/Scene/Entity/EntityMonster.cs b/GameServer/Game/Scene/Entity/EntityMonster.cs index b7c26caf..b40f2724 100644 --- a/GameServer/Game/Scene/Entity/EntityMonster.cs +++ b/GameServer/Game/Scene/Entity/EntityMonster.cs @@ -15,30 +15,29 @@ public class EntityMonster( SceneInstance scene, Position pos, Position rot, - int GroupID, - int InstID, + int groupId, + int instId, NPCMonsterDataExcel excel, - MonsterInfo info) : IGameEntity, IGameModifier + MonsterInfo info) : BaseGameEntity, IGameModifier { public Position Position { get; set; } = pos; public Position Rotation { get; set; } = rot; - public int InstID { get; set; } = InstID; + public int InstId { get; set; } = instId; public SceneInstance Scene { get; set; } = scene; public NPCMonsterDataExcel MonsterData { get; set; } = excel; public MonsterInfo Info { get; set; } = info; public SceneBuff? TempBuff { get; set; } public bool IsAlive { get; private set; } = true; - public int EventID { get; set; } = info.EventID; - public int CustomStageID { get; set; } = 0; + public int EventId { get; set; } = info.EventID; + public int CustomStageId { get; set; } = 0; public int RogueMonsterId { get; set; } = 0; public int CustomLevel { get; set; } = 0; - public List BuffList { get; set; } = []; - public int EntityId { get; set; } = 0; - public int GroupID { get; set; } = GroupID; + public override int EntityId { get; set; } = 0; + public override int GroupId { get; set; } = groupId; - public async ValueTask AddBuff(SceneBuff buff) + public override async ValueTask AddBuff(SceneBuff buff) { if (!GameData.MazeBuffData.TryGetValue(buff.BuffId * 10 + buff.BuffLevel, out var buffExcel)) return; @@ -49,7 +48,7 @@ public class EntityMonster( await Scene.Player.SendPacket(new PacketSyncEntityBuffChangeListScNotify(this, buff)); } - public async ValueTask ApplyBuff(BattleInstance instance) + public override async ValueTask ApplyBuff(BattleInstance instance) { if (TempBuff != null) { @@ -70,13 +69,13 @@ public class EntityMonster( BuffList.Clear(); } - public SceneEntityInfo ToProto() + public override SceneEntityInfo ToProto() { var proto = new SceneEntityInfo { EntityId = (uint)EntityId, - GroupId = (uint)GroupID, - InstId = (uint)InstID, + GroupId = (uint)GroupId, + InstId = (uint)InstId, Motion = new MotionInfo { Pos = Position.ToProto(), @@ -84,7 +83,7 @@ public class EntityMonster( }, NpcMonster = new SceneNpcMonsterInfo { - EventId = (uint)EventID, + EventId = (uint)EventId, MonsterId = (uint)MonsterData.ID, WorldLevel = (uint)Scene.Player.Data.WorldLevel } @@ -148,7 +147,7 @@ public class EntityMonster( public int GetStageId() { - if (CustomStageID > 0) return CustomStageID; + if (CustomStageId > 0) return CustomStageId; return Info.EventID; } diff --git a/GameServer/Game/Scene/Entity/EntityNpc.cs b/GameServer/Game/Scene/Entity/EntityNpc.cs index 4dce6462..724984db 100644 --- a/GameServer/Game/Scene/Entity/EntityNpc.cs +++ b/GameServer/Game/Scene/Entity/EntityNpc.cs @@ -1,32 +1,20 @@ using EggLink.DanhengServer.Data.Config.Scene; -using EggLink.DanhengServer.GameServer.Game.Battle; using EggLink.DanhengServer.Proto; using EggLink.DanhengServer.Util; namespace EggLink.DanhengServer.GameServer.Game.Scene.Entity; -public class EntityNpc(SceneInstance scene, GroupInfo group, NpcInfo npcInfo) : IGameEntity +public class EntityNpc(SceneInstance scene, GroupInfo group, NpcInfo npcInfo) : BaseGameEntity { public SceneInstance Scene { get; set; } = scene; public Position Position { get; set; } = npcInfo.ToPositionProto(); public Position Rotation { get; set; } = npcInfo.ToRotationProto(); public int NpcId { get; set; } = npcInfo.NPCID; public int InstId { get; set; } = npcInfo.ID; - public int EntityId { get; set; } - public int GroupID { get; set; } = group.Id; - public List BuffList { get; set; } = []; + public override int EntityId { get; set; } + public override int GroupId { get; set; } = group.Id; - public async ValueTask AddBuff(SceneBuff buff) - { - await System.Threading.Tasks.Task.CompletedTask; - } - - public async ValueTask ApplyBuff(BattleInstance instance) - { - await System.Threading.Tasks.Task.CompletedTask; - } - - public virtual SceneEntityInfo ToProto() + public override SceneEntityInfo ToProto() { SceneNpcInfo npc = new() { @@ -36,7 +24,7 @@ public class EntityNpc(SceneInstance scene, GroupInfo group, NpcInfo npcInfo) : return new SceneEntityInfo { EntityId = (uint)EntityId, - GroupId = (uint)GroupID, + GroupId = (uint)GroupId, Motion = new MotionInfo { Pos = Position.ToProto(), diff --git a/GameServer/Game/Scene/Entity/EntityProp.cs b/GameServer/Game/Scene/Entity/EntityProp.cs index 865c351c..37a066f9 100644 --- a/GameServer/Game/Scene/Entity/EntityProp.cs +++ b/GameServer/Game/Scene/Entity/EntityProp.cs @@ -2,14 +2,13 @@ using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Database.Scene; using EggLink.DanhengServer.Enums.Scene; -using EggLink.DanhengServer.GameServer.Game.Battle; using EggLink.DanhengServer.GameServer.Server.Packet.Send.Scene; using EggLink.DanhengServer.Proto; using EggLink.DanhengServer.Util; namespace EggLink.DanhengServer.GameServer.Game.Scene.Entity; -public class EntityProp(SceneInstance scene, MazePropExcel excel, GroupInfo group, PropInfo prop) : IGameEntity +public class EntityProp(SceneInstance scene, MazePropExcel excel, GroupInfo group, PropInfo prop) : BaseGameEntity { public Position Position { get; set; } = prop.ToPositionProto(); public Position Rotation { get; set; } = prop.ToRotationProto(); @@ -20,21 +19,10 @@ public class EntityProp(SceneInstance scene, MazePropExcel excel, GroupInfo grou public PropInfo PropInfo { get; set; } = prop; public GroupInfo Group { get; set; } = group; public ScenePropTimelineData? PropTimelineData { get; set; } - public int EntityId { get; set; } - public List BuffList { get; set; } = []; - public int GroupID { get; set; } = group.Id; + public override int EntityId { get; set; } + public override int GroupId { get; set; } = group.Id; - public async ValueTask AddBuff(SceneBuff buff) - { - await System.Threading.Tasks.Task.CompletedTask; - } - - public async ValueTask ApplyBuff(BattleInstance instance) - { - await System.Threading.Tasks.Task.CompletedTask; - } - - public virtual SceneEntityInfo ToProto() + public override SceneEntityInfo ToProto() { var prop = new ScenePropInfo { @@ -51,7 +39,7 @@ public class EntityProp(SceneInstance scene, MazePropExcel excel, GroupInfo grou return new SceneEntityInfo { EntityId = (uint)EntityId, - GroupId = (uint)GroupID, + GroupId = (uint)GroupId, Motion = new MotionInfo { Pos = Position.ToProto(), diff --git a/GameServer/Game/Scene/Entity/EntitySummonUnit.cs b/GameServer/Game/Scene/Entity/EntitySummonUnit.cs index 752a8c7d..aee1107a 100644 --- a/GameServer/Game/Scene/Entity/EntitySummonUnit.cs +++ b/GameServer/Game/Scene/Entity/EntitySummonUnit.cs @@ -1,11 +1,10 @@ using EggLink.DanhengServer.Data.Config.SummonUnit; -using EggLink.DanhengServer.GameServer.Game.Battle; using EggLink.DanhengServer.Proto; using EggLink.DanhengServer.Util; namespace EggLink.DanhengServer.GameServer.Game.Scene.Entity; -public class EntitySummonUnit : IGameEntity +public class EntitySummonUnit : BaseGameEntity { public int CreateAvatarEntityId { get; set; } = 0; public int AttachEntityId { get; set; } = 0; @@ -17,26 +16,15 @@ public class EntitySummonUnit : IGameEntity public List TriggerList { get; set; } = []; public HashSet CaughtEntityIds { get; set; } = []; - public int EntityId { get; set; } - public int GroupID { get; set; } = 0; - public List BuffList { get; set; } = []; + public override int EntityId { get; set; } + public override int GroupId { get; set; } = 0; - public async ValueTask AddBuff(SceneBuff buff) - { - await ValueTask.CompletedTask; - } - - public async ValueTask ApplyBuff(BattleInstance instance) - { - await ValueTask.CompletedTask; - } - - public SceneEntityInfo ToProto() + public override SceneEntityInfo ToProto() { return new SceneEntityInfo { EntityId = (uint)EntityId, - GroupId = (uint)GroupID, + GroupId = (uint)GroupId, Motion = Motion, SummonUnit = new SceneSummonUnitInfo { diff --git a/GameServer/Game/Scene/Entity/IGameEntity.cs b/GameServer/Game/Scene/Entity/IGameEntity.cs deleted file mode 100644 index 0fd13f2e..00000000 --- a/GameServer/Game/Scene/Entity/IGameEntity.cs +++ /dev/null @@ -1,17 +0,0 @@ -using EggLink.DanhengServer.GameServer.Game.Battle; -using EggLink.DanhengServer.Proto; - -namespace EggLink.DanhengServer.GameServer.Game.Scene.Entity; - -public interface IGameEntity -{ - public int EntityId { get; set; } - public int GroupID { get; set; } - - public List BuffList { get; set; } - public ValueTask AddBuff(SceneBuff buff); - public ValueTask ApplyBuff(BattleInstance instance); - - - public SceneEntityInfo ToProto(); -} \ No newline at end of file diff --git a/GameServer/Game/Scene/SceneEntityLoader.cs b/GameServer/Game/Scene/SceneEntityLoader.cs index f984d0db..27c0d399 100644 --- a/GameServer/Game/Scene/SceneEntityLoader.cs +++ b/GameServer/Game/Scene/SceneEntityLoader.cs @@ -35,11 +35,11 @@ public class SceneEntityLoader(SceneInstance scene) { var refreshed = false; var oldGroupId = new List(); - foreach (var entity in Scene.Entities.Values.Where(entity => !oldGroupId.Contains(entity.GroupID))) - oldGroupId.Add(entity.GroupID); + foreach (var entity in Scene.Entities.Values.Where(entity => !oldGroupId.Contains(entity.GroupId))) + oldGroupId.Add(entity.GroupId); - var removeList = new List(); - var addList = new List(); + var removeList = new List(); + var addList = new List(); foreach (var group in Scene.FloorInfo!.Groups.Values .Where(group => group.LoadSide != GroupLoadSideEnum.Client) @@ -54,7 +54,7 @@ public class SceneEntityLoader(SceneInstance scene) group.UnloadCondition.IsTrue(Scene.Player.MissionManager!.Data, false)) // condition: Unload Condition anyone of the conditions is true then unload { - foreach (var entity in Scene.Entities.Values.Where(entity => entity.GroupID == group.Id)) + foreach (var entity in Scene.Entities.Values.Where(entity => entity.GroupId == group.Id)) { await Scene.RemoveEntity(entity, false); removeList.Add(entity); @@ -67,7 +67,7 @@ public class SceneEntityLoader(SceneInstance scene) Scene.Player.MissionManager!.GetMainMissionStatus(group.OwnerMainMissionID) != MissionPhaseEnum.Accept) // condition: Owner Main Mission ID { - foreach (var entity in Scene.Entities.Values.Where(entity => entity.GroupID == group.Id)) + foreach (var entity in Scene.Entities.Values.Where(entity => entity.GroupId == group.Id)) { await Scene.RemoveEntity(entity, false); removeList.Add(entity); @@ -88,7 +88,7 @@ public class SceneEntityLoader(SceneInstance scene) await Scene.Player.SendPacket(new PacketSceneGroupRefreshScNotify(Scene.Player, addList, removeList)); } - public virtual async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) + public virtual async ValueTask?> LoadGroup(GroupInfo info, bool forceLoad = false) { if (!LoadGroups.Contains(info.Id)) return null; // check if group should be loaded in this dimension var missionData = Scene.Player.MissionManager!.Data; // get mission data @@ -146,14 +146,14 @@ public class SceneEntityLoader(SceneInstance scene) // !forceLoad) // condition: Saved Value Condition // return null; - if (Scene.Entities.Values.ToList().FindIndex(x => x.GroupID == info.Id) != + if (Scene.Entities.Values.ToList().FindIndex(x => x.GroupId == info.Id) != -1) // check if group is already loaded return null; // load Scene.Groups.Add(info.Id); // add group to loaded groups - var entityList = new List(); + var entityList = new List(); foreach (var npc in info.NPCList) try { @@ -187,7 +187,7 @@ public class SceneEntityLoader(SceneInstance scene) return entityList; } - public virtual async ValueTask?> LoadGroup(int groupId, bool sendPacket = true) + public virtual async ValueTask?> LoadGroup(int groupId, bool sendPacket = true) { var group = Scene.FloorInfo?.Groups.TryGetValue(groupId, out var v1) == true ? v1 : null; if (group == null) return null; @@ -204,11 +204,11 @@ public class SceneEntityLoader(SceneInstance scene) var group = Scene.FloorInfo?.Groups.TryGetValue(groupId, out var v1) == true ? v1 : null; if (group == null) return; - var removeList = new List(); + var removeList = new List(); var refreshed = false; foreach (var entity in Scene.Entities.Values) - if (entity.GroupID == group.Id) + if (entity.GroupId == group.Id) { await Scene.RemoveEntity(entity, false); removeList.Add(entity); diff --git a/GameServer/Game/Scene/SceneInstance.cs b/GameServer/Game/Scene/SceneInstance.cs index 16446d6e..50edae2f 100644 --- a/GameServer/Game/Scene/SceneInstance.cs +++ b/GameServer/Game/Scene/SceneInstance.cs @@ -82,13 +82,13 @@ public class SceneInstance // add entities to groups foreach (var entity in Entities) { - if (entity.Value.GroupID == 0) continue; - if (groups.FindIndex(x => x.GroupId == entity.Value.GroupID) == -1) + if (entity.Value.GroupId == 0) continue; + if (groups.FindIndex(x => x.GroupId == entity.Value.GroupId) == -1) groups.Add(new SceneEntityGroupInfo { - GroupId = (uint)entity.Value.GroupID + GroupId = (uint)entity.Value.GroupId }); - groups[groups.FindIndex(x => x.GroupId == entity.Value.GroupID)].EntityList.Add(entity.Value.ToProto()); + groups[groups.FindIndex(x => x.GroupId == entity.Value.GroupId)].EntityList.Add(entity.Value.ToProto()); } foreach (var groupId in Groups) // Add for empty group @@ -161,7 +161,7 @@ public class SceneInstance public Dictionary AvatarInfo = []; public int LeaderEntityId; - public Dictionary Entities = []; + public Dictionary Entities = []; public List Groups = []; public List HealingSprings = []; @@ -236,8 +236,8 @@ public class SceneInstance var oldAvatarInfo = AvatarInfo.Values.ToList(); AvatarInfo.Clear(); var sendPacket = false; - var addAvatar = new List(); - var removeAvatar = new List(); + var addAvatar = new List(); + var removeAvatar = new List(); var avatars = Player.LineupManager?.GetAvatarsFromCurTeam() ?? []; foreach (var sceneInfo in oldAvatarInfo) if (avatars.FindIndex(x => x.AvatarInfo.BaseAvatarId == sceneInfo.AvatarInfo.BaseAvatarId) != @@ -346,12 +346,12 @@ public class SceneInstance #region Entity Management - public async ValueTask AddEntity(IGameEntity entity) + public async ValueTask AddEntity(BaseGameEntity entity) { await AddEntity(entity, IsLoaded); } - public async ValueTask AddEntity(IGameEntity entity, bool sendPacket) + public async ValueTask AddEntity(BaseGameEntity entity, bool sendPacket) { if (entity.EntityId != 0) return; entity.EntityId = ++LastEntityId; @@ -368,7 +368,7 @@ public class SceneInstance if (!GameData.SummonUnitDataData.TryGetValue(entity.SummonUnitId, out var summonUnitExcel)) return Retcode.RetMonsterConfigNotExist; - IGameEntity? removeEntity = null; + BaseGameEntity? removeEntity = null; // get old summon unit var summonUnitKey = summonUnitExcel.UniqueGroup == SummonUnitUniqueGroupEnum.None ? summonUnitExcel.ID : 1; if (SummonUnit.TryGetValue(summonUnitKey, out var oldSummonUnit)) @@ -392,12 +392,12 @@ public class SceneInstance return Retcode.RetSucc; } - public async ValueTask RemoveEntity(IGameEntity monster) + public async ValueTask RemoveEntity(BaseGameEntity monster) { await RemoveEntity(monster, IsLoaded); } - public async ValueTask RemoveEntity(IGameEntity monster, bool sendPacket) + public async ValueTask RemoveEntity(BaseGameEntity monster, bool sendPacket) { Entities.Remove(monster.EntityId); @@ -408,7 +408,7 @@ public class SceneInstance { List entities = []; foreach (var entity in Entities) - if (entity.Value.GroupID == groupId && entity.Value is T t) + if (entity.Value.GroupId == groupId && entity.Value is T t) entities.Add(t); return entities; } @@ -430,8 +430,8 @@ public class SceneInstance new PacketRefreshTriggerByClientScNotify(triggerName, (uint)summonUnit.EntityId, targetIds)); // check target - List targetEnter = []; - List targetExit = []; + List targetEnter = []; + List targetExit = []; foreach (var targetId in targetIds) { if (!Entities.TryGetValue((int)targetId, out var entity)) continue; @@ -518,7 +518,7 @@ public class SceneInstance public async ValueTask OnEnterStage() { - List removeEntities = []; + List removeEntities = []; foreach (var unit in SummonUnit.ToArray()) { if (!GameData.SummonUnitDataData.TryGetValue(unit.Value.SummonUnitId, out var excel)) continue; @@ -563,7 +563,7 @@ public class SceneInstance #endregion } -public class AvatarSceneInfo : IGameEntity, IGameModifier +public class AvatarSceneInfo : BaseGameEntity, IGameModifier { public BaseAvatarInfo AvatarInfo; public AvatarType AvatarType; @@ -593,13 +593,11 @@ public class AvatarSceneInfo : IGameEntity, IGameModifier } } - public List BuffList { get; set; } = []; + public override int EntityId { get; set; } - public int EntityId { get; set; } + public override int GroupId { get; set; } = 0; - public int GroupID { get; set; } = 0; - - public async ValueTask AddBuff(SceneBuff buff) + public override async ValueTask AddBuff(SceneBuff buff) { if (!GameData.MazeBuffData.TryGetValue(buff.BuffId * 10 + buff.BuffLevel, out var buffExcel)) return; @@ -626,7 +624,7 @@ public class AvatarSceneInfo : IGameEntity, IGameModifier await AddModifier(buffExcel.ModifierName); } - public async ValueTask ApplyBuff(BattleInstance instance) + public override async ValueTask ApplyBuff(BattleInstance instance) { if (BuffList.Count == 0) return; foreach (var buff in BuffList.Where(buff => !buff.IsExpired())) instance.Buffs.Add(new MazeBuff(buff)); @@ -644,7 +642,7 @@ public class AvatarSceneInfo : IGameEntity, IGameModifier BuffList.Clear(); } - public SceneEntityInfo ToProto() + public override SceneEntityInfo ToProto() { return new SceneEntityInfo { @@ -662,7 +660,6 @@ public class AvatarSceneInfo : IGameEntity, IGameModifier }; } - public List Modifiers { get; set; } = []; public async ValueTask AddModifier(string modifierName) @@ -731,7 +728,7 @@ public class AvatarSceneInfo : IGameEntity, IGameModifier { foreach (var modifier in Modifiers.ToArray()) await RemoveModifier(modifier); - foreach (var monsterInfo in Player.SceneInstance!.Entities.OfType().ToArray()) + foreach (var monsterInfo in Player.SceneInstance!.Entities.Values.OfType().ToArray()) foreach (var buff in monsterInfo.BuffList.Where(x => x.OwnerAvatarId == AvatarInfo.BaseAvatarId).ToArray()) await monsterInfo.RemoveBuff(buff.BuffId); } diff --git a/GameServer/Game/Task/AvatarTask/AbilityLevelTask.cs b/GameServer/Game/Task/AvatarTask/AbilityLevelTask.cs index 75477ae8..cc623501 100644 --- a/GameServer/Game/Task/AvatarTask/AbilityLevelTask.cs +++ b/GameServer/Game/Task/AvatarTask/AbilityLevelTask.cs @@ -22,8 +22,8 @@ public class AbilityLevelTask(PlayerInstance player) #region Selector - public List TargetAlias(TargetEvaluator selector, IGameEntity casterEntity, - List targetEntities) + public List TargetAlias(TargetEvaluator selector, BaseGameEntity casterEntity, + List targetEntities) { if (selector is TargetAlias target) return target.Alias switch @@ -41,7 +41,7 @@ public class AbilityLevelTask(PlayerInstance player) #region Manage public async ValueTask TriggerTasks(AdventureAbilityConfigListInfo abilities, - List tasks, IGameEntity casterEntity, List targetEntities, SceneCastSkillCsReq req, + List tasks, BaseGameEntity casterEntity, List targetEntities, SceneCastSkillCsReq req, string? modifierName = null) { BattleInstance? instance = null; @@ -151,7 +151,7 @@ public class AbilityLevelTask(PlayerInstance player) { var resp = method.Invoke(this, [adventureTriggerAttack.AttackTargetType, param.CasterEntity, param.TargetEntities]); - if (resp is List target) + if (resp is List target) { foreach (var task in adventureTriggerAttack.OnAttack) { @@ -204,7 +204,7 @@ public class AbilityLevelTask(PlayerInstance player) foreach (var dynamicValue in addMazeBuff.DynamicValues) dynamic.Add(dynamicValue.Key, dynamicValue.Value.GetValue()); - if (resp is not List target) return new AbilityLevelResult(instance, battleInfos); + if (resp is not List target) return new AbilityLevelResult(instance, battleInfos); foreach (var entity in target) await entity.AddBuff(new SceneBuff(addMazeBuff.ID, 1, @@ -363,6 +363,8 @@ public class AbilityLevelTask(PlayerInstance player) public async ValueTask AdvModifyMaxMazeMP(AbilityLevelParam param) { + await ValueTask.CompletedTask; + if (param.Act is AdvModifyMaxMazeMP advModifyMaxMazeMp) switch (advModifyMaxMazeMp.ModifyFunction) { @@ -445,7 +447,7 @@ public class AbilityLevelTask(PlayerInstance player) var resp = method.Invoke(this, [byIsContain.TargetType, param.CasterEntity, param.TargetEntities]); - if (resp is List target) + if (resp is List target) foreach (var entity in target) { if (entity is not IGameModifier modifier) continue; @@ -515,7 +517,7 @@ public record AbilityLevelResult(BattleInstance? Instance = null, List TargetEntities, + BaseGameEntity CasterEntity, + List TargetEntities, SceneCastSkillCsReq Request, string? ModifierName); \ No newline at end of file diff --git a/GameServer/Game/Task/AvatarTask/SummonUnitLevelTask.cs b/GameServer/Game/Task/AvatarTask/SummonUnitLevelTask.cs index 92741821..3d990250 100644 --- a/GameServer/Game/Task/AvatarTask/SummonUnitLevelTask.cs +++ b/GameServer/Game/Task/AvatarTask/SummonUnitLevelTask.cs @@ -10,7 +10,7 @@ public class SummonUnitLevelTask { #region Task Condition - public bool ByIsContainAdventureModifier(TaskConfigInfo act, List targetEntities, + public bool ByIsContainAdventureModifier(TaskConfigInfo act, List targetEntities, EntitySummonUnit? summonUnit) { return true; @@ -20,12 +20,12 @@ public class SummonUnitLevelTask #region Manage - public void TriggerTasks(List tasks, List targetEntities, EntitySummonUnit? summonUnit) + public void TriggerTasks(List tasks, List targetEntities, EntitySummonUnit? summonUnit) { foreach (var task in tasks) TriggerTask(task, targetEntities, summonUnit); } - public void TriggerTask(TaskConfigInfo act, List targetEntities, EntitySummonUnit? summonUnit) + public void TriggerTask(TaskConfigInfo act, List targetEntities, EntitySummonUnit? summonUnit) { try { @@ -43,7 +43,7 @@ public class SummonUnitLevelTask #region Task - public async ValueTask PredicateTaskList(TaskConfigInfo act, List targetEntities, + public async ValueTask PredicateTaskList(TaskConfigInfo act, List targetEntities, EntitySummonUnit? summonUnit) { if (act is PredicateTaskList predicateTaskList) @@ -67,7 +67,7 @@ public class SummonUnitLevelTask await ValueTask.CompletedTask; } - public async ValueTask AddMazeBuff(TaskConfigInfo act, List targetEntities, + public async ValueTask AddMazeBuff(TaskConfigInfo act, List targetEntities, EntitySummonUnit? summonUnit) { if (act is not AddMazeBuff addMazeBuff) return; @@ -88,7 +88,7 @@ public class SummonUnitLevelTask } } - public async ValueTask RemoveMazeBuff(TaskConfigInfo act, List targetEntities, + public async ValueTask RemoveMazeBuff(TaskConfigInfo act, List targetEntities, EntitySummonUnit? summonUnit) { if (act is not RemoveMazeBuff removeMazeBuff) return; @@ -101,7 +101,7 @@ public class SummonUnitLevelTask } } - public async ValueTask RefreshMazeBuffTime(TaskConfigInfo act, List targetEntities, + public async ValueTask RefreshMazeBuffTime(TaskConfigInfo act, List targetEntities, EntitySummonUnit? summonUnit) { if (act is not RefreshMazeBuffTime refreshMazeBuffTime) return; @@ -120,7 +120,7 @@ public class SummonUnitLevelTask } } - public async ValueTask TriggerHitProp(TaskConfigInfo act, List targetEntities, + public async ValueTask TriggerHitProp(TaskConfigInfo act, List targetEntities, EntitySummonUnit? summonUnit) { foreach (var targetEntity in targetEntities) diff --git a/GameServer/Game/Task/LevelTask.cs b/GameServer/Game/Task/LevelTask.cs index c4080947..4bd86d8a 100644 --- a/GameServer/Game/Task/LevelTask.cs +++ b/GameServer/Game/Task/LevelTask.cs @@ -23,7 +23,7 @@ public class LevelTask(PlayerInstance player) { if (fetch.FetchType != TargetFetchAdvPropFetchTypeEnum.SinglePropByPropID) return null; foreach (var entity in Player.SceneInstance?.Entities.Values.ToList() ?? []) - if (entity is EntityProp prop && prop.GroupID == fetch.SinglePropID.GroupID.GetValue() && + if (entity is EntityProp prop && prop.GroupId == fetch.SinglePropID.GroupID.GetValue() && prop.InstId == fetch.SinglePropID.ID.GetValue()) return prop; } @@ -72,7 +72,7 @@ public class LevelTask(PlayerInstance player) { if (act is DestroyProp destroyProp) foreach (var entity in Player.SceneInstance!.Entities.Values) - if (entity is EntityProp prop && prop.GroupID == destroyProp.GroupID.GetValue() && + if (entity is EntityProp prop && prop.GroupId == destroyProp.GroupID.GetValue() && prop.InstId == destroyProp.ID.GetValue()) await Player.SceneInstance.RemoveEntity(entity); } @@ -86,7 +86,7 @@ public class LevelTask(PlayerInstance player) out var list)) foreach (var id in list) foreach (var entity in Player.SceneInstance?.Entities.Values.ToList() ?? []) - if (entity is EntityProp prop && prop.GroupID == groupInfo.Key && prop.InstId == id) + if (entity is EntityProp prop && prop.GroupId == groupInfo.Key && prop.InstId == id) await prop.SetState(PropStateEnum.Closed); await Player.MissionManager!.HandleFinishType(MissionFinishTypeEnum.PropState); @@ -147,7 +147,7 @@ public class LevelTask(PlayerInstance player) { if (subMission.SubMissionInfo?.FinishType == MissionFinishTypeEnum.PropState) foreach (var entity in Player.SceneInstance!.Entities.Values) - if (entity is EntityProp prop && prop.GroupID == subMission.SubMissionInfo.ParamInt1 && + if (entity is EntityProp prop && prop.GroupId == subMission.SubMissionInfo.ParamInt1 && prop.InstId == subMission.SubMissionInfo.ParamInt2) try { @@ -163,7 +163,7 @@ public class LevelTask(PlayerInstance player) // Elevator foreach (var id in prop.PropInfo.UnlockControllerID) foreach (var entity2 in Player.SceneInstance!.Entities.Values) - if (entity2 is EntityProp prop2 && prop2.GroupID == id.Key && + if (entity2 is EntityProp prop2 && prop2.GroupId == id.Key && id.Value.Contains(prop2.InstId)) await prop2.SetState(PropStateEnum.Closed); } @@ -268,7 +268,7 @@ public class LevelTask(PlayerInstance player) { if (group != null) foreach (var entity in Player.SceneInstance?.Entities.Values.ToList() ?? []) - if (entity is EntityProp prop && prop.GroupID == group.Id) + if (entity is EntityProp prop && prop.GroupId == group.Id) if (prop.Excel.PropStateList.Contains(PropStateEnum.Open)) await prop.SetState(PropStateEnum.Open); } @@ -278,7 +278,7 @@ public class LevelTask(PlayerInstance player) { if (group != null) foreach (var entity in Player.SceneInstance?.Entities.Values.ToList() ?? []) - if (entity is EntityProp prop && prop.GroupID == group.Id) + if (entity is EntityProp prop && prop.GroupId == group.Id) if (prop.Excel.PropStateList.Contains(PropStateEnum.Open) && (prop.State == PropStateEnum.Closed || prop.State == PropStateEnum.Locked)) await prop.SetState(PropStateEnum.Open); @@ -289,7 +289,7 @@ public class LevelTask(PlayerInstance player) if (act is TriggerEntityEvent triggerEntityEvent) if (group != null) foreach (var entity in Player.SceneInstance?.Entities.Values.ToList() ?? []) - if (entity is EntityProp prop && prop.GroupID == group.Id && + if (entity is EntityProp prop && prop.GroupId == group.Id && prop.InstId == triggerEntityEvent.InstanceID.GetValue()) if (prop.Excel.PropStateList.Contains(PropStateEnum.Closed)) await prop.SetState(PropStateEnum.Closed); diff --git a/GameServer/Server/Packet/Recv/RogueCommon/HandlerRogueWorkbenchGetInfoCsReq.cs b/GameServer/Server/Packet/Recv/RogueCommon/HandlerRogueWorkbenchGetInfoCsReq.cs index d841357c..d2890070 100644 --- a/GameServer/Server/Packet/Recv/RogueCommon/HandlerRogueWorkbenchGetInfoCsReq.cs +++ b/GameServer/Server/Packet/Recv/RogueCommon/HandlerRogueWorkbenchGetInfoCsReq.cs @@ -14,7 +14,7 @@ public class HandlerRogueWorkbenchGetInfoCsReq : Handler var req = RogueWorkbenchGetInfoCsReq.Parser.ParseFrom(data); var player = connection.Player!; - IGameEntity? entity = null; + BaseGameEntity? entity = null; player.SceneInstance?.Entities.TryGetValue((int)req.PropEntityId, out entity); if (entity is not RogueWorkbenchProp prop) { diff --git a/GameServer/Server/Packet/Recv/RogueCommon/HandlerRogueWorkbenchHandleFuncCsReq.cs b/GameServer/Server/Packet/Recv/RogueCommon/HandlerRogueWorkbenchHandleFuncCsReq.cs index f853f3c5..dab26fb7 100644 --- a/GameServer/Server/Packet/Recv/RogueCommon/HandlerRogueWorkbenchHandleFuncCsReq.cs +++ b/GameServer/Server/Packet/Recv/RogueCommon/HandlerRogueWorkbenchHandleFuncCsReq.cs @@ -14,7 +14,7 @@ public class HandlerRogueWorkbenchHandleFuncCsReq : Handler var req = RogueWorkbenchHandleFuncCsReq.Parser.ParseFrom(data); var player = connection.Player!; - IGameEntity? entity = null; + BaseGameEntity? entity = null; player.SceneInstance?.Entities.TryGetValue((int)req.PropEntityId, out entity); if (entity is not RogueWorkbenchProp prop) { diff --git a/GameServer/Server/Packet/Send/Scene/PacketSceneGroupRefreshScNotify.cs b/GameServer/Server/Packet/Send/Scene/PacketSceneGroupRefreshScNotify.cs index 2b07768a..7ed66755 100644 --- a/GameServer/Server/Packet/Send/Scene/PacketSceneGroupRefreshScNotify.cs +++ b/GameServer/Server/Packet/Send/Scene/PacketSceneGroupRefreshScNotify.cs @@ -8,8 +8,8 @@ namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.Scene; public class PacketSceneGroupRefreshScNotify : BasePacket { - public PacketSceneGroupRefreshScNotify(PlayerInstance player, List? addEntity = null, - List? removeEntity = null) + public PacketSceneGroupRefreshScNotify(PlayerInstance player, List? addEntity = null, + List? removeEntity = null) : base(CmdIds.SceneGroupRefreshScNotify) { var proto = new SceneGroupRefreshScNotify @@ -23,7 +23,7 @@ public class PacketSceneGroupRefreshScNotify : BasePacket { var group = new GroupRefreshInfo { - GroupId = (uint)e.GroupID, + GroupId = (uint)e.GroupId, RefreshType = SceneGroupRefreshType.Loaded }; group.RefreshEntity.Add(new SceneEntityRefreshInfo @@ -31,17 +31,17 @@ public class PacketSceneGroupRefreshScNotify : BasePacket DeleteEntity = (uint)e.EntityId }); - if (refreshInfo.TryGetValue(e.GroupID, out var value)) + if (refreshInfo.TryGetValue(e.GroupId, out var value)) value.RefreshEntity.AddRange(group.RefreshEntity); else - refreshInfo[e.GroupID] = group; + refreshInfo[e.GroupId] = group; } foreach (var e in addEntity ?? []) { var group = new GroupRefreshInfo { - GroupId = (uint)e.GroupID, + GroupId = (uint)e.GroupId, RefreshType = SceneGroupRefreshType.Loaded }; group.RefreshEntity.Add(new SceneEntityRefreshInfo @@ -49,10 +49,10 @@ public class PacketSceneGroupRefreshScNotify : BasePacket AddEntity = e.ToProto() }); - if (refreshInfo.TryGetValue(e.GroupID, out var value)) + if (refreshInfo.TryGetValue(e.GroupId, out var value)) value.RefreshEntity.AddRange(group.RefreshEntity); else - refreshInfo[e.GroupID] = group; + refreshInfo[e.GroupId] = group; } proto.GroupRefreshList.AddRange(refreshInfo.Values); @@ -60,8 +60,8 @@ public class PacketSceneGroupRefreshScNotify : BasePacket SetData(proto); } - public PacketSceneGroupRefreshScNotify(PlayerInstance player, IGameEntity? addEntity = null, - IGameEntity? removeEntity = null) : + public PacketSceneGroupRefreshScNotify(PlayerInstance player, BaseGameEntity? addEntity = null, + BaseGameEntity? removeEntity = null) : this(player, addEntity == null ? [] : [addEntity], removeEntity == null ? [] : [removeEntity]) { } diff --git a/GameServer/Server/Packet/Send/Scene/PacketSyncEntityBuffChangeListScNotify.cs b/GameServer/Server/Packet/Send/Scene/PacketSyncEntityBuffChangeListScNotify.cs index ef3d3ce2..c414c40c 100644 --- a/GameServer/Server/Packet/Send/Scene/PacketSyncEntityBuffChangeListScNotify.cs +++ b/GameServer/Server/Packet/Send/Scene/PacketSyncEntityBuffChangeListScNotify.cs @@ -7,7 +7,7 @@ namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.Scene; public class PacketSyncEntityBuffChangeListScNotify : BasePacket { - public PacketSyncEntityBuffChangeListScNotify(IGameEntity entity, SceneBuff buff) : base( + public PacketSyncEntityBuffChangeListScNotify(BaseGameEntity entity, SceneBuff buff) : base( CmdIds.SyncEntityBuffChangeListScNotify) { var proto = new SyncEntityBuffChangeListScNotify(); @@ -21,7 +21,7 @@ public class PacketSyncEntityBuffChangeListScNotify : BasePacket SetData(proto); } - public PacketSyncEntityBuffChangeListScNotify(IGameEntity entity, List buffs) : base( + public PacketSyncEntityBuffChangeListScNotify(BaseGameEntity entity, List buffs) : base( CmdIds.SyncEntityBuffChangeListScNotify) { var proto = new SyncEntityBuffChangeListScNotify();