Created
July 13, 2014 23:02
-
-
Save phrohdoh/ba38db82380818d0d15f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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