Render building previews
This commit is contained in:
@@ -13,6 +13,7 @@ using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
|
||||
namespace OpenRA.Mods.RA.Orders
|
||||
{
|
||||
@@ -60,11 +61,14 @@ namespace OpenRA.Mods.RA.Orders
|
||||
}
|
||||
|
||||
public void Tick( World world ) {}
|
||||
|
||||
public void RenderAfterWorld( WorldRenderer wr, World world ) { }
|
||||
|
||||
public void RenderAfterWorld( WorldRenderer wr, World world ) {}
|
||||
public void RenderBeforeWorld( WorldRenderer wr, World world )
|
||||
{
|
||||
var topleft = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2() - FootprintUtils.AdjustForBuildingSize( BuildingInfo );
|
||||
var renderables = Rules.Info[Building].Traits.Get<RenderBuildingInfo>().BuildingPreview(Rules.Info[Building], world.Map.Tileset);
|
||||
foreach (var r in renderables)
|
||||
r.Sprite.DrawAt(wr,Game.CellSize*topleft + r.Pos, r.Palette ?? world.LocalPlayer.Palette);
|
||||
|
||||
BuildingInfo.DrawBuildingGrid( wr, world, Building );
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Traits;
|
||||
@@ -22,6 +23,14 @@ namespace OpenRA.Mods.RA.Render
|
||||
public readonly bool HasMakeAnimation = true;
|
||||
public readonly float2 Origin = float2.Zero;
|
||||
public override object Create(ActorInitializer init) { return new RenderBuilding(init);}
|
||||
|
||||
public virtual IEnumerable<Renderable> BuildingPreview(ActorInfo building, string Tileset)
|
||||
{
|
||||
var anim = new Animation(RenderSimple.GetImage(building, Tileset), () => 0);
|
||||
anim.PlayRepeating("idle");
|
||||
var rb = building.Traits.Get<RenderBuildingInfo>();
|
||||
yield return new Renderable(anim.Image,rb.Origin,rb.Palette,0);
|
||||
}
|
||||
}
|
||||
|
||||
public class RenderBuilding : RenderSimple, INotifyDamage, INotifySold, IRenderModifier
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -17,6 +18,17 @@ namespace OpenRA.Mods.RA.Render
|
||||
class RenderWarFactoryInfo : RenderBuildingInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderWarFactory(init); }
|
||||
|
||||
public override IEnumerable<Renderable> BuildingPreview(ActorInfo building, string Tileset)
|
||||
{
|
||||
foreach (var r in base.BuildingPreview(building, Tileset))
|
||||
yield return r;
|
||||
|
||||
var anim = new Animation(RenderSimple.GetImage(building, Tileset), () => 0);
|
||||
anim.PlayRepeating("idle-top");
|
||||
var rb = building.Traits.Get<RenderBuildingInfo>();
|
||||
yield return new Renderable(anim.Image,rb.Origin,rb.Palette,0);
|
||||
}
|
||||
}
|
||||
|
||||
class RenderWarFactory : RenderBuilding, INotifyBuildComplete, INotifyDamage, ITick, INotifyProduction, INotifySold
|
||||
|
||||
Reference in New Issue
Block a user