Skip to content

Commit c249d97

Browse files
committed
Added tribe preview dump, Closes #90
1 parent 0321d6c commit c249d97

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

src/Managers/Hub.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using HarmonyLib;
44
using I2.Loc;
55
using Il2CppInterop.Runtime;
6+
using Polytopia.Data;
67
using TMPro;
78
using UnityEngine;
89
using UnityEngine.EventSystems;
@@ -182,6 +183,35 @@ static void PolyModHubButtonClicked(int buttonId, BaseEventData eventData)
182183
}
183184
}
184185
}
186+
foreach (TribeData.Type type in Enum.GetValues(typeof(TribeData.Type)))
187+
{
188+
List<Visual.PreviewTile> previewTiles = new();
189+
SelectTribePopup popup = PopupManager.GetSelectTribePopup();
190+
for (int x = -3; x <= 3; x++)
191+
{
192+
for (int y = -7; y <= 7; y++)
193+
{
194+
Vector2Int pos = new Vector2Int(x, y);
195+
if (popup.UIWorldPreview.worldPreviewData.TryGetData(pos, type, out UITileData tileData))
196+
{
197+
Visual.PreviewTile previewTile = new Visual.PreviewTile
198+
{
199+
x = tileData.Position.x,
200+
y = tileData.Position.y,
201+
terrainType = tileData.terrainType,
202+
resourceType = tileData.resourceType,
203+
unitType = tileData.unitType,
204+
improvementType = tileData.improvementType
205+
};
206+
previewTiles.Add(previewTile);
207+
}
208+
}
209+
}
210+
File.WriteAllTextAsync(
211+
Path.Combine(Plugin.DUMPED_DATA_PATH, $"preview_{type}.json"),
212+
JsonSerializer.Serialize(previewTiles, new JsonSerializerOptions { WriteIndented = true })
213+
);
214+
}
185215
NotificationManager.Notify(Localization.Get("polymod.hub.dumped"));
186216
}),
187217
closesPopup: false

0 commit comments

Comments
 (0)