Use a consistent set of arguments for Render* ctors.
This commit is contained in:
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
: this(init, info, () => 0) { }
|
||||
|
||||
public RenderBuilding(ActorInitializer init, RenderBuildingInfo info, Func<int> baseFacing)
|
||||
: base(init.Self, baseFacing)
|
||||
: base(init, info, baseFacing)
|
||||
{
|
||||
var self = init.Self;
|
||||
this.info = info;
|
||||
|
||||
@@ -16,12 +16,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Invisible during games.")]
|
||||
class RenderEditorOnlyInfo : RenderSimpleInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderEditorOnly(init.Self); }
|
||||
public override object Create(ActorInitializer init) { return new RenderEditorOnly(init, this); }
|
||||
}
|
||||
|
||||
class RenderEditorOnly : RenderSimple
|
||||
{
|
||||
public RenderEditorOnly(Actor self) : base(self, () => 0) { }
|
||||
public RenderEditorOnly(ActorInitializer init, RenderEditorOnlyInfo info)
|
||||
: base(init, info, () => 0) { }
|
||||
|
||||
public override IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr) { return SpriteRenderable.None; }
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
class RenderFlareInfo : RenderSimpleInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderFlare(init.Self); }
|
||||
public override object Create(ActorInitializer init) { return new RenderFlare(init, this); }
|
||||
}
|
||||
|
||||
class RenderFlare : RenderSimple
|
||||
{
|
||||
public RenderFlare(Actor self)
|
||||
: base(self, () => 0)
|
||||
public RenderFlare(ActorInitializer init, RenderFlareInfo info)
|
||||
: base(init, info, () => 0)
|
||||
{
|
||||
DefaultAnimation.PlayThen("open", () => DefaultAnimation.PlayRepeating("idle"));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
class RenderHarvesterInfo : RenderUnitInfo, Requires<HarvesterInfo>
|
||||
{
|
||||
public readonly string[] ImagesByFullness = { "harv" };
|
||||
public override object Create(ActorInitializer init) { return new RenderHarvester(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new RenderHarvester(init, this); }
|
||||
}
|
||||
|
||||
class RenderHarvester : RenderUnit, INotifyHarvesterAction
|
||||
@@ -25,15 +25,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Harvester harv;
|
||||
RenderHarvesterInfo info;
|
||||
|
||||
public RenderHarvester(Actor self, RenderHarvesterInfo info)
|
||||
: base(self)
|
||||
public RenderHarvester(ActorInitializer init, RenderHarvesterInfo info)
|
||||
: base(init, info)
|
||||
{
|
||||
this.info = info;
|
||||
harv = self.Trait<Harvester>();
|
||||
harv = init.Self.Trait<Harvester>();
|
||||
|
||||
// HACK: Force images to be loaded up-front
|
||||
foreach (var image in info.ImagesByFullness)
|
||||
new Animation(self.World, image);
|
||||
new Animation(init.World, image);
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string[] IdleAnimations = { };
|
||||
public readonly string[] StandAnimations = { "stand" };
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RenderInfantry(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new RenderInfantry(init, this); }
|
||||
|
||||
public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||
{
|
||||
@@ -58,14 +58,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
bool IsModifyingSequence { get { return rsm != null && rsm.IsModifyingSequence; } }
|
||||
bool wasModifying;
|
||||
|
||||
public RenderInfantry(Actor self, RenderInfantryInfo info)
|
||||
: base(self, MakeFacingFunc(self))
|
||||
public RenderInfantry(ActorInitializer init, RenderInfantryInfo info)
|
||||
: base(init, info, MakeFacingFunc(init.Self))
|
||||
{
|
||||
this.info = info;
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeInfantrySequence(self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeInfantrySequence(init.Self, info.StandAnimations.Random(Game.CosmeticRandom)), () => 0);
|
||||
state = AnimationState.Waiting;
|
||||
move = self.Trait<IMove>();
|
||||
rsm = self.TraitOrDefault<IRenderInfantrySequenceModifier>();
|
||||
move = init.Self.Trait<IMove>();
|
||||
rsm = init.Self.TraitOrDefault<IRenderInfantrySequenceModifier>();
|
||||
}
|
||||
|
||||
protected virtual string NormalizeInfantrySequence(Actor self, string baseSequence)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class RenderSimpleInfo : RenderSpritesInfo, IRenderActorPreviewSpritesInfo, IQuantizeBodyOrientationInfo, ILegacyEditorRenderInfo, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderSimple(init.Self); }
|
||||
public override object Create(ActorInitializer init) { return new RenderSimple(init, this); }
|
||||
|
||||
public virtual IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||
{
|
||||
@@ -43,17 +43,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public readonly Animation DefaultAnimation;
|
||||
|
||||
public RenderSimple(Actor self, Func<int> baseFacing)
|
||||
: base(self)
|
||||
public RenderSimple(ActorInitializer init, RenderSimpleInfo info, Func<int> baseFacing)
|
||||
: base(init, info)
|
||||
{
|
||||
DefaultAnimation = new Animation(self.World, GetImage(self), baseFacing);
|
||||
DefaultAnimation = new Animation(init.World, GetImage(init.Self), baseFacing);
|
||||
Add("", DefaultAnimation);
|
||||
}
|
||||
|
||||
public RenderSimple(Actor self)
|
||||
: this(self, MakeFacingFunc(self))
|
||||
public RenderSimple(ActorInitializer init, RenderSimpleInfo info)
|
||||
: this(init, info, MakeFacingFunc(init.Self))
|
||||
{
|
||||
DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle"));
|
||||
DefaultAnimation.PlayRepeating(NormalizeSequence(init.Self, "idle"));
|
||||
}
|
||||
|
||||
public int2 SelectionSize(Actor self) { return AutoSelectionSize(self); }
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Change the sprite image size.")]
|
||||
public readonly float Scale = 1f;
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new RenderSprites(init.Self); }
|
||||
public virtual object Create(ActorInitializer init) { return new RenderSprites(init, this); }
|
||||
|
||||
public IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init)
|
||||
{
|
||||
@@ -99,9 +99,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return () => facing.Facing;
|
||||
}
|
||||
|
||||
public RenderSprites(Actor self)
|
||||
public RenderSprites(ActorInitializer init, RenderSpritesInfo info)
|
||||
{
|
||||
info = self.Info.Traits.Get<RenderSpritesInfo>();
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public static string GetImage(ActorInfo actor)
|
||||
|
||||
@@ -15,13 +15,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class RenderUnitInfo : RenderSimpleInfo, Requires<IFacingInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderUnit(init.Self); }
|
||||
public override object Create(ActorInitializer init) { return new RenderUnit(init, this); }
|
||||
}
|
||||
|
||||
public class RenderUnit : RenderSimple
|
||||
{
|
||||
public RenderUnit(Actor self)
|
||||
: base(self) { }
|
||||
public RenderUnit(ActorInitializer init, RenderUnitInfo info)
|
||||
: base(init, info) { }
|
||||
|
||||
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user