From 9abb90b78a62e01be3ad4d4e32edfe9dfa65261f Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 7 Oct 2009 22:44:45 +1300 Subject: [PATCH] merging bob's turreted-unit hax --- OpenRa.Game/Game.cs | 14 ++++++++------ OpenRa.Game/MainWindow.cs | 9 +++++---- OpenRa.Game/Refinery.cs | 7 +++++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 3d124e6e77..c81428fa8f 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using OpenRa.FileFormats; +using System.Linq; using OpenRa.Game.Graphics; @@ -23,7 +24,7 @@ namespace OpenRa.Game public readonly Dictionary players = new Dictionary(); // temporary, until we remove all the subclasses of Building - public Dictionary> buildingCreation = new Dictionary>(); + public Dictionary> buildingCreation; public Player LocalPlayer { get { return players[localPlayerIndex]; } } @@ -48,12 +49,13 @@ namespace OpenRa.Game network = new Network(); - buildingCreation.Add("proc", (location, owner) => new Refinery(location, owner, this)); - buildingCreation.Add("weap", (location, owner) => new WarFactory(location, owner, this)); + var buildings = new[] { "fact", "powr", "apwr", "barr", "atek", "stek", "dome" }; + buildingCreation = buildings.ToDictionary(s => s, + s => (Func)( + (l, o) => new Building(s, l, o, this))); - string[] buildings = { "fact", "powr", "apwr", "barr", "atek", "stek", "dome" }; - foreach (string s in buildings) - buildingCreation.Add(s, (location, owner) => new Building(s, location, owner, this)); + buildingCreation.Add("proc", (location, owner) => new Refinery(location, owner, this)); + buildingCreation.Add("weap", (location, owner) => new WarFactory(location, owner, this)); controller = new Controller(this); // CAREFUL THERES AN UGLY HIDDEN DEPENDENCY HERE STILL worldRenderer = new WorldRenderer(renderer, world); diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index dbacca2a03..8ea7307a13 100644 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -36,9 +36,8 @@ namespace OpenRa.Game Location = Point.Empty; Visible = true; - //bool windowed = !settings.GetValue("fullscreen", false); - //renderer = new Renderer(this, GetResolution(settings), windowed); - renderer = new Renderer( this, new Size( 800, 600 ), true ); + bool windowed = !settings.GetValue("fullscreen", false); + renderer = new Renderer(this, GetResolution(settings), windowed); SheetBuilder.Initialize( renderer ); game = new Game( settings.GetValue( "map", "scg11eb.ini" ), renderer, new int2( ClientSize ) ); @@ -49,10 +48,12 @@ namespace OpenRa.Game game.world.Add( new Unit( "mcv", new int2( 5, 5 ), game.players[ 3 ], game ) ); game.world.Add( new Unit( "mcv", new int2( 7, 5 ), game.players[ 2 ], game ) ); - game.world.Add( controlled = new Unit( "mcv", new int2( 9, 5 ), game.players[ 1 ], game ) ); + game.world.Add( controlled = new TurretedUnit( "jeep", new int2( 9, 7 ), game.players[ 1 ], game ) ); + game.world.Add(controlled = new Unit("mcv", new int2(9, 5), game.players[1], game)); + game.controller.orderGenerator = controlled; sidebar = new Sidebar(Race.Soviet, renderer, game); diff --git a/OpenRa.Game/Refinery.cs b/OpenRa.Game/Refinery.cs index b71d304f1b..c21facc991 100644 --- a/OpenRa.Game/Refinery.cs +++ b/OpenRa.Game/Refinery.cs @@ -1,5 +1,7 @@ using OpenRa.Game.Graphics; using System.Linq; +using System.Collections.Generic; +using IjwFramework.Types; namespace OpenRa.Game { @@ -39,13 +41,14 @@ namespace OpenRa.Game }); } - public override Sprite[] CurrentImages + public override IEnumerable> CurrentImages { get { return (roof == null) ? base.CurrentImages - : (base.CurrentImages.Concat( roof.Images ).ToArray()); + : (base.CurrentImages.Concat( + new[] { Pair.New(roof.Image, 24 * (float2)location) })); } }