diff --git a/OpenRA.Game/Graphics/VoxelAnimation.cs b/OpenRA.Game/Graphics/VoxelAnimation.cs index 42615a7d62..d0474d19f7 100644 --- a/OpenRA.Game/Graphics/VoxelAnimation.cs +++ b/OpenRA.Game/Graphics/VoxelAnimation.cs @@ -21,14 +21,16 @@ namespace OpenRA.Graphics public readonly Func> RotationFunc; public readonly Func DisableFunc; public readonly Func FrameFunc; + public readonly bool ShowShadow; - public VoxelAnimation(Voxel voxel, Func offset, Func> rotation, Func disable, Func frame) + public VoxelAnimation(Voxel voxel, Func offset, Func> rotation, Func disable, Func frame, bool showshadow) { Voxel = voxel; OffsetFunc = offset; RotationFunc = rotation; DisableFunc = disable; FrameFunc = frame; + ShowShadow = showshadow; } } } \ No newline at end of file diff --git a/OpenRA.Game/Graphics/VoxelRenderer.cs b/OpenRA.Game/Graphics/VoxelRenderer.cs index 8c373b5c15..920991ee1f 100644 --- a/OpenRA.Game/Graphics/VoxelRenderer.cs +++ b/OpenRA.Game/Graphics/VoxelRenderer.cs @@ -212,8 +212,9 @@ namespace OpenRA.Graphics lightAmbientColor, lightDiffuseColor, color.TextureMidIndex, normals.TextureMidIndex); // Disable shadow normals by forcing zero diffuse and identity ambient light - Render(rd, Util.MatrixMultiply(shadow, t), lightDirection, - ShadowAmbient, ShadowDiffuse, shadowPalette.TextureMidIndex, normals.TextureMidIndex); + if (v.ShowShadow) + Render(rd, Util.MatrixMultiply(shadow, t), lightDirection, + ShadowAmbient, ShadowDiffuse, shadowPalette.TextureMidIndex, normals.TextureMidIndex); } } })); diff --git a/OpenRA.Mods.Common/Traits/Render/WithVoxelBarrel.cs b/OpenRA.Mods.Common/Traits/Render/WithVoxelBarrel.cs index 4a3ed257f9..edfc419ce2 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithVoxelBarrel.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithVoxelBarrel.cs @@ -29,6 +29,9 @@ namespace OpenRA.Mods.Common.Traits.Render [Desc("Visual offset")] public readonly WVec LocalOffset = WVec.Zero; + [Desc("Defines if the Voxel should have a shadow.")] + public readonly bool ShowShadow = true; + public override object Create(ActorInitializer init) { return new WithVoxelBarrel(init.Self, this); } public IEnumerable RenderPreviewVoxels( @@ -53,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits.Render Func barrelOffset = () => body.LocalToWorld((t.Offset + LocalOffset.Rotate(quantizedTurret())).Rotate(quantizedBody())); yield return new VoxelAnimation(voxel, barrelOffset, () => new[] { turretOrientation(), orientation() }, - () => false, () => 0); + () => false, () => 0, ShowShadow); } } @@ -82,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits.Render var rv = self.Trait(); rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, Info.Sequence), BarrelOffset, BarrelRotation, - () => IsTraitDisabled || !buildComplete, () => 0)); + () => IsTraitDisabled || !buildComplete, () => 0, info.ShowShadow)); } WVec BarrelOffset() diff --git a/OpenRA.Mods.Common/Traits/Render/WithVoxelBody.cs b/OpenRA.Mods.Common/Traits/Render/WithVoxelBody.cs index 7150204052..f5494ccdbf 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithVoxelBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithVoxelBody.cs @@ -23,6 +23,9 @@ namespace OpenRA.Mods.Common.Traits.Render { public readonly string Sequence = "idle"; + [Desc("Defines if the Voxel should have a shadow.")] + public readonly bool ShowShadow = true; + public override object Create(ActorInitializer init) { return new WithVoxelBody(init.Self, this); } public IEnumerable RenderPreviewVoxels( @@ -32,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits.Render var voxel = VoxelProvider.GetVoxel(image, "idle"); yield return new VoxelAnimation(voxel, () => WVec.Zero, () => new[] { body.QuantizeOrientation(orientation(), facings) }, - () => false, () => 0); + () => false, () => 0, ShowShadow); } } @@ -49,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits.Render var voxel = VoxelProvider.GetVoxel(rv.Image, info.Sequence); rv.Add(new VoxelAnimation(voxel, () => WVec.Zero, () => new[] { body.QuantizeOrientation(self, self.Orientation) }, - () => IsTraitDisabled, () => 0)); + () => IsTraitDisabled, () => 0, info.ShowShadow)); // Selection size var rvi = self.Info.TraitInfo(); diff --git a/OpenRA.Mods.Common/Traits/Render/WithVoxelTurret.cs b/OpenRA.Mods.Common/Traits/Render/WithVoxelTurret.cs index 556e390072..5a85056013 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithVoxelTurret.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithVoxelTurret.cs @@ -26,6 +26,9 @@ namespace OpenRA.Mods.Common.Traits.Render [Desc("Turreted 'Turret' key to display")] public readonly string Turret = "primary"; + [Desc("Defines if the Voxel should have a shadow.")] + public readonly bool ShowShadow = true; + public override object Create(ActorInitializer init) { return new WithVoxelTurret(init.Self, this); } public IEnumerable RenderPreviewVoxels( @@ -44,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits.Render var turretFacing = Turreted.TurretFacingFromInit(init, t.InitialFacing, Turret); Func turretBodyOrientation = () => WRot.FromYaw(WAngle.FromFacing(turretFacing()) - orientation().Yaw); yield return new VoxelAnimation(voxel, turretOffset, - () => new[] { turretBodyOrientation(), body.QuantizeOrientation(orientation(), facings) }, () => false, () => 0); + () => new[] { turretBodyOrientation(), body.QuantizeOrientation(orientation(), facings) }, () => false, () => 0, ShowShadow); } } @@ -69,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits.Render var rv = self.Trait(); rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, Info.Sequence), () => turreted.Position(self), TurretRotation, - () => IsTraitDisabled || !buildComplete, () => 0)); + () => IsTraitDisabled || !buildComplete, () => 0, info.ShowShadow)); } IEnumerable TurretRotation() diff --git a/OpenRA.Mods.TS/Traits/Render/WithVoxelUnloadBody.cs b/OpenRA.Mods.TS/Traits/Render/WithVoxelUnloadBody.cs index 1599672a3e..b9360cdcc0 100644 --- a/OpenRA.Mods.TS/Traits/Render/WithVoxelUnloadBody.cs +++ b/OpenRA.Mods.TS/Traits/Render/WithVoxelUnloadBody.cs @@ -28,6 +28,9 @@ namespace OpenRA.Mods.TS.Traits.Render [Desc("Voxel sequence name to use when undocked from a refinery.")] public readonly string IdleSequence = "idle"; + [Desc("Defines if the Voxel should have a shadow.")] + public readonly bool ShowShadow = true; + public object Create(ActorInitializer init) { return new WithVoxelUnloadBody(init.Self, this); } public IEnumerable RenderPreviewVoxels( @@ -37,7 +40,7 @@ namespace OpenRA.Mods.TS.Traits.Render var voxel = VoxelProvider.GetVoxel(image, "idle"); yield return new VoxelAnimation(voxel, () => WVec.Zero, () => new[] { body.QuantizeOrientation(orientation(), facings) }, - () => false, () => 0); + () => false, () => 0, ShowShadow); } } @@ -56,7 +59,7 @@ namespace OpenRA.Mods.TS.Traits.Render rv.Add(new VoxelAnimation(idleVoxel, () => WVec.Zero, () => new[] { body.QuantizeOrientation(self, self.Orientation) }, () => Docked, - () => 0)); + () => 0, info.ShowShadow)); // Selection size var rvi = self.Info.TraitInfo(); @@ -67,7 +70,7 @@ namespace OpenRA.Mods.TS.Traits.Render rv.Add(new VoxelAnimation(unloadVoxel, () => WVec.Zero, () => new[] { body.QuantizeOrientation(self, self.Orientation) }, () => !Docked, - () => 0)); + () => 0, info.ShowShadow)); } public int2 SelectionSize(Actor self) { return size; } diff --git a/OpenRA.Mods.TS/Traits/Render/WithVoxelWalkerBody.cs b/OpenRA.Mods.TS/Traits/Render/WithVoxelWalkerBody.cs index 959039e2d9..b7ef55f66b 100644 --- a/OpenRA.Mods.TS/Traits/Render/WithVoxelWalkerBody.cs +++ b/OpenRA.Mods.TS/Traits/Render/WithVoxelWalkerBody.cs @@ -24,7 +24,11 @@ namespace OpenRA.Mods.TS.Traits.Render { public class WithVoxelWalkerBodyInfo : ITraitInfo, IRenderActorPreviewVoxelsInfo, Requires, Requires, Requires { + [Desc("The speed of the walker's legs.")] public readonly int TickRate = 5; + + [Desc("Defines if the Voxel should have a shadow.")] + public readonly bool ShowShadow = true; public object Create(ActorInitializer init) { return new WithVoxelWalkerBody(init.Self, this); } public IEnumerable RenderPreviewVoxels( @@ -36,7 +40,7 @@ namespace OpenRA.Mods.TS.Traits.Render yield return new VoxelAnimation(voxel, () => WVec.Zero, () => new[] { body.QuantizeOrientation(orientation(), facings) }, - () => false, () => frame); + () => false, () => frame, ShowShadow); } } @@ -62,7 +66,7 @@ namespace OpenRA.Mods.TS.Traits.Render frames = voxel.Frames; rv.Add(new VoxelAnimation(voxel, () => WVec.Zero, () => new[] { body.QuantizeOrientation(self, self.Orientation) }, - () => false, () => frame)); + () => false, () => frame, info.ShowShadow)); // Selection size var rvi = self.Info.TraitInfo();