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,11 +8,8 @@
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System;
namespace OpenRA.FileFormats
{

View File

@@ -20,9 +20,9 @@ namespace OpenRA
sequence = CursorProvider.GetCursorSequence(cursor);
}
public void Draw(int frame, float2 pos)
public void Draw(WorldRenderer wr, int frame, float2 pos)
{
sequence.GetSprite(frame).DrawAt(pos - sequence.Hotspot, sequence.Palette);
sequence.GetSprite(frame).DrawAt(wr, pos - sequence.Hotspot, sequence.Palette);
}
}
}

View File

@@ -141,7 +141,7 @@ namespace OpenRA
using (new PerfSample("render"))
{
++RenderFrame;
viewport.DrawRegions(world);
viewport.DrawRegions(world.WorldRenderer, world);
Sound.SetListenerPosition(viewport.Location + .5f * new float2(viewport.Width, viewport.Height));
}

View File

@@ -50,9 +50,9 @@ namespace OpenRA.Graphics
return uvhax[ k ];
}
public void DrawAt( float2 location, string palette )
public void DrawAt( WorldRenderer wr, float2 location, string palette )
{
Game.Renderer.SpriteRenderer.DrawSprite( this, location, palette, this.size );
Game.Renderer.SpriteRenderer.DrawSprite( this, location, wr, palette, this.size );
}
public void DrawAt( float2 location, int paletteIndex )
@@ -60,11 +60,6 @@ namespace OpenRA.Graphics
Game.Renderer.SpriteRenderer.DrawSprite( this, location, paletteIndex, this.size );
}
public void DrawAt(float2 location, string palette, float2 size)
{
Game.Renderer.SpriteRenderer.DrawSprite( this, location, palette, size );
}
public void DrawAt( float2 location, int paletteIndex, float2 size )
{
Game.Renderer.SpriteRenderer.DrawSprite( this, location, paletteIndex, size );

View File

@@ -54,14 +54,14 @@ namespace OpenRA.Graphics
}
}
public void DrawSprite(Sprite s, float2 location, string palette)
public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette)
{
DrawSprite(s, location, Game.world.WorldRenderer.GetPaletteIndex(palette), s.size);
DrawSprite(s, location, wr.GetPaletteIndex(palette), s.size);
}
public void DrawSprite(Sprite s, float2 location, string palette, float2 size)
public void DrawSprite(Sprite s, float2 location, WorldRenderer wr, string palette, float2 size)
{
DrawSprite(s, location, Game.world.WorldRenderer.GetPaletteIndex(palette), size);
DrawSprite(s, location, wr.GetPaletteIndex(palette), size);
}
public void DrawSprite(Sprite s, float2 location, int paletteIndex, float2 size)

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Graphics
indexBuffer.SetData( indices, ni );
}
public void Draw( Viewport viewport )
public void Draw( WorldRenderer wr, Viewport viewport )
{
int indicesPerRow = map.Width * 6;
int verticesPerRow = map.Width * 4;
@@ -98,7 +98,7 @@ namespace OpenRA.Graphics
PrimitiveType.TriangleList, Game.Renderer.SpriteShader));
foreach (var r in world.WorldActor.TraitsImplementing<IRenderOverlay>())
r.Render();
r.Render( wr );
}
}
}

View File

@@ -11,7 +11,6 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Support;
using OpenRA.Traits;
using OpenRA.Widgets;
@@ -96,16 +95,16 @@ namespace OpenRA.Graphics
this.scrollPosition = Game.CellSize* mapStart;
}
public void DrawRegions( World world )
public void DrawRegions( WorldRenderer wr, World world )
{
renderer.BeginFrame(scrollPosition);
world.WorldRenderer.Draw();
wr.Draw();
Widget.DoDraw(world);
var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default";
var c = new Cursor(cursorName);
c.Draw((int)cursorFrame, Viewport.LastMousePos + Location);
c.Draw(wr, (int)cursorFrame, Viewport.LastMousePos + Location);
renderer.EndFrame();
}

View File

@@ -92,17 +92,17 @@ namespace OpenRA.Graphics
var bounds = GetBoundsRect();
Game.Renderer.EnableScissor(bounds.Left, bounds.Top, bounds.Width, bounds.Height);
terrainRenderer.Draw(Game.viewport);
terrainRenderer.Draw(this, Game.viewport);
if (world.OrderGenerator != null)
world.OrderGenerator.RenderBeforeWorld(world);
world.OrderGenerator.RenderBeforeWorld(this, world);
foreach( var image in worldSprites )
image.Sprite.DrawAt( image.Pos, this.GetPaletteIndex( image.Palette ) );
uiOverlay.Draw(world);
uiOverlay.Draw(this, world);
if (world.OrderGenerator != null)
world.OrderGenerator.RenderAfterWorld(world);
world.OrderGenerator.RenderAfterWorld(this, world);
if (world.LocalPlayer != null)
world.LocalPlayer.Shroud.Draw();

View File

@@ -10,6 +10,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
namespace OpenRA.Orders
{
@@ -43,8 +44,8 @@ namespace OpenRA.Orders
}
public virtual 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) { return world.Map.IsInMap(xy) ? cursor : "generic-blocked"; }
}

View File

@@ -9,6 +9,7 @@
#endregion
using System.Collections.Generic;
using OpenRA.Graphics;
namespace OpenRA
{
@@ -16,8 +17,8 @@ namespace OpenRA
{
IEnumerable<Order> Order(World world, int2 xy, MouseInput mi);
void Tick(World world);
void RenderBeforeWorld(World world);
void RenderAfterWorld(World world);
void RenderBeforeWorld(WorldRenderer wr, World world);
void RenderAfterWorld(WorldRenderer wr, World world);
string GetCursor(World world, int2 xy, MouseInput mi);
}
}

View File

@@ -6,13 +6,12 @@
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Traits;
using OpenRA.FileFormats;
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Orders
{
@@ -41,22 +40,22 @@ namespace OpenRA.Orders
public void Tick( World world ) {}
public void RenderBeforeWorld(World world)
public void RenderBeforeWorld( WorldRenderer wr, World world )
{
foreach (var a in world.Selection.Actors)
if (!a.Destroyed)
foreach (var t in a.TraitsImplementing<IPreRenderSelection>())
t.RenderBeforeWorld(a);
t.RenderBeforeWorld( wr, a );
Game.Renderer.Flush();
}
public void RenderAfterWorld( World world )
public void RenderAfterWorld( WorldRenderer wr, World world )
{
foreach (var a in world.Selection.Actors)
if (!a.Destroyed)
foreach (var t in a.TraitsImplementing<IPostRenderSelection>())
t.RenderAfterWorld(a);
t.RenderAfterWorld( wr, a );
Game.Renderer.Flush();
}

View File

@@ -9,7 +9,6 @@
#endregion
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.Graphics;
namespace OpenRA

View File

@@ -8,8 +8,8 @@
*/
#endregion
using System.Drawing;
using OpenRA.Traits.Activities;
using System.Drawing;
using OpenRA.Graphics;
namespace OpenRA.Traits
{
@@ -45,7 +45,7 @@ namespace OpenRA.Traits
this.c = c;
}
public void RenderAfterWorld(Actor self)
public void RenderAfterWorld(WorldRenderer wr, Actor self)
{
if (self.IsIdle) return;

View File

@@ -10,7 +10,6 @@
using System.Drawing;
using OpenRA.Graphics;
using System.Linq;
namespace OpenRA.Traits
{
@@ -29,7 +28,7 @@ namespace OpenRA.Traits
static readonly string[] pipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray" };
static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" };
public void RenderAfterWorld (Actor self)
public void RenderAfterWorld (WorldRenderer wr, Actor self)
{
var bounds = self.GetBounds(true);
@@ -40,9 +39,9 @@ namespace OpenRA.Traits
DrawSelectionBox(self, xy, Xy, xY, XY, Color.White);
DrawHealthBar(self, xy, Xy);
DrawControlGroup(self, xy);
DrawPips(self, xY);
DrawTags(self, new float2(.5f * (bounds.Left + bounds.Right), bounds.Top));
DrawControlGroup(wr, self, xy);
DrawPips(wr, self, xY);
DrawTags(wr, self, new float2(.5f * (bounds.Left + bounds.Right), bounds.Top));
DrawUnitPath(self);
}
@@ -89,7 +88,7 @@ namespace OpenRA.Traits
Game.Renderer.LineRenderer.DrawLine(xy + new float2(0, -4), z + new float2(0, -4), healthColor2, healthColor2);
}
void DrawControlGroup(Actor self, float2 basePosition)
void DrawControlGroup(WorldRenderer wr, Actor self, float2 basePosition)
{
var group = self.World.Selection.GetControlGroupForActor(self);
if (group == null) return;
@@ -97,10 +96,10 @@ namespace OpenRA.Traits
var pipImages = new Animation("pips");
pipImages.PlayFetchIndex("groups", () => (int)group);
pipImages.Tick();
pipImages.Image.DrawAt(basePosition + new float2(-8, 1), "chrome");
pipImages.Image.DrawAt(wr, basePosition + new float2(-8, 1), "chrome");
}
void DrawPips(Actor self, float2 basePosition)
void DrawPips(WorldRenderer wr, Actor self, float2 basePosition)
{
if (self.Owner != self.World.LocalPlayer) return;
@@ -123,7 +122,7 @@ namespace OpenRA.Traits
}
var pipImages = new Animation("pips");
pipImages.PlayRepeating(pipStrings[(int)pip]);
pipImages.Image.DrawAt(pipxyBase + pipxyOffset, "chrome");
pipImages.Image.DrawAt(wr, pipxyBase + pipxyOffset, "chrome");
pipxyOffset += new float2(4, 0);
}
// Increment row
@@ -132,7 +131,7 @@ namespace OpenRA.Traits
}
}
void DrawTags(Actor self, float2 basePosition)
void DrawTags(WorldRenderer wr, Actor self, float2 basePosition)
{
if (self.Owner != self.World.LocalPlayer) return;
@@ -149,7 +148,7 @@ namespace OpenRA.Traits
var tagImages = new Animation("pips");
tagImages.PlayRepeating(tagStrings[(int)tag]);
tagImages.Image.DrawAt(tagxyBase + tagxyOffset, "chrome");
tagImages.Image.DrawAt(wr, tagxyBase + tagxyOffset, "chrome");
// Increment row
tagxyOffset.Y += 8;

View File

@@ -10,9 +10,9 @@
using System.Collections.Generic;
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.FileFormats;
namespace OpenRA.Traits
{
@@ -211,13 +211,13 @@ namespace OpenRA.Traits
}
}
public interface IRenderOverlay { void Render(); }
public interface IRenderOverlay { void Render( WorldRenderer wr ); }
public interface INotifyIdle { void Idle(Actor self); }
public interface IBlocksBullets { }
public interface IPostRenderSelection { void RenderAfterWorld(Actor self); }
public interface IPreRenderSelection { void RenderBeforeWorld(Actor self); }
public interface IPostRenderSelection { void RenderAfterWorld(WorldRenderer wr, Actor self); }
public interface IPreRenderSelection { void RenderBeforeWorld(WorldRenderer wr, Actor self); }
public struct Target // a target: either an actor, or a fixed location.
{

View File

@@ -6,14 +6,14 @@
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using System;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using System.Collections.Generic;
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
namespace OpenRA.Traits
{
@@ -71,7 +71,7 @@ namespace OpenRA.Traits
}
}
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;
@@ -84,7 +84,7 @@ namespace OpenRA.Traits
if (world.LocalPlayer != null && !world.LocalPlayer.Shroud.IsExplored(kv.Key))
continue;
bibSprites[kv.Value.type - 1][kv.Value.image].DrawAt(
bibSprites[kv.Value.type - 1][kv.Value.image].DrawAt( wr,
Game.CellSize * kv.Key, "terrain");
}
}

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Traits
public ResourceType[] resourceTypes;
CellContents[,] content;
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;
@@ -38,7 +38,7 @@ namespace OpenRA.Traits
var maxy = cliprect.Bottom;
foreach( var rt in world.WorldActor.TraitsImplementing<ResourceType>() )
rt.info.PaletteIndex = world.WorldRenderer.GetPaletteIndex(rt.info.Palette);
rt.info.PaletteIndex = wr.GetPaletteIndex(rt.info.Palette);
for (int x = minx; x < maxx; x++)
for (int y = miny; y < maxy; y++)

