Moving renders
Remove Traits.Render
This commit is contained in:
@@ -12,7 +12,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Traits;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
[Desc("Invisible during games.")]
|
||||
class RenderEditorOnlyInfo : RenderSimpleInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderEditorOnly(init.self); }
|
||||
}
|
||||
|
||||
class RenderEditorOnly : RenderSimple
|
||||
{
|
||||
public RenderEditorOnly(Actor self) : base(self, () => 0) { }
|
||||
|
||||
public override IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr) { return SpriteRenderable.None; }
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
class RenderFlareInfo : RenderSimpleInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderFlare(init.self); }
|
||||
}
|
||||
|
||||
class RenderFlare : RenderSimple
|
||||
{
|
||||
public RenderFlare(Actor self)
|
||||
: base(self, () => 0)
|
||||
{
|
||||
DefaultAnimation.PlayThen("open", () => DefaultAnimation.PlayRepeating("idle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.RA.Traits;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.Common;
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
public class RenderSimpleInfo : RenderSpritesInfo, IRenderActorPreviewSpritesInfo, IQuantizeBodyOrientationInfo, ILegacyEditorRenderInfo, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderSimple(init.self); }
|
||||
|
||||
public virtual IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||
{
|
||||
var ifacing = init.Actor.Traits.GetOrDefault<IFacingInfo>();
|
||||
var facing = ifacing != null ? init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : ifacing.GetInitialFacing() : 0;
|
||||
|
||||
var anim = new Animation(init.World, image, () => facing);
|
||||
anim.PlayRepeating("idle");
|
||||
yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
|
||||
}
|
||||
|
||||
public virtual int QuantizedBodyFacings(SequenceProvider sequenceProvider, ActorInfo ai)
|
||||
{
|
||||
return sequenceProvider.GetSequence(RenderSprites.GetImage(ai), "idle").Facings;
|
||||
}
|
||||
|
||||
public string EditorPalette { get { return Palette; } }
|
||||
public string EditorImage(ActorInfo actor) { return RenderSimple.GetImage(actor); }
|
||||
}
|
||||
|
||||
public class RenderSimple : RenderSprites, IAutoSelectionSize
|
||||
{
|
||||
public readonly Animation DefaultAnimation;
|
||||
|
||||
public RenderSimple(Actor self, Func<int> baseFacing)
|
||||
: base(self)
|
||||
{
|
||||
DefaultAnimation = new Animation(self.World, GetImage(self), baseFacing);
|
||||
Add("", DefaultAnimation);
|
||||
}
|
||||
|
||||
public RenderSimple(Actor self)
|
||||
: this(self, MakeFacingFunc(self))
|
||||
{
|
||||
DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle"));
|
||||
}
|
||||
|
||||
public int2 SelectionSize(Actor self) { return AutoSelectionSize(self); }
|
||||
|
||||
public string NormalizeSequence(Actor self, string sequence)
|
||||
{
|
||||
return NormalizeSequence(DefaultAnimation, self.GetDamageState(), sequence);
|
||||
}
|
||||
|
||||
public void PlayCustomAnim(Actor self, string name)
|
||||
{
|
||||
if (DefaultAnimation.HasSequence(name))
|
||||
DefaultAnimation.PlayThen(NormalizeSequence(self, name),
|
||||
() => DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
public class RenderUnitInfo : RenderSimpleInfo, Requires<IFacingInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderUnit(init.self); }
|
||||
}
|
||||
|
||||
public class RenderUnit : RenderSimple
|
||||
{
|
||||
public RenderUnit(Actor self)
|
||||
: base(self) { }
|
||||
|
||||
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
|
||||
{
|
||||
DefaultAnimation.PlayThen(newAnim, () => { DefaultAnimation.Play("idle"); if (after != null) after(); });
|
||||
}
|
||||
|
||||
public void PlayCustomAnimRepeating(Actor self, string name)
|
||||
{
|
||||
DefaultAnimation.PlayThen(name,
|
||||
() => PlayCustomAnimRepeating(self, name));
|
||||
}
|
||||
|
||||
public void PlayCustomAnimBackwards(Actor self, string name, Action after)
|
||||
{
|
||||
DefaultAnimation.PlayBackwardsThen(name,
|
||||
() => { DefaultAnimation.PlayRepeating("idle"); if (after != null) after(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
[Desc("Changes the animation when the actor constructed a building.")]
|
||||
public class WithBuildingPlacedAnimationInfo : ITraitInfo, Requires<RenderSimpleInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "build";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithBuildingPlacedAnimation(init.self, this); }
|
||||
}
|
||||
|
||||
public class WithBuildingPlacedAnimation : INotifyBuildingPlaced
|
||||
{
|
||||
WithBuildingPlacedAnimationInfo info;
|
||||
RenderSimple renderSimple;
|
||||
|
||||
public WithBuildingPlacedAnimation(Actor self, WithBuildingPlacedAnimationInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
renderSimple = self.Trait<RenderSimple>();
|
||||
}
|
||||
|
||||
public void BuildingPlaced(Actor self)
|
||||
{
|
||||
renderSimple.PlayCustomAnim(self, info.Sequence);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.Mods.Common.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
[Desc("This actor has a death animation.")]
|
||||
public class WithDeathAnimationInfo : ITraitInfo, Requires<RenderSimpleInfo>
|
||||
{
|
||||
[Desc("Sequence to play when this actor is killed by a warhead.")]
|
||||
public readonly string DeathSequence = "die";
|
||||
public readonly string DeathSequencePalette = "player";
|
||||
[Desc("Custom death animation palette is a player palette BaseName")]
|
||||
public readonly bool DeathPaletteIsPlayerPalette = true;
|
||||
[Desc("Should DeathType-specific sequences be used (sequence name = DeathSequence + DeathType).")]
|
||||
public readonly bool UseDeathTypeSuffix = true;
|
||||
[Desc("Sequence to play when this actor is crushed.")]
|
||||
public readonly string CrushedSequence = "die-crushed";
|
||||
public readonly string CrushedSequencePalette = "effect";
|
||||
[Desc("Custom crushed animation palette is a player palette BaseName")]
|
||||
public readonly bool CrushedPaletteIsPlayerPalette = false;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithDeathAnimation(init.self, this); }
|
||||
}
|
||||
|
||||
public class WithDeathAnimation : INotifyKilled
|
||||
{
|
||||
public readonly WithDeathAnimationInfo Info;
|
||||
readonly RenderSimple renderSimple;
|
||||
|
||||
public WithDeathAnimation(Actor self, WithDeathAnimationInfo info)
|
||||
{
|
||||
Info = info;
|
||||
renderSimple = self.Trait<RenderSimple>();
|
||||
}
|
||||
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
// Killed by some non-standard means. This includes being crushed
|
||||
// by a vehicle (Actors with Crushable trait will spawn CrushedSequence instead).
|
||||
if (e.Warhead == null)
|
||||
return;
|
||||
|
||||
var sequence = Info.DeathSequence;
|
||||
if (Info.UseDeathTypeSuffix)
|
||||
sequence += e.Warhead.DeathType;
|
||||
|
||||
var palette = Info.DeathSequencePalette;
|
||||
if (Info.DeathPaletteIsPlayerPalette)
|
||||
palette += self.Owner.InternalName;
|
||||
|
||||
SpawnDeathAnimation(self, sequence, palette);
|
||||
}
|
||||
|
||||
public void SpawnDeathAnimation(Actor self, string sequence, string palette)
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (!self.Destroyed)
|
||||
w.Add(new Corpse(w, self.CenterPosition, renderSimple.GetImage(self), sequence, palette));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -12,7 +12,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.RA.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Traits;
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
[Desc("Displays the fill status of PlayerResources with an extra sprite overlay on the actor.")]
|
||||
class WithResourcesInfo : ITraitInfo, Requires<RenderSimpleInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "resources";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithResources(init.self, this); }
|
||||
}
|
||||
|
||||
class WithResources : INotifyBuildComplete, INotifySold, INotifyOwnerChanged, INotifyDamageStateChanged
|
||||
{
|
||||
WithResourcesInfo info;
|
||||
Animation anim;
|
||||
RenderSimple rs;
|
||||
PlayerResources playerResources;
|
||||
bool buildComplete;
|
||||
|
||||
public WithResources(Actor self, WithResourcesInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
rs = self.Trait<RenderSimple>();
|
||||
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
|
||||
anim = new Animation(self.World, rs.GetImage(self));
|
||||
anim.PlayFetchIndex(info.Sequence,
|
||||
() => playerResources.ResourceCapacity != 0
|
||||
? ((10 * anim.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity)
|
||||
: 0);
|
||||
|
||||
rs.Add("resources_{0}".F(info.Sequence), new AnimationWithOffset(
|
||||
anim, null, () => !buildComplete, 1024));
|
||||
}
|
||||
|
||||
public void BuildingComplete( Actor self )
|
||||
{
|
||||
buildComplete = true;
|
||||
}
|
||||
|
||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (anim.CurrentSequence != null)
|
||||
anim.ReplaceAnim(rs.NormalizeSequence(self, info.Sequence));
|
||||
}
|
||||
|
||||
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||
{
|
||||
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
||||
}
|
||||
|
||||
public void Selling(Actor self) { rs.Remove("resources_{0}".F(info.Sequence)); }
|
||||
public void Sold(Actor self) { }
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
|
||||
Reference in New Issue
Block a user