RenderBeforeWorld/RenderAfterWorld split. still need to sort out which behavior belongs where.

This commit is contained in:
Chris Forbes
2010-07-26 18:19:39 +12:00
parent 9cf8ac0c3d
commit 69d30ac71b
17 changed files with 59 additions and 31 deletions

View File

@@ -98,6 +98,13 @@ namespace OpenRA.Graphics
Game.Renderer.Device.EnableScissor(bounds.Left, bounds.Top, bounds.Width, bounds.Height);
terrainRenderer.Draw(Game.viewport);
if (Game.controller.orderGenerator != null)
Game.controller.orderGenerator.RenderBeforeWorld(world);
Game.Renderer.SpriteRenderer.Flush();
Game.Renderer.LineRenderer.Flush();
foreach (var image in worldSprites)
Game.Renderer.SpriteRenderer.DrawSprite(image.Sprite, image.Pos, image.Palette);
uiOverlay.Draw(world);
@@ -105,7 +112,7 @@ namespace OpenRA.Graphics
DrawBandBox();
if (Game.controller.orderGenerator != null)
Game.controller.orderGenerator.Render(world);
Game.controller.orderGenerator.RenderAfterWorld(world);
if (world.LocalPlayer != null)
world.LocalPlayer.Shroud.Draw();

View File

@@ -40,7 +40,8 @@ namespace OpenRA.Orders
}
public virtual void Tick(World world) { }
public void Render(World world) { }
public void RenderAfterWorld(World world) { }
public void RenderBeforeWorld(World world) { }
public string GetCursor(World world, int2 xy, MouseInput mi) { return world.Map.IsInMap(xy) ? cursor : "generic-blocked"; }
}

View File

@@ -14,9 +14,10 @@ namespace OpenRA
{
public interface IOrderGenerator
{
IEnumerable<Order> Order( World world, int2 xy, MouseInput mi );
void Tick( World world );
void Render( World world );
string GetCursor( World world, int2 xy, MouseInput mi );
IEnumerable<Order> Order(World world, int2 xy, MouseInput mi);
void Tick(World world);
void RenderBeforeWorld(World world);
void RenderAfterWorld(World world);
string GetCursor(World world, int2 xy, MouseInput mi);
}
}

View File

@@ -61,11 +61,13 @@ namespace OpenRA.Orders
Game.controller.CancelInputMode();
}
public void Render( World world )
public void RenderAfterWorld( World world )
{
world.WorldRenderer.uiOverlay.DrawBuildingGrid( world, Building, BuildingInfo );
}
public void RenderBeforeWorld(World world) { }
public string GetCursor(World world, int2 xy, MouseInput mi) { return "default"; }
}
}

View File

@@ -35,13 +35,18 @@ namespace OpenRA.Orders
public void Tick( World world ) {}
public void Render( World world )
public void RenderBeforeWorld(World world)
{
foreach (var a in Game.controller.selection.Actors)
{
foreach (var t in a.traits.WithInterface<IRenderSelection>())
t.Render(a);
}
foreach (var t in a.traits.WithInterface<IPreRenderSelection>())
t.RenderBeforeWorld(a);
}
public void RenderAfterWorld( World world )
{
foreach (var a in Game.controller.selection.Actors)
foreach (var t in a.traits.WithInterface<IPostRenderSelection>())
t.RenderAfterWorld(a);
}
public string GetCursor( World world, int2 xy, MouseInput mi )

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Traits
public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(this); }
}
public class DrawLineToTarget :IRenderSelection
public class DrawLineToTarget :IPostRenderSelection
{
DrawLineToTargetInfo Info;
public DrawLineToTarget(DrawLineToTargetInfo info)
@@ -44,7 +44,7 @@ namespace OpenRA.Traits
this.c = c;
}
public void Render (Actor self)
public void RenderAfterWorld (Actor self)
{
var force = Game.controller.GetModifiers().HasModifier(Modifiers.Alt);
if ((lifetime <= 0 || --lifetime <= 0) && !force)

View File

@@ -23,13 +23,13 @@ namespace OpenRA.Traits
public readonly float Radius = 10;
}
public class Selectable : IRenderSelection
public class Selectable : IPostRenderSelection
{
// depends on the order of pips in TraitsInterfaces.cs!
static readonly string[] pipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray" };
static readonly string[] tagStrings = { "", "tag-fake", "tag-primary" };
public void Render (Actor self)
public void RenderAfterWorld (Actor self)
{
var bounds = self.GetBounds(true);

View File

@@ -165,7 +165,8 @@ namespace OpenRA.Traits
public interface IBlocksBullets { }
public interface IRenderSelection { void Render(Actor self); }
public interface IPostRenderSelection { void RenderAfterWorld(Actor self); }
public interface IPreRenderSelection { void RenderBeforeWorld(Actor self); }
public struct Target // a target: either an actor, or a fixed location.
{