Skip to content

Instantly share code, notes, and snippets.

@phrohdoh
Created July 14, 2014 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phrohdoh/4fa29e2ee0d2e04954b8 to your computer and use it in GitHub Desktop.
Save phrohdoh/4fa29e2ee0d2e04954b8 to your computer and use it in GitHub Desktop.
class ParadropOrderTargeter : IOrderTargeter
{
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Terrain)
return false;
var location = self.World.Map.CellContaining(target.CenterPosition);
if (!self.World.Map.Contains(location))
return false;
// No passengers can unload here
if (!self.Trait<ParaDrop>().Cargo.Passengers
.Any(p => p.Trait<IPositionable>().CanEnterCell(location)))
{
Game.Debug("No passengers can exist at {0}".F(location.ToString()));
return false;
}
cursor = "attack";
return !othersAtTarget.Any() && modifiers.HasModifier(TargetModifiers.ForceAttack);
}
public string OrderID { get { return "CustomParadrop"; } }
public int OrderPriority { get { return 5; } }
public bool IsQueued { get { return false; } }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment