2024-01-04 13:48:39 +00:00
|
|
|
|
using NahidaImpact.Gameserver.Game.Entity.Listener;
|
|
|
|
|
using NahidaImpact.Protocol;
|
|
|
|
|
|
|
|
|
|
namespace NahidaImpact.Gameserver.Game.Entity;
|
|
|
|
|
internal class EntityManager(IEntityEventListener listener)
|
|
|
|
|
{
|
|
|
|
|
private readonly List<SceneEntity> _entities = [];
|
|
|
|
|
private readonly IEntityEventListener _listener = listener;
|
|
|
|
|
|
|
|
|
|
public async ValueTask SpawnEntityAsync(SceneEntity entity, VisionType visionType)
|
|
|
|
|
{
|
|
|
|
|
_entities.Add(entity);
|
|
|
|
|
await _listener.OnEntitySpawned(entity, visionType);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-04 22:58:31 +00:00
|
|
|
|
public async ValueTask ChangeAvatarFightPropAsync(uint entityId, uint key, float value)
|
|
|
|
|
{
|
|
|
|
|
if (GetEntityById(entityId) is AvatarEntity entity)
|
|
|
|
|
{
|
|
|
|
|
entity.SetFightProp(key, value);
|
|
|
|
|
await _listener.OnAvatarFightPropChanged(entity, key, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SceneEntity? GetEntityById(uint id) =>
|
|
|
|
|
_entities.Find(entity => entity.EntityId == id);
|
|
|
|
|
|
2024-01-04 13:48:39 +00:00
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
_entities.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|