Merge pull request #3665 from pchote/frozen-fog-prereqs
Rework bibs (again).
This commit is contained in:
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
public override object Create(ActorInitializer init) { return new Helicopter(init, this); }
|
||||
}
|
||||
|
||||
class Helicopter : Aircraft, ITick, IResolveOrder
|
||||
class Helicopter : Aircraft, ITick, IResolveOrder, IMove
|
||||
{
|
||||
public HelicopterInfo Info;
|
||||
bool firstTick = true;
|
||||
@@ -149,5 +149,9 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
return (d * 1024 * 8) / (int)distSq;
|
||||
}
|
||||
|
||||
public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(cell); }
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(cell); }
|
||||
public Activity MoveWithinRange(Target target, WRange range) { return new HeliFly(target.CenterPosition); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
public override object Create(ActorInitializer init) { return new Plane(init, this); }
|
||||
}
|
||||
|
||||
public class Plane : Aircraft, IResolveOrder, ITick, ISync
|
||||
public class Plane : Aircraft, IResolveOrder, IMove, ITick, ISync
|
||||
{
|
||||
public readonly PlaneInfo Info;
|
||||
[Sync] public WPos RTBPathHash;
|
||||
@@ -89,5 +89,9 @@ namespace OpenRA.Mods.RA.Air
|
||||
UnReserve();
|
||||
}
|
||||
}
|
||||
|
||||
public Activity MoveTo(CPos cell, int nearEnough) { return Fly.ToCell(cell); }
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return Fly.ToCell(cell); }
|
||||
public Activity MoveWithinRange(Target target, WRange range) { return Fly.ToPos(target.CenterPosition); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
foreach (var t in TileSprites[currentTemplate])
|
||||
yield return new SpriteRenderable(t.Value, t.Key.CenterPosition, 0, terrainPalette, 1f);
|
||||
yield return new SpriteRenderable(t.Value, t.Key.CenterPosition, WVec.Zero, 0, terrainPalette, 1f, true);
|
||||
}
|
||||
|
||||
void KillUnitsOnBridge()
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
public object Create(ActorInitializer init) { return new BaseProvider(init.self, this); }
|
||||
}
|
||||
|
||||
public class BaseProvider : ITick, IPreRenderSelection, ISelectionBar
|
||||
public class BaseProvider : ITick, IPostRenderSelection, ISelectionBar
|
||||
{
|
||||
public readonly BaseProviderInfo Info;
|
||||
DeveloperMode devMode;
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
}
|
||||
|
||||
// Range circle
|
||||
public void RenderBeforeWorld(WorldRenderer wr, Actor self)
|
||||
public void RenderAfterWorld(WorldRenderer wr)
|
||||
{
|
||||
// Visible to player and allies
|
||||
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||
|
||||
68
OpenRA.Mods.RA/Buildings/Bib.cs
Executable file
68
OpenRA.Mods.RA/Buildings/Bib.cs
Executable file
@@ -0,0 +1,68 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Buildings
|
||||
{
|
||||
public class BibInfo : ITraitInfo, Requires<BuildingInfo>, Requires<RenderSpritesInfo>
|
||||
{
|
||||
public readonly string Sequence = "bib";
|
||||
public readonly string Palette = "terrain";
|
||||
|
||||
public object Create(ActorInitializer init) { return new Bib(init.self, this); }
|
||||
}
|
||||
|
||||
public class Bib : IRender
|
||||
{
|
||||
readonly BibInfo info;
|
||||
readonly List<AnimationWithOffset> tiles;
|
||||
|
||||
public Bib(Actor self, BibInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var building = self.Info.Traits.Get<BuildingInfo>();
|
||||
var width = building.Dimensions.X;
|
||||
var bibOffset = building.Dimensions.Y - 1;
|
||||
var centerOffset = FootprintUtils.CenterOffset(building);
|
||||
|
||||
tiles = new List<AnimationWithOffset>();
|
||||
for (var i = 0; i < 2*width; i++)
|
||||
{
|
||||
var index = i;
|
||||
var anim = new Animation(rs.GetImage(self));
|
||||
anim.PlayFetchIndex(info.Sequence, () => index);
|
||||
anim.IsDecoration = true;
|
||||
|
||||
// Z-order is one set to the top of the footprint
|
||||
var offset = new CVec(i % width, i / width + bibOffset).ToWVec() - centerOffset;
|
||||
tiles.Add(new AnimationWithOffset(anim, () => offset, null, -(offset.Y + centerOffset.Y + 512)));
|
||||
}
|
||||
}
|
||||
|
||||
bool paletteInitialized;
|
||||
PaletteReference palette;
|
||||
public virtual IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr)
|
||||
{
|
||||
if (!paletteInitialized)
|
||||
{
|
||||
palette = wr.Palette(info.Palette);
|
||||
paletteInitialized = true;
|
||||
}
|
||||
|
||||
return tiles.SelectMany(t => t.Render(self, wr, palette, 1f));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Buildings
|
||||
{
|
||||
class BibLayerInfo : ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new BibLayer(init.self); }
|
||||
}
|
||||
|
||||
struct CachedBib
|
||||
{
|
||||
public Dictionary<CPos, Sprite> Tiles;
|
||||
public IEnumerable<CPos> Footprint;
|
||||
public bool Visible;
|
||||
public bool Immediate;
|
||||
}
|
||||
|
||||
class BibLayer : IRenderOverlay, ITickRender
|
||||
{
|
||||
World world;
|
||||
Dictionary<Actor, CachedBib> visible;
|
||||
Dictionary<Actor, CachedBib> dirty;
|
||||
Cache<string, Sprite[]> sprites;
|
||||
|
||||
public BibLayer(Actor self)
|
||||
{
|
||||
world = self.World;
|
||||
visible = new Dictionary<Actor, CachedBib>();
|
||||
dirty = new Dictionary<Actor, CachedBib>();
|
||||
sprites = new Cache<string, Sprite[]>(x => Game.modData.SpriteLoader.LoadAllSprites(x));
|
||||
}
|
||||
|
||||
public void Update(Actor a, CachedBib bib)
|
||||
{
|
||||
dirty[a] = bib;
|
||||
}
|
||||
|
||||
public Sprite[] LoadSprites(string bibType)
|
||||
{
|
||||
return sprites[bibType];
|
||||
}
|
||||
|
||||
public void TickRender(WorldRenderer wr, Actor self)
|
||||
{
|
||||
var remove = new List<Actor>();
|
||||
foreach (var kv in dirty)
|
||||
{
|
||||
if (kv.Value.Immediate || kv.Value.Footprint.Any(c => !self.World.FogObscures(c)))
|
||||
{
|
||||
if (kv.Value.Visible)
|
||||
visible[kv.Key] = kv.Value;
|
||||
else
|
||||
visible.Remove(kv.Key);
|
||||
|
||||
remove.Add(kv.Key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var r in remove)
|
||||
dirty.Remove(r);
|
||||
}
|
||||
|
||||
public void Render(WorldRenderer wr)
|
||||
{
|
||||
var pal = wr.Palette("terrain");
|
||||
var cliprect = Game.viewport.WorldBounds(world);
|
||||
|
||||
foreach (var bib in visible.Values)
|
||||
{
|
||||
foreach (var kv in bib.Tiles)
|
||||
{
|
||||
if (!cliprect.Contains(kv.Key.X, kv.Key.Y))
|
||||
continue;
|
||||
|
||||
if (world.ShroudObscures(kv.Key))
|
||||
continue;
|
||||
|
||||
kv.Value.DrawAt(wr.ScreenPxPosition(kv.Key.CenterPosition) - 0.5f * kv.Value.size, pal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class BibInfo : ITraitInfo, Requires<BuildingInfo>
|
||||
{
|
||||
public readonly string Sprite = "bib3";
|
||||
|
||||
public object Create(ActorInitializer init) { return new Bib(init.self, this); }
|
||||
}
|
||||
|
||||
public class Bib : INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
{
|
||||
readonly BibInfo info;
|
||||
readonly BibLayer bibLayer;
|
||||
bool firstAdd;
|
||||
|
||||
public Bib(Actor self, BibInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
bibLayer = self.World.WorldActor.Trait<BibLayer>();
|
||||
firstAdd = true;
|
||||
}
|
||||
|
||||
void DoBib(Actor self, bool add)
|
||||
{
|
||||
var buildingInfo = self.Info.Traits.Get<BuildingInfo>();
|
||||
var size = buildingInfo.Dimensions.X;
|
||||
var bibOffset = buildingInfo.Dimensions.Y - 1;
|
||||
var sprites = bibLayer.LoadSprites(info.Sprite);
|
||||
|
||||
if (sprites.Length != 2*size)
|
||||
throw new InvalidOperationException("{0} is an invalid bib for a {1}-wide building".F(info.Sprite, size));
|
||||
|
||||
var immediate = !self.HasTrait<FrozenUnderFog>() ||
|
||||
(firstAdd && self.Info.Traits.GetOrDefault<FrozenUnderFogInfo>().StartsRevealed);
|
||||
|
||||
var dirty = new CachedBib()
|
||||
{
|
||||
Footprint = FootprintUtils.Tiles(self),
|
||||
Tiles = new Dictionary<CPos, Sprite>(),
|
||||
Visible = add,
|
||||
Immediate = immediate
|
||||
};
|
||||
|
||||
for (var i = 0; i < 2 * size; i++)
|
||||
{
|
||||
var cell = self.Location + new CVec(i % size, i / size + bibOffset);
|
||||
dirty.Tiles.Add(cell, sprites[i]);
|
||||
}
|
||||
|
||||
firstAdd = false;
|
||||
bibLayer.Update(self, dirty);
|
||||
}
|
||||
|
||||
public void AddedToWorld(Actor self) { DoBib(self, true); }
|
||||
public void RemovedFromWorld(Actor self) { DoBib(self, false); }
|
||||
}
|
||||
}
|
||||
@@ -143,8 +143,9 @@ namespace OpenRA.Mods.RA
|
||||
if (!self.IsInWorld || self.IsDead())
|
||||
world.CancelInputMode();
|
||||
}
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world) { }
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world)
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world)
|
||||
{
|
||||
if (!self.IsInWorld)
|
||||
return;
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
yield break;
|
||||
|
||||
foreach (var r in a.Render(wr))
|
||||
if (!r.IsDecoration)
|
||||
yield return r.WithPalette(wr.Palette("invuln"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,9 @@ namespace OpenRA.Mods.RA.Effects
|
||||
var shadow = wr.Palette("shadow");
|
||||
foreach (var c in rc)
|
||||
{
|
||||
yield return c.WithPalette(shadow).WithZOffset(-1);
|
||||
if (!c.IsDecoration)
|
||||
yield return c.WithPalette(shadow).WithZOffset(c.ZOffset - 1).AsDecoration();
|
||||
|
||||
yield return c.OffsetBy(pos - c.Pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,8 +118,8 @@ namespace OpenRA.Mods.RA
|
||||
yield break;
|
||||
|
||||
var bounds = self.Bounds.Value;
|
||||
var pos = new float2(bounds.Right, bounds.Bottom - 2);
|
||||
yield return new SpriteRenderable(RankAnim.Image, pos, wr.Palette("effect"), self.CenterLocation.Y);
|
||||
var pos = new PPos(bounds.Right, bounds.Bottom - 2).ToWPos(0);
|
||||
yield return new SpriteRenderable(RankAnim.Image, pos, WVec.Zero, 0, wr.Palette("effect"), 1f, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Copyright & License Information
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA
|
||||
world.CancelInputMode();
|
||||
}
|
||||
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world) { }
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world) { }
|
||||
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi)
|
||||
|
||||
@@ -125,6 +125,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
CPos lastMousePos;
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world)
|
||||
{
|
||||
if (!minelayer.IsInWorld)
|
||||
@@ -138,8 +139,6 @@ namespace OpenRA.Mods.RA
|
||||
wr.DrawLocus(Color.Cyan, minefield);
|
||||
}
|
||||
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world) { }
|
||||
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi) { lastMousePos = xy; return "ability"; } /* TODO */
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,10 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
if (visible)
|
||||
proxy.SetRenderables(self.Render(wr));
|
||||
{
|
||||
var comparer = new RenderableComparer(wr);
|
||||
proxy.SetRenderables(self.Render(wr).OrderBy(r => r, comparer));
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
public int GetInitialFacing() { return InitialFacing; }
|
||||
}
|
||||
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IFacing, ISync
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, IFacing, ISync
|
||||
{
|
||||
public readonly Actor self;
|
||||
public readonly MobileInfo Info;
|
||||
|
||||
@@ -154,7 +154,6 @@
|
||||
<Compile Include="BridgeLayer.cs" />
|
||||
<Compile Include="Buildable.cs" />
|
||||
<Compile Include="BuildingCaptureNotification.cs" />
|
||||
<Compile Include="Buildings\BibLayer.cs" />
|
||||
<Compile Include="Buildings\Building.cs" />
|
||||
<Compile Include="Buildings\BuildingInfluence.cs" />
|
||||
<Compile Include="Buildings\CanPowerDown.cs" />
|
||||
@@ -462,6 +461,7 @@
|
||||
<Compile Include="Effects\FrozenActorProxy.cs" />
|
||||
<Compile Include="Widgets\Logic\WorldTooltipLogic.cs" />
|
||||
<Compile Include="TeslaZapRenderable.cs" />
|
||||
<Compile Include="Buildings\Bib.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -68,8 +68,8 @@ namespace OpenRA.Mods.RA.Orders
|
||||
}
|
||||
|
||||
public void Tick(World world) {}
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world) {}
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world)
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world)
|
||||
{
|
||||
var position = Game.viewport.ViewToWorld(Viewport.LastMousePos);
|
||||
var topLeft = position - FootprintUtils.AdjustForBuildingSize(BuildingInfo);
|
||||
@@ -110,7 +110,10 @@ namespace OpenRA.Mods.RA.Orders
|
||||
|
||||
var pal = wr.Palette("terrain");
|
||||
foreach (var c in cells)
|
||||
(c.Value ? buildOk : buildBlocked).DrawAt(c.Key.ToPPos().ToFloat2(), pal);
|
||||
{
|
||||
var tile = c.Value ? buildOk : buildBlocked;
|
||||
tile.DrawAt(wr.ScreenPxPosition(c.Key.CenterPosition) - 0.5f * tile.size, pal);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi) { return "default"; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Copyright & License Information
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
@@ -55,8 +55,8 @@ namespace OpenRA.Mods.RA.Orders
|
||||
world.CancelInputMode();
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world) { }
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world) { }
|
||||
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Copyright & License Information
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
@@ -49,8 +49,8 @@ namespace OpenRA.Mods.RA.Orders
|
||||
world.CancelInputMode();
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world) { }
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world) { }
|
||||
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi)
|
||||
{
|
||||
|
||||
@@ -38,13 +38,12 @@ namespace OpenRA.Mods.RA.Orders
|
||||
}
|
||||
|
||||
public void Tick( World world ) { }
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld( WorldRenderer wr, World world )
|
||||
{
|
||||
wr.DrawSelectionBox(self, Color.White);
|
||||
}
|
||||
|
||||
public void RenderBeforeWorld( WorldRenderer wr, World world ) { }
|
||||
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi)
|
||||
{
|
||||
if (!world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
|
||||
@@ -94,19 +94,11 @@ namespace OpenRA.Mods.RA
|
||||
if (rp == null)
|
||||
return exitLocation;
|
||||
|
||||
var mobile = newUnit.TraitOrDefault<Mobile>();
|
||||
if (mobile != null)
|
||||
var move = newUnit.TraitOrDefault<IMove>();
|
||||
if (move != null)
|
||||
{
|
||||
newUnit.QueueActivity(new AttackMove.AttackMoveActivity(
|
||||
newUnit, mobile.MoveTo(rp.rallyPoint, rp.nearEnough)));
|
||||
return rp.rallyPoint;
|
||||
}
|
||||
|
||||
// TODO: don't talk about HeliFly here.
|
||||
var helicopter = newUnit.TraitOrDefault<Helicopter>();
|
||||
if (helicopter != null)
|
||||
{
|
||||
newUnit.QueueActivity(new HeliFly(rp.rallyPoint));
|
||||
newUnit, move.MoveTo(rp.rallyPoint, rp.nearEnough)));
|
||||
return rp.rallyPoint;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
return;
|
||||
|
||||
foreach (var a in w.ActorsWithTrait<BaseProvider>())
|
||||
a.Trait.RenderBeforeWorld(wr, a.Actor);
|
||||
a.Trait.RenderAfterWorld(wr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,10 @@ namespace OpenRA.Mods.RA.Render
|
||||
foreach (var a in r)
|
||||
{
|
||||
yield return a;
|
||||
if (disabled)
|
||||
yield return a.WithPalette(wr.Palette("disabled")).WithZOffset(1);
|
||||
if (disabled && !a.IsDecoration)
|
||||
yield return a.WithPalette(wr.Palette("disabled"))
|
||||
.WithZOffset(a.ZOffset + 1)
|
||||
.AsDecoration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,11 @@ namespace OpenRA.Mods.RA.Render
|
||||
? (int)Math.Abs((self.ActorID + Game.LocalTick) / 5 % 4 - 1) - 1 : 0;
|
||||
|
||||
// Contrails shouldn't cast shadows
|
||||
var shadowSprites = r.Where(s => !(s is ContrailRenderable))
|
||||
var shadowSprites = r.Where(s => !s.IsDecoration)
|
||||
.Select(a => a.WithPalette(wr.Palette("shadow"))
|
||||
.OffsetBy(new WVec(0, 0, -a.Pos.Z)).WithZOffset(a.ZOffset + a.Pos.Z));
|
||||
.OffsetBy(new WVec(0, 0, -a.Pos.Z))
|
||||
.WithZOffset(a.ZOffset + a.Pos.Z)
|
||||
.AsDecoration());
|
||||
|
||||
var worldVisualOffset = new WVec(0,0,-43*visualOffset);
|
||||
var flyingSprites = !flying ? r :
|
||||
|
||||
@@ -14,10 +14,18 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderDetectionCircleInfo : TraitInfo<RenderDetectionCircle> { }
|
||||
class RenderDetectionCircle : IPreRenderSelection
|
||||
class RenderDetectionCircleInfo : ITraitInfo
|
||||
{
|
||||
public void RenderBeforeWorld(WorldRenderer wr, Actor self)
|
||||
public object Create(ActorInitializer init) { return new RenderDetectionCircle(init.self); }
|
||||
}
|
||||
|
||||
class RenderDetectionCircle : IPostRenderSelection
|
||||
{
|
||||
Actor self;
|
||||
|
||||
public RenderDetectionCircle(Actor self) { this.self = self; }
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr)
|
||||
{
|
||||
if (self.Owner != self.World.LocalPlayer)
|
||||
return;
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
//todo: remove all the Render*Circle duplication
|
||||
class RenderJammerCircleInfo : TraitInfo<RenderJammerCircle>, IPlaceBuildingDecoration
|
||||
class RenderJammerCircleInfo : ITraitInfo, IPlaceBuildingDecoration
|
||||
{
|
||||
public void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||
{
|
||||
@@ -29,13 +29,19 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
foreach (var a in w.ActorsWithTrait<RenderJammerCircle>())
|
||||
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
||||
a.Trait.RenderBeforeWorld(wr, a.Actor);
|
||||
a.Trait.RenderAfterWorld(wr);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new RenderJammerCircle(init.self); }
|
||||
}
|
||||
|
||||
public class RenderJammerCircle : IPreRenderSelection
|
||||
class RenderJammerCircle : IPostRenderSelection
|
||||
{
|
||||
public void RenderBeforeWorld(WorldRenderer wr, Actor self)
|
||||
Actor self;
|
||||
|
||||
public RenderJammerCircle(Actor self) { this.self = self; }
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr)
|
||||
{
|
||||
if (self.Owner != self.World.LocalPlayer)
|
||||
return;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA
|
||||
void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition);
|
||||
}
|
||||
|
||||
class RenderRangeCircleInfo : TraitInfo<RenderRangeCircle>, IPlaceBuildingDecoration
|
||||
class RenderRangeCircleInfo : ITraitInfo, IPlaceBuildingDecoration
|
||||
{
|
||||
public readonly string RangeCircleType = null;
|
||||
|
||||
@@ -36,13 +36,19 @@ namespace OpenRA.Mods.RA
|
||||
foreach (var a in w.ActorsWithTrait<RenderRangeCircle>())
|
||||
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
||||
if (a.Actor.Info.Traits.Get<RenderRangeCircleInfo>().RangeCircleType == RangeCircleType)
|
||||
a.Trait.RenderBeforeWorld(wr, a.Actor);
|
||||
a.Trait.RenderAfterWorld(wr);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new RenderRangeCircle(init.self); }
|
||||
}
|
||||
|
||||
class RenderRangeCircle : IPreRenderSelection
|
||||
class RenderRangeCircle : IPostRenderSelection
|
||||
{
|
||||
public void RenderBeforeWorld(WorldRenderer wr, Actor self)
|
||||
Actor self;
|
||||
|
||||
public RenderRangeCircle(Actor self) { this.self = self; }
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr)
|
||||
{
|
||||
if (self.Owner != self.World.LocalPlayer)
|
||||
return;
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class RenderShroudCircleInfo : TraitInfo<RenderShroudCircle>, IPlaceBuildingDecoration
|
||||
class RenderShroudCircleInfo : ITraitInfo, IPlaceBuildingDecoration
|
||||
{
|
||||
public void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
|
||||
{
|
||||
@@ -27,13 +27,19 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
foreach (var a in w.ActorsWithTrait<RenderShroudCircle>())
|
||||
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
||||
a.Trait.RenderBeforeWorld(wr, a.Actor);
|
||||
a.Trait.RenderAfterWorld(wr);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new RenderShroudCircle(init.self); }
|
||||
}
|
||||
|
||||
class RenderShroudCircle : IPreRenderSelection
|
||||
class RenderShroudCircle : IPostRenderSelection
|
||||
{
|
||||
public void RenderBeforeWorld(WorldRenderer wr, Actor self)
|
||||
Actor self;
|
||||
|
||||
public RenderShroudCircle(Actor self) { this.self = self; }
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr)
|
||||
{
|
||||
if (self.Owner != self.World.LocalPlayer)
|
||||
return;
|
||||
|
||||
@@ -51,17 +51,6 @@ namespace OpenRA.Mods.RA
|
||||
return self.Owner;
|
||||
}
|
||||
|
||||
public Stance Stance()
|
||||
{
|
||||
if (spy.Disguised)
|
||||
{
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
return self.World.LocalPlayer.Stances[self.Owner];
|
||||
return self.World.LocalPlayer.Stances[spy.disguisedAsPlayer];
|
||||
}
|
||||
return self.World.LocalPlayer.Stances[self.Owner];
|
||||
}
|
||||
|
||||
public SpyToolTip( Actor self, TooltipInfo info )
|
||||
{
|
||||
this.self = self;
|
||||
|
||||
@@ -140,20 +140,18 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
var xy = Game.viewport.ViewToWorld(Viewport.LastMousePos);
|
||||
var targetUnits = power.UnitsInRange(xy);
|
||||
foreach (var unit in targetUnits) {
|
||||
if (manager.self.Owner.Shroud.IsTargetable(unit) || manager.self.Owner.HasFogVisibility()) {
|
||||
foreach (var unit in targetUnits)
|
||||
if (manager.self.Owner.Shroud.IsTargetable(unit) || manager.self.Owner.HasFogVisibility())
|
||||
wr.DrawSelectionBox(unit, Color.Red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world)
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
|
||||
{
|
||||
var xy = Game.viewport.ViewToWorld(Viewport.LastMousePos);
|
||||
var tiles = world.FindTilesInCircle(xy, range);
|
||||
var pal = wr.Palette("terrain");
|
||||
foreach (var t in tiles)
|
||||
tile.DrawAt(t.ToPPos().ToFloat2(), pal);
|
||||
yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
|
||||
}
|
||||
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi)
|
||||
@@ -221,25 +219,23 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world)
|
||||
{
|
||||
foreach (var unit in power.UnitsInRange(sourceLocation)) {
|
||||
if (manager.self.Owner.Shroud.IsTargetable(unit) || manager.self.Owner.HasFogVisibility()) {
|
||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||
if (manager.self.Owner.Shroud.IsTargetable(unit) || manager.self.Owner.HasFogVisibility())
|
||||
wr.DrawSelectionBox(unit, Color.Red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world)
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
|
||||
{
|
||||
var xy = Game.viewport.ViewToWorld(Viewport.LastMousePos);
|
||||
var pal = wr.Palette("terrain");
|
||||
|
||||
// Source tiles
|
||||
foreach (var t in world.FindTilesInCircle(sourceLocation, range))
|
||||
sourceTile.DrawAt(t.ToPPos().ToFloat2(), pal);
|
||||
yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
|
||||
|
||||
// Destination tiles
|
||||
foreach (var t in world.FindTilesInCircle(xy, range))
|
||||
sourceTile.DrawAt(t.ToPPos().ToFloat2(), pal);
|
||||
yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
|
||||
|
||||
// Unit previews
|
||||
foreach (var unit in power.UnitsInRange(sourceLocation))
|
||||
@@ -247,7 +243,7 @@ namespace OpenRA.Mods.RA
|
||||
var offset = (xy - sourceLocation).ToWVec();
|
||||
if (manager.self.Owner.Shroud.IsTargetable(unit))
|
||||
foreach (var r in unit.Render(wr))
|
||||
r.OffsetBy(offset).Render(wr);
|
||||
yield return r.OffsetBy(offset);
|
||||
}
|
||||
|
||||
// Unit tiles
|
||||
@@ -259,7 +255,7 @@ namespace OpenRA.Mods.RA
|
||||
var canEnter = ((manager.self.Owner.Shroud.IsExplored(targetCell) || manager.self.Owner.HasFogVisibility()) &&
|
||||
unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell));
|
||||
var tile = canEnter ? validTile : invalidTile;
|
||||
tile.DrawAt(targetCell.ToPPos().ToFloat2(), pal);
|
||||
yield return new SpriteRenderable(tile, targetCell.CenterPosition, WVec.Zero, -511, pal, 1f, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,7 +272,8 @@ namespace OpenRA.Mods.RA
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!canTeleport) {
|
||||
if (!canTeleport)
|
||||
{
|
||||
// Check the terrain types. This will allow chronoshifts to occur on empty terrain to terrain of
|
||||
// a similar type. This also keeps the cursor from changing in non-visible property, alerting the
|
||||
// chronoshifter of enemy unit presence
|
||||
|
||||
@@ -95,12 +95,12 @@ namespace OpenRA.Mods.RA
|
||||
wr.DrawSelectionBox(unit, Color.Red);
|
||||
}
|
||||
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world)
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
|
||||
{
|
||||
var xy = Game.viewport.ViewToWorld(Viewport.LastMousePos);
|
||||
var pal = wr.Palette("terrain");
|
||||
foreach (var t in world.FindTilesInCircle(xy, range))
|
||||
tile.DrawAt(t.ToPPos().ToFloat2(), pal);
|
||||
yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
|
||||
}
|
||||
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi)
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace OpenRA.Mods.RA
|
||||
world.CancelInputMode();
|
||||
}
|
||||
|
||||
public void RenderBeforeWorld(WorldRenderer wr, World world) { }
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
|
||||
public void RenderAfterWorld(WorldRenderer wr, World world) { }
|
||||
public string GetCursor(World world, CPos xy, MouseInput mi) { return world.Map.IsInMap(xy) ? cursor : "generic-blocked"; }
|
||||
}
|
||||
|
||||
@@ -60,11 +60,13 @@ namespace OpenRA.Mods.RA
|
||||
public float Scale { get { return 1f; } }
|
||||
public PaletteReference Palette { get { return null; } }
|
||||
public int ZOffset { get { return zOffset; } }
|
||||
public bool IsDecoration { get { return true; } }
|
||||
|
||||
public IRenderable WithScale(float newScale) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps); }
|
||||
public IRenderable WithPalette(PaletteReference newPalette) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps); }
|
||||
public IRenderable WithZOffset(int newOffset) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps); }
|
||||
public IRenderable OffsetBy(WVec vec) { return new TeslaZapRenderable(pos + vec, zOffset, length, image, brightZaps, dimZaps); }
|
||||
public IRenderable AsDecoration() { return this; }
|
||||
|
||||
public void BeforeRender(WorldRenderer wr) { }
|
||||
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||
@@ -132,8 +134,8 @@ namespace OpenRA.Mods.RA
|
||||
var step = steps.Where(t => (to - (z + new float2(t[0], t[1]))).LengthSquared < (to - z).LengthSquared)
|
||||
.OrderBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c)).First();
|
||||
|
||||
rs.Add(new SpriteRenderable(s.GetSprite(step[4]), z + new float2(step[2], step[3]),
|
||||
wr.Palette("effect"), (int)from.Y));
|
||||
var pos = new PPos((int)(z.X + step[2]), (int)(z.Y + step[3])).ToWPos(0);
|
||||
rs.Add(new SpriteRenderable(s.GetSprite(step[4]), pos, WVec.Zero, 0, wr.Palette("effect"), 1f, true));
|
||||
|
||||
z += new float2(step[0], step[1]);
|
||||
if (rs.Count >= 1000)
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public string Name() { return Info.Name; }
|
||||
public Player Owner() { return self.Owner; }
|
||||
public Stance Stance() { return self.World.LocalPlayer.Stances[self.Owner]; }
|
||||
|
||||
public Tooltip(Actor self, TooltipInfo info)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user