Change animations to use the proper SequenceProvider
Remove references to the global "Game" and use the SequenceProvider of the current world/map.
This commit is contained in:
@@ -21,15 +21,15 @@ namespace OpenRA.Mods.RA.Render
|
||||
public override object Create(ActorInitializer init) { return new RenderBuildingWarFactory( init, this ); }
|
||||
|
||||
/* get around unverifiability */
|
||||
IEnumerable<IRenderable> BaseBuildingPreview(ActorInfo building, PaletteReference pr)
|
||||
IEnumerable<IRenderable> BaseBuildingPreview(World world, ActorInfo building, PaletteReference pr)
|
||||
{
|
||||
return base.RenderPreview(building, pr);
|
||||
return base.RenderPreview(world, building, pr);
|
||||
}
|
||||
|
||||
public override IEnumerable<IRenderable> RenderPreview(ActorInfo building, PaletteReference pr)
|
||||
public override IEnumerable<IRenderable> RenderPreview(World world, ActorInfo building, PaletteReference pr)
|
||||
{
|
||||
var p = BaseBuildingPreview(building, pr);
|
||||
var anim = new Animation(RenderSprites.GetImage(building), () => 0);
|
||||
var p = BaseBuildingPreview(world, building, pr);
|
||||
var anim = new Animation(world, RenderSprites.GetImage(building), () => 0);
|
||||
anim.PlayRepeating("idle-top");
|
||||
|
||||
return p.Concat(anim.Render(WPos.Zero, WVec.Zero, 0, pr, Scale));
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
public RenderBuildingWarFactory(ActorInitializer init, RenderBuildingInfo info)
|
||||
: base(init, info)
|
||||
{
|
||||
roof = new Animation(GetImage(init.self));
|
||||
roof = new Animation(init.world, GetImage(init.self));
|
||||
var bi = init.self.Info.Traits.Get<BuildingInfo>();
|
||||
|
||||
// Additional 512 units move from center -> top of cell
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
// HACK: Force images to be loaded up-front
|
||||
foreach (var image in info.ImagesByFullness)
|
||||
new Animation(image);
|
||||
new Animation(self.World, image);
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
|
||||
@@ -25,15 +25,15 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
class WithCrateBody : INotifyParachuteLanded
|
||||
{
|
||||
Actor self;
|
||||
Animation anim;
|
||||
readonly Actor self;
|
||||
readonly Animation anim;
|
||||
|
||||
public WithCrateBody(Actor self, WithCrateBodyInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var images = info.XmasImages.Any() && DateTime.Today.Month == 12 ? info.XmasImages : info.Images;
|
||||
anim = new Animation(images.Random(Game.CosmeticRandom));
|
||||
anim = new Animation(self.World, images.Random(Game.CosmeticRandom));
|
||||
anim.Play("idle");
|
||||
rs.anims.Add("", anim);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<IBodyOrientation>();
|
||||
|
||||
anim = new Animation(rs.GetImage(self), RenderSimple.MakeFacingFunc(self));
|
||||
anim = new Animation(self.World, rs.GetImage(self), RenderSimple.MakeFacingFunc(self));
|
||||
anim.Play(info.Sequence);
|
||||
rs.anims.Add("harvest_{0}".F(info.Sequence), new AnimationWithOffset(anim,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
var disabled = self.TraitsImplementing<IDisable>();
|
||||
|
||||
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||
overlay = new Animation(rs.GetImage(self));
|
||||
overlay = new Animation(self.World, rs.GetImage(self));
|
||||
overlay.PlayRepeating(info.Sequence);
|
||||
rs.anims.Add("idle_overlay_{0}".F(info.Sequence),
|
||||
new AnimationWithOffset(overlay,
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
getFacing = turreted != null ? () => turreted.turretFacing :
|
||||
facing != null ? (Func<int>)(() => facing.Facing) : () => 0;
|
||||
|
||||
var muzzleFlash = new Animation(render.GetImage(self), getFacing);
|
||||
var muzzleFlash = new Animation(self.World, render.GetImage(self), getFacing);
|
||||
visible.Add(barrel, false);
|
||||
anims.Add(barrel,
|
||||
new AnimationWithOffset(muzzleFlash,
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
rs = self.Trait<RenderSimple>();
|
||||
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
|
||||
anim = new Animation(rs.GetImage(self));
|
||||
anim = new Animation(self.World, rs.GetImage(self));
|
||||
anim.PlayFetchIndex(info.Sequence,
|
||||
() => playerResources.OreCapacity != 0
|
||||
? ((10 * anim.CurrentSequence.Length - 1) * playerResources.Ore) / (10 * playerResources.OreCapacity)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
var body = self.Trait<IBodyOrientation>();
|
||||
movement = self.Trait<IMove>();
|
||||
|
||||
rotorAnim = new Animation(rs.GetImage(self));
|
||||
rotorAnim = new Animation(self.World, rs.GetImage(self));
|
||||
rotorAnim.PlayRepeating(info.Sequence);
|
||||
rs.anims.Add(info.Id, new AnimationWithOffset(rotorAnim,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
|
||||
anim = new Animation("smoke_m");
|
||||
anim = new Animation(self.World, "smoke_m");
|
||||
rs.anims.Add("smoke", new AnimationWithOffset(anim, null, () => !isSmoking));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
arms = self.TraitsImplementing<Armament>()
|
||||
.Where(w => w.Info.Turret == info.Turret);
|
||||
|
||||
anim = new Animation(rs.GetImage(self), () => t.turretFacing);
|
||||
anim = new Animation(self.World, rs.GetImage(self), () => t.turretFacing);
|
||||
anim.Play(info.Sequence);
|
||||
rs.anims.Add("turret_{0}".F(info.Turret), new AnimationWithOffset(
|
||||
anim, () => TurretOffset(self), null, () => false, p => ZOffsetFromCenter(self, p, 1)));
|
||||
|
||||
Reference in New Issue
Block a user