feat: add pathfinding

This commit is contained in:
k0t9i
2023-10-29 20:55:36 +04:00
parent efffe8a7cb
commit 17a4f82f24
20 changed files with 577 additions and 48 deletions

View File

@@ -39,12 +39,12 @@ namespace Client.Application.ViewModels
worldHandler.RequestAttackOrFollow(Id);
}
private void OnMouseRightClick(object? obj)
private async Task OnMouseRightClick(object? obj)
{
worldHandler.RequestMoveToEntity(Id);
await pathMover.MoveUntilReachedAsync(creature.Transform.Position);
}
public CreatureListViewModel(WorldHandler worldHandler, CreatureInterface creature, Hero hero)
public CreatureListViewModel(WorldHandler worldHandler, AsyncPathMoverInterface pathMover, CreatureInterface creature, Hero hero)
{
creature.PropertyChanged += Creature_PropertyChanged;
creature.Transform.Position.PropertyChanged += Position_PropertyChanged;
@@ -52,11 +52,12 @@ namespace Client.Application.ViewModels
hero.PropertyChanged += Hero_PropertyChanged;
MouseLeftClickCommand = new RelayCommand(OnMouseLeftClick);
MouseLeftDoubleClickCommand = new RelayCommand(OnMouseLeftDoubleClick);
MouseRightClickCommand = new RelayCommand(OnMouseRightClick);
MouseRightClickCommand = new RelayCommand(async (o) => await OnMouseRightClick(o));
this.creature = creature;
this.hero = hero;
this.worldHandler = worldHandler;
this.pathMover = pathMover;
}
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
@@ -94,5 +95,6 @@ namespace Client.Application.ViewModels
private readonly CreatureInterface creature;
private readonly Hero hero;
private readonly WorldHandler worldHandler;
private readonly AsyncPathMoverInterface pathMover;
}
}