feat: add pathfinding
This commit is contained in:
18
Client/Domain/Service/AsyncPathMoverInterface.cs
Normal file
18
Client/Domain/Service/AsyncPathMoverInterface.cs
Normal 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);
|
||||
}
|
||||
}
|
15
Client/Domain/Service/PathfinderInterface.cs
Normal file
15
Client/Domain/Service/PathfinderInterface.cs
Normal 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);
|
||||
}
|
||||
}
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user