renamed Info to LegacyInfo, marked Obsolete. added NewUnitInfo ref as Info.

This commit is contained in:
Chris Forbes
2010-01-10 18:28:24 +13:00
parent 74a2ed9624
commit 99a61ca8d9
52 changed files with 142 additions and 137 deletions

View File

@@ -12,7 +12,10 @@ namespace OpenRa.Game
{ {
[Sync] [Sync]
public readonly TypeDictionary traits = new TypeDictionary(); public readonly TypeDictionary traits = new TypeDictionary();
public readonly LegacyUnitInfo Info;
[Obsolete]
public readonly LegacyUnitInfo LegacyInfo;
public readonly NewUnitInfo Info;
public readonly uint ActorID; public readonly uint ActorID;
[Sync] [Sync]
@@ -26,19 +29,21 @@ namespace OpenRa.Game
public Actor( ActorInfo info, int2 location, Player owner ) public Actor( ActorInfo info, int2 location, Player owner )
{ {
ActorID = Game.world.NextAID(); ActorID = Game.world.NextAID();
Info = (LegacyUnitInfo)info; // temporary LegacyInfo = (LegacyUnitInfo)info; // temporary
Location = location; Location = location;
CenterLocation = Traits.Util.CenterOfCell(Location); CenterLocation = Traits.Util.CenterOfCell(Location);
Owner = owner; Owner = owner;
if (Info == null) return; if (LegacyInfo == null) return;
Health = Info.Strength; /* todo: fix walls, etc so this is always true! */ Health = LegacyInfo.Strength; /* todo: fix walls, etc so this is always true! */
if( Info.Traits == null ) if( LegacyInfo.Traits == null )
throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(Info.Name) ); throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(LegacyInfo.Name) );
foreach (var trait in Rules.NewUnitInfo[Info.Name.ToLower()].Traits.WithInterface<ITraitInfo>()) Info = Rules.NewUnitInfo[LegacyInfo.Name.ToLowerInvariant()];
foreach (var trait in Info.Traits.WithInterface<ITraitInfo>())
traits.Add(trait.Create(this)); traits.Add(trait.Create(this));
} }
@@ -65,8 +70,8 @@ namespace OpenRa.Game
{ {
get get
{ {
if (Info != null && Info.SelectionSize != null) if (LegacyInfo != null && LegacyInfo.SelectionSize != null)
return new float2(Info.SelectionSize[0], Info.SelectionSize[1]); return new float2(LegacyInfo.SelectionSize[0], LegacyInfo.SelectionSize[1]);
var firstSprite = Render().FirstOrDefault(); var firstSprite = Render().FirstOrDefault();
if (firstSprite.Sprite == null) return float2.Zero; if (firstSprite.Sprite == null) return float2.Zero;
@@ -92,7 +97,7 @@ namespace OpenRa.Game
var loc = mi.Location + Game.viewport.Location; var loc = mi.Location + Game.viewport.Location;
var underCursor = Game.FindUnits(loc, loc).FirstOrDefault(); var underCursor = Game.FindUnits(loc, loc).FirstOrDefault();
if (underCursor != null && !underCursor.Info.Selectable) if (underCursor != null && !underCursor.LegacyInfo.Selectable)
underCursor = null; underCursor = null;
return traits.WithInterface<IIssueOrder>() return traits.WithInterface<IIssueOrder>()
@@ -104,8 +109,8 @@ namespace OpenRa.Game
{ {
var size = SelectedSize; var size = SelectedSize;
var loc = CenterLocation - 0.5f * size; var loc = CenterLocation - 0.5f * size;
if (Info != null && Info.SelectionSize != null && Info.SelectionSize.Length > 2) if (LegacyInfo != null && LegacyInfo.SelectionSize != null && LegacyInfo.SelectionSize.Length > 2)
loc += new float2(Info.SelectionSize[2], Info.SelectionSize[3]); loc += new float2(LegacyInfo.SelectionSize[2], LegacyInfo.SelectionSize[3]);
if (useAltitude) if (useAltitude)
{ {
@@ -122,7 +127,7 @@ namespace OpenRa.Game
public DamageState GetDamageState() public DamageState GetDamageState()
{ {
if (Health <= 0) return DamageState.Dead; if (Health <= 0) return DamageState.Dead;
var halfStrength = Info.Strength * Rules.General.ConditionYellow; var halfStrength = LegacyInfo.Strength * Rules.General.ConditionYellow;
return Health < halfStrength ? DamageState.Half : DamageState.Normal; return Health < halfStrength ? DamageState.Half : DamageState.Normal;
} }
@@ -145,8 +150,8 @@ namespace OpenRa.Game
Game.world.AddFrameEndTask(w => w.Remove(this)); Game.world.AddFrameEndTask(w => w.Remove(this));
} }
if (Health > Info.Strength) if (Health > LegacyInfo.Strength)
Health = Info.Strength; Health = LegacyInfo.Strength;
var newState = GetDamageState(); var newState = GetDamageState();

View File

@@ -49,7 +49,7 @@ namespace OpenRa.Game
var distance = (target.CenterLocation - loc).Length*1/24f; var distance = (target.CenterLocation - loc).Length*1/24f;
var rawDamage = weapon.Damage * (float)Math.Exp(-distance / warhead.Spread); var rawDamage = weapon.Damage * (float)Math.Exp(-distance / warhead.Spread);
var multiplier = warhead.EffectivenessAgainst(target.Info.Armor); var multiplier = warhead.EffectivenessAgainst(target.LegacyInfo.Armor);
return rawDamage * multiplier; return rawDamage * multiplier;
} }
@@ -59,7 +59,7 @@ namespace OpenRa.Game
var warhead = Rules.WarheadInfo[weapon.Warhead]; var warhead = Rules.WarheadInfo[weapon.Warhead];
var unit = target.traits.GetOrDefault<Unit>(); var unit = target.traits.GetOrDefault<Unit>();
if (warhead.EffectivenessAgainst(target.Info.Armor) <= 0) if (warhead.EffectivenessAgainst(target.LegacyInfo.Armor) <= 0)
return false; return false;
if (target.traits.Contains<Submarine>()) if (target.traits.Contains<Submarine>())
@@ -68,7 +68,7 @@ namespace OpenRa.Game
if (unit != null && unit.Altitude > 0) if (unit != null && unit.Altitude > 0)
return projectile.AA; return projectile.AA;
if (projectile.UnderWater && !target.Info.WaterBound) if (projectile.UnderWater && !target.LegacyInfo.WaterBound)
return false; return false;
return projectile.AG; return projectile.AG;
@@ -76,10 +76,10 @@ namespace OpenRa.Game
public static bool HasAnyValidWeapons(Actor self, Actor target) public static bool HasAnyValidWeapons(Actor self, Actor target)
{ {
if (self.Info.Primary != null && if (self.LegacyInfo.Primary != null &&
WeaponValidForTarget(Rules.WeaponInfo[self.Info.Primary], target)) return true; WeaponValidForTarget(Rules.WeaponInfo[self.LegacyInfo.Primary], target)) return true;
if (self.Info.Secondary != null && if (self.LegacyInfo.Secondary != null &&
WeaponValidForTarget(Rules.WeaponInfo[self.Info.Secondary], target)) return true; WeaponValidForTarget(Rules.WeaponInfo[self.LegacyInfo.Secondary], target)) return true;
return false; return false;
} }

View File

@@ -15,7 +15,7 @@ namespace OpenRa.Game.Effects
public Corpse(Actor fromActor, int death) public Corpse(Actor fromActor, int death)
{ {
anim = new Animation(fromActor.Info.Image ?? fromActor.Info.Name); anim = new Animation(fromActor.LegacyInfo.Image ?? fromActor.LegacyInfo.Name);
anim.PlayThen("die{0}".F(death + 1), anim.PlayThen("die{0}".F(death + 1),
() => Game.world.AddFrameEndTask(w => w.Remove(this))); () => Game.world.AddFrameEndTask(w => w.Remove(this)));

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) if (a.Owner != null && a.LegacyInfo != null)
a.Owner.Shroud.Explore(a); a.Owner.Shroud.Explore(a);
}; };
@@ -310,8 +310,8 @@ namespace OpenRa.Game
public static IEnumerable<Actor> SelectActorsInBox(float2 a, float2 b) public static IEnumerable<Actor> SelectActorsInBox(float2 a, float2 b)
{ {
return FindUnits(a, b) return FindUnits(a, b)
.Where( x => x.Info.Selectable ) .Where( x => x.LegacyInfo.Selectable )
.GroupBy(x => (x.Owner == LocalPlayer) ? x.Info.SelectionPriority : 0) .GroupBy(x => (x.Owner == LocalPlayer) ? x.LegacyInfo.SelectionPriority : 0)
.OrderByDescending(g => g.Key) .OrderByDescending(g => g.Key)
.Select( g => g.AsEnumerable() ) .Select( g => g.AsEnumerable() )
.DefaultIfEmpty( new Actor[] {} ) .DefaultIfEmpty( new Actor[] {} )
@@ -338,7 +338,7 @@ namespace OpenRa.Game
heuristic = loc => heuristic = loc =>
{ {
var b = Game.BuildingInfluence.GetBuildingAt(loc); var b = Game.BuildingInfluence.GetBuildingAt(loc);
if (b != null && b.Owner == p && (b.Info as LegacyBuildingInfo).BaseNormal) return 0; if (b != null && b.Owner == p && (b.LegacyInfo as LegacyBuildingInfo).BaseNormal) return 0;
if ((loc - position).Length > maxDistance) if ((loc - position).Length > maxDistance)
return float.PositiveInfinity; /* not quite right */ return float.PositiveInfinity; /* not quite right */
return 1; return 1;

View File

@@ -21,8 +21,8 @@ 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 is LegacyBuildingInfo ) ) foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.LegacyInfo is LegacyBuildingInfo ) )
ret[ b.Info.Name ].Add( b ); ret[ b.LegacyInfo.Name ].Add( b );
return ret; return ret;
} }

View File

@@ -97,7 +97,7 @@ namespace OpenRa.Game.Graphics
public void GoToStartLocation() public void GoToStartLocation()
{ {
Center(Game.world.Actors.Where(a => a.Info != null && a.Owner == Game.LocalPlayer)); Center(Game.world.Actors.Where(a => a.LegacyInfo != null && a.Owner == Game.LocalPlayer));
} }
} }
} }

View File

@@ -169,7 +169,7 @@ namespace OpenRa.Game.Graphics
lineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c); lineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c);
lineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c); lineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c);
var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Strength; var healthAmount = (float)selectedUnit.Health / selectedUnit.LegacyInfo.Strength;
var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red
: (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow : (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow
: Color.LimeGreen; : Color.LimeGreen;

View File

@@ -31,9 +31,9 @@ namespace OpenRa.Game.Orders
var underCursor = Game.FindUnits(loc, loc) var underCursor = Game.FindUnits(loc, loc)
.Where(a => a.Owner == Game.LocalPlayer .Where(a => a.Owner == Game.LocalPlayer
&& a.traits.WithInterface<Chronoshiftable>().Any() && a.traits.WithInterface<Chronoshiftable>().Any()
&& a.Info.Selectable).FirstOrDefault(); && a.LegacyInfo.Selectable).FirstOrDefault();
var unit = underCursor != null ? underCursor.Info as LegacyUnitInfo : null; var unit = underCursor != null ? underCursor.LegacyInfo as LegacyUnitInfo : null;
if (unit != null) if (unit != null)
yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, power.Name); yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, power.Name);

View File

@@ -31,9 +31,9 @@ namespace OpenRa.Game.Orders
var underCursor = Game.FindUnits(loc, loc) var underCursor = Game.FindUnits(loc, loc)
.Where(a => a.Owner == Game.LocalPlayer .Where(a => a.Owner == Game.LocalPlayer
&& a.traits.Contains<IronCurtainable>() && a.traits.Contains<IronCurtainable>()
&& a.Info.Selectable).FirstOrDefault(); && a.LegacyInfo.Selectable).FirstOrDefault();
var unit = underCursor != null ? underCursor.Info as LegacyUnitInfo : null; var unit = underCursor != null ? underCursor.LegacyInfo as LegacyUnitInfo : null;
if (unit != null) if (unit != null)
yield return new Order("IronCurtain", underCursor, null, int2.Zero, power.Name); yield return new Order("IronCurtain", underCursor, null, int2.Zero, power.Name);

View File

@@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders
var underCursor = Game.FindUnits(loc, loc) var underCursor = Game.FindUnits(loc, loc)
.Where(a => a.Owner == Game.LocalPlayer .Where(a => a.Owner == Game.LocalPlayer
&& a.traits.Contains<Building>() && a.traits.Contains<Building>()
&& a.Info.Selectable).FirstOrDefault(); && a.LegacyInfo.Selectable).FirstOrDefault();
var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null; var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null;
if (building != null) if (building != null)
yield return new Order("PowerDown", underCursor, null, int2.Zero, null); yield return new Order("PowerDown", underCursor, null, int2.Zero, null);

View File

@@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders
var underCursor = Game.FindUnits(loc, loc) var underCursor = Game.FindUnits(loc, loc)
.Where(a => a.Owner == Game.LocalPlayer .Where(a => a.Owner == Game.LocalPlayer
&& a.traits.Contains<Building>() && a.traits.Contains<Building>()
&& a.Info.Selectable).FirstOrDefault(); && a.LegacyInfo.Selectable).FirstOrDefault();
var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null; var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null;
if (building != null && building.Repairable && underCursor.Health < building.Strength) if (building != null && building.Repairable && underCursor.Health < building.Strength)
yield return new Order("Repair", underCursor, null, int2.Zero, null); yield return new Order("Repair", underCursor, null, int2.Zero, null);

View File

@@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders
var underCursor = Game.FindUnits(loc, loc) var underCursor = Game.FindUnits(loc, loc)
.Where(a => a.Owner == Game.LocalPlayer .Where(a => a.Owner == Game.LocalPlayer
&& a.traits.Contains<Building>() && a.traits.Contains<Building>()
&& a.Info.Selectable).FirstOrDefault(); && a.LegacyInfo.Selectable).FirstOrDefault();
var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null; var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null;
if (building != null && !building.Unsellable) if (building != null && !building.Unsellable)
yield return new Order("Sell", underCursor, null, int2.Zero, null); yield return new Order("Sell", underCursor, null, int2.Zero, null);

View File

@@ -84,7 +84,7 @@ namespace OpenRa.Game
{ {
OreCapacity = Game.world.Actors OreCapacity = Game.world.Actors
.Where(a => a.Owner == this && a.traits.Contains<StoresOre>()) .Where(a => a.Owner == this && a.traits.Contains<StoresOre>())
.Select(a => a.Info as LegacyBuildingInfo) .Select(a => a.LegacyInfo as LegacyBuildingInfo)
.Where(b => b != null) .Where(b => b != null)
.Sum(b => b.Storage); .Sum(b => b.Storage);
} }

View File

@@ -32,7 +32,7 @@ namespace OpenRa.Game
public void Explore(Actor a) public void Explore(Actor a)
{ {
foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.Info.Sight)) foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.LegacyInfo.Sight))
explored[t.X, t.Y] = true; explored[t.X, t.Y] = true;
dirty = true; dirty = true;

View File

@@ -92,7 +92,7 @@ namespace OpenRa.Game
{ {
if (voicedUnit == null) return; if (voicedUnit == null) return;
var mi = voicedUnit.Info as LegacyMobileInfo; var mi = voicedUnit.LegacyInfo as LegacyMobileInfo;
if (mi == null) return; if (mi == null) return;
var vi = Rules.VoiceInfo[mi.Voice]; var vi = Rules.VoiceInfo[mi.Voice];

View File

@@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities
if (target.Owner == self.Owner) if (target.Owner == self.Owner)
{ {
if (target.Health == target.Info.Strength) if (target.Health == target.LegacyInfo.Strength)
return NextActivity; return NextActivity;
target.InflictDamage(self, -EngineerCapture.EngineerDamage, Rules.WarheadInfo["Super"]); target.InflictDamage(self, -EngineerCapture.EngineerDamage, Rules.WarheadInfo["Super"]);
} }

View File

@@ -31,7 +31,7 @@ namespace OpenRa.Game.Traits.Activities
var desiredFacing = Util.GetFacing(d, unit.Facing); var desiredFacing = Util.GetFacing(d, unit.Facing);
if (unit.Altitude == CruiseAltitude) if (unit.Altitude == CruiseAltitude)
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.ROT); Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT);
var speed = .2f * Util.GetEffectiveSpeed(self); var speed = .2f * Util.GetEffectiveSpeed(self);
var angle = unit.Facing / 128f * Math.PI; var angle = unit.Facing / 128f * Math.PI;

View File

@@ -30,11 +30,11 @@ namespace OpenRa.Game.Traits.Activities
return this; return this;
} }
var range = Rules.WeaponInfo[ self.Info.Primary ].Range - 1; var range = Rules.WeaponInfo[ self.LegacyInfo.Primary ].Range - 1;
var dist = target.CenterLocation - self.CenterLocation; var dist = target.CenterLocation - self.CenterLocation;
var desiredFacing = Util.GetFacing(dist, unit.Facing); var desiredFacing = Util.GetFacing(dist, unit.Facing);
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.ROT); Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT);
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize)) if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
{ {

View File

@@ -39,7 +39,7 @@ namespace OpenRa.Game.Traits.Activities
} }
var desiredFacing = Util.GetFacing(dist, unit.Facing); var desiredFacing = Util.GetFacing(dist, unit.Facing);
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.ROT); Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT);
var rawSpeed = .2f * Util.GetEffectiveSpeed(self); var rawSpeed = .2f * Util.GetEffectiveSpeed(self);
self.CenterLocation += (rawSpeed / dist.Length) * dist; self.CenterLocation += (rawSpeed / dist.Length) * dist;

View File

@@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities
static Actor ChooseHelipad(Actor self) static Actor ChooseHelipad(Actor self)
{ {
return Game.world.Actors.FirstOrDefault( return Game.world.Actors.FirstOrDefault(
a => a.Info == Rules.UnitInfo["HPAD"] && a => a.LegacyInfo == Rules.UnitInfo["HPAD"] &&
a.Owner == self.Owner && a.Owner == self.Owner &&
!Reservable.IsReserved(a)); !Reservable.IsReserved(a));
} }
@@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits.Activities
if (dest == null) if (dest == null)
return Util.SequenceActivities( return Util.SequenceActivities(
new Turn(self.Info.InitialFacing), new Turn(self.LegacyInfo.InitialFacing),
new HeliLand(true), new HeliLand(true),
NextActivity); NextActivity);
@@ -34,12 +34,12 @@ namespace OpenRa.Game.Traits.Activities
if (res != null) if (res != null)
self.traits.Get<Helicopter>().reservation = res.Reserve(self); self.traits.Get<Helicopter>().reservation = res.Reserve(self);
var offset = (dest.Info as LegacyBuildingInfo).SpawnOffset; var offset = (dest.LegacyInfo as LegacyBuildingInfo).SpawnOffset;
var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero; var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero;
return Util.SequenceActivities( return Util.SequenceActivities(
new HeliFly(dest.CenterLocation + offsetVec), new HeliFly(dest.CenterLocation + offsetVec),
new Turn(self.Info.InitialFacing), new Turn(self.LegacyInfo.InitialFacing),
new HeliLand(false), new HeliLand(false),
new Rearm(), new Rearm(),
NextActivity); NextActivity);

View File

@@ -28,7 +28,7 @@ namespace OpenRa.Game.Traits.Activities
--unit.Altitude; --unit.Altitude;
var desiredFacing = Util.GetFacing(d, unit.Facing); var desiredFacing = Util.GetFacing(d, unit.Facing);
Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.ROT); Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT);
var speed = .2f * Util.GetEffectiveSpeed(self); var speed = .2f * Util.GetEffectiveSpeed(self);
var angle = unit.Facing / 128f * Math.PI; var angle = unit.Facing / 128f * Math.PI;

View File

@@ -16,8 +16,8 @@ namespace OpenRa.Game.Traits.Activities
if (isCanceled) return NextActivity; if (isCanceled) return NextActivity;
if (remainingTicks == 0) if (remainingTicks == 0)
{ {
var costPerHp = (Rules.General.URepairPercent * self.Info.Cost) / self.Info.Strength; var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength;
var hpToRepair = Math.Min(Rules.General.URepairStep, self.Info.Strength - self.Health); var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health);
var cost = (int)Math.Ceiling(costPerHp * hpToRepair); var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
if (!self.Owner.TakeCash(cost)) if (!self.Owner.TakeCash(cost))
{ {
@@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits.Activities
} }
self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]);
if (self.Health == self.Info.Strength) if (self.Health == self.LegacyInfo.Strength)
return NextActivity; return NextActivity;
var hostBuilding = Game.FindUnits(self.CenterLocation, self.CenterLocation) var hostBuilding = Game.FindUnits(self.CenterLocation, self.CenterLocation)

View File

@@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities
Actor ChooseAirfield(Actor self) Actor ChooseAirfield(Actor self)
{ {
var airfield = Game.world.Actors var airfield = Game.world.Actors
.Where(a => a.Info == Rules.UnitInfo["AFLD"] /* todo: generalize this */ .Where(a => a.LegacyInfo == Rules.UnitInfo["AFLD"] /* todo: generalize this */
&& a.Owner == self.Owner && a.Owner == self.Owner
&& !Reservable.IsReserved(a)) && !Reservable.IsReserved(a))
.FirstOrDefault(); .FirstOrDefault();
@@ -41,7 +41,7 @@ namespace OpenRa.Game.Traits.Activities
var unit = self.traits.Get<Unit>(); var unit = self.traits.Get<Unit>();
var speed = .2f * Util.GetEffectiveSpeed(self); var speed = .2f * Util.GetEffectiveSpeed(self);
var approachStart = landPos - new float2(unit.Altitude * speed, 0); var approachStart = landPos - new float2(unit.Altitude * speed, 0);
var turnRadius = (128f / self.Info.ROT) * speed / (float)Math.PI; var turnRadius = (128f / self.LegacyInfo.ROT) * speed / (float)Math.PI;
/* work out the center points */ /* work out the center points */
var fwd = -float2.FromAngle(unit.Facing / 128f * (float)Math.PI); var fwd = -float2.FromAngle(unit.Facing / 128f * (float)Math.PI);

View File

@@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities
void DoSell(Actor self) void DoSell(Actor self)
{ {
var refund = Rules.General.RefundPercent var refund = Rules.General.RefundPercent
* self.Health * self.Info.Cost / self.Info.Strength; * self.Health * self.LegacyInfo.Cost / self.LegacyInfo.Strength;
self.Owner.GiveCash((int)refund); self.Owner.GiveCash((int)refund);
self.Health = 0; self.Health = 0;

View File

@@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities
if( desiredFacing == unit.Facing ) if( desiredFacing == unit.Facing )
return NextActivity; return NextActivity;
Util.TickFacing( ref unit.Facing, desiredFacing, self.Info.ROT ); Util.TickFacing( ref unit.Facing, desiredFacing, self.LegacyInfo.ROT );
return this; return this;
} }

View File

@@ -33,8 +33,8 @@ namespace OpenRa.Game.Traits.Activities
// if we're a thing that can turn, turn to the // if we're a thing that can turn, turn to the
// right facing for the unload animation // right facing for the unload animation
var unit = self.traits.GetOrDefault<Unit>(); var unit = self.traits.GetOrDefault<Unit>();
if (unit != null && unit.Facing != self.Info.UnloadFacing) if (unit != null && unit.Facing != self.LegacyInfo.UnloadFacing)
return new Turn(self.Info.UnloadFacing) { NextActivity = this }; return new Turn(self.LegacyInfo.UnloadFacing) { NextActivity = this };
// todo: handle the BS of open/close sequences, which are inconsistent, // todo: handle the BS of open/close sequences, which are inconsistent,
// for reasons that probably make good sense to the westwood guys. // for reasons that probably make good sense to the westwood guys.

View File

@@ -28,8 +28,8 @@ namespace OpenRa.Game.Traits
public AttackBase(Actor self) public AttackBase(Actor self)
{ {
var primaryWeapon = self.Info.Primary != null ? Rules.WeaponInfo[self.Info.Primary] : null; var primaryWeapon = self.LegacyInfo.Primary != null ? Rules.WeaponInfo[self.LegacyInfo.Primary] : null;
var secondaryWeapon = self.Info.Secondary != null ? Rules.WeaponInfo[self.Info.Secondary] : null; var secondaryWeapon = self.LegacyInfo.Secondary != null ? Rules.WeaponInfo[self.LegacyInfo.Secondary] : null;
primaryBurst = primaryWeapon != null ? primaryWeapon.Burst : 1; primaryBurst = primaryWeapon != null ? primaryWeapon.Burst : 1;
secondaryBurst = secondaryWeapon != null ? secondaryWeapon.Burst : 1; secondaryBurst = secondaryWeapon != null ? secondaryWeapon.Burst : 1;
@@ -79,18 +79,18 @@ namespace OpenRa.Game.Traits
{ {
var unit = self.traits.GetOrDefault<Unit>(); var unit = self.traits.GetOrDefault<Unit>();
if (self.Info.Primary != null && CheckFire(self, unit, self.Info.Primary, ref primaryFireDelay, if (self.LegacyInfo.Primary != null && CheckFire(self, unit, self.LegacyInfo.Primary, ref primaryFireDelay,
self.Info.PrimaryOffset, ref primaryBurst, self.Info.PrimaryLocalOffset)) self.LegacyInfo.PrimaryOffset, ref primaryBurst, self.LegacyInfo.PrimaryLocalOffset))
{ {
secondaryFireDelay = Math.Max(4, secondaryFireDelay); secondaryFireDelay = Math.Max(4, secondaryFireDelay);
primaryRecoil = 1; primaryRecoil = 1;
return; return;
} }
if (self.Info.Secondary != null && CheckFire(self, unit, self.Info.Secondary, ref secondaryFireDelay, if (self.LegacyInfo.Secondary != null && CheckFire(self, unit, self.LegacyInfo.Secondary, ref secondaryFireDelay,
self.Info.SecondaryOffset ?? self.Info.PrimaryOffset, ref secondaryBurst, self.Info.SecondaryLocalOffset)) self.LegacyInfo.SecondaryOffset ?? self.LegacyInfo.PrimaryOffset, ref secondaryBurst, self.LegacyInfo.SecondaryLocalOffset))
{ {
if (self.Info.SecondaryOffset != null) secondaryRecoil = 1; if (self.LegacyInfo.SecondaryOffset != null) secondaryRecoil = 1;
else primaryRecoil = 1; else primaryRecoil = 1;
return; return;
} }
@@ -132,7 +132,7 @@ namespace OpenRa.Game.Traits
var thisTarget = target; // closure. var thisTarget = target; // closure.
var destUnit = thisTarget.traits.GetOrDefault<Unit>(); var destUnit = thisTarget.traits.GetOrDefault<Unit>();
ScheduleDelayedAction(self.Info.FireDelay, () => ScheduleDelayedAction(self.LegacyInfo.FireDelay, () =>
{ {
var srcAltitude = unit != null ? unit.Altitude : 0; var srcAltitude = unit != null ? unit.Altitude : 0;
var destAltitude = destUnit != null ? destUnit.Altitude : 0; var destAltitude = destUnit != null ? destUnit.Altitude : 0;
@@ -166,7 +166,7 @@ namespace OpenRa.Game.Traits
{ {
if (mi.Button == MouseButton.Left || underCursor == null) return null; if (mi.Button == MouseButton.Left || underCursor == null) return null;
if (self == underCursor) return null; if (self == underCursor) return null;
var isHeal = Rules.WeaponInfo[self.Info.Primary].Damage < 0; var isHeal = Rules.WeaponInfo[self.LegacyInfo.Primary].Damage < 0;
if (((underCursor.Owner == self.Owner) ^ isHeal) if (((underCursor.Owner == self.Owner) ^ isHeal)
&& !mi.Modifiers.HasModifier( Modifiers.Ctrl )) return null; && !mi.Modifiers.HasModifier( Modifiers.Ctrl )) return null;
if (!Combat.HasAnyValidWeapons(self, underCursor)) return null; if (!Combat.HasAnyValidWeapons(self, underCursor)) return null;
@@ -191,7 +191,7 @@ namespace OpenRa.Game.Traits
{ {
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */ const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
/* todo: choose the appropriate weapon, when only one works against this target */ /* todo: choose the appropriate weapon, when only one works against this target */
var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary; var weapon = order.Subject.LegacyInfo.Primary ?? order.Subject.LegacyInfo.Secondary;
self.QueueActivity(new Activities.Attack(order.TargetActor, self.QueueActivity(new Activities.Attack(order.TargetActor,
Math.Max(0, (int)Rules.WeaponInfo[weapon].Range - RangeTolerance))); Math.Max(0, (int)Rules.WeaponInfo[weapon].Range - RangeTolerance)));

View File

@@ -36,7 +36,7 @@ namespace OpenRa.Game.Traits
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */ const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
/* todo: choose the appropriate weapon, when only one works against this target */ /* todo: choose the appropriate weapon, when only one works against this target */
var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary; var weapon = order.Subject.LegacyInfo.Primary ?? order.Subject.LegacyInfo.Secondary;
if (self.traits.Contains<Mobile>()) if (self.traits.Contains<Mobile>())
self.QueueActivity( new Traits.Activities.Follow( order.TargetActor, self.QueueActivity( new Traits.Activities.Follow( order.TargetActor,

View File

@@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits
float GetMaximumRange(Actor self) float GetMaximumRange(Actor self)
{ {
return new[] { self.Info.Primary, self.Info.Secondary } return new[] { self.LegacyInfo.Primary, self.LegacyInfo.Secondary }
.Where(w => w != null) .Where(w => w != null)
.Max(w => Rules.WeaponInfo[w].Range); .Max(w => Rules.WeaponInfo[w].Range);
} }
@@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits
return true; // he's dead. return true; // he's dead.
if ((attack.target.Location - self.Location).LengthSquared > range * range + 2) if ((attack.target.Location - self.Location).LengthSquared > range * range + 2)
return true; // wandered off faster than we could follow return true; // wandered off faster than we could follow
if (attack.target.Health == attack.target.Info.Strength) if (attack.target.Health == attack.target.LegacyInfo.Strength)
return true; // fully healed return true; // fully healed
return false; return false;
@@ -55,7 +55,7 @@ namespace OpenRa.Game.Traits
return inRange return inRange
.Where(a => a.Owner == self.Owner && a != self) /* todo: one day deal with friendly players */ .Where(a => a.Owner == self.Owner && a != self) /* todo: one day deal with friendly players */
.Where(a => Combat.HasAnyValidWeapons(self, a)) .Where(a => Combat.HasAnyValidWeapons(self, a))
.Where(a => a.Health < a.Info.Strength) .Where(a => a.Health < a.LegacyInfo.Strength)
.OrderBy(a => (a.Location - self.Location).LengthSquared) .OrderBy(a => (a.Location - self.Location).LengthSquared)
.FirstOrDefault(); .FirstOrDefault();
} }

View File

@@ -15,7 +15,7 @@ namespace OpenRa.Game.Traits
float GetMaximumRange(Actor self) float GetMaximumRange(Actor self)
{ {
return new[] { self.Info.Primary, self.Info.Secondary } return new[] { self.LegacyInfo.Primary, self.LegacyInfo.Secondary }
.Where(w => w != null) .Where(w => w != null)
.Max(w => Rules.WeaponInfo[w].Range); .Max(w => Rules.WeaponInfo[w].Range);
} }

View File

@@ -29,7 +29,7 @@ namespace OpenRa.Game.Traits
public Building(Actor self) public Building(Actor self)
{ {
this.self = self; this.self = self;
unitInfo = (LegacyBuildingInfo)self.Info; unitInfo = (LegacyBuildingInfo)self.LegacyInfo;
self.CenterLocation = Game.CellSize self.CenterLocation = Game.CellSize
* ((float2)self.Location + .5f * (float2)unitInfo.Dimensions); * ((float2)self.Location + .5f * (float2)unitInfo.Dimensions);
} }
@@ -84,8 +84,8 @@ namespace OpenRa.Game.Traits
if (remainingTicks == 0) if (remainingTicks == 0)
{ {
var costPerHp = (Rules.General.URepairPercent * self.Info.Cost) / self.Info.Strength; var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength;
var hpToRepair = Math.Min(Rules.General.URepairStep, self.Info.Strength - self.Health); var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health);
var cost = (int)Math.Ceiling(costPerHp * hpToRepair); var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
if (!self.Owner.TakeCash(cost)) if (!self.Owner.TakeCash(cost))
{ {
@@ -95,7 +95,7 @@ namespace OpenRa.Game.Traits
Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self))); Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self)));
self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]);
if (self.Health == self.Info.Strength) if (self.Health == self.LegacyInfo.Strength)
{ {
isRepairing = false; isRepairing = false;
return; return;

View File

@@ -46,7 +46,7 @@ namespace OpenRa.Game.Traits
public bool IsFull(Actor self) public bool IsFull(Actor self)
{ {
return cargo.Count == self.Info.Passengers; return cargo.Count == self.LegacyInfo.Passengers;
} }
public bool IsEmpty(Actor self) public bool IsEmpty(Actor self)
@@ -63,7 +63,7 @@ namespace OpenRa.Game.Traits
public IEnumerable<PipType> GetPips( Actor self ) public IEnumerable<PipType> GetPips( Actor self )
{ {
for (var i = 0; i < self.Info.Passengers; i++) for (var i = 0; i < self.LegacyInfo.Passengers; i++)
if (i >= cargo.Count) if (i >= cargo.Count)
yield return PipType.Transparent; yield return PipType.Transparent;
else else

View File

@@ -44,7 +44,7 @@ namespace OpenRa.Game.Traits
int2 detonateLocation = self.CenterLocation.ToInt2(); int2 detonateLocation = self.CenterLocation.ToInt2();
Game.world.AddFrameEndTask( Game.world.AddFrameEndTask(
w => w.Add(new Bullet(self.Info.Primary, detonatedBy.Owner, detonatedBy, w => w.Add(new Bullet(self.LegacyInfo.Primary, detonatedBy.Owner, detonatedBy,
detonateLocation, detonateLocation, altitude, altitude))); detonateLocation, detonateLocation, altitude, altitude)));
} }
} }

View File

@@ -20,8 +20,8 @@ namespace OpenRa.Game.Traits
// todo: push into data! // todo: push into data!
static bool HeliCanEnter(Actor a) static bool HeliCanEnter(Actor a)
{ {
if (a.Info == Rules.UnitInfo["HPAD"]) return true; if (a.LegacyInfo == Rules.UnitInfo["HPAD"]) return true;
if (a.Info == Rules.UnitInfo["FIX"]) return true; if (a.LegacyInfo == Rules.UnitInfo["FIX"]) return true;
return false; return false;
} }
@@ -52,7 +52,7 @@ namespace OpenRa.Game.Traits
{ {
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation))); self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation)));
self.QueueActivity(new Turn(self.Info.InitialFacing)); self.QueueActivity(new Turn(self.LegacyInfo.InitialFacing));
self.QueueActivity(new HeliLand(true)); self.QueueActivity(new HeliLand(true));
} }
@@ -63,14 +63,14 @@ namespace OpenRa.Game.Traits
if (res != null) if (res != null)
reservation = res.Reserve(self); reservation = res.Reserve(self);
var offset = (order.TargetActor.Info as LegacyBuildingInfo).SpawnOffset; var offset = (order.TargetActor.LegacyInfo as LegacyBuildingInfo).SpawnOffset;
var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero; var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero;
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new HeliFly(order.TargetActor.CenterLocation + offsetVec)); self.QueueActivity(new HeliFly(order.TargetActor.CenterLocation + offsetVec));
self.QueueActivity(new Turn(self.Info.InitialFacing)); self.QueueActivity(new Turn(self.LegacyInfo.InitialFacing));
self.QueueActivity(new HeliLand(false)); self.QueueActivity(new HeliLand(false));
self.QueueActivity(order.TargetActor.Info == Rules.UnitInfo["HPAD"] self.QueueActivity(order.TargetActor.LegacyInfo == Rules.UnitInfo["HPAD"]
? (IActivity)new Rearm() : new Repair()); ? (IActivity)new Rearm() : new Repair());
} }
} }

View File

@@ -17,14 +17,14 @@ namespace OpenRa.Game.Traits
public LimitedAmmo(Actor self) public LimitedAmmo(Actor self)
{ {
ammo = self.Info.Ammo; ammo = self.LegacyInfo.Ammo;
this.self = self; this.self = self;
} }
public bool HasAmmo() { return ammo > 0; } public bool HasAmmo() { return ammo > 0; }
public bool GiveAmmo() public bool GiveAmmo()
{ {
if (ammo >= self.Info.Ammo) return false; if (ammo >= self.LegacyInfo.Ammo) return false;
++ammo; ++ammo;
return true; return true;
} }
@@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits
public IEnumerable<PipType> GetPips(Actor self) public IEnumerable<PipType> GetPips(Actor self)
{ {
return Graphics.Util.MakeArray(self.Info.Ammo, return Graphics.Util.MakeArray(self.LegacyInfo.Ammo,
i => ammo > i ? PipType.Green : PipType.Transparent); i => ammo > i ? PipType.Green : PipType.Transparent);
} }
} }

View File

@@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits
// todo: delay a bit? (req making deploy-mine an activity) // todo: delay a bit? (req making deploy-mine an activity)
Game.world.AddFrameEndTask( Game.world.AddFrameEndTask(
w => w.Add(new Actor(Rules.UnitInfo[self.Info.Primary], self.Location, self.Owner))); w => w.Add(new Actor(Rules.UnitInfo[self.LegacyInfo.Primary], self.Location, self.Owner)));
} }
} }
} }

View File

@@ -87,12 +87,12 @@ namespace OpenRa.Game.Traits
public UnitMovementType GetMovementType() public UnitMovementType GetMovementType()
{ {
switch (Rules.UnitCategory[self.Info.Name]) switch (Rules.UnitCategory[self.LegacyInfo.Name])
{ {
case "Infantry": case "Infantry":
return UnitMovementType.Foot; return UnitMovementType.Foot;
case "Vehicle": case "Vehicle":
return (self.Info as VehicleInfo).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel; return (self.LegacyInfo as VehicleInfo).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel;
case "Ship": case "Ship":
return UnitMovementType.Float; return UnitMovementType.Float;
case "Plane": case "Plane":

View File

@@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits
return null; return null;
var umt = self.traits.WithInterface<IMovement>().First().GetMovementType(); var umt = self.traits.WithInterface<IMovement>().First().GetMovementType();
if (!underCursor.Info.PassengerTypes.Contains(umt)) if (!underCursor.LegacyInfo.PassengerTypes.Contains(umt))
return null; return null;
return new Order("EnterTransport", self, underCursor, int2.Zero, null); return new Order("EnterTransport", self, underCursor, int2.Zero, null);

View File

@@ -20,8 +20,8 @@ namespace OpenRa.Game.Traits
// todo: push into data! // todo: push into data!
static bool PlaneCanEnter(Actor a) static bool PlaneCanEnter(Actor a)
{ {
if (a.Info == Rules.UnitInfo["AFLD"]) return true; if (a.LegacyInfo == Rules.UnitInfo["AFLD"]) return true;
if (a.Info == Rules.UnitInfo["FIX"]) return true; if (a.LegacyInfo == Rules.UnitInfo["FIX"]) return true;
return false; return false;
} }
@@ -64,7 +64,7 @@ namespace OpenRa.Game.Traits
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new ReturnToBase(self, order.TargetActor)); self.QueueActivity(new ReturnToBase(self, order.TargetActor));
self.QueueActivity(order.TargetActor.Info == Rules.UnitInfo["AFLD"] self.QueueActivity(order.TargetActor.LegacyInfo == Rules.UnitInfo["AFLD"]
? (IActivity)new Rearm() : new Repair()); ? (IActivity)new Rearm() : new Repair());
} }
} }

View File

