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,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user