Add b99.4 Shop Inventories
This commit is contained in:
1 parent
b4228ab177
commit
3c63df20d0
10 files changed
+1153
-119
No files matched your search
+47
-13
@@ -6,12 +6,16 @@ using UnityEngine;
|
||||
using UnityModManagerNet;
|
||||
using DV.LocoRestoration;
|
||||
using DV.OriginShift;
|
||||
using DV.Shops;
|
||||
using DV.Utils;
|
||||
using DV.UserManagement;
|
||||
|
||||
namespace CommunityMapTool {
|
||||
[EnableReloading]
|
||||
static class Main {
|
||||
private static string trackOutputPath = "map_dump.json";
|
||||
private static string demonstratorOutputPath = "demo_dump.json";
|
||||
private static string shopOutputPath = "shop_dump.json";
|
||||
private static string statusText = "";
|
||||
static bool Load(UnityModManager.ModEntry modEntry) {
|
||||
modEntry.OnUpdate = OnUpdate;
|
||||
@@ -32,6 +36,7 @@ namespace CommunityMapTool {
|
||||
GUILayout.Label($"WorldMover offset: {OriginShift.currentMove}");
|
||||
if(GUILayout.Button("Dump All Tracks")) DumpAllTracks();
|
||||
if(GUILayout.Button("Dump Demonstrator Spawnpoints")) DemonstratorDump();
|
||||
if(GUILayout.Button("Dump Shop Inventories")) DumpShopItems();
|
||||
if(GUILayout.Button("Copy Position To Clipboard")) ClipboardPlayerPosition();
|
||||
if(statusText != "") GUILayout.Label(statusText);
|
||||
}
|
||||
@@ -101,29 +106,58 @@ namespace CommunityMapTool {
|
||||
File.WriteAllText(trackOutputPath, "[" + string.Join(",", records.ToArray()) + "\n]");
|
||||
statusText = $"Dumped to {trackOutputPath}";
|
||||
}
|
||||
static void DumpShopItems() {
|
||||
GlobalShopController shopController = UnityEngine.Object.FindObjectOfType<GlobalShopController>();
|
||||
if(shopController == null) {
|
||||
statusText = "Could not find GlobalShopController";
|
||||
return;
|
||||
}
|
||||
if(SingletonBehaviour<UserManager>.Instance.CurrentUser.CurrentSession.GameMode != "Career") {
|
||||
statusText = "Cannot dump shop prices in sandbox";
|
||||
return;
|
||||
}
|
||||
List<string> records = new List<string>();
|
||||
foreach(ShopItemData shopItem in shopController.shopItemsData) {
|
||||
string[] soldAtShops = new string[shopItem.soldOnlyAt.Count];
|
||||
for(int i = 0; i < soldAtShops.Length; i++) {
|
||||
soldAtShops[i] = "\"" + shopItem.soldOnlyAt[i].name.Replace("[ItemShop] ","").Replace(" (Shop)","") + "\"";
|
||||
}
|
||||
records.Add(jsonKVPToString(new string[] {
|
||||
"name", $"\"{shopItem.item.LocalizedName}\"",
|
||||
"price", $"{shopItem.basePrice}",
|
||||
"count", $"{shopItem.allowedToHaveAmount}",
|
||||
"soldOnlyAt", soldAtShops.Length > 0 ? $"[\n\t\t{string.Join(",\n\t\t", soldAtShops)}\n\t]" : "[]"
|
||||
}));
|
||||
}
|
||||
File.WriteAllText(shopOutputPath, "[" + string.Join(",", records.ToArray()) + "\n]");
|
||||
statusText = $"Dumped to {shopOutputPath}";
|
||||
}
|
||||
static void DemonstratorDump() {
|
||||
List<string> records = new List<string>();
|
||||
foreach(LocoRestorationSpawnPoint spawnPoint in UnityEngine.Object.FindObjectsOfType<LocoRestorationSpawnPoint>()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("\n{");
|
||||
string[] jsonKVP = new[] {
|
||||
records.Add(jsonKVPToString(new string[] {
|
||||
"name", $"\"{spawnPoint.name}\"",
|
||||
"type", $"\"demonstratorSpawn\"",
|
||||
"position", $"{{\"x\":{spawnPoint.transform.position.x - OriginShift.currentMove.x},\"y\":{spawnPoint.transform.position.y - OriginShift.currentMove.y},\"z\":{spawnPoint.transform.position.z - OriginShift.currentMove.z}}}"
|
||||
};
|
||||
for(int i = 0; i < jsonKVP.Length; i++) {
|
||||
if(i % 2 == 0) sb.Append($"\n\t\"{jsonKVP[i]}\":");
|
||||
else{
|
||||
sb.Append($"{jsonKVP[i]}");
|
||||
if(i != jsonKVP.Length - 1) sb.Append(',');
|
||||
}
|
||||
}
|
||||
sb.Append("\n}");
|
||||
records.Add(sb.ToString());
|
||||
}));
|
||||
}
|
||||
|
||||
File.WriteAllText(demonstratorOutputPath, "[" + string.Join(",", records.ToArray()) + "\n]");
|
||||
statusText = $"Dumped to {demonstratorOutputPath}";
|
||||
}
|
||||
|
||||
static string jsonKVPToString(string[] jsonKVP) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("\n{");
|
||||
for(int i = 0; i < jsonKVP.Length; i++) {
|
||||
if(i % 2 == 0) sb.Append($"\n\t\"{jsonKVP[i]}\":");
|
||||
else {
|
||||
sb.Append($"{jsonKVP[i]}");
|
||||
if(i != jsonKVP.Length - 1) sb.Append(',');
|
||||
}
|
||||
}
|
||||
sb.Append("\n}");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user