Skip to content

Commit

Permalink
RA2 high bridge shadow offsets added.. what a mess. And TS probably n…
Browse files Browse the repository at this point in the history
…eeds this too..
  • Loading branch information
zzattack committed Aug 25, 2013
1 parent 1959eea commit 0ed9a0c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions CNCMaps/MapLogic/Drawable.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using CNCMaps.FileFormats;
using CNCMaps.Utility;
using CNCMaps.VirtualFileSystem;
Expand Down Expand Up @@ -103,17 +104,21 @@ class Drawable {

if (p == null && obj is RemappableObject)
p = (obj as RemappableObject).Palette;
else if (UseTilePalette)
else if (UseTilePalette)
p = obj.Tile.Palette;

// hacky bridge crap
// hacky bridge crap, somehow they have crazy offsets. hopefully this never needs to be touched again.
var shadowOffset = offset;
if (Overrides && obj is OverlayObject) {
var o = obj as OverlayObject;
if (TileWidth == 60) { // RA2
// bridge
if (o.IsHighBridge()) {
// 0-8 are bridge parts bottom-left -- top-right, 9-16 are top-left -- bottom right
offset.Y += o.OverlayValue > 8 ? -16 : -1;
offset.X += o.OverlayValue <= 8 ? 0 : 0;
offset.Y += o.OverlayValue <= 8 ? -1 : -16;
shadowOffset.X += o.OverlayValue <= 8 ? 0 : -15;
shadowOffset.Y += o.OverlayValue <= 8 ? -1 : -9;
}
}
else { // TS
Expand All @@ -122,14 +127,15 @@ class Drawable {
}
else {
// 0-8 are bridge parts bottom-left -- top-right, 9-16 are top-left -- bottom right
// but perhaps they're already aligned correctly?
offset.X += o.OverlayValue <= 8 ? 0 : 0;
offset.Y += o.OverlayValue <= 8 ? 0 : 0;
}
}
}
file.Draw(Frame, ds, offset, obj.Tile, p ?? Palette, Overrides);
if (props.hasShadow) {
file.DrawShadow(Frame, ds, offset, obj.Tile);
file.DrawShadow(Frame, ds, shadowOffset, obj.Tile);
}
}

Expand Down

0 comments on commit 0ed9a0c

Please sign in to comment.