configurable and self-documenting idle sequence name

This commit is contained in:
Matthias Mailänder
2014-07-20 13:55:11 +02:00
parent eec36b6d0c
commit 40d0e20fe1

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -15,21 +15,24 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
[Desc("Also returns a default selection size that is calculated automatically from the voxel dimensions.")]
public class WithVoxelBodyInfo : ITraitInfo, Requires<RenderVoxelsInfo>
{
public object Create(ActorInitializer init) { return new WithVoxelBody(init.self); }
public readonly string Sequence = "idle";
public object Create(ActorInitializer init) { return new WithVoxelBody(init.self, this); }
}
public class WithVoxelBody : IAutoSelectionSize
{
int2 size;
public WithVoxelBody(Actor self)
public WithVoxelBody(Actor self, WithVoxelBodyInfo info)
{
var body = self.Trait<IBodyOrientation>();
var rv = self.Trait<RenderVoxels>();
var voxel = VoxelProvider.GetVoxel(rv.Image, "idle");
var voxel = VoxelProvider.GetVoxel(rv.Image, info.Sequence);
rv.Add(new VoxelAnimation(voxel, () => WVec.Zero,
() => new[]{ body.QuantizeOrientation(self, self.Orientation) },
() => false, () => 0));