Skip to content

Instantly share code, notes, and snippets.

@phrohdoh
Created July 21, 2014 22:30
Show Gist options
  • Save phrohdoh/522c6fa9509bb9633289 to your computer and use it in GitHub Desktop.
Save phrohdoh/522c6fa9509bb9633289 to your computer and use it in GitHub Desktop.
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Move")
{
if (Info.MovesToShroud && self.Owner.Shroud.IsExplored(order.TargetLocation))
PerformMove(self, self.World.Map.Clamp(order.TargetLocation),
order.Queued && !self.IsIdle);
}
if (order.OrderString == "Stop")
self.CancelActivity();
if (order.OrderString == "Scatter")
Nudge(self, self, true);
}
class MoveOrderTargeter : IOrderTargeter
{
readonly MobileInfo unitType;
readonly bool rejectMove;
public MoveOrderTargeter(Actor self, MobileInfo unitType)
{
this.unitType = unitType;
this.rejectMove = !self.AcceptsOrder("Move");
}
public string OrderID { get { return "Move"; } }
public int OrderPriority { get { return 4; } }
public bool IsQueued { get; protected set; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
{
if (rejectMove || !target.IsValidFor(self))
return false;
var location = self.World.Map.CellContaining(target.CenterPosition);
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
cursor = "move";
var explored = self.Owner.Shroud.IsExplored(location);
if (explored)
cursor = self.World.Map.GetTerrainInfo(location).CustomCursor ?? cursor;
if (!self.World.Map.Contains(location) ||
!(explored && unitType.MovesToShroud) ||
(explored && unitType.MovementCostForCell(self.World, location) == int.MaxValue))
cursor = "move-blocked";
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment