Skip to content

Commit

Permalink
Fix GPS satellite palette.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote authored and obrakmann committed Apr 24, 2016
1 parent 854cbe7 commit 8039ed7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
12 changes: 6 additions & 6 deletions OpenRA.Mods.RA/Effects/GpsSatellite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ namespace OpenRA.Mods.RA.Effects
{
class GpsSatellite : IEffect
{
readonly GpsPowerInfo info;
readonly Animation anim;
readonly string palette;
WPos pos;

public GpsSatellite(World world, WPos pos, GpsPowerInfo info)
public GpsSatellite(World world, WPos pos, string image, string sequence, string palette)
{
this.info = info;
this.palette = palette;
this.pos = pos;

anim = new Animation(world, info.SatelliteImage);
anim.PlayRepeating(info.SatelliteSequence);
anim = new Animation(world, image);
anim.PlayRepeating(sequence);
}

public void Tick(World world)
Expand All @@ -42,7 +42,7 @@ public void Tick(World world)

public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
return anim.Render(pos, wr.Palette(info.SatellitePalette));
return anim.Render(pos, wr.Palette(palette));
}
}
}
18 changes: 12 additions & 6 deletions OpenRA.Mods.RA/Effects/SatelliteLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,38 @@ namespace OpenRA.Mods.RA.Effects
class SatelliteLaunch : IEffect
{
readonly GpsPowerInfo info;
readonly Actor launcher;
readonly Animation doors;
readonly WPos pos;
int frame = 0;

public SatelliteLaunch(Actor a, GpsPowerInfo info)
public SatelliteLaunch(Actor launcher, GpsPowerInfo info)
{
this.info = info;
this.launcher = launcher;

doors = new Animation(a.World, info.DoorImage);
doors = new Animation(launcher.World, info.DoorImage);
doors.PlayThen(info.DoorSequence,
() => a.World.AddFrameEndTask(w => w.Remove(this)));
() => launcher.World.AddFrameEndTask(w => w.Remove(this)));

pos = a.CenterPosition;
pos = launcher.CenterPosition;
}

public void Tick(World world)
{
doors.Tick();

if (++frame == 19)
world.AddFrameEndTask(w => w.Add(new GpsSatellite(world, pos, info)));
{
var palette = info.SatellitePaletteIsPlayerPalette ? info.SatellitePalette + launcher.Owner.InternalName : info.SatellitePalette;
world.AddFrameEndTask(w => w.Add(new GpsSatellite(world, pos, info.SatelliteImage, info.SatelliteSequence, palette)));
}
}

public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
return doors.Render(pos, wr.Palette(info.DoorPalette));
var palette = info.DoorPaletteIsPlayerPalette ? info.DoorPalette + launcher.Owner.InternalName : info.DoorPalette;
return doors.Render(pos, wr.Palette(palette));
}
}
}
14 changes: 12 additions & 2 deletions OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@ class GpsPowerInfo : SupportPowerInfo

public readonly string DoorImage = "atek";
[SequenceReference("DoorImage")] public readonly string DoorSequence = "active";
[PaletteReference] public readonly string DoorPalette = "effect";

[Desc("Palette to use for rendering the launch animation")]
[PaletteReference("DoorPaletteIsPlayerPalette")] public readonly string DoorPalette = "player";

[Desc("Custom palette is a player palette BaseName")]
public readonly bool DoorPaletteIsPlayerPalette = true;

public readonly string SatelliteImage = "sputnik";
[SequenceReference("SatelliteImage")] public readonly string SatelliteSequence = "idle";
[PaletteReference] public readonly string SatellitePalette = "effect";

[Desc("Palette to use for rendering the satellite projectile")]
[PaletteReference("SatellitePaletteIsPlayerPalette")] public readonly string SatellitePalette = "player";

[Desc("Custom palette is a player palette BaseName")]
public readonly bool SatellitePaletteIsPlayerPalette = true;

public override object Create(ActorInitializer init) { return new GpsPower(init.Self, this); }
}
Expand Down

0 comments on commit 8039ed7

Please sign in to comment.