fixed #2166 - filtering of passengers to show with RenderCargo

This commit is contained in:
Chris Forbes
2012-07-01 18:22:19 +12:00
parent d0548d6766
commit c2029e9d5c
2 changed files with 8 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Cnc
{
/* altitude of the cargo, relative to us. -ve is underneath us */
public readonly int RelativeAltitude = 0;
public readonly string[] PassengerTypes;
public object Create(ActorInitializer init) { return new RenderCargo(init.self, this); }
}
@@ -49,7 +50,12 @@ namespace OpenRA.Mods.Cnc
cargoFacing.Facing = facing.Facing;
}
return r.Concat(cargo.Passengers.SelectMany(a => a.Render())
var visiblePassengers = (Info.PassengerTypes != null && Info.PassengerTypes.Length > 0)
? cargo.Passengers.Where(p =>
Info.PassengerTypes.Contains(p.Trait<Passenger>().info.CargoType))
: cargo.Passengers;
return r.Concat(visiblePassengers.SelectMany(a => a.Render())
.Select(a => a.WithPos(a.Pos - new float2(0, Info.RelativeAltitude))
.WithZOffset(a.ZOffset + Info.RelativeAltitude)));
}

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA
public class Passenger : IIssueOrder, IResolveOrder, IOrderVoice
{
readonly PassengerInfo info;
public readonly PassengerInfo info;
public Passenger( PassengerInfo info ) { this.info = info; }
public IEnumerable<IOrderTargeter> Orders