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

@@ -0,0 +1,18 @@
using Client.Domain.DTO;
using Client.Domain.ValueObjects;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Domain.Service
{
public interface AsyncPathMoverInterface
{
public ObservableCollection<PathSegment> Path { get; }
public Task<bool> MoveAsync(Vector3 location);
public Task MoveUntilReachedAsync(Vector3 location);
}
}

View File

@@ -0,0 +1,15 @@
using Client.Domain.DTO;
using Client.Domain.ValueObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Domain.Service
{
public interface PathfinderInterface
{
public List<PathSegment> FindPath(Vector3 start, Vector3 end);
}
}

View File

@@ -27,6 +27,8 @@ namespace Client.Domain.Service
EventHandlerInterface<ItemCreatedEvent>,
EventHandlerInterface<ItemDeletedEvent>
{
public Hero? Hero => hero;
public void RequestMoveToLocation(Vector3 location)
{
if (hero == null)
@@ -37,24 +39,6 @@ namespace Client.Domain.Service
SendMessage(OutgoingMessageTypeEnum.Move, location);
}
public void RequestMoveToEntity(uint id)
{
if (hero == null)
{
return;
}
if (!creatures.ContainsKey(id) && !drops.ContainsKey(id))
{
Debug.WriteLine("RequestMoveToEntity: entity " + id + " not found");
return;
}
var position = creatures.ContainsKey(id) ? creatures[id].Transform.Position : drops[id].Transform.Position;
RequestMoveToLocation(position);
}
public void RequestAcquireTarget(uint id)
{
if (hero == null)