pass worldRenderer around as necessary

This commit is contained in:
Bob
2010-10-11 19:42:07 +13:00
parent 10bf85f57e
commit ab1e930ba3
34 changed files with 116 additions and 118 deletions

View File

@@ -8,10 +8,10 @@
*/
#endregion
using System.Drawing;
using OpenRA.Traits;
using OpenRA.FileFormats;
using System.Collections.Generic;
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{

View File

@@ -8,10 +8,9 @@
*/
#endregion
using System.Drawing;
using OpenRA.Traits;
using System.Collections.Generic;
using OpenRA.FileFormats;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{

View File

@@ -12,6 +12,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
@@ -41,7 +42,7 @@ namespace OpenRA.Mods.RA
{
if( order is BeginMinefieldOrderTargeter )
{
var start = Util.CellContaining( target.CenterLocation );
var start = Traits.Util.CellContaining( target.CenterLocation );
self.World.OrderGenerator = new MinefieldOrderGenerator( self, start );
return new Order( "BeginMinefield", self, start );
}
@@ -120,7 +121,7 @@ namespace OpenRA.Mods.RA
}
int2 lastMousePos;
public void RenderAfterWorld(World world)
public void RenderAfterWorld(WorldRenderer wr, World world)
{
if (!minelayer.IsInWorld)
return;
@@ -129,21 +130,21 @@ namespace OpenRA.Mods.RA
var minefield = GetMinefieldCells(minefieldStart, lastMousePos, minelayer.Info.Traits.Get<MinelayerInfo>().MinefieldDepth)
.Where(p => movement.CanEnterCell(p)).ToArray();
world.WorldRenderer.DrawLocus(Color.Cyan, minefield);
wr.DrawLocus(Color.Cyan, minefield);
}
public void RenderBeforeWorld(World world) { }
public void RenderBeforeWorld(WorldRenderer wr, World world) { }
public string GetCursor(World world, int2 xy, MouseInput mi) { lastMousePos = xy; return "ability"; } /* todo */
}
public void RenderAfterWorld(Actor self)
public void RenderAfterWorld(WorldRenderer wr, Actor self)
{
if (self.Owner != self.World.LocalPlayer)
return;
if (minefield != null)
self.World.WorldRenderer.DrawLocus(Color.Cyan, minefield);
wr.DrawLocus(Color.Cyan, minefield);
}
class BeginMinefieldOrderTargeter : IOrderTargeter

View File

@@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Orders
@@ -71,11 +72,11 @@ namespace OpenRA.Mods.RA.Orders
// .FirstOrDefault();
}
public void RenderAfterWorld( World world ) {}
public void RenderAfterWorld( WorldRenderer wr, World world ) { }
public void RenderBeforeWorld(World world)
public void RenderBeforeWorld( WorldRenderer wr, World world )
{
world.WorldRenderer.uiOverlay.DrawBuildingGrid(world, Building, BuildingInfo);
wr.uiOverlay.DrawBuildingGrid( wr, world, Building, BuildingInfo );
}
public string GetCursor(World world, int2 xy, MouseInput mi) { return "default"; }

View File

