Skip to content

Commit

Permalink
Fix #1269 - Transport Helicopter Loading while in the Air
Browse files Browse the repository at this point in the history
Note that weight is now checked for cargo (this might break things)
  • Loading branch information
alzeih authored and chrisforbes committed Dec 12, 2011
1 parent 7e590b0 commit b508f7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions OpenRA.Mods.RA/Activities/EnterTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ public override Activity Tick(Actor self)
if (transport == null || !transport.IsInWorld) return NextActivity;

var cargo = transport.Trait<Cargo>();
if (!cargo.HasSpace(1))
if (!cargo.CanLoad(transport, self))
return NextActivity;


// Todo: Queue a move order to the transport? need to be
// careful about units that can't path to the transport
if ((transport.Location - self.Location).LengthSquared > 2)
Expand Down
10 changes: 10 additions & 0 deletions OpenRA.Mods.RA/Cargo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ bool CanUnload(Actor self)
return true;
}

public bool CanLoad(Actor self, Actor a)
{
if (!HasSpace(GetWeight(a)))
return false;

// Cannot load mid-air
var move = self.TraitOrDefault<IMove>();
return move == null || move.Altitude == 0;
}

public string CursorForOrder(Actor self, Order order)
{
if (order.OrderString != "Unload") return null;
Expand Down

0 comments on commit b508f7c

Please sign in to comment.