Change IPlaceBuildingDecorationInfo to use annotations.
This commit is contained in:
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
// TODO: remove all the Render*Circle duplication
|
// TODO: remove all the Render*Circle duplication
|
||||||
class RenderJammerCircleInfo : TraitInfo<RenderJammerCircle>, IPlaceBuildingDecorationInfo
|
class RenderJammerCircleInfo : TraitInfo<RenderJammerCircle>, IPlaceBuildingDecorationInfo
|
||||||
{
|
{
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
public IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||||
{
|
{
|
||||||
var jamsMissiles = ai.TraitInfoOrDefault<JamsMissilesInfo>();
|
var jamsMissiles = ai.TraitInfoOrDefault<JamsMissilesInfo>();
|
||||||
if (jamsMissiles != null)
|
if (jamsMissiles != null)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
[Desc("Contrast color of the circle.")]
|
[Desc("Contrast color of the circle.")]
|
||||||
public readonly Color ContrastColor = Color.FromArgb(96, Color.Black);
|
public readonly Color ContrastColor = Color.FromArgb(96, Color.Black);
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
public IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||||
{
|
{
|
||||||
var localRange = ai.TraitInfos<CreatesShroudInfo>()
|
var localRange = ai.TraitInfos<CreatesShroudInfo>()
|
||||||
.Where(csi => csi.EnabledByDefault)
|
.Where(csi => csi.EnabledByDefault)
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
int2 TopLeftScreenOffset { get; }
|
int2 TopLeftScreenOffset { get; }
|
||||||
void Tick();
|
void Tick();
|
||||||
IEnumerable<IRenderable> Render(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint);
|
IEnumerable<IRenderable> Render(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint);
|
||||||
|
IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, CPos topLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlaceBuildingOrderGenerator : IOrderGenerator
|
public class PlaceBuildingOrderGenerator : IOrderGenerator
|
||||||
@@ -281,7 +282,11 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
return preview != null ? preview.Render(wr, topLeft, footprint) : Enumerable.Empty<IRenderable>();
|
return preview != null ? preview.Render(wr, topLeft, footprint) : Enumerable.Empty<IRenderable>();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IRenderable> IOrderGenerator.RenderAnnotations(WorldRenderer wr, World world) { yield break; }
|
IEnumerable<IRenderable> IOrderGenerator.RenderAnnotations(WorldRenderer wr, World world)
|
||||||
|
{
|
||||||
|
var preview = variants[variant].Preview;
|
||||||
|
return preview != null ? preview.RenderAnnotations(wr, TopLeft) : Enumerable.Empty<IRenderable>();
|
||||||
|
}
|
||||||
|
|
||||||
string IOrderGenerator.GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return "default"; }
|
string IOrderGenerator.GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return "default"; }
|
||||||
|
|
||||||
|
|||||||
@@ -91,9 +91,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (palette != null)
|
if (palette != null)
|
||||||
previewRenderables = previewRenderables.Select(a => a.IsDecoration ? a : a.WithPalette(palette));
|
previewRenderables = previewRenderables.Select(a => a.IsDecoration ? a : a.WithPalette(palette));
|
||||||
|
|
||||||
foreach (var r in RenderDecorations(wr, topLeft))
|
|
||||||
yield return r;
|
|
||||||
|
|
||||||
if (info.FootprintUnderPreview != PlaceBuildingCellType.None)
|
if (info.FootprintUnderPreview != PlaceBuildingCellType.None)
|
||||||
foreach (var r in RenderFootprint(wr, topLeft, footprint, info.FootprintUnderPreview))
|
foreach (var r in RenderFootprint(wr, topLeft, footprint, info.FootprintUnderPreview))
|
||||||
yield return r;
|
yield return r;
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
bool IOccupySpaceInfo.SharesCell { get { return false; } }
|
bool IOccupySpaceInfo.SharesCell { get { return false; } }
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
public IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||||
{
|
{
|
||||||
if (!RequiresBaseProvider)
|
if (!RequiresBaseProvider)
|
||||||
return SpriteRenderable.None;
|
return SpriteRenderable.None;
|
||||||
|
|||||||
@@ -97,19 +97,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IEnumerable<IRenderable> RenderDecorations(WorldRenderer wr, CPos topLeft)
|
protected virtual IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, CPos topLeft)
|
||||||
{
|
{
|
||||||
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + centerOffset;
|
var centerPosition = wr.World.Map.CenterOfCell(topLeft) + centerOffset;
|
||||||
foreach (var d in decorations)
|
foreach (var d in decorations)
|
||||||
foreach (var r in d.Render(wr, wr.World, actorInfo, centerPosition))
|
foreach (var r in d.RenderAnnotations(wr, wr.World, actorInfo, centerPosition))
|
||||||
yield return r;
|
yield return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual IEnumerable<IRenderable> RenderInner(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint)
|
protected virtual IEnumerable<IRenderable> RenderInner(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint)
|
||||||
{
|
{
|
||||||
foreach (var r in RenderDecorations(wr, topLeft))
|
|
||||||
yield return r;
|
|
||||||
|
|
||||||
foreach (var r in RenderFootprint(wr, topLeft, footprint))
|
foreach (var r in RenderFootprint(wr, topLeft, footprint))
|
||||||
yield return r;
|
yield return r;
|
||||||
}
|
}
|
||||||
@@ -119,6 +116,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return RenderInner(wr, topLeft, footprint);
|
return RenderInner(wr, topLeft, footprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEnumerable<IRenderable> IPlaceBuildingPreview.RenderAnnotations(WorldRenderer wr, CPos topLeft)
|
||||||
|
{
|
||||||
|
return RenderAnnotations(wr, topLeft);
|
||||||
|
}
|
||||||
|
|
||||||
void IPlaceBuildingPreview.Tick() { TickInner(); }
|
void IPlaceBuildingPreview.Tick() { TickInner(); }
|
||||||
|
|
||||||
int2 IPlaceBuildingPreview.TopLeftScreenOffset { get { return topLeftScreenOffset; } }
|
int2 IPlaceBuildingPreview.TopLeftScreenOffset { get { return topLeftScreenOffset; } }
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override IEnumerable<IRenderable> RenderInner(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint)
|
protected override IEnumerable<IRenderable> RenderInner(WorldRenderer wr, CPos topLeft, Dictionary<CPos, PlaceBuildingCellType> footprint)
|
||||||
{
|
{
|
||||||
foreach (var r in RenderDecorations(wr, topLeft))
|
foreach (var r in RenderAnnotations(wr, topLeft))
|
||||||
yield return r;
|
yield return r;
|
||||||
|
|
||||||
if (info.FootprintUnderPreview != PlaceBuildingCellType.None)
|
if (info.FootprintUnderPreview != PlaceBuildingCellType.None)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
// Computed range
|
// Computed range
|
||||||
Lazy<WDist> range;
|
Lazy<WDist> range;
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
public IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||||
{
|
{
|
||||||
if (range == null || range.Value == WDist.Zero)
|
if (range == null || range.Value == WDist.Zero)
|
||||||
return SpriteRenderable.None;
|
return SpriteRenderable.None;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
[Desc("Range of the circle")]
|
[Desc("Range of the circle")]
|
||||||
public readonly WDist Range = WDist.Zero;
|
public readonly WDist Range = WDist.Zero;
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
public IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||||
{
|
{
|
||||||
if (EnabledByDefault)
|
if (EnabledByDefault)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public interface IPlaceBuildingDecorationInfo : ITraitInfo
|
public interface IPlaceBuildingDecorationInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition);
|
IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RequireExplicitImplementation]
|
[RequireExplicitImplementation]
|
||||||
|
|||||||
Reference in New Issue
Block a user