Support dynamic offsets in ActorPreviews.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
@@ -30,7 +31,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
public override object Create(ActorInitializer init) { return new WithVoxelBarrel(init.Self, this); }
|
||||
|
||||
public IEnumerable<VoxelAnimation> RenderPreviewVoxels(ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p)
|
||||
public IEnumerable<VoxelAnimation> RenderPreviewVoxels(
|
||||
ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, Func<WRot> orientation, int facings, PaletteReference p)
|
||||
{
|
||||
if (UpgradeMinEnabledLevel > 0)
|
||||
yield break;
|
||||
@@ -44,13 +46,13 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var voxel = VoxelProvider.GetVoxel(image, Sequence);
|
||||
|
||||
var turretFacing = Turreted.GetInitialTurretFacing(init, t.InitialFacing, t.Turret);
|
||||
var turretOrientation = body.QuantizeOrientation(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(turretFacing) - orientation.Yaw), facings);
|
||||
Func<WRot> turretOrientation = () => body.QuantizeOrientation(WRot.FromYaw(WAngle.FromFacing(turretFacing) - orientation().Yaw), facings);
|
||||
|
||||
var quantizedTurret = body.QuantizeOrientation(turretOrientation, facings);
|
||||
var quantizedBody = body.QuantizeOrientation(orientation, facings);
|
||||
var barrelOffset = body.LocalToWorld((t.Offset + LocalOffset.Rotate(quantizedTurret)).Rotate(quantizedBody));
|
||||
Func<WRot> quantizedTurret = () => body.QuantizeOrientation(turretOrientation(), facings);
|
||||
Func<WRot> quantizedBody = () => body.QuantizeOrientation(orientation(), facings);
|
||||
Func<WVec> barrelOffset = () => body.LocalToWorld((t.Offset + LocalOffset.Rotate(quantizedTurret())).Rotate(quantizedBody()));
|
||||
|
||||
yield return new VoxelAnimation(voxel, () => barrelOffset, () => new[] { turretOrientation, orientation },
|
||||
yield return new VoxelAnimation(voxel, barrelOffset, () => new[] { turretOrientation(), orientation() },
|
||||
() => false, () => 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user