Convert NukeLaunch to world coordinates.
This commit is contained in:
@@ -19,13 +19,12 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
{
|
{
|
||||||
readonly Player firedBy;
|
readonly Player firedBy;
|
||||||
Animation anim;
|
Animation anim;
|
||||||
PPos pos;
|
WPos pos;
|
||||||
CPos targetLocation;
|
CPos targetLocation;
|
||||||
int altitude;
|
|
||||||
bool goingUp = true;
|
bool goingUp = true;
|
||||||
string weapon;
|
string weapon;
|
||||||
|
|
||||||
public NukeLaunch(Player firedBy, Actor silo, string weapon, PVecInt spawnOffset, CPos targetLocation)
|
public NukeLaunch(Player firedBy, Actor silo, string weapon, WPos launchPos, CPos targetLocation)
|
||||||
{
|
{
|
||||||
this.firedBy = firedBy;
|
this.firedBy = firedBy;
|
||||||
this.targetLocation = targetLocation;
|
this.targetLocation = targetLocation;
|
||||||
@@ -33,18 +32,14 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
anim = new Animation(weapon);
|
anim = new Animation(weapon);
|
||||||
anim.PlayRepeating("up");
|
anim.PlayRepeating("up");
|
||||||
|
|
||||||
|
pos = launchPos;
|
||||||
if (silo == null)
|
if (silo == null)
|
||||||
{
|
|
||||||
altitude = firedBy.World.Map.Bounds.Height*Game.CellSize;
|
|
||||||
StartDescent(firedBy.World);
|
StartDescent(firedBy.World);
|
||||||
}
|
|
||||||
else
|
|
||||||
pos = silo.CenterLocation + spawnOffset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartDescent(World world)
|
void StartDescent(World world)
|
||||||
{
|
{
|
||||||
pos = OpenRA.Traits.Util.CenterOfCell(targetLocation);
|
pos = targetLocation.CenterPosition + new WVec(0, 0, 1024*firedBy.World.Map.Bounds.Height);
|
||||||
anim.PlayRepeating("down");
|
anim.PlayRepeating("down");
|
||||||
goingUp = false;
|
goingUp = false;
|
||||||
}
|
}
|
||||||
@@ -53,16 +48,17 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
{
|
{
|
||||||
anim.Tick();
|
anim.Tick();
|
||||||
|
|
||||||
|
var delta = new WVec(0,0,427);
|
||||||
if (goingUp)
|
if (goingUp)
|
||||||
{
|
{
|
||||||
altitude += 10;
|
pos += delta;
|
||||||
if (altitude >= world.Map.Bounds.Height*Game.CellSize)
|
if (pos.Z >= world.Map.Bounds.Height*1024)
|
||||||
StartDescent(world);
|
StartDescent(world);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
altitude -= 10;
|
pos -= delta;
|
||||||
if (altitude <= 0)
|
if (pos.Z <= 0)
|
||||||
Explode(world);
|
Explode(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,8 +66,8 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
void Explode(World world)
|
void Explode(World world)
|
||||||
{
|
{
|
||||||
world.AddFrameEndTask(w => w.Remove(this));
|
world.AddFrameEndTask(w => w.Remove(this));
|
||||||
Combat.DoExplosion(firedBy.PlayerActor, weapon, pos, 0);
|
Combat.DoExplosion(firedBy.PlayerActor, weapon, PPos.FromWPos(pos), pos.Z * Game.CellSize / 1024);
|
||||||
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos.ToFloat2(), 5);
|
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, PPos.FromWPos(pos).ToFloat2(), 5);
|
||||||
|
|
||||||
foreach (var a in world.ActorsWithTrait<NukePaletteEffect>())
|
foreach (var a in world.ActorsWithTrait<NukePaletteEffect>())
|
||||||
a.Trait.Enable();
|
a.Trait.Enable();
|
||||||
@@ -79,8 +75,7 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
yield return new SpriteRenderable(anim.Image, pos.ToFloat2() - new float2(0, altitude),
|
yield return new SpriteRenderable(anim.Image, pos, 0, wr.Palette("effect"), 1f);
|
||||||
wr.Palette("effect"), (int)pos.Y);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
[WeaponReference]
|
[WeaponReference]
|
||||||
public readonly string MissileWeapon = "";
|
public readonly string MissileWeapon = "";
|
||||||
public readonly int2 SpawnOffset = int2.Zero;
|
public readonly WVec SpawnOffset = WVec.Zero;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new NukePower(init.self, this); }
|
public override object Create(ActorInitializer init) { return new NukePower(init.self, this); }
|
||||||
}
|
}
|
||||||
@@ -39,10 +39,10 @@ namespace OpenRA.Mods.RA
|
|||||||
Sound.Play(Info.LaunchSound);
|
Sound.Play(Info.LaunchSound);
|
||||||
|
|
||||||
var npi = Info as NukePowerInfo;
|
var npi = Info as NukePowerInfo;
|
||||||
|
var rb = self.Trait<RenderSimple>();
|
||||||
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
|
rb.PlayCustomAnim(self, "active");
|
||||||
self.World.AddFrameEndTask(w => w.Add(
|
self.World.AddFrameEndTask(w => w.Add(
|
||||||
new NukeLaunch(self.Owner, self, npi.MissileWeapon, (PVecInt)npi.SpawnOffset, order.TargetLocation)));
|
new NukeLaunch(self.Owner, self, npi.MissileWeapon, self.CenterPosition + rb.LocalToWorld(npi.SpawnOffset), order.TargetLocation)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ PALACEH:
|
|||||||
SelectTargetSound:
|
SelectTargetSound:
|
||||||
LaunchSound:
|
LaunchSound:
|
||||||
MissileWeapon: atomic
|
MissileWeapon: atomic
|
||||||
SpawnOffset: 28,12
|
SpawnOffset:-512,1c171,0
|
||||||
CanPowerDown:
|
CanPowerDown:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
SupportPowerChargeBar:
|
SupportPowerChargeBar:
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ MSLO:
|
|||||||
SelectTargetSound: slcttgt1.aud
|
SelectTargetSound: slcttgt1.aud
|
||||||
LaunchSound: alaunch1.aud
|
LaunchSound: alaunch1.aud
|
||||||
MissileWeapon: atomic
|
MissileWeapon: atomic
|
||||||
SpawnOffset: 10,0
|
SpawnOffset: 0,427,0
|
||||||
CanPowerDown:
|
CanPowerDown:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
SupportPowerChargeBar:
|
SupportPowerChargeBar:
|
||||||
|
|||||||
Reference in New Issue
Block a user