Fix Turreted style issues.
This commit is contained in:
@@ -44,11 +44,11 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
var turret = self.TraitsImplementing<Turreted>()
|
var turret = self.TraitsImplementing<Turreted>()
|
||||||
.First(t => t.Name == info.Turret);
|
.First(t => t.Name == info.Turret);
|
||||||
|
|
||||||
left = new Animation(self.World, name, () => turret.turretFacing);
|
left = new Animation(self.World, name, () => turret.TurretFacing);
|
||||||
left.Play(info.LeftSequence);
|
left.Play(info.LeftSequence);
|
||||||
Add(info.LeftSequence, new AnimationWithOffset(left, null, () => facing.Facing > 128, 0));
|
Add(info.LeftSequence, new AnimationWithOffset(left, null, () => facing.Facing > 128, 0));
|
||||||
|
|
||||||
right = new Animation(self.World, name, () => turret.turretFacing);
|
right = new Animation(self.World, name, () => turret.TurretFacing);
|
||||||
right.Play(info.RightSequence);
|
right.Play(info.RightSequence);
|
||||||
Add(info.RightSequence, new AnimationWithOffset(right, null, () => facing.Facing <= 128, 0));
|
Add(info.RightSequence, new AnimationWithOffset(right, null, () => facing.Facing <= 128, 0));
|
||||||
|
|
||||||
|
|||||||
@@ -80,17 +80,17 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (state == PopupState.Open && idleTicks++ > info.CloseDelay)
|
if (state == PopupState.Open && idleTicks++ > info.CloseDelay)
|
||||||
{
|
{
|
||||||
turret.desiredFacing = info.DefaultFacing;
|
turret.DesiredFacing = info.DefaultFacing;
|
||||||
state = PopupState.Rotating;
|
state = PopupState.Rotating;
|
||||||
}
|
}
|
||||||
else if (state == PopupState.Rotating && turret.turretFacing == info.DefaultFacing)
|
else if (state == PopupState.Rotating && turret.TurretFacing == info.DefaultFacing)
|
||||||
{
|
{
|
||||||
state = PopupState.Transitioning;
|
state = PopupState.Transitioning;
|
||||||
rb.PlayCustomAnimThen(self, "closing", () =>
|
rb.PlayCustomAnimThen(self, "closing", () =>
|
||||||
{
|
{
|
||||||
state = PopupState.Closed;
|
state = PopupState.Closed;
|
||||||
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
||||||
turret.desiredFacing = null;
|
turret.DesiredFacing = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
state = PopupState.Closed;
|
state = PopupState.Closed;
|
||||||
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
||||||
turret.desiredFacing = null;
|
turret.DesiredFacing = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA
|
|||||||
// This isn't a problem with the current units, but may be a problem for mods
|
// This isn't a problem with the current units, but may be a problem for mods
|
||||||
var turreted = self.TraitsImplementing<Turreted>().FirstOrDefault();
|
var turreted = self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||||
if (turreted != null)
|
if (turreted != null)
|
||||||
td.Add(new TurretFacingInit(turreted.turretFacing));
|
td.Add(new TurretFacingInit(turreted.TurretFacing));
|
||||||
|
|
||||||
var chronoshiftable = self.TraitOrDefault<Chronoshiftable>();
|
var chronoshiftable = self.TraitOrDefault<Chronoshiftable>();
|
||||||
if (chronoshiftable != null && chronoshiftable.ReturnTicks > 0)
|
if (chronoshiftable != null && chronoshiftable.ReturnTicks > 0)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
{
|
{
|
||||||
// Turret artwork is baked into the sprite, so only the first turret makes sense.
|
// Turret artwork is baked into the sprite, so only the first turret makes sense.
|
||||||
var turreted = self.TraitsImplementing<Turreted>().FirstOrDefault();
|
var turreted = self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||||
return () => turreted.turretFacing;
|
return () => turreted.TurretFacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderBuildingTurreted(ActorInitializer init, RenderBuildingInfo info)
|
public RenderBuildingTurreted(ActorInitializer init, RenderBuildingInfo info)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
.First(tt => tt.Name == armament.Info.Turret);
|
.First(tt => tt.Name == armament.Info.Turret);
|
||||||
|
|
||||||
var rs = self.Trait<RenderSprites>();
|
var rs = self.Trait<RenderSprites>();
|
||||||
anim = new Animation(self.World, rs.GetImage(self), () => turreted.turretFacing);
|
anim = new Animation(self.World, rs.GetImage(self), () => turreted.TurretFacing);
|
||||||
anim.Play(info.Sequence);
|
anim.Play(info.Sequence);
|
||||||
rs.Add("barrel_{0}".F(info.Barrel), new AnimationWithOffset(
|
rs.Add("barrel_{0}".F(info.Barrel), new AnimationWithOffset(
|
||||||
anim, () => BarrelOffset(), null, () => false, p => WithTurret.ZOffsetFromCenter(self, p, 0)));
|
anim, () => BarrelOffset(), null, () => false, p => WithTurret.ZOffsetFromCenter(self, p, 0)));
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
var turreted = self.TraitsImplementing<Turreted>()
|
var turreted = self.TraitsImplementing<Turreted>()
|
||||||
.FirstOrDefault(t => t.Name == arm.Info.Turret);
|
.FirstOrDefault(t => t.Name == arm.Info.Turret);
|
||||||
|
|
||||||
getFacing = turreted != null ? () => turreted.turretFacing :
|
getFacing = turreted != null ? () => turreted.TurretFacing :
|
||||||
facing != null ? (Func<int>)(() => facing.Facing) : () => 0;
|
facing != null ? (Func<int>)(() => facing.Facing) : () => 0;
|
||||||
|
|
||||||
var muzzleFlash = new Animation(self.World, render.GetImage(self), getFacing);
|
var muzzleFlash = new Animation(self.World, render.GetImage(self), getFacing);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
arms = self.TraitsImplementing<Armament>()
|
arms = self.TraitsImplementing<Armament>()
|
||||||
.Where(w => w.Info.Turret == info.Turret);
|
.Where(w => w.Info.Turret == info.Turret);
|
||||||
|
|
||||||
anim = new Animation(self.World, rs.GetImage(self), () => t.turretFacing);
|
anim = new Animation(self.World, rs.GetImage(self), () => t.TurretFacing);
|
||||||
anim.Play(info.Sequence);
|
anim.Play(info.Sequence);
|
||||||
rs.Add("turret_{0}".F(info.Turret), new AnimationWithOffset(
|
rs.Add("turret_{0}".F(info.Turret), new AnimationWithOffset(
|
||||||
anim, () => TurretOffset(self), null, () => false, p => ZOffsetFromCenter(self, p, 1)));
|
anim, () => TurretOffset(self), null, () => false, p => ZOffsetFromCenter(self, p, 1)));
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (e.Damage > 0 && (e.Warhead == null || !e.Warhead.PreventProne)) /* Don't go prone when healed */
|
if (e.Damage > 0 && (e.Warhead == null || !e.Warhead.PreventProne)) /* Don't go prone when healed */
|
||||||
{
|
{
|
||||||
if (!isProne)
|
if (!isProne)
|
||||||
LocalOffset = info.ProneOffset;
|
localOffset = info.ProneOffset;
|
||||||
|
|
||||||
remainingProneTime = info.ProneTime;
|
remainingProneTime = info.ProneTime;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
|
|||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
|
|
||||||
if (isProne && --remainingProneTime == 0)
|
if (isProne && --remainingProneTime == 0)
|
||||||
LocalOffset = WVec.Zero;
|
localOffset = WVec.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ namespace OpenRA.Mods.RA
|
|||||||
IFacing facing;
|
IFacing facing;
|
||||||
|
|
||||||
[Sync] public int QuantizedFacings = 0;
|
[Sync] public int QuantizedFacings = 0;
|
||||||
[Sync] public int turretFacing = 0;
|
[Sync] public int TurretFacing = 0;
|
||||||
public int? desiredFacing;
|
public int? DesiredFacing;
|
||||||
int realignTick = 0;
|
int realignTick = 0;
|
||||||
|
|
||||||
// For subclasses that want to move the turret relative to the body
|
// For subclasses that want to move the turret relative to the body
|
||||||
protected WVec LocalOffset = WVec.Zero;
|
protected WVec localOffset = WVec.Zero;
|
||||||
|
|
||||||
public WVec Offset { get { return info.Offset + LocalOffset; } }
|
public WVec Offset { get { return info.Offset + localOffset; } }
|
||||||
public string Name { get { return info.Turret; } }
|
public string Name { get { return info.Turret; } }
|
||||||
|
|
||||||
public static int GetInitialTurretFacing(ActorInitializer init, int def)
|
public static int GetInitialTurretFacing(ActorInitializer init, int def)
|
||||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public Turreted(ActorInitializer init, TurretedInfo info)
|
public Turreted(ActorInitializer init, TurretedInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
turretFacing = GetInitialTurretFacing(init, info.InitialFacing);
|
TurretFacing = GetInitialTurretFacing(init, info.InitialFacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Created(Actor self)
|
public void Created(Actor self)
|
||||||
@@ -76,19 +76,19 @@ namespace OpenRA.Mods.RA
|
|||||||
if (realignTick < info.RealignDelay)
|
if (realignTick < info.RealignDelay)
|
||||||
realignTick++;
|
realignTick++;
|
||||||
else if (info.RealignDelay > -1)
|
else if (info.RealignDelay > -1)
|
||||||
desiredFacing = null;
|
DesiredFacing = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
realignTick = 0;
|
realignTick = 0;
|
||||||
|
|
||||||
var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing );
|
var df = DesiredFacing ?? (facing != null ? facing.Facing : TurretFacing);
|
||||||
turretFacing = Util.TickFacing(turretFacing, df, info.ROT);
|
TurretFacing = Util.TickFacing(TurretFacing, df, info.ROT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FaceTarget(Actor self, Target target)
|
public bool FaceTarget(Actor self, Target target)
|
||||||
{
|
{
|
||||||
desiredFacing = Util.GetFacing(target.CenterPosition - self.CenterPosition, turretFacing);
|
DesiredFacing = Util.GetFacing(target.CenterPosition - self.CenterPosition, TurretFacing);
|
||||||
return turretFacing == desiredFacing;
|
return TurretFacing == DesiredFacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turret offset in world-space
|
// Turret offset in world-space
|
||||||
@@ -102,9 +102,8 @@ namespace OpenRA.Mods.RA
|
|||||||
// Orientation in unit-space
|
// Orientation in unit-space
|
||||||
public WRot LocalOrientation(Actor self)
|
public WRot LocalOrientation(Actor self)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Hack: turretFacing is relative to the world, so subtract the body yaw
|
// Hack: turretFacing is relative to the world, so subtract the body yaw
|
||||||
var local = WRot.FromYaw(WAngle.FromFacing(turretFacing) - self.Orientation.Yaw);
|
var local = WRot.FromYaw(WAngle.FromFacing(TurretFacing) - self.Orientation.Yaw);
|
||||||
|
|
||||||
if (QuantizedFacings == 0)
|
if (QuantizedFacings == 0)
|
||||||
return local;
|
return local;
|
||||||
|
|||||||
Reference in New Issue
Block a user