Extend WithSpriteBody funtionality

Move building placement range circle to PlaceBuilding, add
PauseAnimationWhenDisabled.
This commit is contained in:
reaperrr
2015-07-18 22:27:21 +02:00
parent 8d1e46dc54
commit bc2b60be05
3 changed files with 28 additions and 13 deletions

View File

@@ -8,15 +8,17 @@
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Effects;
using OpenRA.Graphics;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Allows the player to execute build orders.", " Attach this to the player actor.")]
public class PlaceBuildingInfo : ITraitInfo
public class PlaceBuildingInfo : ITraitInfo, IPlaceBuildingDecoration
{
[Desc("Palette to use for rendering the placement sprite.")]
[PaletteReference] public readonly string Palette = "terrain";
@@ -28,6 +30,16 @@ namespace OpenRA.Mods.Common.Traits
public readonly string NewOptionsNotification = "NewOptions";
public object Create(ActorInitializer init) { return new PlaceBuilding(this); }
public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
{
if (!ai.Traits.Get<BuildingInfo>().RequiresBaseProvider)
yield break;
foreach (var a in w.ActorsWithTrait<BaseProvider>())
foreach (var r in a.Trait.RenderAfterWorld(wr))
yield return r;
}
}
public class PlaceBuilding : IResolveOrder