add Passenger to crate; remove special cases in Cargo to support not having Passenger; #851

This commit is contained in:
Chris Forbes
2011-07-17 17:21:55 +12:00
parent a95b59081f
commit a635e8a4d8
2 changed files with 6 additions and 7 deletions

View File

@@ -92,14 +92,13 @@ namespace OpenRA.Mods.RA
public Actor Peek(Actor self) { return cargo[0]; } public Actor Peek(Actor self) { return cargo[0]; }
static int GetWeight(Actor a) { return a.Info.Traits.Get<PassengerInfo>().Weight; }
public Actor Unload(Actor self) public Actor Unload(Actor self)
{ {
var a = cargo[0]; var a = cargo[0];
cargo.RemoveAt(0); cargo.RemoveAt(0);
totalWeight -= GetWeight(a);
var pi = a.Info.Traits.GetOrDefault<PassengerInfo>();
totalWeight -= pi != null ? pi.Weight : 1;
return a; return a;
} }
@@ -130,8 +129,7 @@ namespace OpenRA.Mods.RA
public void Load(Actor self, Actor a) public void Load(Actor self, Actor a)
{ {
cargo.Add(a); cargo.Add(a);
var pi = a.Info.Traits.GetOrDefault<PassengerInfo>(); totalWeight += GetWeight(a);
totalWeight += pi != null ? pi.Weight : 1;
} }
public void Killed(Actor self, AttackInfo e) public void Killed(Actor self, AttackInfo e)

View File

@@ -287,6 +287,7 @@ CRATE:
BelowUnits: BelowUnits:
ProximityCaptor: ProximityCaptor:
Types:Crate Types:Crate
Passenger:
CAMERA: CAMERA:
Aircraft: Aircraft:
@@ -338,4 +339,4 @@ mpspawn:
waypoint: waypoint:
Waypoint: Waypoint:
RenderEditorOnly: RenderEditorOnly: