From 99a61ca8d92a78f42e5844925b3f58e36cdf28b0 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 18:28:24 +1300 Subject: [PATCH] renamed Info to LegacyInfo, marked Obsolete. added NewUnitInfo ref as Info. --- OpenRa.Game/Actor.cs | 35 +++++++++++-------- OpenRa.Game/Combat.cs | 14 ++++---- OpenRa.Game/Effects/Corpse.cs | 2 +- OpenRa.Game/Game.cs | 8 ++--- OpenRa.Game/GameRules/TechTree.cs | 4 +-- OpenRa.Game/Graphics/Viewport.cs | 2 +- OpenRa.Game/Graphics/WorldRenderer.cs | 2 +- .../ChronosphereSelectOrderGenerator.cs | 4 +-- .../Orders/IronCurtainOrderGenerator.cs | 4 +-- OpenRa.Game/Orders/PowerDownOrderGenerator.cs | 4 +-- OpenRa.Game/Orders/RepairOrderGenerator.cs | 4 +-- OpenRa.Game/Orders/SellOrderGenerator.cs | 4 +-- OpenRa.Game/Player.cs | 2 +- OpenRa.Game/Shroud.cs | 2 +- OpenRa.Game/Sound.cs | 2 +- .../Traits/Activities/CaptureBuilding.cs | 2 +- OpenRa.Game/Traits/Activities/Fly.cs | 2 +- OpenRa.Game/Traits/Activities/HeliAttack.cs | 4 +-- OpenRa.Game/Traits/Activities/HeliFly.cs | 2 +- OpenRa.Game/Traits/Activities/HeliReturn.cs | 8 ++--- OpenRa.Game/Traits/Activities/Land.cs | 2 +- OpenRa.Game/Traits/Activities/Repair.cs | 6 ++-- OpenRa.Game/Traits/Activities/ReturnToBase.cs | 4 +-- OpenRa.Game/Traits/Activities/Sell.cs | 2 +- OpenRa.Game/Traits/Activities/Turn.cs | 2 +- OpenRa.Game/Traits/Activities/UnloadCargo.cs | 4 +-- OpenRa.Game/Traits/AttackBase.cs | 20 +++++------ OpenRa.Game/Traits/AttackTurreted.cs | 2 +- OpenRa.Game/Traits/AutoHeal.cs | 6 ++-- OpenRa.Game/Traits/AutoTarget.cs | 2 +- OpenRa.Game/Traits/Building.cs | 8 ++--- OpenRa.Game/Traits/Cargo.cs | 4 +-- OpenRa.Game/Traits/DemoTruck.cs | 2 +- OpenRa.Game/Traits/Helicopter.cs | 12 +++---- OpenRa.Game/Traits/LimitedAmmo.cs | 6 ++-- OpenRa.Game/Traits/Minelayer.cs | 2 +- OpenRa.Game/Traits/Mobile.cs | 4 +-- OpenRa.Game/Traits/Passenger.cs | 2 +- OpenRa.Game/Traits/Plane.cs | 6 ++-- OpenRa.Game/Traits/Production.cs | 8 ++--- OpenRa.Game/Traits/ProductionQueue.cs | 4 +-- .../Traits/RenderBuildingWarFactory.cs | 2 +- OpenRa.Game/Traits/RenderSimple.cs | 2 +- OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs | 6 ++-- OpenRa.Game/Traits/RenderUnitRotor.cs | 10 +++--- OpenRa.Game/Traits/RenderUnitSpinner.cs | 4 +-- OpenRa.Game/Traits/RenderUnitTurreted.cs | 16 ++++----- OpenRa.Game/Traits/Repairable.cs | 2 +- OpenRa.Game/Traits/StoresOre.cs | 6 ++-- OpenRa.Game/Traits/Turreted.cs | 4 +-- OpenRa.Game/Traits/Util.cs | 6 ++-- OpenRa.Game/UnitInfluenceMap.cs | 2 +- 52 files changed, 142 insertions(+), 137 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 95ec80365a..51b31518a2 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -12,7 +12,10 @@ namespace OpenRa.Game { [Sync] public readonly TypeDictionary traits = new TypeDictionary(); - public readonly LegacyUnitInfo Info; + + [Obsolete] + public readonly LegacyUnitInfo LegacyInfo; + public readonly NewUnitInfo Info; public readonly uint ActorID; [Sync] @@ -26,19 +29,21 @@ namespace OpenRa.Game public Actor( ActorInfo info, int2 location, Player owner ) { ActorID = Game.world.NextAID(); - Info = (LegacyUnitInfo)info; // temporary + LegacyInfo = (LegacyUnitInfo)info; // temporary Location = location; CenterLocation = Traits.Util.CenterOfCell(Location); 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 ) - throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(Info.Name) ); + if( LegacyInfo.Traits == null ) + 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()) + Info = Rules.NewUnitInfo[LegacyInfo.Name.ToLowerInvariant()]; + + foreach (var trait in Info.Traits.WithInterface()) traits.Add(trait.Create(this)); } @@ -65,8 +70,8 @@ namespace OpenRa.Game { get { - if (Info != null && Info.SelectionSize != null) - return new float2(Info.SelectionSize[0], Info.SelectionSize[1]); + if (LegacyInfo != null && LegacyInfo.SelectionSize != null) + return new float2(LegacyInfo.SelectionSize[0], LegacyInfo.SelectionSize[1]); var firstSprite = Render().FirstOrDefault(); if (firstSprite.Sprite == null) return float2.Zero; @@ -92,7 +97,7 @@ namespace OpenRa.Game var loc = mi.Location + Game.viewport.Location; var underCursor = Game.FindUnits(loc, loc).FirstOrDefault(); - if (underCursor != null && !underCursor.Info.Selectable) + if (underCursor != null && !underCursor.LegacyInfo.Selectable) underCursor = null; return traits.WithInterface() @@ -104,8 +109,8 @@ namespace OpenRa.Game { var size = SelectedSize; var loc = CenterLocation - 0.5f * size; - if (Info != null && Info.SelectionSize != null && Info.SelectionSize.Length > 2) - loc += new float2(Info.SelectionSize[2], Info.SelectionSize[3]); + if (LegacyInfo != null && LegacyInfo.SelectionSize != null && LegacyInfo.SelectionSize.Length > 2) + loc += new float2(LegacyInfo.SelectionSize[2], LegacyInfo.SelectionSize[3]); if (useAltitude) { @@ -122,7 +127,7 @@ namespace OpenRa.Game public DamageState GetDamageState() { 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; } @@ -145,8 +150,8 @@ namespace OpenRa.Game Game.world.AddFrameEndTask(w => w.Remove(this)); } - if (Health > Info.Strength) - Health = Info.Strength; + if (Health > LegacyInfo.Strength) + Health = LegacyInfo.Strength; var newState = GetDamageState(); diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index b6cb373754..e8100a5495 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -49,7 +49,7 @@ namespace OpenRa.Game var distance = (target.CenterLocation - loc).Length*1/24f; 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; } @@ -59,7 +59,7 @@ namespace OpenRa.Game var warhead = Rules.WarheadInfo[weapon.Warhead]; var unit = target.traits.GetOrDefault(); - if (warhead.EffectivenessAgainst(target.Info.Armor) <= 0) + if (warhead.EffectivenessAgainst(target.LegacyInfo.Armor) <= 0) return false; if (target.traits.Contains()) @@ -68,7 +68,7 @@ namespace OpenRa.Game if (unit != null && unit.Altitude > 0) return projectile.AA; - if (projectile.UnderWater && !target.Info.WaterBound) + if (projectile.UnderWater && !target.LegacyInfo.WaterBound) return false; return projectile.AG; @@ -76,10 +76,10 @@ namespace OpenRa.Game public static bool HasAnyValidWeapons(Actor self, Actor target) { - if (self.Info.Primary != null && - WeaponValidForTarget(Rules.WeaponInfo[self.Info.Primary], target)) return true; - if (self.Info.Secondary != null && - WeaponValidForTarget(Rules.WeaponInfo[self.Info.Secondary], target)) return true; + if (self.LegacyInfo.Primary != null && + WeaponValidForTarget(Rules.WeaponInfo[self.LegacyInfo.Primary], target)) return true; + if (self.LegacyInfo.Secondary != null && + WeaponValidForTarget(Rules.WeaponInfo[self.LegacyInfo.Secondary], target)) return true; return false; } diff --git a/OpenRa.Game/Effects/Corpse.cs b/OpenRa.Game/Effects/Corpse.cs index efdbf8cb4c..f37a1116b3 100755 --- a/OpenRa.Game/Effects/Corpse.cs +++ b/OpenRa.Game/Effects/Corpse.cs @@ -15,7 +15,7 @@ namespace OpenRa.Game.Effects 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), () => Game.world.AddFrameEndTask(w => w.Remove(this))); diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 1fa4fac1ac..38b24f3c4c 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -61,7 +61,7 @@ namespace OpenRa.Game world = new World(); Game.world.ActorAdded += a => { - if (a.Owner != null && a.Info != null) + if (a.Owner != null && a.LegacyInfo != null) a.Owner.Shroud.Explore(a); }; @@ -310,8 +310,8 @@ namespace OpenRa.Game public static IEnumerable SelectActorsInBox(float2 a, float2 b) { return FindUnits(a, b) - .Where( x => x.Info.Selectable ) - .GroupBy(x => (x.Owner == LocalPlayer) ? x.Info.SelectionPriority : 0) + .Where( x => x.LegacyInfo.Selectable ) + .GroupBy(x => (x.Owner == LocalPlayer) ? x.LegacyInfo.SelectionPriority : 0) .OrderByDescending(g => g.Key) .Select( g => g.AsEnumerable() ) .DefaultIfEmpty( new Actor[] {} ) @@ -338,7 +338,7 @@ namespace OpenRa.Game heuristic = 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) return float.PositiveInfinity; /* not quite right */ return 1; diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 8e8253f782..c732f7819d 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -21,8 +21,8 @@ namespace OpenRa.Game.GameRules public Cache> GatherBuildings( Player player ) { var ret = new Cache>( x => new List() ); - foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info is LegacyBuildingInfo ) ) - ret[ b.Info.Name ].Add( b ); + foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.LegacyInfo is LegacyBuildingInfo ) ) + ret[ b.LegacyInfo.Name ].Add( b ); return ret; } diff --git a/OpenRa.Game/Graphics/Viewport.cs b/OpenRa.Game/Graphics/Viewport.cs index 9a35a4ef5b..5af11ba1d5 100644 --- a/OpenRa.Game/Graphics/Viewport.cs +++ b/OpenRa.Game/Graphics/Viewport.cs @@ -97,7 +97,7 @@ namespace OpenRa.Game.Graphics 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)); } } } diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index 1060f5467a..4223cb2de1 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -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); - var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Strength; + var healthAmount = (float)selectedUnit.Health / selectedUnit.LegacyInfo.Strength; var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red : (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow : Color.LimeGreen; diff --git a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs index b4a013b15a..889965abbc 100644 --- a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs +++ b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs @@ -31,9 +31,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.WithInterface().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) yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, power.Name); diff --git a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs index 57f9870c5a..a33d67587e 100644 --- a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs +++ b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs @@ -31,9 +31,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && 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) yield return new Order("IronCurtain", underCursor, null, int2.Zero, power.Name); diff --git a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs index 5a33cbf1d0..2bfbb12359 100644 --- a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs +++ b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs @@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && 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) yield return new Order("PowerDown", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Orders/RepairOrderGenerator.cs b/OpenRa.Game/Orders/RepairOrderGenerator.cs index 84da77c725..3d87fe6b6d 100644 --- a/OpenRa.Game/Orders/RepairOrderGenerator.cs +++ b/OpenRa.Game/Orders/RepairOrderGenerator.cs @@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && 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) yield return new Order("Repair", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Orders/SellOrderGenerator.cs b/OpenRa.Game/Orders/SellOrderGenerator.cs index c46b459d55..b74c3b79cb 100644 --- a/OpenRa.Game/Orders/SellOrderGenerator.cs +++ b/OpenRa.Game/Orders/SellOrderGenerator.cs @@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && 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) yield return new Order("Sell", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index 9a162aa067..9e3d335b31 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -84,7 +84,7 @@ namespace OpenRa.Game { OreCapacity = Game.world.Actors .Where(a => a.Owner == this && a.traits.Contains()) - .Select(a => a.Info as LegacyBuildingInfo) + .Select(a => a.LegacyInfo as LegacyBuildingInfo) .Where(b => b != null) .Sum(b => b.Storage); } diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index 697e774406..18dab2724d 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -32,7 +32,7 @@ namespace OpenRa.Game 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; dirty = true; diff --git a/OpenRa.Game/Sound.cs b/OpenRa.Game/Sound.cs index 84c637fa02..f3dea39130 100644 --- a/OpenRa.Game/Sound.cs +++ b/OpenRa.Game/Sound.cs @@ -92,7 +92,7 @@ namespace OpenRa.Game { if (voicedUnit == null) return; - var mi = voicedUnit.Info as LegacyMobileInfo; + var mi = voicedUnit.LegacyInfo as LegacyMobileInfo; if (mi == null) return; var vi = Rules.VoiceInfo[mi.Voice]; diff --git a/OpenRa.Game/Traits/Activities/CaptureBuilding.cs b/OpenRa.Game/Traits/Activities/CaptureBuilding.cs index 6cb033960c..66fa2fdf5a 100644 --- a/OpenRa.Game/Traits/Activities/CaptureBuilding.cs +++ b/OpenRa.Game/Traits/Activities/CaptureBuilding.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities if (target.Owner == self.Owner) { - if (target.Health == target.Info.Strength) + if (target.Health == target.LegacyInfo.Strength) return NextActivity; target.InflictDamage(self, -EngineerCapture.EngineerDamage, Rules.WarheadInfo["Super"]); } diff --git a/OpenRa.Game/Traits/Activities/Fly.cs b/OpenRa.Game/Traits/Activities/Fly.cs index 4f7a4241f7..cae1f43899 100644 --- a/OpenRa.Game/Traits/Activities/Fly.cs +++ b/OpenRa.Game/Traits/Activities/Fly.cs @@ -31,7 +31,7 @@ namespace OpenRa.Game.Traits.Activities var desiredFacing = Util.GetFacing(d, unit.Facing); 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 angle = unit.Facing / 128f * Math.PI; diff --git a/OpenRa.Game/Traits/Activities/HeliAttack.cs b/OpenRa.Game/Traits/Activities/HeliAttack.cs index 65c6f44ef3..1a50596e64 100644 --- a/OpenRa.Game/Traits/Activities/HeliAttack.cs +++ b/OpenRa.Game/Traits/Activities/HeliAttack.cs @@ -30,11 +30,11 @@ namespace OpenRa.Game.Traits.Activities 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 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)) { diff --git a/OpenRa.Game/Traits/Activities/HeliFly.cs b/OpenRa.Game/Traits/Activities/HeliFly.cs index 4f9fb658c6..fd1ac6aa50 100644 --- a/OpenRa.Game/Traits/Activities/HeliFly.cs +++ b/OpenRa.Game/Traits/Activities/HeliFly.cs @@ -39,7 +39,7 @@ namespace OpenRa.Game.Traits.Activities } 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); self.CenterLocation += (rawSpeed / dist.Length) * dist; diff --git a/OpenRa.Game/Traits/Activities/HeliReturn.cs b/OpenRa.Game/Traits/Activities/HeliReturn.cs index 6a26fc918b..dcaf9f7f3b 100644 --- a/OpenRa.Game/Traits/Activities/HeliReturn.cs +++ b/OpenRa.Game/Traits/Activities/HeliReturn.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities static Actor ChooseHelipad(Actor self) { return Game.world.Actors.FirstOrDefault( - a => a.Info == Rules.UnitInfo["HPAD"] && + a => a.LegacyInfo == Rules.UnitInfo["HPAD"] && a.Owner == self.Owner && !Reservable.IsReserved(a)); } @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits.Activities if (dest == null) return Util.SequenceActivities( - new Turn(self.Info.InitialFacing), + new Turn(self.LegacyInfo.InitialFacing), new HeliLand(true), NextActivity); @@ -34,12 +34,12 @@ namespace OpenRa.Game.Traits.Activities if (res != null) self.traits.Get().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; return Util.SequenceActivities( new HeliFly(dest.CenterLocation + offsetVec), - new Turn(self.Info.InitialFacing), + new Turn(self.LegacyInfo.InitialFacing), new HeliLand(false), new Rearm(), NextActivity); diff --git a/OpenRa.Game/Traits/Activities/Land.cs b/OpenRa.Game/Traits/Activities/Land.cs index 5c4cf06ea5..5f99dd6b19 100644 --- a/OpenRa.Game/Traits/Activities/Land.cs +++ b/OpenRa.Game/Traits/Activities/Land.cs @@ -28,7 +28,7 @@ namespace OpenRa.Game.Traits.Activities --unit.Altitude; 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 angle = unit.Facing / 128f * Math.PI; diff --git a/OpenRa.Game/Traits/Activities/Repair.cs b/OpenRa.Game/Traits/Activities/Repair.cs index 63f6e1fd92..f6fcf06b59 100644 --- a/OpenRa.Game/Traits/Activities/Repair.cs +++ b/OpenRa.Game/Traits/Activities/Repair.cs @@ -16,8 +16,8 @@ namespace OpenRa.Game.Traits.Activities if (isCanceled) return NextActivity; if (remainingTicks == 0) { - var costPerHp = (Rules.General.URepairPercent * self.Info.Cost) / self.Info.Strength; - var hpToRepair = Math.Min(Rules.General.URepairStep, self.Info.Strength - self.Health); + var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength; + var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health); var cost = (int)Math.Ceiling(costPerHp * hpToRepair); if (!self.Owner.TakeCash(cost)) { @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits.Activities } self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); - if (self.Health == self.Info.Strength) + if (self.Health == self.LegacyInfo.Strength) return NextActivity; var hostBuilding = Game.FindUnits(self.CenterLocation, self.CenterLocation) diff --git a/OpenRa.Game/Traits/Activities/ReturnToBase.cs b/OpenRa.Game/Traits/Activities/ReturnToBase.cs index 29aad3bc5d..75715798ea 100644 --- a/OpenRa.Game/Traits/Activities/ReturnToBase.cs +++ b/OpenRa.Game/Traits/Activities/ReturnToBase.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities Actor ChooseAirfield(Actor self) { 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 && !Reservable.IsReserved(a)) .FirstOrDefault(); @@ -41,7 +41,7 @@ namespace OpenRa.Game.Traits.Activities var unit = self.traits.Get(); var speed = .2f * Util.GetEffectiveSpeed(self); 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 */ var fwd = -float2.FromAngle(unit.Facing / 128f * (float)Math.PI); diff --git a/OpenRa.Game/Traits/Activities/Sell.cs b/OpenRa.Game/Traits/Activities/Sell.cs index 109d93785a..330e69692b 100644 --- a/OpenRa.Game/Traits/Activities/Sell.cs +++ b/OpenRa.Game/Traits/Activities/Sell.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities void DoSell(Actor self) { 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.Health = 0; diff --git a/OpenRa.Game/Traits/Activities/Turn.cs b/OpenRa.Game/Traits/Activities/Turn.cs index 1b81859e31..4750cc7574 100755 --- a/OpenRa.Game/Traits/Activities/Turn.cs +++ b/OpenRa.Game/Traits/Activities/Turn.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities if( desiredFacing == unit.Facing ) return NextActivity; - Util.TickFacing( ref unit.Facing, desiredFacing, self.Info.ROT ); + Util.TickFacing( ref unit.Facing, desiredFacing, self.LegacyInfo.ROT ); return this; } diff --git a/OpenRa.Game/Traits/Activities/UnloadCargo.cs b/OpenRa.Game/Traits/Activities/UnloadCargo.cs index b0af980ab5..ff2c8d6fcb 100644 --- a/OpenRa.Game/Traits/Activities/UnloadCargo.cs +++ b/OpenRa.Game/Traits/Activities/UnloadCargo.cs @@ -33,8 +33,8 @@ namespace OpenRa.Game.Traits.Activities // if we're a thing that can turn, turn to the // right facing for the unload animation var unit = self.traits.GetOrDefault(); - if (unit != null && unit.Facing != self.Info.UnloadFacing) - return new Turn(self.Info.UnloadFacing) { NextActivity = this }; + if (unit != null && unit.Facing != self.LegacyInfo.UnloadFacing) + return new Turn(self.LegacyInfo.UnloadFacing) { NextActivity = this }; // todo: handle the BS of open/close sequences, which are inconsistent, // for reasons that probably make good sense to the westwood guys. diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 4b99833445..2e38d3dc15 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -28,8 +28,8 @@ namespace OpenRa.Game.Traits public AttackBase(Actor self) { - var primaryWeapon = self.Info.Primary != null ? Rules.WeaponInfo[self.Info.Primary] : null; - var secondaryWeapon = self.Info.Secondary != null ? Rules.WeaponInfo[self.Info.Secondary] : null; + var primaryWeapon = self.LegacyInfo.Primary != null ? Rules.WeaponInfo[self.LegacyInfo.Primary] : null; + var secondaryWeapon = self.LegacyInfo.Secondary != null ? Rules.WeaponInfo[self.LegacyInfo.Secondary] : null; primaryBurst = primaryWeapon != null ? primaryWeapon.Burst : 1; secondaryBurst = secondaryWeapon != null ? secondaryWeapon.Burst : 1; @@ -79,18 +79,18 @@ namespace OpenRa.Game.Traits { var unit = self.traits.GetOrDefault(); - if (self.Info.Primary != null && CheckFire(self, unit, self.Info.Primary, ref primaryFireDelay, - self.Info.PrimaryOffset, ref primaryBurst, self.Info.PrimaryLocalOffset)) + if (self.LegacyInfo.Primary != null && CheckFire(self, unit, self.LegacyInfo.Primary, ref primaryFireDelay, + self.LegacyInfo.PrimaryOffset, ref primaryBurst, self.LegacyInfo.PrimaryLocalOffset)) { secondaryFireDelay = Math.Max(4, secondaryFireDelay); primaryRecoil = 1; return; } - if (self.Info.Secondary != null && CheckFire(self, unit, self.Info.Secondary, ref secondaryFireDelay, - self.Info.SecondaryOffset ?? self.Info.PrimaryOffset, ref secondaryBurst, self.Info.SecondaryLocalOffset)) + if (self.LegacyInfo.Secondary != null && CheckFire(self, unit, self.LegacyInfo.Secondary, ref secondaryFireDelay, + 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; return; } @@ -132,7 +132,7 @@ namespace OpenRa.Game.Traits var thisTarget = target; // closure. var destUnit = thisTarget.traits.GetOrDefault(); - ScheduleDelayedAction(self.Info.FireDelay, () => + ScheduleDelayedAction(self.LegacyInfo.FireDelay, () => { var srcAltitude = unit != null ? unit.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 (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) && !mi.Modifiers.HasModifier( Modifiers.Ctrl )) 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 */ /* 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, Math.Max(0, (int)Rules.WeaponInfo[weapon].Range - RangeTolerance))); diff --git a/OpenRa.Game/Traits/AttackTurreted.cs b/OpenRa.Game/Traits/AttackTurreted.cs index dff7ff4001..c8305e192c 100755 --- a/OpenRa.Game/Traits/AttackTurreted.cs +++ b/OpenRa.Game/Traits/AttackTurreted.cs @@ -36,7 +36,7 @@ namespace OpenRa.Game.Traits 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 */ - var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary; + var weapon = order.Subject.LegacyInfo.Primary ?? order.Subject.LegacyInfo.Secondary; if (self.traits.Contains()) self.QueueActivity( new Traits.Activities.Follow( order.TargetActor, diff --git a/OpenRa.Game/Traits/AutoHeal.cs b/OpenRa.Game/Traits/AutoHeal.cs index eb882df245..a833cc8c25 100644 --- a/OpenRa.Game/Traits/AutoHeal.cs +++ b/OpenRa.Game/Traits/AutoHeal.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits float GetMaximumRange(Actor self) { - return new[] { self.Info.Primary, self.Info.Secondary } + return new[] { self.LegacyInfo.Primary, self.LegacyInfo.Secondary } .Where(w => w != null) .Max(w => Rules.WeaponInfo[w].Range); } @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits return true; // he's dead. if ((attack.target.Location - self.Location).LengthSquared > range * range + 2) 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 false; @@ -55,7 +55,7 @@ namespace OpenRa.Game.Traits return inRange .Where(a => a.Owner == self.Owner && a != self) /* todo: one day deal with friendly players */ .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) .FirstOrDefault(); } diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index 0906fac297..f247ca218a 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -15,7 +15,7 @@ namespace OpenRa.Game.Traits float GetMaximumRange(Actor self) { - return new[] { self.Info.Primary, self.Info.Secondary } + return new[] { self.LegacyInfo.Primary, self.LegacyInfo.Secondary } .Where(w => w != null) .Max(w => Rules.WeaponInfo[w].Range); } diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index 2e7b204008..934f2c8156 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -29,7 +29,7 @@ namespace OpenRa.Game.Traits public Building(Actor self) { this.self = self; - unitInfo = (LegacyBuildingInfo)self.Info; + unitInfo = (LegacyBuildingInfo)self.LegacyInfo; self.CenterLocation = Game.CellSize * ((float2)self.Location + .5f * (float2)unitInfo.Dimensions); } @@ -84,8 +84,8 @@ namespace OpenRa.Game.Traits if (remainingTicks == 0) { - var costPerHp = (Rules.General.URepairPercent * self.Info.Cost) / self.Info.Strength; - var hpToRepair = Math.Min(Rules.General.URepairStep, self.Info.Strength - self.Health); + var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength; + var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health); var cost = (int)Math.Ceiling(costPerHp * hpToRepair); if (!self.Owner.TakeCash(cost)) { @@ -95,7 +95,7 @@ namespace OpenRa.Game.Traits Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self))); self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); - if (self.Health == self.Info.Strength) + if (self.Health == self.LegacyInfo.Strength) { isRepairing = false; return; diff --git a/OpenRa.Game/Traits/Cargo.cs b/OpenRa.Game/Traits/Cargo.cs index d9798efd0c..87bcb94e65 100644 --- a/OpenRa.Game/Traits/Cargo.cs +++ b/OpenRa.Game/Traits/Cargo.cs @@ -46,7 +46,7 @@ namespace OpenRa.Game.Traits public bool IsFull(Actor self) { - return cargo.Count == self.Info.Passengers; + return cargo.Count == self.LegacyInfo.Passengers; } public bool IsEmpty(Actor self) @@ -63,7 +63,7 @@ namespace OpenRa.Game.Traits public IEnumerable 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) yield return PipType.Transparent; else diff --git a/OpenRa.Game/Traits/DemoTruck.cs b/OpenRa.Game/Traits/DemoTruck.cs index 2659a3bb3e..6cc66b11b1 100644 --- a/OpenRa.Game/Traits/DemoTruck.cs +++ b/OpenRa.Game/Traits/DemoTruck.cs @@ -44,7 +44,7 @@ namespace OpenRa.Game.Traits int2 detonateLocation = self.CenterLocation.ToInt2(); 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))); } } diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 8477103c63..4773133a30 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -20,8 +20,8 @@ namespace OpenRa.Game.Traits // todo: push into data! static bool HeliCanEnter(Actor a) { - if (a.Info == Rules.UnitInfo["HPAD"]) return true; - if (a.Info == Rules.UnitInfo["FIX"]) return true; + if (a.LegacyInfo == Rules.UnitInfo["HPAD"]) return true; + if (a.LegacyInfo == Rules.UnitInfo["FIX"]) return true; return false; } @@ -52,7 +52,7 @@ namespace OpenRa.Game.Traits { self.CancelActivity(); 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)); } @@ -63,14 +63,14 @@ namespace OpenRa.Game.Traits if (res != null) 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; self.CancelActivity(); 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(order.TargetActor.Info == Rules.UnitInfo["HPAD"] + self.QueueActivity(order.TargetActor.LegacyInfo == Rules.UnitInfo["HPAD"] ? (IActivity)new Rearm() : new Repair()); } } diff --git a/OpenRa.Game/Traits/LimitedAmmo.cs b/OpenRa.Game/Traits/LimitedAmmo.cs index e2c5cc0797..3e8536b948 100644 --- a/OpenRa.Game/Traits/LimitedAmmo.cs +++ b/OpenRa.Game/Traits/LimitedAmmo.cs @@ -17,14 +17,14 @@ namespace OpenRa.Game.Traits public LimitedAmmo(Actor self) { - ammo = self.Info.Ammo; + ammo = self.LegacyInfo.Ammo; this.self = self; } public bool HasAmmo() { return ammo > 0; } public bool GiveAmmo() { - if (ammo >= self.Info.Ammo) return false; + if (ammo >= self.LegacyInfo.Ammo) return false; ++ammo; return true; } @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips(Actor self) { - return Graphics.Util.MakeArray(self.Info.Ammo, + return Graphics.Util.MakeArray(self.LegacyInfo.Ammo, i => ammo > i ? PipType.Green : PipType.Transparent); } } diff --git a/OpenRa.Game/Traits/Minelayer.cs b/OpenRa.Game/Traits/Minelayer.cs index 1012998d5e..cc590269c7 100644 --- a/OpenRa.Game/Traits/Minelayer.cs +++ b/OpenRa.Game/Traits/Minelayer.cs @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits // todo: delay a bit? (req making deploy-mine an activity) 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))); } } } diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 0e0efe835b..febe071a7c 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -87,12 +87,12 @@ namespace OpenRa.Game.Traits public UnitMovementType GetMovementType() { - switch (Rules.UnitCategory[self.Info.Name]) + switch (Rules.UnitCategory[self.LegacyInfo.Name]) { case "Infantry": return UnitMovementType.Foot; case "Vehicle": - return (self.Info as VehicleInfo).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel; + return (self.LegacyInfo as VehicleInfo).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel; case "Ship": return UnitMovementType.Float; case "Plane": diff --git a/OpenRa.Game/Traits/Passenger.cs b/OpenRa.Game/Traits/Passenger.cs index 7a7305a060..ecf4a42a5a 100644 --- a/OpenRa.Game/Traits/Passenger.cs +++ b/OpenRa.Game/Traits/Passenger.cs @@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits return null; var umt = self.traits.WithInterface().First().GetMovementType(); - if (!underCursor.Info.PassengerTypes.Contains(umt)) + if (!underCursor.LegacyInfo.PassengerTypes.Contains(umt)) return null; return new Order("EnterTransport", self, underCursor, int2.Zero, null); diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index 27030b4705..0733fcf541 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -20,8 +20,8 @@ namespace OpenRa.Game.Traits // todo: push into data! static bool PlaneCanEnter(Actor a) { - if (a.Info == Rules.UnitInfo["AFLD"]) return true; - if (a.Info == Rules.UnitInfo["FIX"]) return true; + if (a.LegacyInfo == Rules.UnitInfo["AFLD"]) return true; + if (a.LegacyInfo == Rules.UnitInfo["FIX"]) return true; return false; } @@ -64,7 +64,7 @@ namespace OpenRa.Game.Traits self.CancelActivity(); 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()); } } diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 1a6a270a94..b6b2481248 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -23,7 +23,7 @@ namespace OpenRa.Game.Traits public virtual int CreationFacing( Actor self, Actor newUnit ) { - return newUnit.Info.InitialFacing; + return newUnit.LegacyInfo.InitialFacing; } public bool Produce( Actor self, LegacyUnitInfo producee ) @@ -43,7 +43,7 @@ namespace OpenRa.Game.Traits 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) newUnit.CenterLocation = self.CenterLocation + new float2(bi.SpawnOffset[0], bi.SpawnOffset[1]); @@ -83,12 +83,12 @@ namespace OpenRa.Game.Traits } // 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() && x.Owner == self.Owner && x.traits.Get().IsPrimary == true - && (x.Info as LegacyBuildingInfo).Produces.Contains(p))) + && (x.LegacyInfo as LegacyBuildingInfo).Produces.Contains(p))) { b.traits.Get().SetPrimaryProducer(b, false); } diff --git a/OpenRa.Game/Traits/ProductionQueue.cs b/OpenRa.Game/Traits/ProductionQueue.cs index b5945c76ff..06340287dd 100755 --- a/OpenRa.Game/Traits/ProductionQueue.cs +++ b/OpenRa.Game/Traits/ProductionQueue.cs @@ -133,7 +133,7 @@ namespace OpenRa.Game.Traits // Prioritise primary structure in build order var primaryProducers = Game.world.Actors .Where(x => x.traits.Contains() - && producerTypes.Contains(x.Info) + && producerTypes.Contains(x.LegacyInfo) && x.Owner == self.Owner && x.traits.Get().IsPrimary == true); @@ -153,7 +153,7 @@ namespace OpenRa.Game.Traits if (producer == null) { 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(); } diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index aa33fe1c18..f55731579c 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits public RenderWarFactory(Actor 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 ) diff --git a/OpenRa.Game/Traits/RenderSimple.cs b/OpenRa.Game/Traits/RenderSimple.cs index 4eb4570dad..1b1ed3ff26 100644 --- a/OpenRa.Game/Traits/RenderSimple.cs +++ b/OpenRa.Game/Traits/RenderSimple.cs @@ -18,7 +18,7 @@ namespace OpenRa.Game.Traits 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 Render( Actor self ) diff --git a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs index d8beee320d..118abcbe18 100644 --- a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs +++ b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs @@ -15,17 +15,17 @@ namespace OpenRa.Game.Traits public RenderUnitMuzzleFlash(Actor self) : base(self) { - if (!self.Info.MuzzleFlash) throw new InvalidOperationException("wtf??"); + if (!self.LegacyInfo.MuzzleFlash) throw new InvalidOperationException("wtf??"); var unit = self.traits.Get(); var attack = self.traits.WithInterface().First(); - var muzzleFlash = new Animation(self.Info.Name); + var muzzleFlash = new Animation(self.LegacyInfo.Name); muzzleFlash.PlayFetchIndex("muzzle", () => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f)); anims.Add( "muzzle", new AnimationWithOffset( muzzleFlash, - () => self.Info.PrimaryOffset.AbsOffset(), + () => self.LegacyInfo.PrimaryOffset.AbsOffset(), () => attack.primaryRecoil <= 0 ) ); } } diff --git a/OpenRa.Game/Traits/RenderUnitRotor.cs b/OpenRa.Game/Traits/RenderUnitRotor.cs index 32ea23ad80..ef4f70431b 100755 --- a/OpenRa.Game/Traits/RenderUnitRotor.cs +++ b/OpenRa.Game/Traits/RenderUnitRotor.cs @@ -16,20 +16,20 @@ namespace OpenRa.Game.Traits { var unit = self.traits.Get(); - rotorAnim = new Animation(self.Info.Name); + rotorAnim = new Animation(self.LegacyInfo.Name); rotorAnim.PlayRepeating("rotor"); anims.Add( "rotor_1", new AnimationWithOffset( rotorAnim, - () => Util.GetTurretPosition( self, unit, self.Info.RotorOffset, 0 ), + () => Util.GetTurretPosition( self, unit, self.LegacyInfo.RotorOffset, 0 ), 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" ); anims.Add( "rotor_2", new AnimationWithOffset( secondRotorAnim, - () => Util.GetTurretPosition(self, unit, self.Info.RotorOffset2, 0), + () => Util.GetTurretPosition(self, unit, self.LegacyInfo.RotorOffset2, 0), null ) ); } diff --git a/OpenRa.Game/Traits/RenderUnitSpinner.cs b/OpenRa.Game/Traits/RenderUnitSpinner.cs index ab1212f97f..54794eb915 100755 --- a/OpenRa.Game/Traits/RenderUnitSpinner.cs +++ b/OpenRa.Game/Traits/RenderUnitSpinner.cs @@ -15,11 +15,11 @@ namespace OpenRa.Game.Traits { var unit = self.traits.Get(); - var spinnerAnim = new Animation( self.Info.Name ); + var spinnerAnim = new Animation( self.LegacyInfo.Name ); spinnerAnim.PlayRepeating( "spinner" ); anims.Add( "spinner", new AnimationWithOffset( spinnerAnim, - () => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, 0 ), + () => Util.GetTurretPosition( self, unit, self.LegacyInfo.PrimaryOffset, 0 ), null ) ); } } diff --git a/OpenRa.Game/Traits/RenderUnitTurreted.cs b/OpenRa.Game/Traits/RenderUnitTurreted.cs index e88d9fd29a..3aa1c94a9f 100644 --- a/OpenRa.Game/Traits/RenderUnitTurreted.cs +++ b/OpenRa.Game/Traits/RenderUnitTurreted.cs @@ -18,30 +18,30 @@ namespace OpenRa.Game.Traits var turreted = self.traits.Get(); var attack = self.traits.WithInterface().FirstOrDefault(); - var turretAnim = new Animation(self.Info.Name); + var turretAnim = new Animation(self.LegacyInfo.Name); turretAnim.PlayFacing( "turret", () => turreted.turretFacing ); - if( self.Info.PrimaryOffset != null ) + if( self.LegacyInfo.PrimaryOffset != null ) anims.Add("turret_1", new AnimationWithOffset( turretAnim, - () => Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, attack.primaryRecoil), + () => Util.GetTurretPosition(self, unit, self.LegacyInfo.PrimaryOffset, attack.primaryRecoil), null) { ZOffset = 1 }); - if( self.Info.SecondaryOffset != null ) + if( self.LegacyInfo.SecondaryOffset != null ) anims.Add("turret_2", new AnimationWithOffset( turretAnim, - () => Util.GetTurretPosition(self, unit, self.Info.SecondaryOffset, attack.secondaryRecoil), + () => Util.GetTurretPosition(self, unit, self.LegacyInfo.SecondaryOffset, attack.secondaryRecoil), 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", () => ( Util.QuantizeFacing( self.traits.Get().turretFacing, 8 ) ) * 6 + (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */ anims.Add( "muzzle_flash", new AnimationWithOffset( muzzleFlash, - () => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, attack.primaryRecoil ), + () => Util.GetTurretPosition( self, unit, self.LegacyInfo.PrimaryOffset, attack.primaryRecoil ), () => attack.primaryRecoil <= 0 ) ); } } diff --git a/OpenRa.Game/Traits/Repairable.cs b/OpenRa.Game/Traits/Repairable.cs index 7e75fd48ce..77de5d6e35 100644 --- a/OpenRa.Game/Traits/Repairable.cs +++ b/OpenRa.Game/Traits/Repairable.cs @@ -21,7 +21,7 @@ namespace OpenRa.Game.Traits if (mi.Button != MouseButton.Right) return null; if (underCursor == null) return null; - if (underCursor.Info == Rules.UnitInfo["FIX"] + if (underCursor.LegacyInfo == Rules.UnitInfo["FIX"] && underCursor.Owner == self.Owner && !Reservable.IsReserved(underCursor)) return new Order("Enter", self, underCursor, int2.Zero, null); diff --git a/OpenRa.Game/Traits/StoresOre.cs b/OpenRa.Game/Traits/StoresOre.cs index 5630ef83c3..67aa4af48d 100644 --- a/OpenRa.Game/Traits/StoresOre.cs +++ b/OpenRa.Game/Traits/StoresOre.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits public void OnSteal(Actor self, Actor thief) { // 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); thief.Owner.GiveCash(toSteal); @@ -28,9 +28,9 @@ namespace OpenRa.Game.Traits public IEnumerable 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; continue; diff --git a/OpenRa.Game/Traits/Turreted.cs b/OpenRa.Game/Traits/Turreted.cs index 0e2c7318d7..cacb90e7aa 100644 --- a/OpenRa.Game/Traits/Turreted.cs +++ b/OpenRa.Game/Traits/Turreted.cs @@ -14,13 +14,13 @@ namespace OpenRa.Game.Traits public Turreted(Actor self) { - turretFacing = self.Info.InitialFacing; + turretFacing = self.LegacyInfo.InitialFacing; } public void Tick( Actor self ) { var df = desiredFacing ?? ( self.traits.Contains() ? self.traits.Get().Facing : turretFacing ); - Util.TickFacing( ref turretFacing, df, self.Info.ROT ); + Util.TickFacing( ref turretFacing, df, self.LegacyInfo.ROT ); } } } diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index 3a71fb98ae..fda0a447a1 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -82,14 +82,14 @@ namespace OpenRa.Game.Traits 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().FirstOrDefault(); if (rut == null) return float2.Zero; var facing = self.traits.Get().turretFacing; 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) @@ -127,7 +127,7 @@ namespace OpenRa.Game.Traits public static float GetEffectiveSpeed(Actor self) { - var mi = self.Info as LegacyMobileInfo; + var mi = self.LegacyInfo as LegacyMobileInfo; if (mi == null) return 0f; var modifier = self.traits diff --git a/OpenRa.Game/UnitInfluenceMap.cs b/OpenRa.Game/UnitInfluenceMap.cs index 0982ea957d..6f50bf1dad 100644 --- a/OpenRa.Game/UnitInfluenceMap.cs +++ b/OpenRa.Game/UnitInfluenceMap.cs @@ -36,7 +36,7 @@ namespace OpenRa.Game var crusher = GetUnitsAt(cell).Where(b => a != b && Game.IsActorCrushableByActor(a, b)).FirstOrDefault(); 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 foreach (var crush in a.traits.WithInterface()) crush.OnCrush(crusher);