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
@@ -46,6 +46,10 @@
|
||||
<HintPath>lib\BezierCurves.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="DV.Common">
|
||||
<HintPath>lib\DV.Common.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="DV.OriginShiftInfo">
|
||||
<HintPath>lib\DV.OriginShiftInfo.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
@@ -54,6 +58,10 @@
|
||||
<HintPath>lib\DV.RailTrack.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="DV.UserManagement">
|
||||
<HintPath>lib\DV.UserManagement.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="DV.Utils">
|
||||
<HintPath>lib\DV.Utils.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"Id":"CommunityMapTool",
|
||||
"DisplayName":"Derail Valley Community Map Tool",
|
||||
"Author":"PyroNicampt",
|
||||
"Version":"1.2.0",
|
||||
"Version":"1.3.0",
|
||||
"ManagerVersion":"0.31.1.0",
|
||||
"EntryMethod":"CommunityMapTool.Main.Load"
|
||||
}
|
||||
+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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
[assembly: AssemblyVersion("1.3.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.3.0.0")]
|
||||
@@ -3,8 +3,10 @@ Assuming Visual Studio Community:
|
||||
1. Add the following to the `lib` folder from `[steam common dir]/Derail Valley/DerailValley_Data/Managed/UnityModManager`:
|
||||
- `Assembly-CSharp.dll`
|
||||
- `BezierCurves.dll`
|
||||
- `DV.Common.dll`
|
||||
- `DV.OriginShiftInfo.dll`
|
||||
- `DV.RailTrack.dll`
|
||||
- `DV.UserManagement.dll`
|
||||
- `DV.Utils.dll`
|
||||
- `UnityEngine.dll`
|
||||
- `UnityEngine.UI.dll`
|
||||
|
||||
Reference in new issue
Block a user