feat: add hero target

This commit is contained in:
k0t9i
2023-01-31 17:35:18 +04:00
parent d2b20e0666
commit bd50473bfb
9 changed files with 261 additions and 60 deletions

View File

@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace Client.Domain.Service
{
public class NpcHandler : EntityHandler<NPC>
public class NpcHandler : EntityHandler<NPC>, EventHandlerInterface<TargetChangedEvent>
{
public override void OnCreate(NPC entity)
{
@ -23,6 +23,16 @@ namespace Client.Domain.Service
eventBus.Publish(new CreatureDeletedEvent(entity.Id));
}
public void Handle(TargetChangedEvent @event)
{
var target = GetEntity(@event.Hero.TargetId);
if (target == null)
{
return;
}
@event.Hero.Target = target;
}
public NpcHandler(EntityFactoryInterface<NPC> factory, EventBusInterface eventBus, NpcInfoHelperInterface npcInfoHelper) : base(factory)
{
this.eventBus = eventBus;