From 09517acf18bebc35d30c8fe19536dfa0bfa15509 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 16:33:03 +1300 Subject: [PATCH] more fixes --- OpenRa.Game/Player.cs | 5 ++--- OpenRa.Game/Traits/Cargo.cs | 5 +++-- OpenRa.Game/Traits/Production.cs | 4 ++-- OpenRa.Game/Traits/RenderBuilding.cs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index 9e3d335b31..a7e29cb8c2 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -84,9 +84,8 @@ namespace OpenRa.Game { OreCapacity = Game.world.Actors .Where(a => a.Owner == this && a.traits.Contains()) - .Select(a => a.LegacyInfo as LegacyBuildingInfo) - .Where(b => b != null) - .Sum(b => b.Storage); + .Select(a => a.Info.Traits.Get()) + .Sum(b => b.Capacity); } void GiveAdvice(string advice) diff --git a/OpenRa.Game/Traits/Cargo.cs b/OpenRa.Game/Traits/Cargo.cs index 99707546bc..c9b99b79a7 100644 --- a/OpenRa.Game/Traits/Cargo.cs +++ b/OpenRa.Game/Traits/Cargo.cs @@ -48,7 +48,7 @@ namespace OpenRa.Game.Traits public bool IsFull(Actor self) { - return cargo.Count == self.LegacyInfo.Passengers; + return cargo.Count == self.Info.Traits.Get().Passengers; } public bool IsEmpty(Actor self) @@ -65,7 +65,8 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips( Actor self ) { - for (var i = 0; i < self.Info.Traits.Get().Passengers; i++) + var numPips = self.Info.Traits.Get().Passengers; + for (var i = 0; i < numPips; i++) if (i >= cargo.Count) yield return PipType.Transparent; else diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index a35beeb11e..0f86a7b41e 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -86,12 +86,12 @@ namespace OpenRa.Game.Traits } // Cancel existing primaries - foreach (var p in (self.LegacyInfo as LegacyBuildingInfo).Produces) + foreach (var p in self.Info.Traits.Get().Produces) { foreach (var b in Game.world.Actors.Where(x => x.traits.Contains() && x.Owner == self.Owner && x.traits.Get().IsPrimary == true - && (x.LegacyInfo as LegacyBuildingInfo).Produces.Contains(p))) + && (x.Info.Traits.Get().Produces.Contains(p)))) { b.traits.Get().SetPrimaryProducer(b, false); } diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index 48e58af0ca..1024581177 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits void DoBib(Actor self, bool isRemove) { - var buildingInfo = self.traits.Get().unitInfo; + var buildingInfo = self.Info.Traits.Get(); if (buildingInfo.Bib) { var size = buildingInfo.Dimensions.X;