Merge pull request #10119 from RoosterDragon/sort-effects-with-actors

Interleave renderables for effects and actors
This commit is contained in:
Matthias Mailänder
2015-12-31 12:31:47 +01:00
14 changed files with 153 additions and 76 deletions

View File

@@ -59,6 +59,9 @@ namespace OpenRA.Mods.Common.Effects
[Desc("Should the beam be visuall rendered? False = Beam is invisible.")]
public readonly bool RenderBeam = true;
[Desc("Equivalent to sequence ZOffset. Controls Z sorting.")]
public readonly int ZOffset = 0;
[Desc("Color of the beam.")]
public readonly Color Color = Color.Red;
@@ -193,7 +196,7 @@ namespace OpenRA.Mods.Common.Effects
{
if (!IsBeamComplete && info.RenderBeam && !(wr.World.FogObscures(tailPos) && wr.World.FogObscures(headPos)))
{
var beamRender = new BeamRenderable(headPos, 0, tailPos - headPos, info.Shape, info.Width, color);
var beamRender = new BeamRenderable(headPos, info.ZOffset, tailPos - headPos, info.Shape, info.Width, color);
return new[] { (IRenderable)beamRender };
}

View File

@@ -69,6 +69,7 @@ namespace OpenRA.Mods.Common.Effects
public readonly bool TrailUsePlayerPalette = false;
public readonly int ContrailLength = 0;
public readonly int ContrailZOffset = 2047;
public readonly Color ContrailColor = Color.White;
public readonly bool ContrailUsePlayerColor = false;
public readonly int ContrailDelay = 1;
@@ -134,7 +135,7 @@ namespace OpenRA.Mods.Common.Effects
if (info.ContrailLength > 0)
{
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, 0);
contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, info.ContrailZOffset);
}
trailPalette = info.TrailPalette;

View File

@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Common.Effects
[Desc("Position relative to body")]
public readonly WVec Offset = WVec.Zero;
[Desc("Offset for Z sorting.")]
public readonly int ZOffset = 0;
[Desc("Length of the trail (in ticks).")]
public readonly int TrailLength = 25;
@@ -51,7 +54,7 @@ namespace OpenRA.Mods.Common.Effects
this.info = info;
var color = info.UsePlayerColor ? ContrailRenderable.ChooseColor(self) : info.Color;
trail = new ContrailRenderable(self.World, color, info.TrailWidth, info.TrailLength, 0, 0);
trail = new ContrailRenderable(self.World, color, info.TrailWidth, info.TrailLength, 0, info.ZOffset);
body = self.Trait<BodyOrientation>();
}

View File

@@ -49,7 +49,8 @@ namespace OpenRA.Mods.Common.Effects
if (wr.World.FogObscures(pos))
yield break;
yield return new TextRenderable(font, pos, 0, color, text);
// Arbitrary large value used for the z-offset to try and ensure the text displays above everything else.
yield return new TextRenderable(font, pos, 4096, color, text);
}
public static string FormatCashTick(int cashAmount)

View File

@@ -27,6 +27,9 @@ namespace OpenRA.Mods.Common.Effects
[Desc("The shape of the beam. Accepts values Cylindrical or Flat.")]
public readonly BeamRenderableShape Shape = BeamRenderableShape.Cylindrical;
[Desc("Equivalent to sequence ZOffset. Controls Z sorting.")]
public readonly int ZOffset = 0;
public readonly int BeamDuration = 10;
public readonly bool UsePlayerColor = false;
@@ -102,7 +105,7 @@ namespace OpenRA.Mods.Common.Effects
if (ticks < info.BeamDuration)
{
var rc = Color.FromArgb((info.BeamDuration - ticks) * 255 / info.BeamDuration, color);
yield return new BeamRenderable(args.Source, 0, target - args.Source, info.Shape, info.Width, rc);
yield return new BeamRenderable(args.Source, info.ZOffset, target - args.Source, info.Shape, info.Width, rc);
}
if (hitanim != null)

View File

@@ -111,6 +111,8 @@ namespace OpenRA.Mods.Common.Effects
public readonly int ContrailLength = 0;
public readonly int ContrailZOffset = 2047;
public readonly WDist ContrailWidth = new WDist(64);
public readonly Color ContrailColor = Color.White;
@@ -217,7 +219,7 @@ namespace OpenRA.Mods.Common.Effects
if (info.ContrailLength > 0)
{
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, 0);
contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, info.ContrailZOffset);
}
trailPalette = info.TrailPalette;