everything is now imported correctly

master
EvilPunkin 2023-08-16 18:19:48 -07:00
parent 3c48300bf9
commit 2ef5b0cc46
2 changed files with 112 additions and 37 deletions

View File

@ -6,8 +6,20 @@ using UnityModManagerNet;
using UnityEngine; using UnityEngine;
using System.Collections.Generic; using System.Collections.Generic;
using DV; using DV;
using DV.Utils;
using DV.Simulation;
using DV.Common;
using System.Linq;
using System.Threading.Tasks;
using DV.RemoteControls;
using DV.Wheels;
using DV.Simulation.Cars;
using DV.ThingTypes;
using LocoSim.Implementations;
using static Oculus.Avatar.CAPI;
using UnityEngine.UI; using UnityEngine.UI;
using System.ComponentModel; using System.ComponentModel;
using static UnityModManagerNet.UnityModManager.Param;
namespace dumb282tweaks; namespace dumb282tweaks;
@ -16,6 +28,8 @@ public static class Main {
public static UnityModManager.ModEntry Instance { get; private set; } public static UnityModManager.ModEntry Instance { get; private set; }
public static dumb282tweaksSettings Settings { get; private set; } public static dumb282tweaksSettings Settings { get; private set; }
public static bool enabled;
private static readonly string[] cabTypeTexts = new[] { private static readonly string[] cabTypeTexts = new[] {
"Default", "Default",
//"Soviet", //"Soviet",
@ -28,7 +42,8 @@ public static class Main {
"German" "German"
}; };
private static AssetBundle loadedAssetBundle; public static GameObject fullCabLoad;
public static GameObject smokeDeflectorLoad;
// Load // Load
private static bool Load(UnityModManager.ModEntry modEntry) { private static bool Load(UnityModManager.ModEntry modEntry) {
@ -44,7 +59,13 @@ public static class Main {
harmony = new Harmony(Instance.Info.Id); harmony = new Harmony(Instance.Info.Id);
harmony.PatchAll(Assembly.GetExecutingAssembly()); harmony.PatchAll(Assembly.GetExecutingAssembly());
WorldStreamingInit.LoadingFinished += GameLoaded; // Asset Loading
var assetPath = Path.Combine(Instance.Path.ToString(), "assets\\");
var fullCabBundle = AssetBundle.LoadFromFile(Path.Combine(assetPath, "FullCab"));
var smokeDeflectorBundle = AssetBundle.LoadFromFile(Path.Combine(assetPath, "SmokeDeflector"));
fullCabLoad = fullCabBundle.LoadAsset<GameObject>("Assets/fullcab.prefab");
smokeDeflectorLoad = smokeDeflectorBundle.LoadAsset<GameObject>("Assets/SmokeDeflector.prefab");
} catch (Exception ex) { } 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);
@ -54,35 +75,10 @@ public static class Main {
return true; return true;
} }
private static void GameLoaded() {
WorldMover worldMoverScript = GameObject.Find("WorldMover").GetComponent<WorldMover>();
// Asset Loading
var modelPath = Path.Combine(Instance.Path.ToString(), "assets\\fullcab");
var loadedAssetBundle = AssetBundle.LoadFromFile(modelPath);
GameObject fullCabLoad = loadedAssetBundle.LoadAsset<GameObject>("Assets/fullcab.prefab");
//GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
GameObject fullCab = GameObject.Instantiate(fullCabLoad);
fullCab.transform.position = PlayerManager.GetWorldAbsolutePlayerPosition() + new Vector3(0, 6, 0);
fullCab.transform.localScale = new Vector3(1, 1, 1);
fullCab.transform.position += WorldMover.currentMove;
worldMoverScript.AddObjectToMove(fullCab.transform);
// Find all GameObjects
//foreach(GameObject obj in Resources.FindObjectsOfTypeAll<GameObject>()) {
//}
}
// GUI Rendering // GUI Rendering
static void OnGUI(UnityModManager.ModEntry modEntry) { static void OnGUI(UnityModManager.ModEntry modEntry) {
GUILayout.BeginVertical(); GUILayout.BeginVertical();
Settings.toggleTweaks = GUILayout.Toggle(Settings.toggleTweaks, "Toggle Tweaks");
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);
@ -96,21 +92,29 @@ public static class Main {
Settings.Save(modEntry); Settings.Save(modEntry);
} }
// Logger Commands [HarmonyPatch(typeof(TrainCar), "Start")]
public static void Log(string message) { class CarPatch {
Instance.Logger.Log(message); static void Postfix(ref TrainCar __instance) {
} if(__instance is not null && __instance.carType == TrainCarType.LocoSteamHeavy) {
public static void Warning(string message) { GameObject fullCab = UnityEngine.Object.Instantiate(fullCabLoad);
Instance.Logger.Warning(message); fullCab.transform.parent = __instance.transform;
} fullCab.transform.localPosition = new Vector3(0, 3, 0);
public static void Error(string message) { fullCab.transform.localRotation = Quaternion.identity;
Instance.Logger.Error(message); fullCab.transform.localScale = new Vector3(1, 1, 1);
GameObject smokeDeflector = UnityEngine.Object.Instantiate(smokeDeflectorLoad);
smokeDeflector.transform.parent = __instance.transform;
smokeDeflector.transform.localPosition = new Vector3(0, 2.55f, 10.23f);
smokeDeflector.transform.localRotation = Quaternion.identity;
smokeDeflector.transform.localScale = new Vector3(1, 1, 1);
}
}
} }
public enum CabType { public enum CabType {
[Description("Default 282 Cab")] [Description("Default 282 Cab")]
Default, Default,
[Description("German Type Cab")] [Description("German Cab")]
German German
} }
@ -132,4 +136,15 @@ public static class Main {
Save(this, modEntry); Save(this, modEntry);
} }
} }
// Logger Commands
public static void Log(string message) {
Instance.Logger.Log(message);
}
public static void Warning(string message) {
Instance.Logger.Warning(message);
}
public static void Error(string message) {
Instance.Logger.Error(message);
}
} }

