Fixing uses of legacyInfo.WaterBound

This commit is contained in:
Bob
2010-01-12 19:31:06 +13:00
parent 5afedbf001
commit b21e1adc2d
8 changed files with 109 additions and 8 deletions

View File

@@ -68,7 +68,7 @@ namespace OpenRa.Game
if (unit != null && unit.Altitude > 0)
return projectile.AA;
if (projectile.UnderWater && !target.LegacyInfo.WaterBound)
if (projectile.UnderWater && !target.Info.Traits.Get<OwnedActorInfo>().WaterBound)
return false;
return projectile.AG;

View File

@@ -10,6 +10,7 @@ namespace OpenRa.Game.Traits
public readonly int TechLevel = -1;
public readonly string Tab = null;
public readonly string[] Prerequisites = { };
public readonly string[] BuiltAt = { };
public readonly Race[] Owner = { };
public readonly int Cost = 0;
public readonly string Description = "";

View File

@@ -16,6 +16,7 @@ namespace OpenRa.Game.Traits
public readonly bool Crewed = false; // replace with trait?
public readonly int InitialFacing = 128;
public readonly int Sight = 0;
public readonly bool WaterBound = false;
}
class BuildingInfo : OwnedActorInfo, ITraitInfo
@@ -30,7 +31,6 @@ namespace OpenRa.Game.Traits
public readonly string Footprint = "x";
public readonly string[] Produces = { }; // does this go somewhere else?
public readonly int2 Dimensions = new int2(1, 1);
public readonly bool WaterBound = false;
public readonly bool Unsellable = false;
public object Create(Actor self) { return new Building(self); }

View File

@@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits
public Production( Actor self ) { }
public virtual int2? CreationLocation( Actor self, LegacyUnitInfo producee )
public virtual int2? CreationLocation( Actor self, NewUnitInfo producee )
{
return ( 1 / 24f * self.CenterLocation ).ToInt2();
}
@@ -29,7 +29,7 @@ namespace OpenRa.Game.Traits
return newUnit.Info.Traits.GetOrDefault<OwnedActorInfo>().InitialFacing;
}
public bool Produce( Actor self, LegacyUnitInfo producee )
public bool Produce( Actor self, NewUnitInfo producee )
{
var location = CreationLocation( self, producee );
if( location == null || Game.UnitInfluence.GetUnitsAt( location.Value ).Any() )

View File

@@ -126,7 +126,7 @@ namespace OpenRa.Game.Traits
public void BuildUnit( string name )
{
var newUnitType = Rules.UnitInfo[ name ];
var newUnitType = Rules.NewUnitInfo[ name ];
var producerTypes = Rules.TechTree.UnitBuiltAt( newUnitType );
Actor producer = null;

View File

@@ -26,9 +26,9 @@ namespace OpenRa.Game.Traits
return null;
}
public override int2? CreationLocation(Actor self, LegacyUnitInfo producee)
public override int2? CreationLocation(Actor self, NewUnitInfo producee)
{
return FindAdjacentTile(self, producee.WaterBound ?
return FindAdjacentTile(self, producee.Traits.Get<OwnedActorInfo>().WaterBound ?
UnitMovementType.Float : UnitMovementType.Wheel); /* hackety hack */
}

View File

@@ -25,7 +25,7 @@ namespace OpenRa.Game.Traits
interface IProducer
{
bool Produce( Actor self, LegacyUnitInfo producee );
bool Produce( Actor self, NewUnitInfo producee );
void SetPrimaryProducer(Actor self, bool isPrimary);
}
interface IOccupySpace { IEnumerable<int2> OccupiedCells(); }