Skip to content

Commit fcded29

Browse files
committed
enable Y sort for each tilemap layer
1 parent c5f1826 commit fcded29

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

C7/AnimationTracker.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Threading;
55
using System.Linq;
66
using C7GameData;
7-
using C7Engine;
87

98
public partial class AnimationTracker {
109
private AnimationManager civ3AnimData;
@@ -22,7 +21,7 @@ public struct ActiveAnimation {
2221
public C7Animation anim;
2322
}
2423

25-
private Dictionary<string, ActiveAnimation> activeAnims = new Dictionary<string, ActiveAnimation>();
24+
public Dictionary<string, ActiveAnimation> activeAnims = new Dictionary<string, ActiveAnimation>();
2625

2726
public long getCurrentTimeMS()
2827
{
@@ -45,8 +44,9 @@ private void startAnimation(string id, C7Animation anim, AutoResetEvent completi
4544
if (activeAnims.TryGetValue(id, out aa)) {
4645
// If there's already an animation playing for this unit, end it first before replacing it
4746
// TODO: Consider instead queueing up the new animation until after the first one is completed
48-
if (aa.completionEvent != null)
47+
if (aa.completionEvent is not null) {
4948
aa.completionEvent.Set();
49+
}
5050
}
5151
aa = new ActiveAnimation { startTimeMS = currentTimeMS, endTimeMS = currentTimeMS + animDurationMS, completionEvent = completionEvent,
5252
ending = ending, anim = anim };
@@ -158,9 +158,6 @@ public MapUnit.Appearance getUnitAppearance(MapUnit unit)
158158
public C7Animation getTileEffect(Tile tile)
159159
{
160160
ActiveAnimation aa;
161-
if (activeAnims.TryGetValue(getTileID(tile), out aa))
162-
return aa.anim;
163-
else
164-
return null;
161+
return activeAnims.TryGetValue(getTileID(tile), out aa) ? aa.anim : null;
165162
}
166163
}

C7/Map/MapView.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,18 @@ public bool showGrid {
2525
showGrid = value;
2626
}
2727
}
28+
private Game game;
2829
private GameMap gameMap;
2930

31+
public override void _Draw() {
32+
GD.Print("draw...");
33+
game.animTracker.update();
34+
foreach ((string id, AnimationTracker.ActiveAnimation anim) in game.animTracker.activeAnims) {
35+
GD.Print($"{id}: {anim.ToString()}");
36+
}
37+
base._Draw();
38+
}
39+
3040
public override void _Process(double delta) {
3141
base._Process(delta);
3242
}
@@ -48,6 +58,7 @@ private void initializeTileMap() {
4858
foreach (Layer layer in Enum.GetValues(typeof(Layer))) {
4959
if (layer != Layer.Invalid) {
5060
tilemap.AddLayer(layer.Index());
61+
tilemap.SetLayerYSortEnabled(layer.Index(), true);
5162
}
5263
}
5364

@@ -108,6 +119,7 @@ private Vector2I stackedCoords(Tile tile) {
108119
}
109120

110121
public MapView(Game game, GameData data) {
122+
this.game = game;
111123
gameMap = data.map;
112124
width = gameMap.numTilesWide / 2;
113125
height = gameMap.numTilesTall;

0 commit comments

Comments
 (0)