@@ -23,7 +23,7 @@ namespace OpenRa.Game.Traits
public virtual int CreationFacing( Actor self, Actor newUnit ) public virtual int CreationFacing( Actor self, Actor newUnit )
{ {
return newUnit.Info.InitialFacing; return newUnit.LegacyInfo.InitialFacing;
} }
public bool Produce( Actor self, LegacyUnitInfo producee ) public bool Produce( Actor self, LegacyUnitInfo producee )
@@ -43,7 +43,7 @@ namespace OpenRa.Game.Traits
newUnit.QueueActivity( new Activities.Move( rp.rallyPoint, 1 ) ); newUnit.QueueActivity( new Activities.Move( rp.rallyPoint, 1 ) );
} }
var bi = self.Info as LegacyBuildingInfo; var bi = self.LegacyInfo as LegacyBuildingInfo;
if (bi != null && bi.SpawnOffset != null) if (bi != null && bi.SpawnOffset != null)
newUnit.CenterLocation = self.CenterLocation newUnit.CenterLocation = self.CenterLocation
+ new float2(bi.SpawnOffset[0], bi.SpawnOffset[1]); + new float2(bi.SpawnOffset[0], bi.SpawnOffset[1]);
@@ -83,12 +83,12 @@ namespace OpenRa.Game.Traits
} }
// Cancel existing primaries // Cancel existing primaries
foreach (var p in (self.Info as LegacyBuildingInfo).Produces) foreach (var p in (self.LegacyInfo as LegacyBuildingInfo).Produces)
{ {
foreach (var b in Game.world.Actors.Where(x => x.traits.Contains<Production>() foreach (var b in Game.world.Actors.Where(x => x.traits.Contains<Production>()
&& x.Owner == self.Owner && x.Owner == self.Owner
&& x.traits.Get<Production>().IsPrimary == true && x.traits.Get<Production>().IsPrimary == true
&& (x.Info as LegacyBuildingInfo).Produces.Contains(p))) && (x.LegacyInfo as LegacyBuildingInfo).Produces.Contains(p)))
{ {
b.traits.Get<Production>().SetPrimaryProducer(b, false); b.traits.Get<Production>().SetPrimaryProducer(b, false);
} }

View File

@@ -133,7 +133,7 @@ namespace OpenRa.Game.Traits
// Prioritise primary structure in build order // Prioritise primary structure in build order
var primaryProducers = Game.world.Actors var primaryProducers = Game.world.Actors
.Where(x => x.traits.Contains<Production>() .Where(x => x.traits.Contains<Production>()
&& producerTypes.Contains(x.Info) && producerTypes.Contains(x.LegacyInfo)
&& x.Owner == self.Owner && x.Owner == self.Owner
&& x.traits.Get<Production>().IsPrimary == true); && x.traits.Get<Production>().IsPrimary == true);
@@ -153,7 +153,7 @@ namespace OpenRa.Game.Traits
if (producer == null) if (producer == null)
{ {
producer = Game.world.Actors producer = Game.world.Actors
.Where( x => producerTypes.Contains( x.Info ) && x.Owner == self.Owner ) .Where( x => producerTypes.Contains( x.LegacyInfo ) && x.Owner == self.Owner )
.FirstOrDefault(); .FirstOrDefault();
} }

View File

@@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits
public RenderWarFactory(Actor self) public RenderWarFactory(Actor self)
{ {
this.self = self; this.self = self;
roof = new Animation(self.Info.Image ?? self.Info.Name); roof = new Animation(self.LegacyInfo.Image ?? self.LegacyInfo.Name);
} }
public void BuildingComplete( Actor self ) public void BuildingComplete( Actor self )

View File

@@ -18,7 +18,7 @@ namespace OpenRa.Game.Traits
public RenderSimple(Actor self) public RenderSimple(Actor self)
{ {
anims.Add( "", new Animation( self.Info.Image ?? self.Info.Name ) ); anims.Add( "", new Animation( self.LegacyInfo.Image ?? self.LegacyInfo.Name ) );
} }
public virtual IEnumerable<Renderable> Render( Actor self ) public virtual IEnumerable<Renderable> Render( Actor self )

View File

@@ -15,17 +15,17 @@ namespace OpenRa.Game.Traits
public RenderUnitMuzzleFlash(Actor self) public RenderUnitMuzzleFlash(Actor self)
: base(self) : base(self)
{ {
if (!self.Info.MuzzleFlash) throw new InvalidOperationException("wtf??"); if (!self.LegacyInfo.MuzzleFlash) throw new InvalidOperationException("wtf??");
var unit = self.traits.Get<Unit>(); var unit = self.traits.Get<Unit>();
var attack = self.traits.WithInterface<AttackBase>().First(); var attack = self.traits.WithInterface<AttackBase>().First();
var muzzleFlash = new Animation(self.Info.Name); var muzzleFlash = new Animation(self.LegacyInfo.Name);
muzzleFlash.PlayFetchIndex("muzzle", muzzleFlash.PlayFetchIndex("muzzle",
() => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f)); () => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f));
anims.Add( "muzzle", new AnimationWithOffset( anims.Add( "muzzle", new AnimationWithOffset(
muzzleFlash, muzzleFlash,
() => self.Info.PrimaryOffset.AbsOffset(), () => self.LegacyInfo.PrimaryOffset.AbsOffset(),
() => attack.primaryRecoil <= 0 ) ); () => attack.primaryRecoil <= 0 ) );
} }
} }

View File

@@ -16,20 +16,20 @@ namespace OpenRa.Game.Traits
{ {
var unit = self.traits.Get<Unit>(); var unit = self.traits.Get<Unit>();
rotorAnim = new Animation(self.Info.Name); rotorAnim = new Animation(self.LegacyInfo.Name);
rotorAnim.PlayRepeating("rotor"); rotorAnim.PlayRepeating("rotor");
anims.Add( "rotor_1", new AnimationWithOffset( anims.Add( "rotor_1", new AnimationWithOffset(
rotorAnim, rotorAnim,
() => Util.GetTurretPosition( self, unit, self.Info.RotorOffset, 0 ), () => Util.GetTurretPosition( self, unit, self.LegacyInfo.RotorOffset, 0 ),
null ) ); null ) );
if (self.Info.RotorOffset2 == null) return; if (self.LegacyInfo.RotorOffset2 == null) return;
secondRotorAnim = new Animation( self.Info.Name ); secondRotorAnim = new Animation( self.LegacyInfo.Name );
secondRotorAnim.PlayRepeating( "rotor2" ); secondRotorAnim.PlayRepeating( "rotor2" );
anims.Add( "rotor_2", new AnimationWithOffset( anims.Add( "rotor_2", new AnimationWithOffset(
secondRotorAnim, secondRotorAnim,
() => Util.GetTurretPosition(self, unit, self.Info.RotorOffset2, 0), () => Util.GetTurretPosition(self, unit, self.LegacyInfo.RotorOffset2, 0),
null ) ); null ) );
} }

View File

@@ -15,11 +15,11 @@ namespace OpenRa.Game.Traits
{ {
var unit = self.traits.Get<Unit>(); var unit = self.traits.Get<Unit>();
var spinnerAnim = new Animation( self.Info.Name ); var spinnerAnim = new Animation( self.LegacyInfo.Name );
spinnerAnim.PlayRepeating( "spinner" ); spinnerAnim.PlayRepeating( "spinner" );
anims.Add( "spinner", new AnimationWithOffset( anims.Add( "spinner", new AnimationWithOffset(
spinnerAnim, spinnerAnim,
() => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, 0 ), () => Util.GetTurretPosition( self, unit, self.LegacyInfo.PrimaryOffset, 0 ),
null ) ); null ) );
} }
} }

View File