View File

@@ -14,7 +14,6 @@ using System.Linq;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA
{
@@ -40,7 +39,7 @@ namespace OpenRA
return Game.modData.SheetBuilder.Add(data, new Size(Game.CellSize, Game.CellSize));
}
public void Draw( World world )
public void Draw( WorldRenderer wr, World world )
{
if (Game.Settings.Debug.ShowCollisions)
{
@@ -49,11 +48,11 @@ namespace OpenRA
for (var i = world.Map.Bounds.Left; i < world.Map.Bounds.Right; i++)
for (var j = world.Map.Bounds.Top; j < world.Map.Bounds.Bottom; j++)
if (uim.GetUnitsAt(new int2(i, j)).Any())
unitDebug.DrawAt(Game.CellSize * new float2(i, j), "terrain");
unitDebug.DrawAt(wr, Game.CellSize * new float2(i, j), "terrain");
}
}
public void DrawBuildingGrid( World world, string name, BuildingInfo bi )
public void DrawBuildingGrid( WorldRenderer wr, World world, string name, BuildingInfo bi )
{
var position = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2();
var topLeft = position - Footprint.AdjustForBuildingSize( bi );
@@ -64,7 +63,7 @@ namespace OpenRA
{
foreach (var t in LineBuildUtils.GetLineBuildCells(world, topLeft, name, bi))
(world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, t) ? buildOk : buildBlocked)
.DrawAt(Game.CellSize * t, "terrain");
.DrawAt(wr, Game.CellSize * t, "terrain");
}
else
{
@@ -72,7 +71,7 @@ namespace OpenRA
var isCloseEnough = world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, topLeft);
foreach (var t in Footprint.Tiles(name, bi, topLeft))
((isCloseEnough && world.IsCellBuildable(t, bi.WaterBound) && res.GetResource(t) == null) ? buildOk : buildBlocked)
.DrawAt(Game.CellSize * t, "terrain");
.DrawAt( wr, Game.CellSize * t, "terrain");
}
}
}

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Widgets
cachedFrame = frame;
}
Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite,RenderOrigin, palette);
Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite,RenderOrigin, Game.world.WorldRenderer, palette);
}
}
}

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Widgets
public static void DrawSHP(Sprite s, float2 pos)
{
Game.Renderer.WorldSpriteRenderer.DrawSprite(s,pos, "chrome");
Game.Renderer.WorldSpriteRenderer.DrawSprite(s,pos, Game.world.WorldRenderer, "chrome");
}
public static void DrawPanel(string collection, Rectangle Bounds)

View File

@@ -14,11 +14,11 @@ using OpenRA.Collections;
using OpenRA.Effects;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Orders;
using OpenRA.Traits;
using XRandom = OpenRA.Thirdparty.Random;
using OpenRA.Network;
namespace OpenRA
{

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");
}
}