diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 7db4f217d8..56d7aaf44f 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -12,7 +12,7 @@ namespace OpenRa.Game class Actor { public readonly TypeDictionary traits = new TypeDictionary(); - public readonly UnitInfo unitInfo; + public readonly UnitInfo Info; public readonly uint ActorID; public int2 Location; @@ -20,18 +20,18 @@ namespace OpenRa.Game public int Health; IActivity currentActivity; - public Actor( string name, int2 location, Player owner ) + public Actor( ActorInfo info, int2 location, Player owner ) { ActorID = Game.world.NextAID(); - unitInfo = Rules.UnitInfo[ name ]; + Info = (UnitInfo)info; // temporary Location = location; CenterLocation = new float2( 12, 12 ) + Game.CellSize * (float2)Location; Owner = owner; - Health = unitInfo.Strength; /* todo: handle cases where this is not true! */ + Health = Info.Strength; /* todo: handle cases where this is not true! */ - if( unitInfo.Traits != null ) + if( Info.Traits != null ) { - foreach( var traitName in unitInfo.Traits ) + foreach( var traitName in Info.Traits ) { var type = typeof( Traits.Mobile ).Assembly.GetType( typeof( Traits.Mobile ).Namespace + "." + traitName, true, false ); var ctor = type.GetConstructor( new[] { typeof( Actor ) } ); @@ -39,7 +39,7 @@ namespace OpenRa.Game } } else - throw new InvalidOperationException( "No Actor traits for " + unitInfo.Name + throw new InvalidOperationException( "No Actor traits for " + Info.Name + "; add Traits= to units.ini for appropriate unit" ); } @@ -74,7 +74,7 @@ namespace OpenRa.Game var underCursor = Game.UnitInfluence.GetUnitAt( xy ) ?? Game.BuildingInfluence.GetBuildingAt( xy ); - if (underCursor != null && !underCursor.unitInfo.Selectable) + if (underCursor != null && !underCursor.Info.Selectable) underCursor = null; return traits.WithInterface() @@ -117,7 +117,7 @@ namespace OpenRa.Game Sound.Play("kaboom22.aud"); } - var halfStrength = unitInfo.Strength * Rules.General.ConditionYellow; + var halfStrength = Info.Strength * Rules.General.ConditionYellow; if (Health < halfStrength && (Health + damage) >= halfStrength) { /* we just went below half health! */ diff --git a/OpenRa.Game/Bullet.cs b/OpenRa.Game/Bullet.cs index 862d59d5d1..2b93c522a0 100644 --- a/OpenRa.Game/Bullet.cs +++ b/OpenRa.Game/Bullet.cs @@ -138,13 +138,10 @@ namespace OpenRa.Game float GetDamageToInflict(Actor target) { - if( target.unitInfo == null ) // tree or other doodad - return 0; - /* todo: some things can't be damaged AT ALL by certain weapons! */ var distance = (target.CenterLocation - Dest).Length; var rawDamage = Weapon.Damage * (float)Math.Exp(-distance / Warhead.Spread); - var multiplier = Warhead.EffectivenessAgainst(target.unitInfo.Armor); + var multiplier = Warhead.EffectivenessAgainst(target.Info.Armor); return rawDamage * multiplier; } diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 2472a49060..83c5abe1cf 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -71,7 +71,7 @@ namespace OpenRa.Game UnitInfluence = new UnitInfluenceMap(); foreach (TreeReference treeReference in Rules.Map.Trees) - world.Add(new Actor(treeReference.Image, + world.Add(new Actor(Rules.UnitInfo[treeReference.Image], new int2(treeReference.Location), null)); @@ -108,7 +108,7 @@ namespace OpenRa.Game //num=owner,type,health,location,facing,trigger,unknown,shouldRepair var parts = s.Value.ToLowerInvariant().Split(','); var loc = int.Parse(parts[3]); - world.Add(new Actor(parts[1], new int2(loc % 128, loc / 128), players[0])); + world.Add(new Actor(Rules.UnitInfo[parts[1]], new int2(loc % 128, loc / 128), players[0])); } } @@ -117,9 +117,9 @@ namespace OpenRa.Game foreach (var s in mapfile.GetSection("UNITS", true)) { //num=owner,type,health,location,facing,action,trigger - var parts = s.Value.Split(','); + var parts = s.Value.ToLowerInvariant().Split( ',' ); var loc = int.Parse(parts[3]); - world.Add(new Actor(parts[1].ToLowerInvariant(), new int2(loc % 128, loc / 128), + world.Add(new Actor(Rules.UnitInfo[parts[1]], new int2(loc % 128, loc / 128), players.Values.FirstOrDefault(p => p.PlayerName == parts[0]) ?? players[0])); } @@ -244,8 +244,8 @@ namespace OpenRa.Game public static IEnumerable SelectActorsInBox(float2 a, float2 b) { return FindUnits(a, b) - .Where( x => x.unitInfo.Selectable ) - .GroupBy(x => (x.Owner == LocalPlayer) ? x.unitInfo.SelectionPriority : 0) + .Where( x => x.Info.Selectable ) + .GroupBy(x => (x.Owner == LocalPlayer) ? x.Info.SelectionPriority : 0) .OrderByDescending(g => g.Key) .Select( g => g.AsEnumerable() ) .DefaultIfEmpty( new Actor[] {} ) @@ -315,7 +315,7 @@ namespace OpenRa.Game var producerTypes = Rules.TechTree.UnitBuiltAt( newUnitType ); // TODO: choose producer based on "primary building" var producer = world.Actors - .Where( x => producerTypes.Contains( x.unitInfo ) && x.Owner == player ) + .Where( x => producerTypes.Contains( x.Info ) && x.Owner == player ) .FirstOrDefault(); if (producer == null) diff --git a/OpenRa.Game/GameRules/ActorInfo.cs b/OpenRa.Game/GameRules/ActorInfo.cs new file mode 100755 index 0000000000..8dfd822d3e --- /dev/null +++ b/OpenRa.Game/GameRules/ActorInfo.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRa.Game.GameRules +{ + public class ActorInfo + { + } +} diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 6793affc68..463934796e 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.unitInfo is BuildingInfo ) ) - ret[ b.unitInfo.Name ].Add( b ); + foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info is BuildingInfo ) ) + ret[ b.Info.Name ].Add( b ); return ret; } diff --git a/OpenRa.Game/GameRules/UnitInfo.cs b/OpenRa.Game/GameRules/UnitInfo.cs index ad220b5452..3702978ddf 100755 --- a/OpenRa.Game/GameRules/UnitInfo.cs +++ b/OpenRa.Game/GameRules/UnitInfo.cs @@ -10,7 +10,7 @@ namespace OpenRa.Game.GameRules concrete = 4, } - public class UnitInfo + public class UnitInfo : ActorInfo { public readonly string Name; diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index b5aa8480dc..8b798853ba 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -116,7 +116,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.unitInfo.Strength; + var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Strength; var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red : (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow : Color.LimeGreen; diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 65a61c360d..f262a8333a 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -80,6 +80,7 @@ + diff --git a/OpenRa.Game/Sound.cs b/OpenRa.Game/Sound.cs index 8b48b6a3d7..7dbde0c6ba 100644 --- a/OpenRa.Game/Sound.cs +++ b/OpenRa.Game/Sound.cs @@ -40,7 +40,7 @@ namespace OpenRa.Game { if (voicedUnit == null) return; - var mi = voicedUnit.unitInfo as MobileInfo; + var mi = voicedUnit.Info as MobileInfo; if (mi == null) return; var vi = Rules.VoiceInfo[mi.Voice]; diff --git a/OpenRa.Game/Traits/AcceptsOre.cs b/OpenRa.Game/Traits/AcceptsOre.cs index d511d79dd2..49d6bc129a 100644 --- a/OpenRa.Game/Traits/AcceptsOre.cs +++ b/OpenRa.Game/Traits/AcceptsOre.cs @@ -9,7 +9,7 @@ namespace OpenRa.Game.Traits Game.world.AddFrameEndTask( w => { /* create the free harvester! */ - var harvester = new Actor("harv", self.Location + new int2(1, 2), self.Owner); + var harvester = new Actor(Rules.UnitInfo["harv"], self.Location + new int2(1, 2), self.Owner); var unit = harvester.traits.Get(); var mobile = harvester.traits.Get(); unit.Facing = 64; diff --git a/OpenRa.Game/Traits/Activities/DeployMcv.cs b/OpenRa.Game/Traits/Activities/DeployMcv.cs index 2957c8323d..2fb43ffd1a 100755 --- a/OpenRa.Game/Traits/Activities/DeployMcv.cs +++ b/OpenRa.Game/Traits/Activities/DeployMcv.cs @@ -11,7 +11,7 @@ namespace OpenRa.Game.Traits.Activities Game.world.AddFrameEndTask( _ => { Game.world.Remove( self ); - Game.world.Add( new Actor( "fact", self.Location - new int2( 1, 1 ), self.Owner ) ); + Game.world.Add( new Actor( Rules.UnitInfo["fact"], self.Location - new int2( 1, 1 ), self.Owner ) ); } ); return null; } diff --git a/OpenRa.Game/Traits/Activities/Move.cs b/OpenRa.Game/Traits/Activities/Move.cs index 0096c5e5e0..746906b44d 100755 --- a/OpenRa.Game/Traits/Activities/Move.cs +++ b/OpenRa.Game/Traits/Activities/Move.cs @@ -180,7 +180,7 @@ namespace OpenRa.Game.Traits.Activities var oldFraction = moveFraction; var oldTotal = moveFractionTotal; - moveFraction += ( self.unitInfo as MobileInfo ).Speed; + moveFraction += ( self.Info as MobileInfo ).Speed; UpdateCenterLocation( self, mobile ); if( moveFraction >= moveFractionTotal ) { diff --git a/OpenRa.Game/Traits/Activities/Turn.cs b/OpenRa.Game/Traits/Activities/Turn.cs index 3d79961729..53d22b822b 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.unitInfo.ROT ); + Util.TickFacing( ref unit.Facing, desiredFacing, self.Info.ROT ); return null; } diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 10d3e4550f..d1a241fa28 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -39,18 +39,18 @@ namespace OpenRa.Game.Traits { var unit = self.traits.Get(); - if (self.unitInfo.Primary != null && CheckFire(self, unit, self.unitInfo.Primary, ref primaryFireDelay, - self.unitInfo.PrimaryOffset)) + if (self.Info.Primary != null && CheckFire(self, unit, self.Info.Primary, ref primaryFireDelay, + self.Info.PrimaryOffset)) { secondaryFireDelay = Math.Max(4, secondaryFireDelay); primaryRecoil = 1; return; } - if (self.unitInfo.Secondary != null && CheckFire(self, unit, self.unitInfo.Secondary, ref secondaryFireDelay, - self.unitInfo.SecondaryOffset ?? self.unitInfo.PrimaryOffset)) + if (self.Info.Secondary != null && CheckFire(self, unit, self.Info.Secondary, ref secondaryFireDelay, + self.Info.SecondaryOffset ?? self.Info.PrimaryOffset)) { - if (self.unitInfo.SecondaryOffset != null) secondaryRecoil = 1; + if (self.Info.SecondaryOffset != null) secondaryRecoil = 1; else primaryRecoil = 1; return; } @@ -91,7 +91,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.unitInfo.Primary ?? order.Subject.unitInfo.Secondary; + var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary; self.QueueActivity(new Traits.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 cfa6a2d3da..8f89794166 100755 --- a/OpenRa.Game/Traits/AttackTurreted.cs +++ b/OpenRa.Game/Traits/AttackTurreted.cs @@ -24,7 +24,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.unitInfo.Primary ?? order.Subject.unitInfo.Secondary; + var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary; self.QueueActivity( new Traits.Activities.Follow( order.TargetActor, Math.Max( 0, (int)Rules.WeaponInfo[ weapon ].Range - RangeTolerance ) ) ); diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index 4b68e497d4..896b38a184 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -8,7 +8,7 @@ namespace OpenRa.Game.Traits public Building(Actor self) { - unitInfo = (BuildingInfo)self.unitInfo; + unitInfo = (BuildingInfo)self.Info; } bool first = true; diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index d20c0cf556..22a512f417 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -47,10 +47,10 @@ namespace OpenRa.Game.Traits var dist = Game.CellSize * (targetLocation + new float2(.5f,.5f)) - self.CenterLocation; var desiredFacing = Util.GetFacing(dist, unit.Facing); Util.TickFacing(ref unit.Facing, desiredFacing, - self.unitInfo.ROT); + self.Info.ROT); // .6f going the wrong way; .8f going sideways, 1f going forward. - var rawSpeed = .2f * (self.unitInfo as VehicleInfo).Speed; + var rawSpeed = .2f * (self.Info as VehicleInfo).Speed; var angle = (unit.Facing - desiredFacing) / 128f * Math.PI; var scale = .4f + .6f * (float)Math.Cos(angle); diff --git a/OpenRa.Game/Traits/InfantrySquad.cs b/OpenRa.Game/Traits/InfantrySquad.cs index 65c38c6c31..d159ceb1f8 100644 --- a/OpenRa.Game/Traits/InfantrySquad.cs +++ b/OpenRa.Game/Traits/InfantrySquad.cs @@ -19,9 +19,9 @@ namespace OpenRa.Game.Traits public InfantrySquad(Actor self) { - var ii = (InfantryInfo)self.unitInfo; + var ii = (InfantryInfo)self.Info; for (int i = 0; i < ii.SquadSize; i++) - elements.Add(new Soldier(self.unitInfo.Name, + elements.Add(new Soldier(self.Info.Name, self.CenterLocation.ToInt2() + elementOffsets[ii.SquadSize][i])); } diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 80048e2bbd..0f5f3721b2 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -52,12 +52,12 @@ namespace OpenRa.Game.Traits public UnitMovementType GetMovementType() { - switch( Rules.UnitCategory[ self.unitInfo.Name ] ) + switch( Rules.UnitCategory[ self.Info.Name ] ) { case "Infantry": return UnitMovementType.Foot; case "Vehicle": - return ( self.unitInfo as VehicleInfo ).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel; + return ( self.Info as VehicleInfo ).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel; case "Ship": return UnitMovementType.Float; case "Plane": diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 8dd5b75d1a..27fc22ad65 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -13,7 +13,7 @@ namespace OpenRa.Game.Traits public virtual int CreationFacing( Actor self, Actor newUnit ) { - return newUnit.unitInfo.InitialFacing; + return newUnit.Info.InitialFacing; } public bool Produce( Actor self, UnitInfo producee ) @@ -22,7 +22,7 @@ namespace OpenRa.Game.Traits if( location == null || Game.UnitInfluence.GetUnitAt( location.Value ) != null ) return false; - var newUnit = new Actor( producee.Name, location.Value, self.Owner ); + var newUnit = new Actor( producee, location.Value, self.Owner ); newUnit.traits.Get().Facing = CreationFacing( self, newUnit ); ; var rp = self.traits.GetOrDefault(); @@ -37,7 +37,7 @@ namespace OpenRa.Game.Traits heli.targetLocation = rp.rallyPoint; // TODO: make Activity.Move work for helis. } - var bi = self.unitInfo as BuildingInfo; + var bi = self.Info as BuildingInfo; if (bi != null && bi.SpawnOffset != null) newUnit.CenterLocation = self.CenterLocation + new float2(bi.SpawnOffset[0], bi.SpawnOffset[1]); diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index d0923938f8..10dd2e334c 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -16,7 +16,7 @@ namespace OpenRa.Game.Traits { this.self = self; - roof = new Animation(self.unitInfo.Image ?? self.unitInfo.Name); + roof = new Animation(self.Info.Image ?? self.Info.Name); Make( () => { doneBuilding = true; diff --git a/OpenRa.Game/Traits/RenderSimple.cs b/OpenRa.Game/Traits/RenderSimple.cs index 19a4481e91..dc82273fd6 100644 --- a/OpenRa.Game/Traits/RenderSimple.cs +++ b/OpenRa.Game/Traits/RenderSimple.cs @@ -9,7 +9,7 @@ namespace OpenRa.Game.Traits public RenderSimple(Actor self) { - anim = new Animation(self.unitInfo.Image ?? self.unitInfo.Name); + anim = new Animation(self.Info.Image ?? self.Info.Name); } public abstract IEnumerable> Render(Actor self); diff --git a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs index 4f5b86509e..5d5937d2bd 100644 --- a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs +++ b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs @@ -12,9 +12,9 @@ namespace OpenRa.Game.Traits public RenderUnitMuzzleFlash(Actor self) : base(self) { - if (!self.unitInfo.MuzzleFlash) throw new InvalidOperationException("wtf??"); + if (!self.Info.MuzzleFlash) throw new InvalidOperationException("wtf??"); - muzzleFlash = new Animation(self.unitInfo.Name); + muzzleFlash = new Animation(self.Info.Name); muzzleFlash.PlayFetchIndex("muzzle", () => { @@ -37,8 +37,8 @@ namespace OpenRa.Game.Traits if (attack.primaryRecoil > 0) return base.Render(self).Concat(new[] {Util.Centered(self, muzzleFlash.Image, self.CenterLocation + new float2( - self.unitInfo.PrimaryOffset.ElementAtOrDefault(2), - self.unitInfo.PrimaryOffset.ElementAtOrDefault(3)))}); + self.Info.PrimaryOffset.ElementAtOrDefault(2), + self.Info.PrimaryOffset.ElementAtOrDefault(3)))}); else return base.Render(self); } diff --git a/OpenRa.Game/Traits/RenderUnitRotor.cs b/OpenRa.Game/Traits/RenderUnitRotor.cs index 65b6e29c23..673716127c 100755 --- a/OpenRa.Game/Traits/RenderUnitRotor.cs +++ b/OpenRa.Game/Traits/RenderUnitRotor.cs @@ -10,13 +10,13 @@ namespace OpenRa.Game.Traits public RenderUnitRotor( Actor self ) : base(self) { - rotorAnim = new Animation(self.unitInfo.Name); + rotorAnim = new Animation(self.Info.Name); rotorAnim.PlayRepeating("rotor"); - if (self.unitInfo.SecondaryAnim != null) + if (self.Info.SecondaryAnim != null) { - secondRotorAnim = new Animation(self.unitInfo.Name); - secondRotorAnim.PlayRepeating(self.unitInfo.SecondaryAnim); + secondRotorAnim = new Animation(self.Info.Name); + secondRotorAnim.PlayRepeating(self.Info.SecondaryAnim); } } @@ -26,20 +26,20 @@ namespace OpenRa.Game.Traits yield return Util.CenteredShadow(self, anim.Image, self.CenterLocation); yield return Util.CenteredShadow(self, rotorAnim.Image, self.CenterLocation - + Util.GetTurretPosition(self, unit, self.unitInfo.PrimaryOffset, 0)); - if (self.unitInfo.SecondaryOffset != null) + + Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, 0)); + if (self.Info.SecondaryOffset != null) yield return Util.CenteredShadow(self, (secondRotorAnim ?? rotorAnim).Image, self.CenterLocation - + Util.GetTurretPosition(self, unit, self.unitInfo.SecondaryOffset, 0)); + + Util.GetTurretPosition(self, unit, self.Info.SecondaryOffset, 0)); var heli = self.traits.Get(); var p = self.CenterLocation - new float2( 0, heli.altitude ); yield return Util.Centered(self, anim.Image, p); yield return Util.Centered(self, rotorAnim.Image, p - + Util.GetTurretPosition( self, unit, self.unitInfo.PrimaryOffset, 0 ) ); - if (self.unitInfo.SecondaryOffset != null) + + Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, 0 ) ); + if (self.Info.SecondaryOffset != null) yield return Util.Centered(self, (secondRotorAnim ?? rotorAnim).Image, p - + Util.GetTurretPosition( self, unit, self.unitInfo.SecondaryOffset, 0 ) ); + + Util.GetTurretPosition( self, unit, self.Info.SecondaryOffset, 0 ) ); } public override void Tick(Actor self) diff --git a/OpenRa.Game/Traits/RenderUnitSpinner.cs b/OpenRa.Game/Traits/RenderUnitSpinner.cs index 57b9a2c4ba..2522404929 100755 --- a/OpenRa.Game/Traits/RenderUnitSpinner.cs +++ b/OpenRa.Game/Traits/RenderUnitSpinner.cs @@ -10,7 +10,7 @@ namespace OpenRa.Game.Traits public RenderUnitSpinner( Actor self ) : base(self) { - spinnerAnim = new Animation( self.unitInfo.Name ); + spinnerAnim = new Animation( self.Info.Name ); spinnerAnim.PlayRepeating( "spinner" ); } @@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits yield return Util.Centered(self, anim.Image, self.CenterLocation); yield return Util.Centered( self, spinnerAnim.Image, self.CenterLocation - + Util.GetTurretPosition(self, unit, self.unitInfo.PrimaryOffset, 0)); + + Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, 0)); } public override void Tick(Actor self) diff --git a/OpenRa.Game/Traits/RenderUnitTurreted.cs b/OpenRa.Game/Traits/RenderUnitTurreted.cs index b50e2f317b..1c158df44c 100644 --- a/OpenRa.Game/Traits/RenderUnitTurreted.cs +++ b/OpenRa.Game/Traits/RenderUnitTurreted.cs @@ -13,12 +13,12 @@ namespace OpenRa.Game.Traits : base(self) { self.traits.Get(); - turretAnim = new Animation(self.unitInfo.Name); + turretAnim = new Animation(self.Info.Name); - if (self.unitInfo.MuzzleFlash) + if (self.Info.MuzzleFlash) { var attack = self.traits.WithInterface().First(); - muzzleFlash = new Animation(self.unitInfo.Name); + muzzleFlash = new Animation(self.Info.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 */ @@ -35,14 +35,14 @@ namespace OpenRa.Game.Traits yield return Util.Centered(self, anim.Image, self.CenterLocation); yield return Util.Centered(self, turretAnim.Image, self.CenterLocation - + Util.GetTurretPosition(self, unit, self.unitInfo.PrimaryOffset, attack.primaryRecoil)); - if (self.unitInfo.SecondaryOffset != null) + + Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, attack.primaryRecoil)); + if (self.Info.SecondaryOffset != null) yield return Util.Centered(self, turretAnim.Image, self.CenterLocation - + Util.GetTurretPosition(self, unit, self.unitInfo.SecondaryOffset, attack.secondaryRecoil)); + + Util.GetTurretPosition(self, unit, self.Info.SecondaryOffset, attack.secondaryRecoil)); if (muzzleFlash != null && attack.primaryRecoil > 0) yield return Util.Centered(self, muzzleFlash.Image, self.CenterLocation - + Util.GetTurretPosition(self, unit, self.unitInfo.PrimaryOffset, attack.primaryRecoil)); + + Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, attack.primaryRecoil)); } public override void Tick(Actor self) diff --git a/OpenRa.Game/Traits/Turreted.cs b/OpenRa.Game/Traits/Turreted.cs index 2e1ad6fd91..ee2fde30c7 100644 --- a/OpenRa.Game/Traits/Turreted.cs +++ b/OpenRa.Game/Traits/Turreted.cs @@ -8,13 +8,13 @@ namespace OpenRa.Game.Traits public Turreted(Actor self) { - turretFacing = self.unitInfo.InitialFacing; + turretFacing = self.Info.InitialFacing; } public void Tick( Actor self ) { var df = desiredFacing ?? ( self.traits.Contains() ? self.traits.Get().Facing : turretFacing ); - Util.TickFacing( ref turretFacing, df, self.unitInfo.ROT ); + Util.TickFacing( ref turretFacing, df, self.Info.ROT ); } } } diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index 6fabf69d49..67d7a34899 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -73,14 +73,14 @@ namespace OpenRa.Game.Traits static float2 GetRecoil(Actor self, float recoil) { - if (self.unitInfo.Recoil == 0) return float2.Zero; + if (self.Info.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.turretAnim.CurrentSequence.Length) * (256 / rut.turretAnim.CurrentSequence.Length); - return RotateVectorByFacing(new float2(0, recoil * self.unitInfo.Recoil), quantizedFacing, .7f); + return RotateVectorByFacing(new float2(0, recoil * self.Info.Recoil), quantizedFacing, .7f); } public static float2 GetTurretPosition(Actor self, Unit unit, int[] offset, float recoil) diff --git a/OpenRa.Game/UnitOrders.cs b/OpenRa.Game/UnitOrders.cs index 11fd0bd138..bc1c05b7a3 100755 --- a/OpenRa.Game/UnitOrders.cs +++ b/OpenRa.Game/UnitOrders.cs @@ -40,7 +40,7 @@ namespace OpenRa.Game Log.Write( "Player \"{0}\" builds {1}", order.Player.PlayerName, building.Name ); - Game.world.Add( new Actor( building.Name, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building ), order.Player ) ); + Game.world.Add( new Actor( building, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building ), order.Player ) ); if (order.Player == Game.LocalPlayer) { Sound.Play("placbldg.aud");