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:
Pavlos Touboulidis
2014-05-11 03:05:47 +03:00
parent 6eabc6adf5
commit b560268495
52 changed files with 132 additions and 117 deletions

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Effects
public MoveFlash(WPos pos, World world)
{
this.pos = pos;
anim = new Animation("moveflsh");
anim = new Animation(world, "moveflsh");
anim.PlayThen("idle", () => world.AddFrameEndTask(w => w.Remove(this)));
}

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Graphics
public bool IsDecoration = false;
public Func<bool> Paused;
Func<int> facingFunc;
readonly Func<int> facingFunc;
int frame = 0;
bool backwards = false;
@@ -29,27 +29,19 @@ namespace OpenRA.Graphics
public string Name { get { return name; } }
readonly SequenceProvider sequenceProvider;
static SequenceProvider lastSequenceProvider;
public Animation(string name)
: this(name, () => 0) {}
public Animation(World world, string name)
: this(world, name, () => 0) { }
public Animation(string name, Func<int> facingFunc)
public Animation(World world, string name, Func<int> facingFunc)
: this(world.Map.SequenceProvider, name, facingFunc) { }
public Animation(SequenceProvider sequenceProvider, string name, Func<int> facingFunc)
{
this.sequenceProvider = sequenceProvider;
this.name = name.ToLowerInvariant();
this.tickFunc = () => {};
this.facingFunc = facingFunc;
// TODO: This is wrong, don't use the static
if (Game.orderManager != null && Game.orderManager.world != null && Game.orderManager.world.Map != null)
sequenceProvider = Game.orderManager.world.Map.SequenceProvider;
// HACK: This just makes sure we have a sequence provider in between map changes for delayed actions
// It sucks but it can only be removed when we don't use the statics above but replace them with
// a possible parameter on this constructor.
if (sequenceProvider == null)
sequenceProvider = lastSequenceProvider;
else
lastSequenceProvider = sequenceProvider;
}
int CurrentFrame { get { return backwards ? CurrentSequence.Start + CurrentSequence.Length - frame - 1 : frame; } }

View File

@@ -19,9 +19,9 @@ namespace OpenRA.Traits
{
public override object Create(ActorInitializer init) { return new RenderSimple(init.self); }
public virtual IEnumerable<IRenderable> RenderPreview(ActorInfo ai, PaletteReference pr)
public virtual IEnumerable<IRenderable> RenderPreview(World world, ActorInfo ai, PaletteReference pr)
{
var anim = new Animation(RenderSimple.GetImage(ai), () => 0);
var anim = new Animation(world, RenderSimple.GetImage(ai), () => 0);
anim.PlayRepeating("idle");
return anim.Render(WPos.Zero, WVec.Zero, 0, pr, Scale);
@@ -35,7 +35,7 @@ namespace OpenRA.Traits
public RenderSimple(Actor self, Func<int> baseFacing)
: base(self)
{
anims.Add("", new Animation(GetImage(self), baseFacing));
anims.Add("", new Animation(self.World, GetImage(self), baseFacing));
Info = self.Info.Traits.Get<RenderSimpleInfo>();
}

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Traits
var group = self.World.Selection.GetControlGroupForActor(self);
if (group == null) return;
var pipImages = new Animation("pips");
var pipImages = new Animation(self.World, "pips");
var pal = wr.Palette(Info.Palette);
pipImages.PlayFetchIndex("groups", () => (int)group);
pipImages.Tick();
@@ -75,7 +75,7 @@ namespace OpenRA.Traits
if (!pipSources.Any())
return;
var pipImages = new Animation("pips");
var pipImages = new Animation(self.World, "pips");
pipImages.PlayRepeating(pipStrings[0]);
var pipSize = pipImages.Image.size.ToInt2();
@@ -115,7 +115,7 @@ namespace OpenRA.Traits
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
return;
var tagImages = new Animation("pips");
var tagImages = new Animation(self.World, "pips");
var pal = wr.Palette(Info.Palette);
var tagxyOffset = new int2(0, 6);
var tagBase = wr.Viewport.WorldToViewPx(basePosition);

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Widgets
if (Unit != null && Sequence != null)
{
var anim = new Animation(Unit, () => Facing);
var anim = new Animation(worldRenderer.world, Unit, () => Facing);
anim.PlayFetchIndex(Sequence, () => Frame);
GetAnimation = () => anim;
}

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Widgets
public Func<string> GetPalette;
public Func<Sprite> GetSprite;
readonly WorldRenderer worldRenderer;
protected readonly WorldRenderer worldRenderer;
[ObjectCreator.UseCtor]
public SpriteWidget(WorldRenderer worldRenderer)

View File

@@ -18,11 +18,11 @@ namespace OpenRA.Mods.Cnc.Effects
{
public class IonCannon : IEffect
{
Target target;
Animation anim;
Player firedBy;
string palette;
string weapon;
readonly Target target;
readonly Animation anim;
readonly Player firedBy;
readonly string palette;
readonly string weapon;
public IonCannon(Player firedBy, string weapon, World world, CPos location, string effect, string palette)
{
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc.Effects
this.weapon = weapon;
this.palette = palette;
target = Target.FromCell(location);
anim = new Animation(effect);
anim = new Animation(world, effect);
anim.PlayThen("idle", () => Finish(world));
}

View File

@@ -35,19 +35,19 @@ namespace OpenRA.Mods.RA.Render
var turret = self.TraitsImplementing<Turreted>()
.First(t => t.Name == info.Turret);
left = new Animation(name, () => turret.turretFacing);
left = new Animation(self.World, name, () => turret.turretFacing);
left.Play("left");
anims.Add("left", new AnimationWithOffset(left, null, () => facing.Facing > 128, 0));
right = new Animation(name, () => turret.turretFacing);
right = new Animation(self.World, name, () => turret.turretFacing);
right.Play("right");
anims.Add("right", new AnimationWithOffset(right, null, () => facing.Facing <= 128, 0));
var leftWake = new Animation(name);
var leftWake = new Animation(self.World, name);
leftWake.Play("wake-left");
anims.Add("wake-left", new AnimationWithOffset(leftWake, null, () => facing.Facing > 128, -87));
var rightWake = new Animation(name);
var rightWake = new Animation(self.World, name);
rightWake.Play("wake-right");
anims.Add("wake-right", new AnimationWithOffset(rightWake, null, () => facing.Facing <= 128, -87));

View File

@@ -72,9 +72,9 @@ namespace OpenRA.Mods.Cnc.Widgets
tooltipContainer = Exts.Lazy(() =>
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
cantBuild = new Animation("clock");
cantBuild = new Animation(world, "clock");
cantBuild.PlayFetchIndex("idle", () => 0);
clock = new Animation("clock");
clock = new Animation(world, "clock");
}
public override void Tick()
@@ -183,7 +183,7 @@ namespace OpenRA.Mods.Cnc.Widgets
var x = i % Columns;
var y = i / Columns;
var rect = new Rectangle(rb.X + x * 64 + 1, rb.Y + y * 48 + 1, 64, 48);
var icon = new Animation(RenderSimple.GetImage(item));
var icon = new Animation(World, RenderSimple.GetImage(item));
icon.Play(item.Traits.Get<TooltipInfo>().Icon);
var pi = new ProductionIcon()
{

View File

@@ -52,8 +52,8 @@ namespace OpenRA.Mods.Cnc.Widgets
tooltipContainer = Exts.Lazy(() =>
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
icon = new Animation("icon");
clock = new Animation("clock");
icon = new Animation(world, "icon");
clock = new Animation(world, "clock");
}
public class SupportPowerIcon

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Cnc
public WithFire(Actor self, WithFireInfo info)
{
var rs = self.Trait<RenderSprites>();
var roof = new Animation(rs.GetImage(self));
var roof = new Animation(self.World, rs.GetImage(self));
roof.PlayThen("fire-start", () => roof.PlayRepeating("fire-loop"));
rs.anims.Add("fire", new AnimationWithOffset(roof, null, null, 1024));
}

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Cnc
public WithRoof(Actor self)
{
var rs = self.Trait<RenderSprites>();
var roof = new Animation(rs.GetImage(self), () => self.Trait<IFacing>().Facing);
var roof = new Animation(self.World, rs.GetImage(self), () => self.Trait<IFacing>().Facing);
roof.Play("roof");
rs.anims.Add("roof", new AnimationWithOffset(roof, null, null, 1024));
}

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Render
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
overlay = new Animation(rs.GetImage(self));
overlay = new Animation(self.World, rs.GetImage(self));
overlay.Play(info.Sequence);
rs.anims.Add("crane_overlay_{0}".F(info.Sequence),
new AnimationWithOffset(overlay,

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Render
if (!init.Contains<SkipMakeAnimsInit>())
{
var overlay = new Animation(rs.GetImage(init.self));
var overlay = new Animation(init.world, rs.GetImage(init.self));
overlay.PlayThen(info.Sequence, () => buildComplete = false);
rs.anims.Add("make_overlay_{0}".F(info.Sequence),
new AnimationWithOffset(overlay, null, () => !buildComplete));

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Render
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("production_overlay_{0}".F(info.Sequence),
new AnimationWithOffset(overlay,

View File

@@ -157,7 +157,7 @@ namespace OpenRA.Mods.RA
if (barrel != null && a.Info.MuzzleSequence != null)
{
// Muzzle facing is fixed once the firing starts
var muzzleAnim = new Animation(paxRender[a.Actor].GetImage(a.Actor), () => muzzleFacing);
var muzzleAnim = new Animation(self.World, paxRender[a.Actor].GetImage(a.Actor), () => muzzleFacing);
var sequence = a.Info.MuzzleSequence;
if (a.Info.MuzzleSplitFacings > 0)

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Buildings
for (var i = 0; i < rows * width; i++)
{
var index = i;
var anim = new Animation(rs.GetImage(self));
var anim = new Animation(self.World, rs.GetImage(self));
var cellOffset = new CVec(i % width, i / width + bibOffset);
// Some mods may define terrain-specific bibs

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA
{
Info = info;
var anim = new Animation("fire", () => 0);
var anim = new Animation(self.World, "fire", () => 0);
anim.IsDecoration = true;
anim.PlayRepeating(Info.Anim);
self.Trait<RenderSprites>().anims.Add("fire", anim);

View File

@@ -21,8 +21,8 @@ namespace OpenRA.Mods.RA.Effects
readonly WPos position;
readonly string palettePrefix;
readonly string posterPalette;
readonly Animation arrow = new Animation("beacon");
readonly Animation circles = new Animation("beacon");
readonly Animation arrow;
readonly Animation circles;
readonly Animation poster;
static readonly int maxArrowHeight = 512;
int arrowHeight = maxArrowHeight;
@@ -35,12 +35,15 @@ namespace OpenRA.Mods.RA.Effects
this.palettePrefix = palettePrefix;
this.posterPalette = posterPalette;
arrow = new Animation(owner.World, "beacon");
circles = new Animation(owner.World, "beacon");
arrow.Play("arrow");
circles.Play("circles");
if (posterType != null)
{
poster = new Animation("beacon");
poster = new Animation(owner.World, "beacon");
poster.Play(posterType);
}

View File

@@ -66,6 +66,8 @@ namespace OpenRA.Mods.RA.Effects
this.args = args;
this.pos = args.Source;
var world = args.SourceActor.World;
if (info.Angle.Length > 1 && info.Speed.Length > 1)
{
angle = new WAngle(args.SourceActor.World.SharedRandom.Next(info.Angle[0].Angle, info.Angle[1].Angle));
@@ -89,7 +91,7 @@ namespace OpenRA.Mods.RA.Effects
if (info.Image != null)
{
anim = new Animation(info.Image, GetEffectiveFacing);
anim = new Animation(world, info.Image, GetEffectiveFacing);
anim.PlayRepeating("idle");
}

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Effects
this.pos = pos;
this.cell = pos.ToCPos();
this.paletteName = paletteName;
anim = new Animation(image);
anim = new Animation(world, image);
anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));
}

View File

@@ -17,13 +17,15 @@ namespace OpenRA.Mods.RA.Effects
class CrateEffect : IEffect
{
readonly string palette;
Actor a;
Animation anim = new Animation("crate-effects");
readonly Actor a;
readonly Animation anim;
public CrateEffect(Actor a, string seq, string palette)
{
this.a = a;
this.palette = palette;
anim = new Animation(a.World, "crate-effects");
anim.PlayThen(seq, () => a.World.AddFrameEndTask(w => w.Remove(this)));
}

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Effects
this.pos = pos;
this.cell = pos.ToCPos();
this.palette = palette;
anim = new Animation("explosion");
anim = new Animation(world, "explosion");
anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));
}

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Effects
{
this.self = self;
this.info = info;
anim = new Animation("gpsdot");
anim = new Animation(self.World, "gpsdot");
anim.PlayRepeating(info.String);
self.World.AddFrameEndTask(w => w.Add(this));

View File

@@ -16,27 +16,29 @@ namespace OpenRA.Mods.RA.Effects
{
class GpsSatellite : IEffect
{
WPos Pos;
Animation Anim = new Animation("sputnik");
WPos pos;
readonly Animation anim;
public GpsSatellite(WPos pos)
public GpsSatellite(World world, WPos pos)
{
Pos = pos;
Anim.PlayRepeating("idle");
this.pos = pos;
anim = new Animation(world, "sputnik");
anim.PlayRepeating("idle");
}
public void Tick( World world )
{
Anim.Tick();
Pos += new WVec(0, 0, 427);
anim.Tick();
pos += new WVec(0, 0, 427);
if (Pos.Z > Pos.Y)
if (pos.Z > pos.Y)
world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
return Anim.Render(Pos, wr.Palette("effect"));
return anim.Render(pos, wr.Palette("effect"));
}
}
}

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Effects
pos = args.Source;
velocity = new WVec(WRange.Zero, WRange.Zero, -info.Velocity);
anim = new Animation(info.Image);
anim = new Animation(args.SourceActor.World, info.Image);
if (anim.HasSequence("open"))
anim.PlayThen("open", () => anim.PlayRepeating("idle"));
else

View File

@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA.Effects
this.target = args.PassiveTarget;
if (info.HitAnim != null)
this.hitanim = new Animation(info.HitAnim);
this.hitanim = new Animation(args.SourceActor.World, info.HitAnim);
}
public void Tick(World world)

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA.Effects
if (info.Image != null)
{
anim = new Animation(info.Image, () => facing);
anim = new Animation(args.SourceActor.World, info.Image, () => facing);
anim.PlayRepeating("idle");
}

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Effects
descendSource = targetPos + offset;
descendTarget = targetPos;
anim = new Animation(weapon);
anim = new Animation(firedBy.World, weapon);
anim.PlayRepeating("up");
pos = launchPos;

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Effects
this.cargo = cargo;
var pai = cargo.Info.Traits.GetOrDefault<ParachuteAttachmentInfo>();
paraAnim = new Animation(pai != null ? pai.ParachuteSprite : "parach");
paraAnim = new Animation(cargo.World, pai != null ? pai.ParachuteSprite : "parach");
paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));
if (pai != null)

View File

@@ -18,12 +18,15 @@ namespace OpenRA.Mods.RA.Effects
{
class PowerdownIndicator : IEffect
{
Actor a;
Animation anim = new Animation("poweroff");
readonly Actor a;
readonly Animation anim;
public PowerdownIndicator(Actor a)
{
this.a = a; anim.PlayRepeating("offline");
this.a = a;
anim = new Animation(a.World, "poweroff");
anim.PlayRepeating("offline");
}
public void Tick(World world)

View File

@@ -21,14 +21,19 @@ namespace OpenRA.Mods.RA.Effects
readonly Actor building;
readonly RA.RallyPoint rp;
readonly string palettePrefix;
public Animation flag = new Animation("rallypoint");
public Animation circles = new Animation("rallypoint");
readonly Animation flag;
readonly Animation circles;
public RallyPoint(Actor building, string palettePrefix)
{
this.building = building;
rp = building.Trait<RA.RallyPoint>();
this.palettePrefix = palettePrefix;
rp = building.Trait<RA.RallyPoint>();
flag = new Animation(building.World, "rallypoint");
circles = new Animation(building.World, "rallypoint");
flag.PlayRepeating("flag");
circles.Play("circles");
}

View File

@@ -17,16 +17,17 @@ namespace OpenRA.Mods.RA.Effects
{
class Rank : IEffect
{
Actor self;
Animation anim = new Animation("rank");
readonly Actor self;
readonly Animation anim;
readonly string paletteName;
public Rank(Actor self, string paletteName)
{
this.self = self;
this.paletteName = paletteName;
var xp = self.Trait<GainsExperience>();
var xp = self.Trait<GainsExperience>();
anim = new Animation(self.World, "rank");
anim.PlayRepeating("rank");
anim.PlayFetchIndex("rank", () => xp.Level == 0 ? 0 : xp.Level - 1);
}

View File

@@ -18,18 +18,20 @@ namespace OpenRA.Mods.RA.Effects
{
class RepairIndicator : IEffect
{
Actor building;
Player player;
string palettePrefix;
Animation anim = new Animation("allyrepair");
RepairableBuilding rb;
readonly Actor building;
readonly Player player;
readonly string palettePrefix;
readonly Animation anim;
readonly RepairableBuilding rb;
public RepairIndicator(Actor building, string palettePrefix, Player player)
{
this.building = building;
this.player = player;
this.palettePrefix = palettePrefix;
rb = building.Trait<RepairableBuilding>();
anim = new Animation(building.World, "allyrepair");
anim.PlayRepeating("repair");
}

View File

@@ -17,11 +17,13 @@ namespace OpenRA.Mods.RA.Effects
class SatelliteLaunch : IEffect
{
int frame = 0;
Animation doors = new Animation("atek");
WPos pos;
readonly Animation doors;
readonly WPos pos;
public SatelliteLaunch(Actor a)
{
doors = new Animation(a.World, "atek");
doors.PlayThen("active",
() => a.World.AddFrameEndTask(w => w.Remove(this)));
@@ -33,7 +35,7 @@ namespace OpenRA.Mods.RA.Effects
doors.Tick();
if (++frame == 19)
world.AddFrameEndTask(w => w.Add(new GpsSatellite(pos)));
world.AddFrameEndTask(w => w.Add(new GpsSatellite(world, pos)));
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)

View File

@@ -26,7 +26,8 @@ namespace OpenRA.Mods.RA.Effects
this.world = world;
this.pos = pos;
this.cell = pos.ToCPos();
anim = new Animation(trail);
anim = new Animation(world, trail);
anim.PlayThen("idle",
() => world.AddFrameEndTask(w => w.Remove(this)));
}

View File

@@ -100,7 +100,7 @@ namespace OpenRA.Mods.RA.Orders
var palette = rbi.Palette ?? (Producer.Owner != null ?
rbi.PlayerPalette + Producer.Owner.InternalName : null);
preview = rbi.RenderPreview(rules.Actors[Building], wr.Palette(palette));
preview = rbi.RenderPreview(world, rules.Actors[Building], wr.Palette(palette));
}
initialized = true;

View File

@@ -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

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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))),

View File

@@ -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,

View File

@@ -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,

View File

@@ -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)

View File

@@ -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))),

View File

@@ -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));
}

View File

@@ -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)));

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.RA
// Facing rotation
rotation = WRange.FromPDF(Game.CosmeticRandom, 2).Range * info.ROT / 1024;
var anim = new Animation(rs.GetImage(self), () => (int)facing);
var anim = new Animation(init.world, rs.GetImage(self), () => (int)facing);
anim.PlayRepeating(info.Anim);
rs.anims.Add(info.Anim, new AnimationWithOffset(anim, () => pos, null));
}

