Interactions can now end themselves.
parent
187dac2d85
commit
d2611c6073
|
@ -10,6 +10,12 @@ public class InteractionComponent: Component
|
||||||
[Signal]
|
[Signal]
|
||||||
delegate void InteractionEnd(Spatial owningEntity, Spatial targetEntity);
|
delegate void InteractionEnd(Spatial owningEntity, Spatial targetEntity);
|
||||||
|
|
||||||
|
public void EndInteraction()
|
||||||
|
{
|
||||||
|
hasStopped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool hasStopped = false;
|
||||||
public Spatial OwningEntity;
|
public Spatial OwningEntity;
|
||||||
public Spatial TargetEntity;
|
public Spatial TargetEntity;
|
||||||
}
|
}
|
|
@ -27,10 +27,8 @@ public class TaskQueueComponent : Component
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
var currentTask = Queue.Peek();
|
var currentTask = Queue.Peek();
|
||||||
var interactionTask = currentTask as InteractionTask;
|
|
||||||
if (interactionTask != null) EmitSignal("StartInteraction", entity, interactionTask.TargetEntity);
|
|
||||||
|
|
||||||
if (currentTask.PerformTask(entity, delta))
|
if (currentTask.PerformTask(entity, this, delta))
|
||||||
Queue.Dequeue();
|
Queue.Dequeue();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
@ -43,7 +41,7 @@ public class TaskQueueComponent : Component
|
||||||
/// Executes a Task on the specified entity.
|
/// Executes a Task on the specified entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>true when the Task is complete, false otherwise</returns>
|
/// <returns>true when the Task is complete, false otherwise</returns>
|
||||||
public abstract bool PerformTask(Entity entity, float delta);
|
public abstract bool PerformTask(Entity entity, TaskQueueComponent taskQueueComponent, float delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -59,7 +57,7 @@ public class TaskQueueComponent : Component
|
||||||
NavigationPoint = navigationPoint;
|
NavigationPoint = navigationPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool PerformTask(Entity entity, float delta)
|
public override bool PerformTask(Entity entity, TaskQueueComponent taskQueueComponent, float delta)
|
||||||
{
|
{
|
||||||
return NavigationPoint.IsReached(entity.GlobalTransform);
|
return NavigationPoint.IsReached(entity.GlobalTransform);
|
||||||
}
|
}
|
||||||
|
@ -74,8 +72,10 @@ public class TaskQueueComponent : Component
|
||||||
TargetEntity = entity;
|
TargetEntity = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool PerformTask(Entity entity, float delta)
|
public override bool PerformTask(Entity entity, TaskQueueComponent taskQueueComponent, float delta)
|
||||||
{
|
{
|
||||||
|
taskQueueComponent.EmitSignal("StartInteraction", entity, TargetEntity);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,9 @@ public class World : Spatial
|
||||||
[Signal]
|
[Signal]
|
||||||
private delegate void OnHeightmapImageChanged(Image heightmapImage);
|
private delegate void OnHeightmapImageChanged(Image heightmapImage);
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void EntityClicked(Entity entity);
|
||||||
|
|
||||||
public World()
|
public World()
|
||||||
{
|
{
|
||||||
Debug.Assert(ChunkSize % 2 == 0);
|
Debug.Assert(ChunkSize % 2 == 0);
|
||||||
|
@ -500,4 +503,9 @@ public class World : Spatial
|
||||||
State = GenerationState.Done;
|
State = GenerationState.Done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEntityClicked(Entity entity)
|
||||||
|
{
|
||||||
|
EmitSignal("EntityClicked", entity);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue