added streamlining and settings and a bit more probably
parent
2ef5b0cc46
commit
a487a1d521
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -20,6 +20,7 @@ using static Oculus.Avatar.CAPI;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using static UnityModManagerNet.UnityModManager.Param;
|
using static UnityModManagerNet.UnityModManager.Param;
|
||||||
|
using static dumb282tweaks.Main;
|
||||||
|
|
||||||
namespace dumb282tweaks;
|
namespace dumb282tweaks;
|
||||||
|
|
||||||
|
@ -32,18 +33,55 @@ public static class Main {
|
||||||
|
|
||||||
private static readonly string[] cabTypeTexts = new[] {
|
private static readonly string[] cabTypeTexts = new[] {
|
||||||
"Default",
|
"Default",
|
||||||
//"Soviet",
|
|
||||||
"German"
|
"German"
|
||||||
};
|
};
|
||||||
|
public enum CabType {
|
||||||
|
[Description("Default 282 Cab")]
|
||||||
|
Default,
|
||||||
|
[Description("German Cab")]
|
||||||
|
German
|
||||||
|
}
|
||||||
|
|
||||||
private static readonly string[] smokeDeflectorTypeTexts = new[] {
|
private static readonly string[] smokeDeflectorTypeTexts = new[] {
|
||||||
"Default",
|
"None",
|
||||||
"Soviet",
|
"Witte",
|
||||||
"German"
|
"Wagner"
|
||||||
};
|
};
|
||||||
|
public enum SmokeDeflectorType {
|
||||||
|
[Description("No Smoke Deflectors")]
|
||||||
|
None,
|
||||||
|
[Description("Witte Smoke Deflectors")]
|
||||||
|
Witte,
|
||||||
|
[Description("Wagner Smoke Deflectors")]
|
||||||
|
Wagner,
|
||||||
|
}
|
||||||
|
|
||||||
public static GameObject fullCabLoad;
|
private static readonly string[] boilerTypeTexts = new[] {
|
||||||
public static GameObject smokeDeflectorLoad;
|
"Default",
|
||||||
|
"Streamlined"
|
||||||
|
};
|
||||||
|
public enum BoilerType {
|
||||||
|
[Description("Default Boiler")]
|
||||||
|
Default,
|
||||||
|
[Description("Streamlined Boiler")]
|
||||||
|
Streamlined,
|
||||||
|
}
|
||||||
|
public class dumb282tweaksSettings : UnityModManager.ModSettings {
|
||||||
|
public bool toggleTweaks = true;
|
||||||
|
public CabType cabType = CabType.Default;
|
||||||
|
public SmokeDeflectorType smokeDeflectorType = SmokeDeflectorType.Wagner;
|
||||||
|
public BoilerType boilerType = BoilerType.Default;
|
||||||
|
|
||||||
|
public override void Save(UnityModManager.ModEntry modEntry) {
|
||||||
|
Save(this, modEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string assetPath;
|
||||||
|
//public static GameObject germanCabLoad;
|
||||||
|
public static GameObject wagnerSmokeDeflectorsLoad;
|
||||||
|
public static GameObject witteSmokeDeflectorsLoad;
|
||||||
|
public static GameObject streamlinedBoilerLoad;
|
||||||
|
|
||||||
// Load
|
// Load
|
||||||
private static bool Load(UnityModManager.ModEntry modEntry) {
|
private static bool Load(UnityModManager.ModEntry modEntry) {
|
||||||
|
@ -55,18 +93,23 @@ public static class Main {
|
||||||
|
|
||||||
Instance.OnGUI = OnGUI;
|
Instance.OnGUI = OnGUI;
|
||||||
Instance.OnSaveGUI = OnSaveGUI;
|
Instance.OnSaveGUI = OnSaveGUI;
|
||||||
|
modEntry.Logger.Log("gam");
|
||||||
|
|
||||||
harmony = new Harmony(Instance.Info.Id);
|
harmony = new Harmony(Instance.Info.Id);
|
||||||
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
harmony.PatchAll(Assembly.GetExecutingAssembly());
|
||||||
|
modEntry.Logger.Log("gamer");
|
||||||
|
|
||||||
// Asset Loading
|
assetPath = Path.Combine(Instance.Path.ToString(), "assets\\");
|
||||||
var assetPath = Path.Combine(Instance.Path.ToString(), "assets\\");
|
// Smoke Deflectors
|
||||||
var fullCabBundle = AssetBundle.LoadFromFile(Path.Combine(assetPath, "FullCab"));
|
var wagnerSmokeDeflectorsBundle = AssetBundle.LoadFromFile(Path.Combine(assetPath, "wagnersmokedeflectors"));
|
||||||
var smokeDeflectorBundle = AssetBundle.LoadFromFile(Path.Combine(assetPath, "SmokeDeflector"));
|
wagnerSmokeDeflectorsLoad = wagnerSmokeDeflectorsBundle.LoadAsset<GameObject>("Assets/WagnerSmokeDeflectors.prefab");
|
||||||
fullCabLoad = fullCabBundle.LoadAsset<GameObject>("Assets/fullcab.prefab");
|
var witteSmokeDeflectorsBundle = AssetBundle.LoadFromFile(Path.Combine(assetPath, "wittesmokedeflectors"));
|
||||||
smokeDeflectorLoad = smokeDeflectorBundle.LoadAsset<GameObject>("Assets/SmokeDeflector.prefab");
|
witteSmokeDeflectorsLoad = witteSmokeDeflectorsBundle.LoadAsset<GameObject>("Assets/WitteSmokeDeflectors.prefab");
|
||||||
|
|
||||||
} catch (Exception ex) {
|
// Boiler
|
||||||
|
var streamlinedBoilerBundle = AssetBundle.LoadFromFile(Path.Combine(assetPath, "streamline"));
|
||||||
|
streamlinedBoilerLoad = streamlinedBoilerBundle.LoadAsset<GameObject>("Assets/Streamline.prefab");
|
||||||
|
} catch(Exception ex) {
|
||||||
Instance.Logger.LogException($"Failed to load {Instance.Info.DisplayName}:", ex);
|
Instance.Logger.LogException($"Failed to load {Instance.Info.DisplayName}:", ex);
|
||||||
harmony?.UnpatchAll(Instance.Info.Id);
|
harmony?.UnpatchAll(Instance.Info.Id);
|
||||||
return false;
|
return false;
|
||||||
|
@ -79,64 +122,102 @@ public static class Main {
|
||||||
static void OnGUI(UnityModManager.ModEntry modEntry) {
|
static void OnGUI(UnityModManager.ModEntry modEntry) {
|
||||||
GUILayout.BeginVertical();
|
GUILayout.BeginVertical();
|
||||||
|
|
||||||
|
GUILayout.Label("These settings are applied on train spawn, meaning rejoining the game will refresh all 282 locos to the settings specified here, but if you don't unload the train it will keep whatever settings were there previously. This is a temporary solution until I have a proper GUI implemented.");
|
||||||
|
|
||||||
GUILayout.Label("Cab Type");
|
GUILayout.Label("Cab Type");
|
||||||
Settings.cabType = (CabType)GUILayout.SelectionGrid((int)Settings.cabType, cabTypeTexts, 1, "toggle");
|
Settings.cabType = (CabType)GUILayout.SelectionGrid((int) Settings.cabType, cabTypeTexts, 1, "toggle");
|
||||||
GUILayout.Space(2);
|
GUILayout.Space(2);
|
||||||
|
|
||||||
GUILayout.Label("Smoke Deflector Type");
|
GUILayout.Label("Smoke Deflector Type");
|
||||||
Settings.smokeDeflectorType = (SmokeDeflectorType) GUILayout.SelectionGrid((int) Settings.smokeDeflectorType, smokeDeflectorTypeTexts, 1, "toggle");
|
Settings.smokeDeflectorType = (SmokeDeflectorType) GUILayout.SelectionGrid((int) Settings.smokeDeflectorType, smokeDeflectorTypeTexts, 1, "toggle");
|
||||||
|
|
||||||
|
GUILayout.Label("Boiler Type");
|
||||||
|
Settings.boilerType = (BoilerType) GUILayout.SelectionGrid((int) Settings.boilerType, boilerTypeTexts, 1, "toggle");
|
||||||
|
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
static void OnSaveGUI(UnityModManager.ModEntry modEntry) {
|
static void OnSaveGUI(UnityModManager.ModEntry modEntry) {
|
||||||
Settings.Save(modEntry);
|
Settings.Save(modEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(TrainCar), "Start")]
|
[HarmonyPatch(typeof(TrainCar), "Start")]
|
||||||
class CarPatch {
|
class CarPatch {
|
||||||
static void Postfix(ref TrainCar __instance) {
|
static void Postfix(ref TrainCar __instance) {
|
||||||
if(__instance is not null && __instance.carType == TrainCarType.LocoSteamHeavy) {
|
//switch(Settings.cabType) {
|
||||||
GameObject fullCab = UnityEngine.Object.Instantiate(fullCabLoad);
|
// case CabType.Default:
|
||||||
fullCab.transform.parent = __instance.transform;
|
// break;
|
||||||
fullCab.transform.localPosition = new Vector3(0, 3, 0);
|
// case CabType.German:
|
||||||
fullCab.transform.localRotation = Quaternion.identity;
|
// if(__instance != null && __instance.carType == TrainCarType.LocoSteamHeavy) {
|
||||||
fullCab.transform.localScale = new Vector3(1, 1, 1);
|
|
||||||
|
|
||||||
GameObject smokeDeflector = UnityEngine.Object.Instantiate(smokeDeflectorLoad);
|
// var fullCabBundle = AssetBundle.LoadFromFile(Path.Combine(assetPath, "fullcab"));
|
||||||
smokeDeflector.transform.parent = __instance.transform;
|
// var fullCabLoad = fullCabBundle.LoadAsset<GameObject>("Assets/FullCab.prefab");
|
||||||
smokeDeflector.transform.localPosition = new Vector3(0, 2.55f, 10.23f);
|
|
||||||
smokeDeflector.transform.localRotation = Quaternion.identity;
|
// GameObject fullCab = UnityEngine.Object.Instantiate(fullCabLoad);
|
||||||
smokeDeflector.transform.localScale = new Vector3(1, 1, 1);
|
// fullCab.transform.parent = __instance.transform;
|
||||||
}
|
// fullCab.transform.localPosition = new Vector3(0, 3, 0);
|
||||||
}
|
// fullCab.transform.localRotation = Quaternion.identity;
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
//}
|
||||||
|
// Smoke Deflector Type
|
||||||
|
if(__instance != null && __instance.carType == TrainCarType.LocoSteamHeavy) {
|
||||||
|
// This is a terrible way to get the material of the locomotive since a simple gameobject reordering will break it, but it's alright for now. If something breaks, just note that this is likely the reason
|
||||||
|
Material s282Mat = __instance.transform.GetChild(5).transform.GetChild(0).transform.GetChild(0).GetComponent<MeshRenderer>().material;
|
||||||
|
|
||||||
|
Log(Path.Combine(assetPath, "wittesmokedeflectors"));
|
||||||
|
|
||||||
|
switch(Settings.smokeDeflectorType) {
|
||||||
|
case SmokeDeflectorType.None:
|
||||||
|
break;
|
||||||
|
case SmokeDeflectorType.Witte:
|
||||||
|
GameObject witteSmokeDeflector = UnityEngine.Object.Instantiate(witteSmokeDeflectorsLoad);
|
||||||
|
|
||||||
|
// This is also a terrible way to set the material of the smoke deflectors, but oh well
|
||||||
|
witteSmokeDeflector.transform.GetChild(0).GetComponent<MeshRenderer>().material = s282Mat;
|
||||||
|
witteSmokeDeflector.transform.GetChild(1).GetComponent<MeshRenderer>().material = s282Mat;
|
||||||
|
|
||||||
|
//Log(smokeDeflector.GetComponent<MeshRenderer>().material.name.ToString());
|
||||||
|
witteSmokeDeflector.transform.parent = __instance.transform;
|
||||||
|
witteSmokeDeflector.transform.localPosition = new Vector3(0, 2.1f, 5f);
|
||||||
|
witteSmokeDeflector.transform.localRotation = Quaternion.identity;
|
||||||
|
break;
|
||||||
|
case SmokeDeflectorType.Wagner:
|
||||||
|
GameObject wagnerSmokeDeflector = UnityEngine.Object.Instantiate(wagnerSmokeDeflectorsLoad);
|
||||||
|
|
||||||
|
// This is also a terrible way to set the material of the smoke deflectors, but oh well
|
||||||
|
wagnerSmokeDeflector.transform.GetChild(0).GetComponent<MeshRenderer>().material = s282Mat;
|
||||||
|
wagnerSmokeDeflector.transform.GetChild(1).GetComponent<MeshRenderer>().material = s282Mat;
|
||||||
|
|
||||||
|
//Log(smokeDeflector.GetComponent<MeshRenderer>().material.name.ToString());
|
||||||
|
wagnerSmokeDeflector.transform.parent = __instance.transform;
|
||||||
|
wagnerSmokeDeflector.transform.localPosition = new Vector3(0, 2.1f, 5f);
|
||||||
|
wagnerSmokeDeflector.transform.localRotation = Quaternion.identity;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CabType {
|
switch(Settings.boilerType) {
|
||||||
[Description("Default 282 Cab")]
|
case BoilerType.Default:
|
||||||
Default,
|
break;
|
||||||
[Description("German Cab")]
|
case BoilerType.Streamlined:
|
||||||
German
|
GameObject streamlinedBoiler = UnityEngine.Object.Instantiate(streamlinedBoilerLoad);
|
||||||
}
|
|
||||||
|
|
||||||
public enum SmokeDeflectorType {
|
// This is also a terrible way to set the material of the smoke deflectors, but oh well
|
||||||
[Description("No Smoke Deflectors")]
|
streamlinedBoiler.transform.GetChild(0).GetComponent<MeshRenderer>().material = s282Mat;
|
||||||
None,
|
streamlinedBoiler.transform.GetChild(1).GetComponent<MeshRenderer>().material = s282Mat;
|
||||||
[Description("Soviet Smoke Deflectors")]
|
streamlinedBoiler.transform.GetChild(2).GetComponent<MeshRenderer>().material = s282Mat;
|
||||||
Soviet,
|
streamlinedBoiler.transform.GetChild(3).GetComponent<MeshRenderer>().material = s282Mat;
|
||||||
[Description("German Smoke Deflectors")]
|
|
||||||
German,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class dumb282tweaksSettings : UnityModManager.ModSettings {
|
//Log(smokeDeflector.GetComponent<MeshRenderer>().material.name.ToString());
|
||||||
public bool toggleTweaks = true;
|
streamlinedBoiler.transform.parent = __instance.transform;
|
||||||
public CabType cabType = CabType.German;
|
streamlinedBoiler.transform.localPosition = new Vector3(0, 2.15f, 5.1f);
|
||||||
public SmokeDeflectorType smokeDeflectorType = SmokeDeflectorType.Soviet;
|
streamlinedBoiler.transform.localRotation = Quaternion.identity;
|
||||||
|
break;
|
||||||
public override void Save(UnityModManager.ModEntry modEntry) {
|
}
|
||||||
Save(this, modEntry);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger Commands
|
// Logger Commands
|
||||||
public static void Log(string message) {
|
public static void Log(string message) {
|
||||||
Instance.Logger.Log(message);
|
Instance.Logger.Log(message);
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace dumb282tweaks {
|
||||||
|
internal class Patch282 {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue