Add support for voxels in actor previews.

This commit is contained in:
Paul Chote
2014-07-21 17:36:12 +12:00
parent 3903b9b2b5
commit b5e4e0e074
7 changed files with 142 additions and 6 deletions

View File

@@ -12,11 +12,12 @@ using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.RA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
public class WithVoxelUnloadBodyInfo : ITraitInfo, IQuantizeBodyOrientationInfo, Requires<RenderVoxelsInfo>
public class WithVoxelUnloadBodyInfo : ITraitInfo, IQuantizeBodyOrientationInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>
{
[Desc("Voxel sequence name to use when docked to a refinery.")]
public readonly string UnloadSequence = "unload";
@@ -26,6 +27,15 @@ namespace OpenRA.Mods.RA.Render
public object Create(ActorInitializer init) { return new WithVoxelUnloadBody(init.self, this); }
public IEnumerable<VoxelAnimation> RenderPreviewVoxels(ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, WRot orientation, int facings, PaletteReference p)
{
var body = init.Actor.Traits.Get<BodyOrientationInfo>();
var voxel = VoxelProvider.GetVoxel(image, "idle");
yield return new VoxelAnimation(voxel, () => WVec.Zero,
() => new[]{ body.QuantizeOrientation(orientation, facings) },
() => false, () => 0);
}
public int QuantizedBodyFacings(SequenceProvider sequenceProvider, ActorInfo ai) { return 0; }
}