Fix Turreted style issues.
This commit is contained in:
@@ -44,11 +44,11 @@ namespace OpenRA.Mods.RA.Render
|
||||
var turret = self.TraitsImplementing<Turreted>()
|
||||
.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);
|
||||
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);
|
||||
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)
|
||||
{
|
||||
turret.desiredFacing = info.DefaultFacing;
|
||||
turret.DesiredFacing = info.DefaultFacing;
|
||||
state = PopupState.Rotating;
|
||||
}
|
||||
else if (state == PopupState.Rotating && turret.turretFacing == info.DefaultFacing)
|
||||
else if (state == PopupState.Rotating && turret.TurretFacing == info.DefaultFacing)
|
||||
{
|
||||
state = PopupState.Transitioning;
|
||||
rb.PlayCustomAnimThen(self, "closing", () =>
|
||||
{
|
||||
state = PopupState.Closed;
|
||||
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
||||
turret.desiredFacing = null;
|
||||
turret.DesiredFacing = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
state = PopupState.Closed;
|
||||
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
|
||||
var turreted = self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||
if (turreted != null)
|
||||
td.Add(new TurretFacingInit(turreted.turretFacing));
|
||||
td.Add(new TurretFacingInit(turreted.TurretFacing));
|
||||
|
||||
var chronoshiftable = self.TraitOrDefault<Chronoshiftable>();
|
||||
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.
|
||||
var turreted = self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||
return () => turreted.turretFacing;
|
||||
return () => turreted.TurretFacing;
|
||||
}
|
||||
|
||||
public RenderBuildingTurreted(ActorInitializer init, RenderBuildingInfo info)
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
.First(tt => tt.Name == armament.Info.Turret);
|
||||
|
||||
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);
|
||||
rs.Add("barrel_{0}".F(info.Barrel), new AnimationWithOffset(
|
||||
anim, () => BarrelOffset(), null, () => false, p => WithTurret.ZOffsetFromCenter(self, p, 0)));
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
var turreted = self.TraitsImplementing<Turreted>()
|
||||
.FirstOrDefault(t => t.Name == arm.Info.Turret);
|
||||
|
||||
getFacing = turreted != null ? () => turreted.turretFacing :
|
||||
getFacing = turreted != null ? () => turreted.TurretFacing :
|
||||
facing != null ? (Func<int>)(() => facing.Facing) : () => 0;
|
||||
|
||||
var muzzleFlash = new Animation(self.World, render.GetImage(self), getFacing);
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
arms = self.TraitsImplementing<Armament>()
|
||||
.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);
|
||||
rs.Add("turret_{0}".F(info.Turret), new AnimationWithOffset(
|
||||
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 (!isProne)
|
||||
LocalOffset = info.ProneOffset;
|
||||
localOffset = info.ProneOffset;
|
||||
|
||||
remainingProneTime = info.ProneTime;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
|
||||
base.Tick(self);
|
||||
|
||||
if (isProne && --remainingProneTime == 0)
|
||||
LocalOffset = WVec.Zero;
|
||||
localOffset = WVec.Zero;
|
||||
}
|
||||
|
||||
public int GetDamageModifier(Actor attacker, DamageWarhead warhead)
|
||||
|
||||
@@ -36,23 +36,23 @@ namespace OpenRA.Mods.RA
|
||||
IFacing facing;
|
||||
|
||||
[Sync] public int QuantizedFacings = 0;
|
||||
[Sync] public int turretFacing = 0;
|
||||
public int? desiredFacing;
|
||||
[Sync] public int TurretFacing = 0;
|
||||
public int? DesiredFacing;
|
||||
int realignTick = 0;
|
||||
|
||||
// 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 static int GetInitialTurretFacing(ActorInitializer init, int def)
|
||||
{
|
||||
if (init.Contains<TurretFacingInit>())
|
||||
return init.Get<TurretFacingInit,int>();
|
||||
return init.Get<TurretFacingInit, int>();
|
||||
|
||||
if (init.Contains<FacingInit>())
|
||||
return init.Get<FacingInit,int>();
|
||||
return init.Get<FacingInit, int>();
|
||||
|
||||
return def;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
|
||||
public Turreted(ActorInitializer init, TurretedInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
turretFacing = GetInitialTurretFacing(init, info.InitialFacing);
|
||||
TurretFacing = GetInitialTurretFacing(init, info.InitialFacing);
|
||||
}
|
||||
|
||||
public void Created(Actor self)
|
||||
@@ -76,19 +76,19 @@ namespace OpenRA.Mods.RA
|
||||
if (realignTick < info.RealignDelay)
|
||||
realignTick++;
|
||||
else if (info.RealignDelay > -1)
|
||||
desiredFacing = null;
|
||||
DesiredFacing = null;
|
||||
}
|
||||
else
|
||||
realignTick = 0;
|
||||
|
||||
var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing );
|
||||
turretFacing = Util.TickFacing(turretFacing, df, info.ROT);
|
||||
var df = DesiredFacing ?? (facing != null ? facing.Facing : TurretFacing);
|
||||
TurretFacing = Util.TickFacing(TurretFacing, df, info.ROT);
|
||||
}
|
||||
|
||||
public bool FaceTarget(Actor self, Target target)
|
||||
{
|
||||
desiredFacing = Util.GetFacing(target.CenterPosition - self.CenterPosition, turretFacing);
|
||||
return turretFacing == desiredFacing;
|
||||
DesiredFacing = Util.GetFacing(target.CenterPosition - self.CenterPosition, TurretFacing);
|
||||
return TurretFacing == DesiredFacing;
|
||||
}
|
||||
|
||||
// Turret offset in world-space
|
||||
@@ -102,9 +102,8 @@ namespace OpenRA.Mods.RA
|
||||
// Orientation in unit-space
|
||||
public WRot LocalOrientation(Actor self)
|
||||
{
|
||||
|
||||
// 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)
|
||||
return local;
|
||||
|
||||
Reference in New Issue
Block a user