Actor.Info is now never null
This commit is contained in:
@@ -62,7 +62,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
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)
|
||||
return new float2(si.Bounds[0], si.Bounds[1]);
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace OpenRa.Game
|
||||
|
||||
public RectangleF GetBounds(bool useAltitude)
|
||||
{
|
||||
var si = Info != null ? Info.Traits.GetOrDefault<SelectableInfo>() : null;
|
||||
var si = Info.Traits.GetOrDefault<SelectableInfo>();
|
||||
|
||||
var size = SelectedSize;
|
||||
var loc = CenterLocation - 0.5f * size;
|
||||
|
||||
@@ -54,7 +54,6 @@ namespace OpenRa.Game
|
||||
|
||||
public static int GetMaxHP(this Actor self)
|
||||
{
|
||||
if (self.Info == null) return 0;
|
||||
var oai = self.Info.Traits.GetOrDefault<OwnedActorInfo>();
|
||||
if (oai == null) return 0;
|
||||
return oai.HP;
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRa.Game
|
||||
world = new World();
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRa.Game.GameRules
|
||||
public Cache<string, List<Actor>> GatherBuildings( Player player )
|
||||
{
|
||||
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 );
|
||||
var buildable = b.Info.Traits.GetOrDefault<BuildableInfo>();
|
||||
|
||||
@@ -98,8 +98,7 @@ namespace OpenRa.Game.Graphics
|
||||
|
||||
public void GoToStartLocation()
|
||||
{
|
||||
Center(Game.world.Actors.Where(a => a.Info != null
|
||||
&& a.traits.Contains<Selectable>() && a.Owner == Game.LocalPlayer));
|
||||
Center(Game.world.Actors.Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains<Selectable>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user