From d6dba3e5454777f88230a367f4708ccc83421326 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 16 Nov 2024 12:16:28 +0000 Subject: [PATCH] Fix Animation shadow to account for height. If a unit is above the terrain, the shadow shouldn't display directly underneath the unit, it should take the height into account and display further down. This fix uses the same adjustment as applied by the WithShadow trait. --- OpenRA.Game/Graphics/Animation.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Graphics/Animation.cs b/OpenRA.Game/Graphics/Animation.cs index a1d0c0b03b..78609531b8 100644 --- a/OpenRA.Game/Graphics/Animation.cs +++ b/OpenRA.Game/Graphics/Animation.cs @@ -22,6 +22,7 @@ namespace OpenRA.Graphics public string Name { get; private set; } public bool IsDecoration { get; set; } + readonly Map map; readonly SequenceSet sequences; readonly Func facingFunc; readonly Func paused; @@ -43,6 +44,7 @@ namespace OpenRA.Graphics public Animation(World world, string name, Func facingFunc, Func paused) { + map = world.Map; sequences = world.Map.Sequences; Name = name.ToLowerInvariant(); this.facingFunc = facingFunc; @@ -65,8 +67,10 @@ namespace OpenRA.Graphics var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc()); if (shadow != null) { + var height = map.DistanceAboveTerrain(pos).Length; + var shadowRenderable = new SpriteRenderable( - shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette, + shadow, pos, offset - new WVec(0, 0, height), CurrentSequence.ShadowZOffset + zOffset + height, palette, CurrentSequence.Scale, 1f, float3.Ones, tintModifiers, true, rotation); return new IRenderable[] { shadowRenderable, imageRenderable };