Add b99.4 Shop Inventories

This commit is contained in:
Pyro Nicampt committed 2025-04-20 18:36:50 -05:00
1 parent b4228ab177
commit 3c63df20d0
10 files changed
+1149 -115

No files matched your search

+8
View File
@@ -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>
+1 -1
View File
@@ -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"
}
+43 -9
View File
@@ -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,16 +106,49 @@ 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}}}"
};
}));
}
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 {
@@ -119,11 +157,7 @@ namespace CommunityMapTool {
}
}
sb.Append("\n}");
records.Add(sb.ToString());
}
File.WriteAllText(demonstratorOutputPath, "[" + string.Join(",", records.ToArray()) + "\n]");
statusText = $"Dumped to {demonstratorOutputPath}";
return sb.ToString();
}
}
}
+2 -2
View File
@@ -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")]
+2
View File
@@ -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`
+9
View File
@@ -20,6 +20,7 @@ const zoomLevelDisplay = document.getElementById('zoomLevelDisplay');
let isNavigating = false;
document.addEventListener('DOMContentLoaded', async () => {
await loadShopData('shop_items.json');
await loadTrackData('trackdata_dv.json');
await loadPoiData('poi_dv.json');
MapData.sortMarkers();
@@ -246,6 +247,14 @@ async function loadPoiData(file){
}
}
async function loadShopData(file) {
let shopData = await (await fetch(new Request(file))).json();
for(let item of shopData){
MapData.addShopItem(item);
}
MapData.sortShops();
}
let railTrack = {};
let curve = {};
+51 -1
View File
@@ -15,6 +15,10 @@ let uniqueTrackNames = {};
export let testPoint = {x:0,y:0};
export let Shops = {
Common:[]
}
export let matrix = {
initialize: () => {
matrix.minX = Infinity;
@@ -112,6 +116,14 @@ export function sortMarkers(){
});
}
export function sortShops(){
for(let shop in Shops){
Shops[shop].sort((a,b) => {
return a.name.localeCompare(b.name);
});
}
}
export function filterToTrack(trackName, trackNum = 0){
if(typeof(trackName) == 'string'){
for(let railTrack of railTracks){
@@ -247,7 +259,16 @@ export function addPoi(poiData, level = 0){
newPoi.tooltip = `<h1>${poiData.name}</h1>`;
break;
case 'shop':
newPoi.tooltip = `<h1>Shop</h1>${poiData.stock ? '<hr>'+poiData.stock.sort().join('\n') : ''}`;
newPoi.tooltip = '<h1>Shop</h1><hr><div class="smol" style="columns:2">';
if(poiData.shopId){
for(let item of Shops[poiData.shopId]){
newPoi.tooltip += `<div>${item.name}${item.count > 1 ? ` (x${item.count})` : ''} - $${item.price}</div>`;
}
for(let item of Shops.Common){
newPoi.tooltip += `<div class="quiet">${item.name}${item.count > 1 ? ` (x${item.count})` : ''} - $${item.price}</div>`;
}
}
newPoi.tooltip += '</div>';
break;
case 'water':
newPoi.tooltip = '<h1>Water Tower</h1>';
@@ -284,6 +305,35 @@ export function addPoi(poiData, level = 0){
}
}
export function addShopItem(itemData){
let newItem = {
name: itemData.name,
price: itemData.price,
count: itemData.count,
};
if(itemData.soldOnlyAt.length == 0){
for(let item of Shops.Common){
if(item.name == newItem.name && item.price == newItem.price){
item.count += newItem.count;
return;
}
}
Shops.Common.push(newItem);
}else{
for(let shop of itemData.soldOnlyAt){
if(!Shops[shop]) Shops[shop] = [];
for(let item of Shops[shop]){
if(item.name == newItem.name && item.price == newItem.price){
item.count += newItem.count;
return;
}
}
Shops[shop].push(newItem);
}
}
}
export function generateTrackSignage(){
let yardMarkers = {};
for(const railTrack of railTracks){
+5 -102
View File
@@ -136,39 +136,7 @@
},
{
"type":"shop",
"stock":[
"Boombox",
"Red Beacon",
"Plastic Crate",
"Cassette A7",
"Cassette P6",
"Cassette P9",
"Red Light Bar",
"File Box",
"Purple Flag Marker",
"Reginald's Garage Key",
"Cassette P10",
"Cassette P5",
"Cassette P7",
"Handheld Game Console",
"Wooden Crate",
"Cassette A1",
"Cassette P2",
"Yellow Flag Marker",
"Green Flag Marker",
"Orange Flag Marker",
"Cyan Flag Marker",
"Cassette P4",
"Green Light Bar",
"Cassette P1",
"Blue Flag Marker",
"Cassette P8",
"White Flag Marker",
"Red Flag Marker",
"Cassette A2",
"Blue Beacon",
"Cassette P3"
],
"shopId":"CitySouthWest",
"position":{"x":1911.48,"y":122.26,"z":5788.65}
}
]
@@ -198,13 +166,7 @@
},
{
"type":"shop",
"stock":[
"Cassette A12",
"Cassette A15",
"Cassette A6",
"Cassette A3",
"Old Bob's Garage Key"
],
"shopId":"FoodFactory",
"position":{"x":9528.669,"y":119.3432,"z":13419.99}
}
]
@@ -289,30 +251,7 @@
},
{
"type":"shop",
"stock":[
"Shelf",
"Rotary Controller",
"Analog Controller",
"Cassette A16",
"Crimping Tool",
"Blue Light Bar",
"Brake Cylinder LED Bar",
"Electric Hand Drill",
"Digital Speedometer",
"Golden Shovel",
"Infrared Thermometer",
"Button Controller",
"Filler Gun",
"Sun Visor",
"Cassette A10",
"Expert Shovel",
"Digital Clock",
"Alternating Controller",
"White Light Bar",
"Soldering Gun",
"Clinometer",
"Cassette A8"
],
"shopId":"GoodsFactory",
"position":{"x":13035.07,"y":140.1661,"z":11158.79}
}
]
@@ -351,20 +290,7 @@
},
{
"type":"shop",
"stock":[
"Plastic Crate",
"Steve's Garage Key",
"Wooden Crate",
"Red Beacon",
"Steam Locomotive Checklist",
"File Box",
"Cassette A11",
"Purple Light Bar",
"Cassette A4",
"Pocketwatch",
"Blue Beacon",
"Cyan Light Bar"
],
"shopId":"Harbor",
"position":{"x":13423.26,"y":113.1099,"z":3611.852}
}
]
@@ -475,30 +401,7 @@
},
{
"type":"shop",
"stock":[
"Amber Beacon",
"Headlight",
"Button Controller",
"Automatic Train Stop",
"Analog Controller",
"Cassette A13",
"Rotary Controller",
"Locomotive Remote",
"Alternating Controller",
"Olaf's Garage Key",
"Demonstrator Paint Can",
"Yellow Light Bar",
"Wireless MU Controller",
"Anti-Wheelslip Computer",
"Overheat Protection",
"Cassette A14",
"Orange Light Bar",
"Cassette A9",
"Distance Tracker",
"Amp Limiter",
"Switch Setter",
"Cassette A5"
],
"shopId":"MachineFactory",
"position":{"x":2236.745,"y":159.266,"z":10834.23}
}
]
+1019
View File
File diff suppressed because it is too large. Load diff
+9
View File
@@ -32,6 +32,15 @@ a:visited{
color: #e79830;
}
.quiet{
opacity: 0.7;
}
.smol{
font-size: 11px;
color: #fff;
}
.panel{
border: 2px solid #b3b3b396;
background: linear-gradient(120deg, #2c3f58, #191e2e);