Skip to content

Instantly share code, notes, and snippets.

@phrohdoh
Created July 13, 2014 23:02
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/ba38db82380818d0d15f to your computer and use it in GitHub Desktop.
Save phrohdoh/ba38db82380818d0d15f to your computer and use it in GitHub Desktop.
class ParaDropOrderGenerator : IOrderGenerator
{
Actor self;
public ParaDropOrderGenerator(Actor self) { this.self = self; }
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
{
if (mi.Button == Game.mouseButtonPreference.Action)
yield return new Order("DoParadrop", self, false) { TargetLocation = xy };
}
public void Tick(World world) { }
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
public void RenderAfterWorld(WorldRenderer wr, World world) { }
public string GetCursor(World world, CPos xy, MouseInput mi) { return "attack"; }
}
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)))
return false;
cursor = "attack";
return !othersAtTarget.Any() && modifiers.HasModifier(TargetModifiers.ForceAttack);
}
public string OrderID { get { return "DoParadrop"; } }
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