Raise PathComplete event from IMobEntity

...when the current path is completed
This commit is contained in:
Drew DeVault 2015-07-15 20:25:01 -06:00
parent 19e52bda45
commit f927f86d43
2 changed files with 7 additions and 2 deletions

View File

@ -5,6 +5,7 @@ namespace TrueCraft.API.Entities
{ {
public interface IMobEntity : IEntity, IAABBEntity public interface IMobEntity : IEntity, IAABBEntity
{ {
event EventHandler PathComplete;
PathResult CurrentPath { get; set; } PathResult CurrentPath { get; set; }
bool AdvancePath(TimeSpan time, bool faceRoute = true); bool AdvancePath(TimeSpan time, bool faceRoute = true);
void Face(Vector3 target); void Face(Vector3 target);

View File

@ -19,6 +19,8 @@ namespace TrueCraft.Core.Entities
CurrentState = new WanderState(); CurrentState = new WanderState();
} }
public event EventHandler PathComplete;
public override IPacket SpawnPacket public override IPacket SpawnPacket
{ {
get get
@ -124,7 +126,9 @@ namespace TrueCraft.Core.Entities
CurrentPath.Index++; CurrentPath.Index++;
if (CurrentPath.Index >= CurrentPath.Waypoints.Count) if (CurrentPath.Index >= CurrentPath.Waypoints.Count)
{ {
CurrentPath = null; // TODO: Raise path complete event or something? CurrentPath = null;
if (PathComplete != null)
PathComplete(this, null);
return true; return true;
} }
} }