Allow beacons to be placed and drawn above the shroud.
This commit is contained in:
@@ -17,7 +17,7 @@ using OpenRA.Scripting;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Effects
|
namespace OpenRA.Mods.Common.Effects
|
||||||
{
|
{
|
||||||
public class Beacon : IEffect, IScriptBindable
|
public class Beacon : IEffect, IScriptBindable, IEffectAboveShroud
|
||||||
{
|
{
|
||||||
static readonly int MaxArrowHeight = 512;
|
static readonly int MaxArrowHeight = 512;
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(World world)
|
void IEffect.Tick(World world)
|
||||||
{
|
{
|
||||||
arrowHeight += arrowSpeed;
|
arrowHeight += arrowSpeed;
|
||||||
var clamped = arrowHeight.Clamp(0, MaxArrowHeight);
|
var clamped = arrowHeight.Clamp(0, MaxArrowHeight);
|
||||||
@@ -98,7 +98,9 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
clock.Tick();
|
clock.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer r)
|
IEnumerable<IRenderable> IEffect.Render(WorldRenderer r) { return SpriteRenderable.None; }
|
||||||
|
|
||||||
|
IEnumerable<IRenderable> IEffectAboveShroud.RenderAboveShroud(WorldRenderer r)
|
||||||
{
|
{
|
||||||
if (!owner.IsAlliedWith(owner.World.RenderPlayer))
|
if (!owner.IsAlliedWith(owner.World.RenderPlayer))
|
||||||
yield break;
|
yield break;
|
||||||
|
|||||||
@@ -17,22 +17,17 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
public class BeaconOrderGenerator : IOrderGenerator
|
public class BeaconOrderGenerator : IOrderGenerator
|
||||||
{
|
{
|
||||||
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
||||||
{
|
|
||||||
if (mi.Button != MouseButton.Left)
|
|
||||||
world.CancelInputMode();
|
|
||||||
else if (!world.ShroudObscures(cell))
|
|
||||||
{
|
{
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
yield return new Order("PlaceBeacon", world.LocalPlayer.PlayerActor, false) { TargetLocation = cell, SuppressVisualFeedback = true };
|
yield return new Order("PlaceBeacon", world.LocalPlayer.PlayerActor, false) { TargetLocation = cell, SuppressVisualFeedback = true };
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Tick(World world) { }
|
public virtual void Tick(World world) { }
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||||
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr, World world) { yield break; }
|
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr, World world) { yield break; }
|
||||||
public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
||||||
{
|
{
|
||||||
return !world.ShroudObscures(cell) ? "ability" : "generic-blocked";
|
return "ability";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using OpenRA.Scripting;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.TS.Effects
|
namespace OpenRA.Mods.TS.Effects
|
||||||
{
|
{
|
||||||
public class AnimatedBeacon : IEffect
|
public class AnimatedBeacon : IEffect, IEffectAboveShroud
|
||||||
{
|
{
|
||||||
readonly Player owner;
|
readonly Player owner;
|
||||||
readonly WPos position;
|
readonly WPos position;
|
||||||
@@ -43,19 +43,21 @@ namespace OpenRA.Mods.TS.Effects
|
|||||||
owner.World.Add(new DelayedAction(duration, () => owner.World.Remove(this)));
|
owner.World.Add(new DelayedAction(duration, () => owner.World.Remove(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(World world)
|
void IEffect.Tick(World world)
|
||||||
{
|
{
|
||||||
if (beacon != null)
|
if (beacon != null)
|
||||||
beacon.Tick();
|
beacon.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer r)
|
IEnumerable<IRenderable> IEffect.Render(WorldRenderer r) { return SpriteRenderable.None; }
|
||||||
|
|
||||||
|
IEnumerable<IRenderable> IEffectAboveShroud.RenderAboveShroud(WorldRenderer r)
|
||||||
{
|
{
|
||||||
if (beacon == null)
|
if (beacon == null)
|
||||||
return Enumerable.Empty<IRenderable>();
|
return SpriteRenderable.None;
|
||||||
|
|
||||||
if (!owner.IsAlliedWith(owner.World.RenderPlayer))
|
if (!owner.IsAlliedWith(owner.World.RenderPlayer))
|
||||||
return Enumerable.Empty<IRenderable>();
|
return SpriteRenderable.None;
|
||||||
|
|
||||||
var palette = r.Palette(isPlayerPalette ? beaconPalette + owner.InternalName : beaconPalette);
|
var palette = r.Palette(isPlayerPalette ? beaconPalette + owner.InternalName : beaconPalette);
|
||||||
return beacon.Render(position, palette);
|
return beacon.Render(position, palette);
|
||||||
|
|||||||
Reference in New Issue
Block a user