Make ThrowsParticle use WAngle instead of float
This commit is contained in:
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly int Velocity = 75;
|
public readonly int Velocity = 75;
|
||||||
|
|
||||||
[Desc("Speed at which the particle turns.")]
|
[Desc("Speed at which the particle turns.")]
|
||||||
public readonly float TurnSpeed = 15;
|
public readonly int TurnSpeed = 15;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new ThrowsParticle(init, this); }
|
public object Create(ActorInitializer init) { return new ThrowsParticle(init, this); }
|
||||||
}
|
}
|
||||||
@@ -53,8 +53,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
int tick = 0;
|
int tick = 0;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
float facing;
|
WAngle facing;
|
||||||
float rotation;
|
WAngle rotation;
|
||||||
|
|
||||||
public ThrowsParticle(ActorInitializer init, ThrowsParticleInfo info)
|
public ThrowsParticle(ActorInitializer init, ThrowsParticleInfo info)
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
// TODO: Carry orientation over from the parent instead of just facing
|
// TODO: Carry orientation over from the parent instead of just facing
|
||||||
var bodyFacing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : 0;
|
var bodyFacing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : 0;
|
||||||
facing = Turreted.GetInitialTurretFacing(init, 0);
|
facing = WAngle.FromFacing(Turreted.GetInitialTurretFacing(init, 0));
|
||||||
|
|
||||||
// Calculate final position
|
// Calculate final position
|
||||||
var throwRotation = WRot.FromFacing(Game.CosmeticRandom.Next(1024));
|
var throwRotation = WRot.FromFacing(Game.CosmeticRandom.Next(1024));
|
||||||
@@ -76,23 +76,23 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
length = (finalPos - initialPos).Length / info.Velocity;
|
length = (finalPos - initialPos).Length / info.Velocity;
|
||||||
|
|
||||||
// Facing rotation
|
// Facing rotation
|
||||||
rotation = WDist.FromPDF(Game.CosmeticRandom, 2).Length * info.TurnSpeed / 1024;
|
rotation = WAngle.FromFacing(WDist.FromPDF(Game.CosmeticRandom, 2).Length * info.TurnSpeed / 1024);
|
||||||
|
|
||||||
var anim = new Animation(init.World, rs.GetImage(self), () => (int)facing);
|
var anim = new Animation(init.World, rs.GetImage(self), () => facing.Angle / 4);
|
||||||
anim.PlayRepeating(info.Anim);
|
anim.PlayRepeating(info.Anim);
|
||||||
rs.Add(new AnimationWithOffset(anim, () => pos, null));
|
rs.Add(new AnimationWithOffset(anim, () => pos, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (tick == length)
|
if (tick >= length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pos = WVec.LerpQuadratic(initialPos, finalPos, angle, tick++, length);
|
pos = WVec.LerpQuadratic(initialPos, finalPos, angle, tick++, length);
|
||||||
|
|
||||||
// Spin the particle
|
// Spin the particle
|
||||||
facing += rotation;
|
facing += rotation;
|
||||||
rotation *= .9f;
|
rotation = new WAngle(rotation.Angle * 90 / 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user