diff --git a/OpenRa.Game/GameRules/UnitInfo.cs b/OpenRa.Game/GameRules/UnitInfo.cs index 7a3eef801b..4acef1a740 100755 --- a/OpenRa.Game/GameRules/UnitInfo.cs +++ b/OpenRa.Game/GameRules/UnitInfo.cs @@ -53,6 +53,7 @@ namespace OpenRa.Game.GameRules public readonly string SecondaryAnim = null; public readonly bool MuzzleFlash = false; public readonly int SelectionPriority = 10; + public readonly int InitialFacing = 128; public UnitInfo(string name) { Name = name; } diff --git a/OpenRa.Game/Graphics/TerrainRenderer.cs b/OpenRa.Game/Graphics/TerrainRenderer.cs index 5840daaf9e..2e5cb8b0ec 100644 --- a/OpenRa.Game/Graphics/TerrainRenderer.cs +++ b/OpenRa.Game/Graphics/TerrainRenderer.cs @@ -23,7 +23,7 @@ namespace OpenRa.Game.Graphics Size tileSize = new Size( Game.CellSize, Game.CellSize ); - SheetBuilder.ForceNewSheet(); + // SheetBuilder.ForceNewSheet(); var tileMapping = new Cache( x => SheetBuilder.Add(Rules.TileSet.GetBytes(x), tileSize)); diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 48302621b6..35d9b32a23 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -82,6 +82,7 @@ + diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index b87dc08628..82723abffc 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace OpenRa.Game @@ -47,8 +46,7 @@ namespace OpenRa.Game public void GiveCash( int num ) { - // TODO: increase cash - Cash += num; // TODO: slowly + Cash += num; } public bool TakeCash( int num ) @@ -97,45 +95,4 @@ namespace OpenRa.Game production[ group ] = item; } } - - class ProductionItem - { - public readonly string Item; - - public readonly int TotalTime; - public readonly int TotalCost; - public int RemainingTime { get; private set; } - public int RemainingCost { get; private set; } - - public bool Paused = false, Done = false; - public Action OnComplete; - - public ProductionItem( string item, int time, int cost, Action onComplete ) - { - Item = item; - RemainingTime = TotalTime = time; - RemainingCost = TotalCost = cost; - OnComplete = onComplete; - } - - public void Tick( Player player ) - { - if (Done) - { - if (OnComplete != null) OnComplete(); - return; - } - - if( Paused ) return; - - var costThisFrame = RemainingCost / RemainingTime; - if( costThisFrame != 0 && !player.TakeCash( costThisFrame ) ) return; - - RemainingCost -= costThisFrame; - RemainingTime -= 1; - if( RemainingTime > 0 ) return; - - Done = true; - } - } } diff --git a/OpenRa.Game/ProductionItem.cs b/OpenRa.Game/ProductionItem.cs new file mode 100644 index 0000000000..0234c3147f --- /dev/null +++ b/OpenRa.Game/ProductionItem.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRa.Game +{ + class ProductionItem + { + public readonly string Item; + + public readonly int TotalTime; + public readonly int TotalCost; + public int RemainingTime { get; private set; } + public int RemainingCost { get; private set; } + + public bool Paused = false, Done = false; + public Action OnComplete; + + public ProductionItem(string item, int time, int cost, Action onComplete) + { + Item = item; + RemainingTime = TotalTime = time; + RemainingCost = TotalCost = cost; + OnComplete = onComplete; + } + + public void Tick(Player player) + { + if (Done) + { + if (OnComplete != null) OnComplete(); + return; + } + + if (Paused) return; + + var costThisFrame = RemainingCost / RemainingTime; + if (costThisFrame != 0 && !player.TakeCash(costThisFrame)) return; + + RemainingCost -= costThisFrame; + RemainingTime -= 1; + if (RemainingTime > 0) return; + + Done = true; + } + } +} diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index cf1e5856a6..5397377ffe 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -17,9 +17,7 @@ namespace OpenRa.Game.Traits public virtual int CreationFacing( Actor self, Actor newUnit ) { - if( newUnit.traits.Contains() ) - return 20; - return 128; + return newUnit.unitInfo.InitialFacing; } public bool Produce( Actor self, UnitInfo producee ) diff --git a/OpenRa.Game/Traits/Turreted.cs b/OpenRa.Game/Traits/Turreted.cs index 7bad6cdf2b..c8935b267c 100644 --- a/OpenRa.Game/Traits/Turreted.cs +++ b/OpenRa.Game/Traits/Turreted.cs @@ -12,6 +12,7 @@ namespace OpenRa.Game.Traits public Turreted(Actor self) { + turretFacing = self.unitInfo.InitialFacing; } public void Tick( Actor self ) diff --git a/OpenRa.Game/UnitOrders.cs b/OpenRa.Game/UnitOrders.cs index e2c3da0273..e8ccf325fc 100755 --- a/OpenRa.Game/UnitOrders.cs +++ b/OpenRa.Game/UnitOrders.cs @@ -36,6 +36,8 @@ 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 ) ); + if (order.Player == Game.LocalPlayer) + Game.PlaySound("build5.aud", false); order.Player.FinishProduction(Rules.UnitCategory[building.Name]); } ); diff --git a/units.ini b/units.ini index fbb58177e9..bbd8e3bdf5 100755 --- a/units.ini +++ b/units.ini @@ -123,10 +123,12 @@ HIND Description=Mig Attack Plane BuiltAt=afld Traits=Unit, Mobile, RenderUnit +InitialFacing=192 [YAK] Description=Yak Attack Plane BuiltAt=afld Traits=Unit, Mobile, RenderUnit +InitialFacing=192 [TRAN] Description=Transport Helicopter PrimaryOffset=0,14,0,-4 @@ -134,15 +136,18 @@ SecondaryOffset=0,-14,0,-2 BuiltAt=hpad Traits=Unit, Helicopter, RenderUnitRotor SecondaryAnim=rotor2 +InitialFacing=20 [HELI] Description=Longbow BuiltAt=hpad Traits=Unit, Helicopter, RenderUnitRotor PrimaryOffset=0,0,0,-2 +InitialFacing=20 [HIND] Description=Hind BuiltAt=hpad Traits=Unit, Helicopter, RenderUnitRotor +InitialFacing=20 @@ -262,12 +267,14 @@ Traits=Building, Turreted, RenderBuildingTurreted Dimensions=1,1 Footprint=x SelectionPriority=3 +InitialFacing=50 [AGUN] Description=AA Gun Traits=Building, Turreted, RenderBuildingTurreted Dimensions=1,2 Footprint=_ x SelectionPriority=3 +InitialFacing=224 [FTUR] Description=Flame Turret Traits=Building, RenderBuilding