View File

@@ -63,9 +63,9 @@ namespace OpenRA.Mods.RA.Widgets
this.world = world;
this.worldRenderer = worldRenderer;
cantBuild = new Animation("clock");
cantBuild = new Animation(world, "clock");
cantBuild.PlayFetchIndex("idle", () => 0);
clock = new Animation("clock");
clock = new Animation(world, "clock");
VisibleQueues = new List<ProductionQueue>();
CurrentQueue = null;
}
@@ -231,7 +231,7 @@ namespace OpenRA.Mods.RA.Widgets
{
var rect = new RectangleF(origin.X + x * IconWidth, origin.Y + IconHeight * y, IconWidth, IconHeight);
var drawPos = new float2(rect.Location);
var icon = new Animation(RenderSimple.GetImage(item));
var icon = new Animation(world, RenderSimple.GetImage(item));
icon.Play(item.Traits.Get<TooltipInfo>().Icon);
WidgetUtils.DrawSHPCentered(icon.Image, drawPos + iconOffset, worldRenderer);

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA.Widgets
{
if (!clocks.ContainsKey(queue.Trait))
{
clocks.Add(queue.Trait, new Animation("clock"));
clocks.Add(queue.Trait, new Animation(world, "clock"));
}
}
@@ -75,7 +75,7 @@ namespace OpenRA.Mods.RA.Widgets
if (actor == null)
continue;
var icon = new Animation(RenderSimple.GetImage(actor));
var icon = new Animation(world, RenderSimple.GetImage(actor));
icon.Play(actor.Traits.Get<TooltipInfo>().Icon);
var location = new float2(RenderBounds.Location) + new float2(queue.i * (IconWidth + IconSpacing), 0);
WidgetUtils.DrawSHPCentered(icon.Image, location + 0.5f * iconSize, worldRenderer, 0.5f);

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Widgets
this.world = world;
this.worldRenderer = worldRenderer;
clocks = new Dictionary<string, Animation>();
icon = new Animation("icon");
icon = new Animation(world, "icon");
}
protected ObserverSupportPowerIconsWidget(ObserverSupportPowerIconsWidget other)
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Widgets
{
if (!clocks.ContainsKey(power.a.Key))
{
clocks.Add(power.a.Key, new Animation("clock"));
clocks.Add(power.a.Key, new Animation(world, "clock"));
}
}

View File

@@ -44,8 +44,8 @@ namespace OpenRA.Mods.RA.Widgets
{
base.Initialize(args);
icon = new Animation("icon");
clock = new Animation("clock");
icon = new Animation(world, "icon");
clock = new Animation(world, "clock");
}
public override Rectangle EventBounds