Convert turret facings to WAngle relative to the body.
This commit is contained in:
@@ -51,13 +51,11 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
var model = init.World.ModelCache.GetModelSequence(image, Sequence);
|
||||
|
||||
var turretFacing = Turreted.TurretFacingFromInit(init, t);
|
||||
Func<WRot> turretOrientation = () => body.QuantizeOrientation(WRot.FromYaw(turretFacing() - orientation().Yaw), facings);
|
||||
|
||||
Func<WRot> quantizedTurret = () => body.QuantizeOrientation(turretOrientation(), facings);
|
||||
var turretOrientation = t.PreviewOrientation(init, orientation, facings);
|
||||
Func<WRot> quantizedBody = () => body.QuantizeOrientation(orientation(), facings);
|
||||
Func<WVec> barrelOffset = () => body.LocalToWorld((t.Offset + LocalOffset.Rotate(quantizedTurret())).Rotate(quantizedBody()));
|
||||
Func<WRot> barrelOrientation = () => turretOrientation().Rotate(orientation());
|
||||
Func<WVec> barrelOffset = () => body.LocalToWorld((t.Offset + LocalOffset.Rotate(turretOrientation())).Rotate(quantizedBody()));
|
||||
Func<WRot> barrelOrientation = () => LocalOrientation.Rotate(turretOrientation()).Rotate(quantizedBody());
|
||||
|
||||
yield return new ModelAnimation(model, barrelOffset, barrelOrientation, () => false, () => 0, ShowShadow);
|
||||
}
|
||||
}
|
||||
@@ -87,21 +85,15 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
WVec BarrelOffset()
|
||||
{
|
||||
var b = self.Orientation;
|
||||
var qb = body.QuantizeOrientation(self, b);
|
||||
var orientation = turreted != null ? turreted.WorldOrientation : self.Orientation;
|
||||
var localOffset = Info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.Zero);
|
||||
var turretLocalOffset = turreted != null ? turreted.Offset : WVec.Zero;
|
||||
var turretOrientation = turreted != null ? turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw) : WRot.None;
|
||||
|
||||
return body.LocalToWorld((turretLocalOffset + localOffset.Rotate(turretOrientation)).Rotate(qb));
|
||||
return body.LocalToWorld(turretLocalOffset + localOffset.Rotate(orientation));
|
||||
}
|
||||
|
||||
WRot BarrelRotation()
|
||||
{
|
||||
var b = self.Orientation;
|
||||
var qb = body.QuantizeOrientation(self, b);
|
||||
var t = turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw);
|
||||
return Info.LocalOrientation.Rotate(t).Rotate(qb);
|
||||
return Info.LocalOrientation.Rotate(turreted != null ? turreted.WorldOrientation : self.Orientation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user