Skip to content

Commit 7430ffa

Browse files
committed
Re-implement Translucency for building animations, fix bug in handling of alpha in object renderer
1 parent 9ccdf3a commit 7430ffa

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/TSMapEditor/Rendering/ObjectRenderers/BuildingRenderer.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,22 @@ private void DrawAnimationImage(Structure gameObject, Animation animation, Shape
523523
if (!isBelowBuilding)
524524
depthRectangle += GetDepthAddition(gameObject);
525525

526+
switch (animation.AnimType.ArtConfig.Translucency)
527+
{
528+
default:
529+
case 0:
530+
break;
531+
case 25:
532+
color = color with { A = 192 };
533+
break;
534+
case 50:
535+
color = color with { A = 128 };
536+
break;
537+
case 75:
538+
color = color with { A = 64 };
539+
break;
540+
}
541+
526542
RenderFrame(gameObject, frame, remapFrame, color, drawRemap, remapColor,
527543
drawingBounds, image.GetPaletteTexture(), lighting, depthRectangle);
528544
}

src/TSMapEditor/Rendering/ObjectRenderers/ObjectRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ protected void RenderFrame(T gameObject, PositionedTexture frame, PositionedText
495495
{
496496
color = new Color((color.R / 255.0f) * lightingColor.X / 2f,
497497
(color.B / 255.0f) * lightingColor.Y / 2f,
498-
(color.B / 255.0f) * lightingColor.Z / 2f, color.A);
498+
(color.B / 255.0f) * lightingColor.Z / 2f, color.A / 255.0f);
499499

500500
RenderDependencies.ObjectSpriteRecord.AddGraphicsEntry(new ObjectSpriteEntry(paletteTexture, frame, drawingBounds, color, false, false, depthRectangle));
501501

@@ -505,7 +505,7 @@ protected void RenderFrame(T gameObject, PositionedTexture frame, PositionedText
505505
(remapColor.R / 255.0f),
506506
(remapColor.G / 255.0f),
507507
(remapColor.B / 255.0f),
508-
color.A);
508+
color.A / 255.0f);
509509

510510
RenderDependencies.ObjectSpriteRecord.AddGraphicsEntry(new ObjectSpriteEntry(paletteTexture, remapFrame, drawingBounds, remapColor, true, false, depthRectangle + Constants.DepthEpsilon));
511511
}

0 commit comments

Comments
 (0)