View File

@ -31,9 +31,69 @@
<Reference Include="Assembly-CSharp-firstpass"> <Reference Include="Assembly-CSharp-firstpass">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath> <HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference> </Reference>
<Reference Include="DV.BrakeSystem">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.BrakeSystem.dll</HintPath>
</Reference>
<Reference Include="DV.Common">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Common.dll</HintPath>
</Reference>
<Reference Include="DV.ControllerAnchors">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.ControllerAnchors.dll</HintPath>
</Reference>
<Reference Include="DV.Highlighting">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Highlighting.dll</HintPath>
</Reference>
<Reference Include="DV.Interaction">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Interaction.dll</HintPath>
</Reference>
<Reference Include="DV.Inventory">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Inventory.dll</HintPath>
</Reference>
<Reference Include="DV.Localization">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Localization.dll</HintPath>
</Reference>
<Reference Include="DV.NAudio">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.NAudio.dll</HintPath>
</Reference>
<Reference Include="DV.PointSet">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.PointSet.dll</HintPath>
</Reference>
<Reference Include="DV.RadioPlayer">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.RadioPlayer.dll</HintPath>
</Reference>
<Reference Include="DV.Scenarios.CRUD">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Scenarios.CRUD.dll</HintPath>
</Reference>
<Reference Include="DV.Simulation">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Simulation.dll</HintPath>
</Reference>
<Reference Include="DV.Telemetry">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Telemetry.dll</HintPath>
</Reference>
<Reference Include="DV.TerrainSystem">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.TerrainSystem.dll</HintPath>
</Reference>
<Reference Include="DV.TerrainTools">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.TerrainTools.dll</HintPath>
</Reference>
<Reference Include="DV.ThingTypes">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.ThingTypes.dll</HintPath>
</Reference>
<Reference Include="DV.UI">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.UI.dll</HintPath>
</Reference>
<Reference Include="DV.UIFramework">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.UIFramework.dll</HintPath>
</Reference>
<Reference Include="DV.UserManagement">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.UserManagement.dll</HintPath>
</Reference>
<Reference Include="DV.Utils"> <Reference Include="DV.Utils">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Utils.dll</HintPath> <HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.Utils.dll</HintPath>
</Reference> </Reference>
<Reference Include="DV.WeatherSystem">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\DV.WeatherSystem.dll</HintPath>
</Reference>
<Reference Include="UnityEngine"> <Reference Include="UnityEngine">
<HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\UnityEngine.dll</HintPath> <HintPath>G:\SteamLibrary\steamapps\common\Derail Valley\DerailValley_Data\Managed\UnityEngine.dll</HintPath>
</Reference> </Reference>