@@ -18,30 +18,30 @@ namespace OpenRa.Game.Traits
var turreted = self.traits.Get<Turreted>(); var turreted = self.traits.Get<Turreted>();
var attack = self.traits.WithInterface<AttackBase>().FirstOrDefault(); var attack = self.traits.WithInterface<AttackBase>().FirstOrDefault();
var turretAnim = new Animation(self.Info.Name); var turretAnim = new Animation(self.LegacyInfo.Name);
turretAnim.PlayFacing( "turret", () => turreted.turretFacing ); turretAnim.PlayFacing( "turret", () => turreted.turretFacing );
if( self.Info.PrimaryOffset != null ) if( self.LegacyInfo.PrimaryOffset != null )
anims.Add("turret_1", new AnimationWithOffset( anims.Add("turret_1", new AnimationWithOffset(
turretAnim, turretAnim,
() => Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, attack.primaryRecoil), () => Util.GetTurretPosition(self, unit, self.LegacyInfo.PrimaryOffset, attack.primaryRecoil),
null) { ZOffset = 1 }); null) { ZOffset = 1 });
if( self.Info.SecondaryOffset != null ) if( self.LegacyInfo.SecondaryOffset != null )
anims.Add("turret_2", new AnimationWithOffset( anims.Add("turret_2", new AnimationWithOffset(
turretAnim, turretAnim,
() => Util.GetTurretPosition(self, unit, self.Info.SecondaryOffset, attack.secondaryRecoil), () => Util.GetTurretPosition(self, unit, self.LegacyInfo.SecondaryOffset, attack.secondaryRecoil),
null) { ZOffset = 1 }); null) { ZOffset = 1 });
if( self.Info.MuzzleFlash ) if( self.LegacyInfo.MuzzleFlash )
{ {
var muzzleFlash = new Animation( self.Info.Name ); var muzzleFlash = new Animation( self.LegacyInfo.Name );
muzzleFlash.PlayFetchIndex( "muzzle", muzzleFlash.PlayFetchIndex( "muzzle",
() => ( Util.QuantizeFacing( self.traits.Get<Turreted>().turretFacing, 8 ) ) * 6 () => ( Util.QuantizeFacing( self.traits.Get<Turreted>().turretFacing, 8 ) ) * 6
+ (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */ + (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */
anims.Add( "muzzle_flash", new AnimationWithOffset( anims.Add( "muzzle_flash", new AnimationWithOffset(
muzzleFlash, muzzleFlash,
() => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, attack.primaryRecoil ), () => Util.GetTurretPosition( self, unit, self.LegacyInfo.PrimaryOffset, attack.primaryRecoil ),
() => attack.primaryRecoil <= 0 ) ); () => attack.primaryRecoil <= 0 ) );
} }
} }

View File

@@ -21,7 +21,7 @@ namespace OpenRa.Game.Traits
if (mi.Button != MouseButton.Right) return null; if (mi.Button != MouseButton.Right) return null;
if (underCursor == null) return null; if (underCursor == null) return null;
if (underCursor.Info == Rules.UnitInfo["FIX"] if (underCursor.LegacyInfo == Rules.UnitInfo["FIX"]
&& underCursor.Owner == self.Owner && underCursor.Owner == self.Owner
&& !Reservable.IsReserved(underCursor)) && !Reservable.IsReserved(underCursor))
return new Order("Enter", self, underCursor, int2.Zero, null); return new Order("Enter", self, underCursor, int2.Zero, null);

View File

@@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits
public void OnSteal(Actor self, Actor thief) public void OnSteal(Actor self, Actor thief)
{ {
// Steal half the ore the building holds // Steal half the ore the building holds
var toSteal = (self.Info as LegacyBuildingInfo).Storage/2; var toSteal = (self.LegacyInfo as LegacyBuildingInfo).Storage/2;
self.Owner.TakeCash(toSteal); self.Owner.TakeCash(toSteal);
thief.Owner.GiveCash(toSteal); thief.Owner.GiveCash(toSteal);
@@ -28,9 +28,9 @@ namespace OpenRa.Game.Traits
public IEnumerable<PipType> GetPips(Actor self) public IEnumerable<PipType> GetPips(Actor self)
{ {
for (int i = 0; i < self.Info.OrePips; i++) for (int i = 0; i < self.LegacyInfo.OrePips; i++)
{ {
if (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / self.Info.OrePips) if (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / self.LegacyInfo.OrePips)
{ {
yield return PipType.Yellow; yield return PipType.Yellow;
continue; continue;

View File

@@ -14,13 +14,13 @@ namespace OpenRa.Game.Traits
public Turreted(Actor self) public Turreted(Actor self)
{ {
turretFacing = self.Info.InitialFacing; turretFacing = self.LegacyInfo.InitialFacing;
} }
public void Tick( Actor self ) public void Tick( Actor self )
{ {
var df = desiredFacing ?? ( self.traits.Contains<Unit>() ? self.traits.Get<Unit>().Facing : turretFacing ); var df = desiredFacing ?? ( self.traits.Contains<Unit>() ? self.traits.Get<Unit>().Facing : turretFacing );
Util.TickFacing( ref turretFacing, df, self.Info.ROT ); Util.TickFacing( ref turretFacing, df, self.LegacyInfo.ROT );
} }
} }
} }

View File

@@ -82,14 +82,14 @@ namespace OpenRa.Game.Traits
static float2 GetRecoil(Actor self, float recoil) static float2 GetRecoil(Actor self, float recoil)
{ {
if (self.Info.Recoil == 0) return float2.Zero; if (self.LegacyInfo.Recoil == 0) return float2.Zero;
var rut = self.traits.WithInterface<RenderUnitTurreted>().FirstOrDefault(); var rut = self.traits.WithInterface<RenderUnitTurreted>().FirstOrDefault();
if (rut == null) return float2.Zero; if (rut == null) return float2.Zero;
var facing = self.traits.Get<Turreted>().turretFacing; var facing = self.traits.Get<Turreted>().turretFacing;
var quantizedFacing = QuantizeFacing(facing, rut.anim.CurrentSequence.Length) * (256 / rut.anim.CurrentSequence.Length); var quantizedFacing = QuantizeFacing(facing, rut.anim.CurrentSequence.Length) * (256 / rut.anim.CurrentSequence.Length);
return RotateVectorByFacing(new float2(0, recoil * self.Info.Recoil), quantizedFacing, .7f); return RotateVectorByFacing(new float2(0, recoil * self.LegacyInfo.Recoil), quantizedFacing, .7f);
} }
public static float2 CenterOfCell(int2 loc) public static float2 CenterOfCell(int2 loc)
@@ -127,7 +127,7 @@ namespace OpenRa.Game.Traits
public static float GetEffectiveSpeed(Actor self) public static float GetEffectiveSpeed(Actor self)
{ {
var mi = self.Info as LegacyMobileInfo; var mi = self.LegacyInfo as LegacyMobileInfo;
if (mi == null) return 0f; if (mi == null) return 0f;
var modifier = self.traits var modifier = self.traits

View File

@@ -36,7 +36,7 @@ namespace OpenRa.Game
var crusher = GetUnitsAt(cell).Where(b => a != b && Game.IsActorCrushableByActor(a, b)).FirstOrDefault(); var crusher = GetUnitsAt(cell).Where(b => a != b && Game.IsActorCrushableByActor(a, b)).FirstOrDefault();
if (crusher != null) if (crusher != null)
{ {
Log.Write("{0} crushes {1}", crusher.Info.Name, a.Info.Name); Log.Write("{0} crushes {1}", crusher.LegacyInfo.Name, a.LegacyInfo.Name);
// Apply the crush action // Apply the crush action
foreach (var crush in a.traits.WithInterface<ICrushable>()) foreach (var crush in a.traits.WithInterface<ICrushable>())
crush.OnCrush(crusher); crush.OnCrush(crusher);