mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-02 20:26:03 +08:00
refactor: change entity interface to base class
This commit is contained in:
@@ -19,8 +19,8 @@ public class CommandScene : ICommand
|
||||
var scene = arg.Target!.Player!.SceneInstance!;
|
||||
var loadedGroup = new List<int>();
|
||||
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}");
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class BattleManager(PlayerInstance player) : BasePlayerManager(player)
|
||||
{
|
||||
public StageConfigExcel? NextBattleStageConfig { get; set; }
|
||||
|
||||
public async ValueTask<BattleInstance?> StartBattle(IGameEntity attackEntity, List<IGameEntity> targetEntityList,
|
||||
public async ValueTask<BattleInstance?> StartBattle(BaseGameEntity attackEntity, List<BaseGameEntity> targetEntityList,
|
||||
bool isSkill)
|
||||
{
|
||||
if (Player.BattleInstance != null) return Player.BattleInstance;
|
||||
|
||||
@@ -12,8 +12,8 @@ public class SceneSkillManager(PlayerInstance player) : BasePlayerManager(player
|
||||
public async ValueTask<SkillResultData> OnCast(SceneCastSkillCsReq req)
|
||||
{
|
||||
// get entities
|
||||
List<IGameEntity> targetEntities = []; // enemy
|
||||
IGameEntity? attackEntity; // caster
|
||||
List<BaseGameEntity> targetEntities = []; // enemy
|
||||
BaseGameEntity? attackEntity; // caster
|
||||
List<int> 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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<LobbyPlayerInstance> Players { get; set; } = [];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class StoryLineEntityLoader(SceneInstance scene) : SceneEntityLoader(scen
|
||||
Scene.IsLoaded = true;
|
||||
}
|
||||
|
||||
public override async ValueTask<List<IGameEntity>?> LoadGroup(GroupInfo info, bool forceLoad = false)
|
||||
public override async ValueTask<List<BaseGameEntity>?> LoadGroup(GroupInfo info, bool forceLoad = false)
|
||||
{
|
||||
if (!LoadGroups.Contains(info.Id)) return null;
|
||||
return await base.LoadGroup(info, forceLoad);
|
||||
|
||||
@@ -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<EntityProp>(prop.GroupID))
|
||||
foreach (var p in SceneInstance.GetEntitiesInGroup<EntityProp>(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<EntityProp>(prop.GroupID).Where(p =>
|
||||
foreach (var p in SceneInstance.GetEntitiesInGroup<EntityProp>(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<EntityProp>(prop.GroupID))
|
||||
foreach (var p in SceneInstance.GetEntitiesInGroup<EntityProp>(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<EntityProp>(prop.GroupID))
|
||||
foreach (var p in SceneInstance.GetEntitiesInGroup<EntityProp>(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<EntityProp>(prop.GroupID)
|
||||
var pieceDone = SceneInstance.GetEntitiesInGroup<EntityProp>(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<EntityProp>(prop.GroupID)
|
||||
foreach (var p in SceneInstance.GetEntitiesInGroup<EntityProp>(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<int, ScenePropTimelineData>();
|
||||
if (!floorData.ContainsKey(prop.GroupId))
|
||||
floorData[prop.GroupId] = new Dictionary<int, ScenePropTimelineData>();
|
||||
|
||||
floorData[prop.GroupID][prop.PropInfo.ID] = data;
|
||||
floorData[prop.GroupId][prop.PropInfo.ID] = data;
|
||||
|
||||
prop.PropTimelineData = data;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ public class RogueEntityLoader(SceneInstance scene, PlayerInstance player) : Sce
|
||||
Scene.IsLoaded = true;
|
||||
}
|
||||
|
||||
public override async ValueTask<List<IGameEntity>?> LoadGroup(GroupInfo info, bool forceLoad = false)
|
||||
public override async ValueTask<List<BaseGameEntity>?> LoadGroup(GroupInfo info, bool forceLoad = false)
|
||||
{
|
||||
var entityList = new List<IGameEntity>();
|
||||
var entityList = new List<BaseGameEntity>();
|
||||
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,
|
||||
|
||||
@@ -41,9 +41,9 @@ public class RogueMagicEntityLoader(SceneInstance scene, PlayerInstance player)
|
||||
Scene.IsLoaded = true;
|
||||
}
|
||||
|
||||
public override async ValueTask<List<IGameEntity>?> LoadGroup(GroupInfo info, bool forceLoad = false)
|
||||
public override async ValueTask<List<BaseGameEntity>?> LoadGroup(GroupInfo info, bool forceLoad = false)
|
||||
{
|
||||
var entityList = new List<IGameEntity>();
|
||||
var entityList = new List<BaseGameEntity>();
|
||||
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,
|
||||
|
||||
@@ -38,9 +38,9 @@ public class RogueTournEntityLoader(SceneInstance scene, PlayerInstance player)
|
||||
Scene.IsLoaded = true;
|
||||
}
|
||||
|
||||
public override async ValueTask<List<IGameEntity>?> LoadGroup(GroupInfo info, bool forceLoad = false)
|
||||
public override async ValueTask<List<BaseGameEntity>?> LoadGroup(GroupInfo info, bool forceLoad = false)
|
||||
{
|
||||
var entityList = new List<IGameEntity>();
|
||||
var entityList = new List<BaseGameEntity>();
|
||||
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,
|
||||
|
||||
25
GameServer/Game/Scene/Entity/BaseGameEntity.cs
Normal file
25
GameServer/Game/Scene/Entity/BaseGameEntity.cs
Normal file
@@ -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<SceneBuff> 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();
|
||||
}
|
||||
@@ -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<SceneBuff> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<SceneBuff> 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(),
|
||||
|
||||
@@ -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<SceneBuff> 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(),
|
||||
|
||||
@@ -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<UnitCustomTriggerConfigInfo> TriggerList { get; set; } = [];
|
||||
public HashSet<int> CaughtEntityIds { get; set; } = [];
|
||||
public int EntityId { get; set; }
|
||||
public int GroupID { get; set; } = 0;
|
||||
public List<SceneBuff> 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
|
||||
{
|
||||
|
||||
@@ -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<SceneBuff> BuffList { get; set; }
|
||||
public ValueTask AddBuff(SceneBuff buff);
|
||||
public ValueTask ApplyBuff(BattleInstance instance);
|
||||
|
||||
|
||||
public SceneEntityInfo ToProto();
|
||||
}
|
||||
@@ -35,11 +35,11 @@ public class SceneEntityLoader(SceneInstance scene)
|
||||
{
|
||||
var refreshed = false;
|
||||
var oldGroupId = new List<int>();
|
||||
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<IGameEntity>();
|
||||
var addList = new List<IGameEntity>();
|
||||
var removeList = new List<BaseGameEntity>();
|
||||
var addList = new List<BaseGameEntity>();
|
||||
|
||||
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<List<IGameEntity>?> LoadGroup(GroupInfo info, bool forceLoad = false)
|
||||
public virtual async ValueTask<List<BaseGameEntity>?> 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<IGameEntity>();
|
||||
var entityList = new List<BaseGameEntity>();
|
||||
foreach (var npc in info.NPCList)
|
||||
try
|
||||
{
|
||||
@@ -187,7 +187,7 @@ public class SceneEntityLoader(SceneInstance scene)
|
||||
return entityList;
|
||||
}
|
||||
|
||||
public virtual async ValueTask<List<IGameEntity>?> LoadGroup(int groupId, bool sendPacket = true)
|
||||
public virtual async ValueTask<List<BaseGameEntity>?> 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<IGameEntity>();
|
||||
var removeList = new List<BaseGameEntity>();
|
||||
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);
|
||||
|
||||
@@ -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<int, AvatarSceneInfo> AvatarInfo = [];
|
||||
public int LeaderEntityId;
|
||||
public Dictionary<int, IGameEntity> Entities = [];
|
||||
public Dictionary<int, BaseGameEntity> Entities = [];
|
||||
public List<int> Groups = [];
|
||||
public List<EntityProp> HealingSprings = [];
|
||||
|
||||
@@ -236,8 +236,8 @@ public class SceneInstance
|
||||
var oldAvatarInfo = AvatarInfo.Values.ToList();
|
||||
AvatarInfo.Clear();
|
||||
var sendPacket = false;
|
||||
var addAvatar = new List<IGameEntity>();
|
||||
var removeAvatar = new List<IGameEntity>();
|
||||
var addAvatar = new List<BaseGameEntity>();
|
||||
var removeAvatar = new List<BaseGameEntity>();
|
||||
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<T> 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<IGameEntity> targetEnter = [];
|
||||
List<IGameEntity> targetExit = [];
|
||||
List<BaseGameEntity> targetEnter = [];
|
||||
List<BaseGameEntity> 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<IGameEntity> removeEntities = [];
|
||||
List<BaseGameEntity> 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<SceneBuff> 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<string> 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<EntityMonster>().ToArray())
|
||||
foreach (var monsterInfo in Player.SceneInstance!.Entities.Values.OfType<EntityMonster>().ToArray())
|
||||
foreach (var buff in monsterInfo.BuffList.Where(x => x.OwnerAvatarId == AvatarInfo.BaseAvatarId).ToArray())
|
||||
await monsterInfo.RemoveBuff(buff.BuffId);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ public class AbilityLevelTask(PlayerInstance player)
|
||||
|
||||
#region Selector
|
||||
|
||||
public List<IGameEntity> TargetAlias(TargetEvaluator selector, IGameEntity casterEntity,
|
||||
List<IGameEntity> targetEntities)
|
||||
public List<BaseGameEntity> TargetAlias(TargetEvaluator selector, BaseGameEntity casterEntity,
|
||||
List<BaseGameEntity> targetEntities)
|
||||
{
|
||||
if (selector is TargetAlias target)
|
||||
return target.Alias switch
|
||||
@@ -41,7 +41,7 @@ public class AbilityLevelTask(PlayerInstance player)
|
||||
#region Manage
|
||||
|
||||
public async ValueTask<AbilityLevelResult> TriggerTasks(AdventureAbilityConfigListInfo abilities,
|
||||
List<TaskConfigInfo> tasks, IGameEntity casterEntity, List<IGameEntity> targetEntities, SceneCastSkillCsReq req,
|
||||
List<TaskConfigInfo> tasks, BaseGameEntity casterEntity, List<BaseGameEntity> 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<IGameEntity> target)
|
||||
if (resp is List<BaseGameEntity> 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<IGameEntity> target) return new AbilityLevelResult(instance, battleInfos);
|
||||
if (resp is not List<BaseGameEntity> 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<AbilityLevelResult> 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<IGameEntity> target)
|
||||
if (resp is List<BaseGameEntity> target)
|
||||
foreach (var entity in target)
|
||||
{
|
||||
if (entity is not IGameModifier modifier) continue;
|
||||
@@ -515,7 +517,7 @@ public record AbilityLevelResult(BattleInstance? Instance = null, List<HitMonste
|
||||
public record AbilityLevelParam(
|
||||
AdventureAbilityConfigListInfo AdventureAbility,
|
||||
TaskConfigInfo Act,
|
||||
IGameEntity CasterEntity,
|
||||
List<IGameEntity> TargetEntities,
|
||||
BaseGameEntity CasterEntity,
|
||||
List<BaseGameEntity> TargetEntities,
|
||||
SceneCastSkillCsReq Request,
|
||||
string? ModifierName);
|
||||
@@ -10,7 +10,7 @@ public class SummonUnitLevelTask
|
||||
{
|
||||
#region Task Condition
|
||||
|
||||
public bool ByIsContainAdventureModifier(TaskConfigInfo act, List<IGameEntity> targetEntities,
|
||||
public bool ByIsContainAdventureModifier(TaskConfigInfo act, List<BaseGameEntity> targetEntities,
|
||||
EntitySummonUnit? summonUnit)
|
||||
{
|
||||
return true;
|
||||
@@ -20,12 +20,12 @@ public class SummonUnitLevelTask
|
||||
|
||||
#region Manage
|
||||
|
||||
public void TriggerTasks(List<TaskConfigInfo> tasks, List<IGameEntity> targetEntities, EntitySummonUnit? summonUnit)
|
||||
public void TriggerTasks(List<TaskConfigInfo> tasks, List<BaseGameEntity> targetEntities, EntitySummonUnit? summonUnit)
|
||||
{
|
||||
foreach (var task in tasks) TriggerTask(task, targetEntities, summonUnit);
|
||||
}
|
||||
|
||||
public void TriggerTask(TaskConfigInfo act, List<IGameEntity> targetEntities, EntitySummonUnit? summonUnit)
|
||||
public void TriggerTask(TaskConfigInfo act, List<BaseGameEntity> targetEntities, EntitySummonUnit? summonUnit)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -43,7 +43,7 @@ public class SummonUnitLevelTask
|
||||
|
||||
#region Task
|
||||
|
||||
public async ValueTask PredicateTaskList(TaskConfigInfo act, List<IGameEntity> targetEntities,
|
||||
public async ValueTask PredicateTaskList(TaskConfigInfo act, List<BaseGameEntity> 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<IGameEntity> targetEntities,
|
||||
public async ValueTask AddMazeBuff(TaskConfigInfo act, List<BaseGameEntity> targetEntities,
|
||||
EntitySummonUnit? summonUnit)
|
||||
{
|
||||
if (act is not AddMazeBuff addMazeBuff) return;
|
||||
@@ -88,7 +88,7 @@ public class SummonUnitLevelTask
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask RemoveMazeBuff(TaskConfigInfo act, List<IGameEntity> targetEntities,
|
||||
public async ValueTask RemoveMazeBuff(TaskConfigInfo act, List<BaseGameEntity> targetEntities,
|
||||
EntitySummonUnit? summonUnit)
|
||||
{
|
||||
if (act is not RemoveMazeBuff removeMazeBuff) return;
|
||||
@@ -101,7 +101,7 @@ public class SummonUnitLevelTask
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask RefreshMazeBuffTime(TaskConfigInfo act, List<IGameEntity> targetEntities,
|
||||
public async ValueTask RefreshMazeBuffTime(TaskConfigInfo act, List<BaseGameEntity> targetEntities,
|
||||
EntitySummonUnit? summonUnit)
|
||||
{
|
||||
if (act is not RefreshMazeBuffTime refreshMazeBuffTime) return;
|
||||
@@ -120,7 +120,7 @@ public class SummonUnitLevelTask
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask TriggerHitProp(TaskConfigInfo act, List<IGameEntity> targetEntities,
|
||||
public async ValueTask TriggerHitProp(TaskConfigInfo act, List<BaseGameEntity> targetEntities,
|
||||
EntitySummonUnit? summonUnit)
|
||||
{
|
||||
foreach (var targetEntity in targetEntities)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.Scene;
|
||||
|
||||
public class PacketSceneGroupRefreshScNotify : BasePacket
|
||||
{
|
||||
public PacketSceneGroupRefreshScNotify(PlayerInstance player, List<IGameEntity>? addEntity = null,
|
||||
List<IGameEntity>? removeEntity = null)
|
||||
public PacketSceneGroupRefreshScNotify(PlayerInstance player, List<BaseGameEntity>? addEntity = null,
|
||||
List<BaseGameEntity>? 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])
|
||||
{
|
||||
}
|
||||
|
||||
@@ -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<SceneBuff> buffs) : base(
|
||||
public PacketSyncEntityBuffChangeListScNotify(BaseGameEntity entity, List<SceneBuff> buffs) : base(
|
||||
CmdIds.SyncEntityBuffChangeListScNotify)
|
||||
{
|
||||
var proto = new SyncEntityBuffChangeListScNotify();
|
||||
|
||||
Reference in New Issue
Block a user