@@ -10,6 +10,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
namespace OpenRA.Mods.RA.Orders
{
@@ -38,8 +39,8 @@ namespace OpenRA.Mods.RA.Orders
}
public void Tick(World world) { }
public void RenderAfterWorld(World world) { }
public void RenderBeforeWorld(World world) { }
public void RenderAfterWorld(WorldRenderer wr, World world) { }
public void RenderBeforeWorld(WorldRenderer wr, World world) { }
public string GetCursor(World world, int2 xy, MouseInput mi)
{

View File

@@ -10,6 +10,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Orders
@@ -51,8 +52,8 @@ namespace OpenRA.Mods.RA.Orders
return world.Queries.OwnedBy[ world.LocalPlayer ].WithTrait<AllowsBuildingRepair>().Any();
}
public void RenderAfterWorld( World world ) {}
public void RenderBeforeWorld(World world) { }
public void RenderAfterWorld( WorldRenderer wr, World world ) { }
public void RenderBeforeWorld( WorldRenderer wr, World world ) { }
public string GetCursor(World world, int2 xy, MouseInput mi)
{

View File

@@ -10,6 +10,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Orders
@@ -41,8 +42,8 @@ namespace OpenRA.Mods.RA.Orders
}
public void Tick( World world ) {}
public void RenderAfterWorld( World world ) {}
public void RenderBeforeWorld(World world) { }
public void RenderAfterWorld( WorldRenderer wr, World world ) { }
public void RenderBeforeWorld( WorldRenderer wr, World world ) { }
public string GetCursor(World world, int2 xy, MouseInput mi)
{

View File

@@ -10,6 +10,7 @@
using System.Collections.Generic;
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Orders
@@ -36,12 +37,12 @@ namespace OpenRA.Mods.RA.Orders
}
public void Tick( World world ) { }
public void RenderAfterWorld( World world )
public void RenderAfterWorld( WorldRenderer wr, World world )
{
world.WorldRenderer.DrawSelectionBox(self, Color.White);
wr.DrawSelectionBox(self, Color.White);
}
public void RenderBeforeWorld(World world) { }
public void RenderBeforeWorld( WorldRenderer wr, World world ) { }
public string GetCursor(World world, int2 xy, MouseInput mi)
{

View File

@@ -9,6 +9,7 @@
#endregion
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -16,12 +17,12 @@ namespace OpenRA.Mods.RA
class RenderDetectionCircleInfo : TraitInfo<RenderDetectionCircle> { }
class RenderDetectionCircle : IPreRenderSelection
{
public void RenderBeforeWorld(Actor self)
public void RenderBeforeWorld(WorldRenderer wr, Actor self)
{
if (self.Owner != self.World.LocalPlayer)
return;
self.World.WorldRenderer.DrawRangeCircle(
wr.DrawRangeCircle(
Color.FromArgb(128, Color.LimeGreen),
self.CenterLocation, self.Info.Traits.Get<DetectCloakedInfo>().Range);
}

View File

@@ -9,6 +9,7 @@
#endregion
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -16,12 +17,12 @@ namespace OpenRA.Mods.RA
class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle> { }
class RenderRangeCircle : IPreRenderSelection
{
public void RenderBeforeWorld(Actor self)
public void RenderBeforeWorld(WorldRenderer wr, Actor self)
{
if (self.Owner != self.World.LocalPlayer)
return;
self.World.WorldRenderer.DrawRangeCircle(
wr.DrawRangeCircle(
Color.FromArgb(128, Color.Yellow),
self.CenterLocation, (int)self.Trait<AttackBase>().GetMaximumRange());
}

View File

@@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
@@ -96,8 +97,8 @@ namespace OpenRA.Mods.RA
// TODO: Check if the selected unit is still alive
}
public void RenderAfterWorld( World world ) { }
public void RenderBeforeWorld(World world) { }
public void RenderAfterWorld( WorldRenderer wr, World world ) { }
public void RenderBeforeWorld( WorldRenderer wr, World world ) { }
public string GetCursor(World world, int2 xy, MouseInput mi)
{
@@ -145,12 +146,12 @@ namespace OpenRA.Mods.RA
// TODO: Check if the selected unit is still alive
}
public void RenderAfterWorld(World world)
public void RenderAfterWorld(WorldRenderer wr, World world)
{
world.WorldRenderer.DrawSelectionBox(self, Color.Red);
wr.DrawSelectionBox(self, Color.Red);
}
public void RenderBeforeWorld(World world) { }
public void RenderBeforeWorld(WorldRenderer wr, World world) { }
public string GetCursor(World world, int2 xy, MouseInput mi)
{

View File

@@ -10,6 +10,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
@@ -95,8 +96,8 @@ namespace OpenRA.Mods.RA
world.CancelInputMode();
}
public void RenderAfterWorld(World world) { }
public void RenderBeforeWorld(World world) { }
public void RenderAfterWorld(WorldRenderer wr, World world) { }
public void RenderBeforeWorld(WorldRenderer wr, World world) { }
public string GetCursor(World world, int2 xy, MouseInput mi)
{

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.RA
}
}
public void Render()
public void Render( WorldRenderer wr )
{
var cliprect = Game.viewport.ShroudBounds().HasValue
? Rectangle.Intersect(Game.viewport.ShroudBounds().Value, world.Map.Bounds) : world.Map.Bounds;
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(kv.Key))
continue;
smudgeSprites[kv.Value.type- 1][kv.Value.image].DrawAt(
smudgeSprites[kv.Value.type- 1][kv.Value.image].DrawAt( wr,
Game.CellSize * kv.Key, "terrain");
}
}