Actor.Info is now never null

This commit is contained in:
Chris Forbes
2010-01-14 17:51:00 +13:00
parent a3ba286b06
commit ef59f3cb05
5 changed files with 5 additions and 7 deletions

View File

@@ -62,7 +62,7 @@ namespace OpenRa.Game
{ {
get // todo: inline into GetBounds get // todo: inline into GetBounds
{ {
var si = Info != null ? Info.Traits.GetOrDefault<SelectableInfo>() : null; var si = Info.Traits.GetOrDefault<SelectableInfo>();
if (si != null && si.Bounds != null) if (si != null && si.Bounds != null)
return new float2(si.Bounds[0], si.Bounds[1]); return new float2(si.Bounds[0], si.Bounds[1]);
@@ -100,7 +100,7 @@ namespace OpenRa.Game
public RectangleF GetBounds(bool useAltitude) public RectangleF GetBounds(bool useAltitude)
{ {
var si = Info != null ? Info.Traits.GetOrDefault<SelectableInfo>() : null; var si = Info.Traits.GetOrDefault<SelectableInfo>();
var size = SelectedSize; var size = SelectedSize;
var loc = CenterLocation - 0.5f * size; var loc = CenterLocation - 0.5f * size;

View File

@@ -54,7 +54,6 @@ namespace OpenRa.Game
public static int GetMaxHP(this Actor self) public static int GetMaxHP(this Actor self)
{ {
if (self.Info == null) return 0;
var oai = self.Info.Traits.GetOrDefault<OwnedActorInfo>(); var oai = self.Info.Traits.GetOrDefault<OwnedActorInfo>();
if (oai == null) return 0; if (oai == null) return 0;
return oai.HP; return oai.HP;

View File

@@ -61,7 +61,7 @@ namespace OpenRa.Game
world = new World(); world = new World();
Game.world.ActorAdded += a => Game.world.ActorAdded += a =>
{ {
if (a.Owner != null && a.Info != null && a.Info.Traits.Contains<OwnedActorInfo>()) if (a.Owner != null && a.Info.Traits.Contains<OwnedActorInfo>())
a.Owner.Shroud.Explore(a); a.Owner.Shroud.Explore(a);
}; };

View File

@@ -23,7 +23,7 @@ namespace OpenRa.Game.GameRules
public Cache<string, List<Actor>> GatherBuildings( Player player ) public Cache<string, List<Actor>> GatherBuildings( Player player )
{ {
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() ); var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info != null && x.Info.Traits.Contains<BuildingInfo>() ) ) foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info.Traits.Contains<BuildingInfo>() ) )
{ {
ret[ b.Info.Name ].Add( b ); ret[ b.Info.Name ].Add( b );
var buildable = b.Info.Traits.GetOrDefault<BuildableInfo>(); var buildable = b.Info.Traits.GetOrDefault<BuildableInfo>();

View File

@@ -98,8 +98,7 @@ namespace OpenRa.Game.Graphics
public void GoToStartLocation() public void GoToStartLocation()
{ {
Center(Game.world.Actors.Where(a => a.Info != null Center(Game.world.Actors.Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains<Selectable>()));
&& a.traits.Contains<Selectable>() && a.Owner == Game.LocalPlayer));
} }
} }
} }