Decompiled source of Truck Editor v1.0.2
TruckEditor.dll
Decompiled 13 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using MenuLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TruckEditor")] [assembly: AssemblyTitle("TruckEditor")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [BepInPlugin("Omniscye.TruckEditor", "Truck Editor", "1.0.0")] public sealed class TruckEditorPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(MenuPageMain), "ButtonEventHostGame")] private static class MenuPageMainHostGamePatch { private static bool Prefix() { TruckEditorPlugin instance = Instance; if ((Object)(object)instance == (Object)null || !instance.ShouldHijackHostGameButton()) { return true; } instance.hijackHostGameUntilTime = 0f; instance.OpenTruckEditorFromMenu(); return false; } } [HarmonyPatch(typeof(MenuButton), "OnSelect")] private static class MenuButtonOnSelectPatch { private static bool Prefix(MenuButton __instance) { TruckEditorPlugin instance = Instance; if ((Object)(object)instance == (Object)null || !instance.IsInjectedTruckEditorButton(__instance)) { return true; } instance.hijackHostGameUntilTime = Time.unscaledTime + 0.5f; instance.OpenTruckEditorFromMenu(); return false; } } [HarmonyPatch(typeof(ChargingStation), "Start")] private static class ChargingStationStartPatch { private static bool Prefix(ChargingStation __instance) { TruckEditorPlugin instance = Instance; if ((Object)(object)instance == (Object)null || !instance.ShouldForceEditorChargingStation()) { return true; } instance.PrepareEditorChargingStation(__instance); return false; } } private sealed class CatalogEntry { public string ResourcePath = string.Empty; public string DisplayName = string.Empty; public string Category = string.Empty; public string Section = string.Empty; } [Serializable] private sealed class SerializableVector3 { public float X; public float Y; public float Z; public SerializableVector3() { } public SerializableVector3(Vector3 value) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) X = value.x; Y = value.y; Z = value.z; } public Vector3 ToVector3() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return new Vector3(X, Y, Z); } } [Serializable] private sealed class TruckObjectRecord { public string Id = string.Empty; public string ResourcePath = string.Empty; public string DisplayName = string.Empty; public string Category = string.Empty; public string Section = string.Empty; public SerializableVector3 Position = new SerializableVector3(); public SerializableVector3 Rotation = new SerializableVector3(); } [Serializable] private sealed class TruckLayoutData { public string Name = string.Empty; public string CreatedUtc = string.Empty; public string LastEditedUtc = string.Empty; public List<TruckObjectRecord> Objects = new List<TruckObjectRecord>(); } private sealed class PlacedMarker : MonoBehaviour { public string Id = string.Empty; } private readonly struct TruckAnchorInfo { public readonly RoomVolume Room; public readonly Vector3 WorldPosition; public readonly Quaternion WorldRotation; public readonly Bounds LocalBounds; public TruckAnchorInfo(RoomVolume room, Vector3 worldPosition, Quaternion worldRotation, Bounds localBounds) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Room = room; WorldPosition = worldPosition; WorldRotation = worldRotation; LocalBounds = localBounds; } } private readonly struct PlacementState { public readonly Vector3 Position; public readonly Quaternion Rotation; public PlacementState(Vector3 position, Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Position = position; Rotation = rotation; } } public const string PluginGuid = "Omniscye.TruckEditor"; public const string PluginName = "Truck Editor"; public const string PluginVersion = "1.0.0"; private const string RoomPropertyTruckLayoutName = "OMNI_TRUCK_LAYOUT_NAME"; private const string RoomPropertyTruckLayoutPayload = "OMNI_TRUCK_LAYOUT_DATA"; private const float UiCaptureRefresh = 0.2f; private const float PlacementRotationDegreesPerSecond = 90f; private readonly JsonSerializerSettings jsonSettings = new JsonSerializerSettings { Formatting = (Formatting)1, NullValueHandling = (NullValueHandling)1 }; private ConfigEntry<string> layoutDirectoryConfig = null; private ConfigEntry<string> selectedLayoutConfig = null; private ConfigEntry<bool> enableHostTruckDecorConfig = null; private ConfigEntry<KeyboardShortcut> openEditorHotkeyConfig = null; private ConfigEntry<KeyCode> toggleForgeModeKeyConfig = null; private ConfigEntry<KeyCode> toggleEditorUiKeyConfig = null; private ConfigEntry<KeyCode> exitToMenuKeyConfig = null; private ConfigEntry<KeyCode> cursorModifierKeyConfig = null; private ConfigEntry<KeyCode> fastMoveModifierKeyConfig = null; private ConfigEntry<KeyCode> moveForwardKeyConfig = null; private ConfigEntry<KeyCode> moveBackwardKeyConfig = null; private ConfigEntry<KeyCode> moveLeftKeyConfig = null; private ConfigEntry<KeyCode> moveRightKeyConfig = null; private ConfigEntry<KeyCode> moveUpKeyConfig = null; private ConfigEntry<KeyCode> moveDownKeyConfig = null; private ConfigEntry<KeyCode> placementRotateXKeyConfig = null; private ConfigEntry<KeyCode> placementRotateYKeyConfig = null; private ConfigEntry<KeyCode> placementRotateZKeyConfig = null; private ConfigEntry<KeyCode> placementOffsetDownKeyConfig = null; private ConfigEntry<KeyCode> placementOffsetUpKeyConfig = null; private ConfigEntry<KeyCode> moveSelectedModifierKeyConfig = null; private ConfigEntry<KeyCode> rotateSelectedKeyConfig = null; private ConfigEntry<KeyCode> duplicateSelectedKeyConfig = null; private ConfigEntry<KeyCode> deleteSelectedKeyConfig = null; private ConfigEntry<KeyCode> selectedHeightUpKeyConfig = null; private ConfigEntry<KeyCode> selectedHeightDownKeyConfig = null; private ConfigEntry<bool> showMainMenuFallbackButtonConfig = null; private ConfigEntry<float> moveSpeedConfig = null; private ConfigEntry<float> fastMoveSpeedConfig = null; private static TruckEditorPlugin? Instance; private Harmony? harmony; private Texture2D? pixel; private Texture2D? editorCursorTexture; private GUIStyle? titleStyle; private GUIStyle? subtitleStyle; private GUIStyle? bodyStyle; private GUIStyle? smallStyle; private GUIStyle? buttonStyle; private GUIStyle? selectedButtonStyle; private GUIStyle? textFieldStyle; private GUIStyle? listButtonStyle; private GUIStyle? selectedListButtonStyle; private GUIStyle? overlayStyle; private bool menuRegistered; private MenuButton? injectedMainMenuButton; private float hijackHostGameUntilTime; private bool pendingTruckEditorLaunch; private bool truckSessionActive; private bool forgeModeActive; private bool editorCursorActive; private bool editorUiVisible = true; private string editorLayoutName = "Untitled_Truck"; private string editorSearch = string.Empty; private string selectedCategory = "All"; private string selectedObjectId = string.Empty; private string selectedPlacedObjectId = string.Empty; private string loadedLayoutFileName = string.Empty; private string editorCreatedUtc = string.Empty; private string statusText = string.Empty; private float statusTimer; private float editorYaw; private float editorPitch; private Vector3 placementRotationEuler; private float previewDistance = 3.5f; private float placementHeightOffset; private Vector2 categoryScroll; private Vector2 prefabScroll; private Vector2 filesScroll; private Transform? editorCameraRoot; private Transform? editorCameraRestoreParent; private Vector3 editorCameraRestoreLocalPosition; private Quaternion editorCameraRestoreLocalRotation; private GameObject? editorPreviewInstance; private string previewResourcePath = string.Empty; private RoomVolume? sessionTruckRoom; private Transform? sessionTruckAnchorRoot; private readonly List<CatalogEntry> catalogEntries = new List<CatalogEntry>(); private readonly List<string> categoryNames = new List<string>(); private readonly Dictionary<string, TruckObjectRecord> editorObjects = new Dictionary<string, TruckObjectRecord>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, GameObject> editorInstances = new Dictionary<string, GameObject>(StringComparer.OrdinalIgnoreCase); private LevelGenerator? trackedLevelGenerator; private string runtimePublishedFingerprint = string.Empty; private string runtimeAppliedFingerprint = string.Empty; private string runtimeAppliedLayoutName = string.Empty; private GameObject? runtimeDecorRoot; private ManualLogSource Log => ((BaseUnityPlugin)this).Logger; private void Awake() { Instance = this; BindConfig(); EnsurePluginPersistence(); EnsureHarmonyPatched(); SetStatus("Truck Editor booted.", 2.5f); } private void Start() { BuildCatalogIfNeeded(force: true); } private void OnDestroy() { if (Instance == this) { Instance = null; } if (harmony != null) { harmony.UnpatchSelf(); harmony = null; } EndTruckEditorSession(loadMainMenu: false); ResetRuntimeTracking(); } private void Update() { TickStatus(); EnsureMenuRegistered(); HandleMainMenuOpenHotkey(); BuildCatalogIfNeeded(force: false); UpdateTruckEditorSessionLifecycle(); UpdateRuntimeLifecycle(); } private void OnGUI() { EnsureStyles(); if (forgeModeActive && editorUiVisible) { DrawEditorGui(); } if (forgeModeActive && !editorUiVisible) { DrawHiddenEditorHint(); } if (truckSessionActive && !forgeModeActive) { DrawTruckSessionHint(); } DrawMainMenuFallbackButton(); DrawStatusOverlay(); } private void EnsureHarmonyPatched() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (harmony == null) { harmony = new Harmony("Omniscye.TruckEditor"); harmony.PatchAll(typeof(TruckEditorPlugin).Assembly); } } private void BindConfig() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(Paths.PluginPath, "Omniscye-TruckEditor", "Layouts"); layoutDirectoryConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Files", "TruckLayoutsDirectory", text, "Folder for saved truck layout files."); selectedLayoutConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Runtime", "SelectedTruckLayout", "Untitled_Truck", "Selected truck layout file name."); enableHostTruckDecorConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Runtime", "EnableHostTruckDecor", true, "Host shares the selected truck decoration layout during real runs."); openEditorHotkeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "OpenTruckEditorFromMainMenu", new KeyboardShortcut((KeyCode)116, Array.Empty<KeyCode>()), "Fallback hotkey for opening Truck Editor from the main menu."); toggleForgeModeKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ToggleForgeModeKey", (KeyCode)92, "Switches between normal truck view and forge mode."); toggleEditorUiKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ToggleEditorUiKey", (KeyCode)117, "Shows or hides the Truck Editor UI while forging."); exitToMenuKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ExitToMainMenuKey", (KeyCode)27, "Leaves Truck Editor and returns to the main menu."); cursorModifierKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "EditorCursorModifierKey", (KeyCode)308, "Hold this key to unlock the cursor and interact with the Truck Editor UI."); fastMoveModifierKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "FastMoveModifierKey", (KeyCode)304, "Hold this key for faster forge camera movement."); moveForwardKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MoveForwardKey", (KeyCode)119, "Moves the forge camera forward."); moveBackwardKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MoveBackwardKey", (KeyCode)115, "Moves the forge camera backward."); moveLeftKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MoveLeftKey", (KeyCode)97, "Moves the forge camera left."); moveRightKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MoveRightKey", (KeyCode)100, "Moves the forge camera right."); moveUpKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MoveUpKey", (KeyCode)101, "Moves the forge camera upward."); moveDownKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MoveDownKey", (KeyCode)113, "Moves the forge camera downward."); placementRotateXKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "RotatePlacementXKey", (KeyCode)114, "Smoothly rotates the current preview object around the X axis while held."); placementRotateYKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "RotatePlacementYKey", (KeyCode)116, "Smoothly rotates the current preview object around the Y axis while held."); placementRotateZKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "RotatePlacementZKey", (KeyCode)121, "Smoothly rotates the current preview object around the Z axis while held."); placementOffsetDownKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "PlacementOffsetDownKey", (KeyCode)91, "Lowers the current preview object."); placementOffsetUpKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "PlacementOffsetUpKey", (KeyCode)93, "Raises the current preview object."); moveSelectedModifierKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MoveSelectedModifierKey", (KeyCode)306, "Hold this key and left click to move the selected placed object."); rotateSelectedKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "RotateSelectedKey", (KeyCode)103, "Smoothly rotates the selected placed object around the Y axis while held."); duplicateSelectedKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "DuplicateSelectedKey", (KeyCode)99, "Duplicates the selected placed object."); deleteSelectedKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "DeleteSelectedKey", (KeyCode)127, "Deletes the selected placed object."); selectedHeightUpKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "SelectedHeightUpKey", (KeyCode)280, "Moves the selected placed object upward."); selectedHeightDownKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "SelectedHeightDownKey", (KeyCode)281, "Moves the selected placed object downward."); showMainMenuFallbackButtonConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowMainMenuFallbackButton", false, "Shows a backup main menu button drawn by the plugin itself."); moveSpeedConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Editor", "MoveSpeed", 7f, "Base fly speed while forging inside the truck."); fastMoveSpeedConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Editor", "FastMoveSpeed", 18f, "Fast fly speed while forging inside the truck."); } private bool IsConfiguredKeyDown(ConfigEntry<KeyCode> keyConfig) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected I4, but got Unknown KeyCode value = keyConfig.Value; if (Input.GetKeyDown(value)) { return true; } if (1 == 0) { } bool result = (((int)value == 8) ? Input.GetKeyDown((KeyCode)127) : (((int)value == 127) ? Input.GetKeyDown((KeyCode)8) : ((value - 303) switch { 5 => Input.GetKeyDown((KeyCode)307), 4 => Input.GetKeyDown((KeyCode)308), 1 => Input.GetKeyDown((KeyCode)303), 0 => Input.GetKeyDown((KeyCode)304), 3 => Input.GetKeyDown((KeyCode)305), 2 => Input.GetKeyDown((KeyCode)306), _ => false, }))); if (1 == 0) { } return result; } private bool IsConfiguredKeyHeld(ConfigEntry<KeyCode> keyConfig) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected I4, but got Unknown KeyCode value = keyConfig.Value; if (Input.GetKey(value)) { return true; } if (1 == 0) { } bool result = (value - 303) switch { 5 => Input.GetKey((KeyCode)307), 4 => Input.GetKey((KeyCode)308), 1 => Input.GetKey((KeyCode)303), 0 => Input.GetKey((KeyCode)304), 3 => Input.GetKey((KeyCode)305), 2 => Input.GetKey((KeyCode)306), _ => false, }; if (1 == 0) { } return result; } private string KeyLabel(ConfigEntry<KeyCode> keyConfig) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) KeyCode value = keyConfig.Value; return ((object)(KeyCode)(ref value)).ToString(); } private void EnsurePluginPersistence() { ((Object)((Component)this).gameObject).name = "Omniscye.TruckEditor"; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void TickStatus() { if (!(statusTimer <= 0f)) { statusTimer -= Time.deltaTime; if (statusTimer <= 0f) { statusText = string.Empty; statusTimer = 0f; } } } private void EnsureMenuRegistered() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (menuRegistered || (Object)(object)RunManager.instance == (Object)null || !SemiFunc.MenuLevel()) { return; } try { MenuAPI.AddElementToMainMenu((BuilderDelegate)delegate(Transform parent) { TryInjectMainMenuButton(parent); }); menuRegistered = true; Log.LogInfo((object)"[TruckEditor] MenuLib button registered."); } catch (Exception ex) { Log.LogWarning((object)("[TruckEditor] MenuLib registration failed: " + ex.Message)); } } private void TryInjectMainMenuButton(Transform parent) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)parent == (Object)null || (Object)(object)injectedMainMenuButton != (Object)null) { return; } MenuButton val = FindMainMenuButton(parent, "PRIVATE GAME"); if ((Object)(object)val == (Object)null || (Object)(object)val.button == (Object)null || (Object)(object)val.buttonText == (Object)null) { Log.LogWarning((object)"[TruckEditor] Could not find the PRIVATE GAME button for MenuLib placement."); return; } MenuButton val2 = Object.Instantiate<MenuButton>(val, ((Component)val).transform.parent); ((Object)((Component)val2).gameObject).name = "Menu Button - Truck Editor"; val2.button.onClick = new ButtonClickedEvent(); ((UnityEvent)val2.button.onClick).AddListener(new UnityAction(OpenTruckEditorFromMenu)); val2.buttonTextString = "TRUCK EDITOR"; val2.originalText = "TRUCK EDITOR"; ((TMP_Text)val2.buttonText).text = "TRUCK EDITOR"; val2.disabled = false; val2.doButtonEffect = val.doButtonEffect; val2.hasHold = false; if ((Object)(object)val2.rectTransform == (Object)null) { val2.rectTransform = ((Component)val2).GetComponent<RectTransform>(); } if ((Object)(object)val.rectTransform == (Object)null) { val.rectTransform = ((Component)val).GetComponent<RectTransform>(); } float num = 72f; MenuButton val3 = FindMainMenuButton(parent, "PUBLIC GAME"); if ((Object)(object)val.rectTransform != (Object)null && (Object)(object)val3 != (Object)null) { if ((Object)(object)val3.rectTransform == (Object)null) { val3.rectTransform = ((Component)val3).GetComponent<RectTransform>(); } if ((Object)(object)val3.rectTransform != (Object)null) { num = Mathf.Abs(val.rectTransform.anchoredPosition.y - val3.rectTransform.anchoredPosition.y); } } if ((Object)(object)val2.rectTransform != (Object)null && (Object)(object)val.rectTransform != (Object)null) { val2.rectTransform.anchorMin = val.rectTransform.anchorMin; val2.rectTransform.anchorMax = val.rectTransform.anchorMax; val2.rectTransform.pivot = val.rectTransform.pivot; val2.rectTransform.sizeDelta = val.rectTransform.sizeDelta; val2.rectTransform.anchoredPosition = val.rectTransform.anchoredPosition + new Vector2(0f, num); ((Transform)val2.rectTransform).localScale = Vector3.one; } ((Component)val2).transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex()); if ((Object)(object)val2.menuSelectableElement != (Object)null) { val2.menuSelectableElement.menuID = "truck_editor_" + Guid.NewGuid().ToString("N"); } val2.buttonPitch = (((Object)(object)val2.rectTransform != (Object)null) ? SemiFunc.MenuGetPitchFromYPos(val2.rectTransform) : val.buttonPitch); injectedMainMenuButton = val2; } private MenuButton? FindMainMenuButton(Transform parent, string label) { string label2 = label; if ((Object)(object)parent == (Object)null) { return null; } return ((IEnumerable<MenuButton>)((Component)parent).GetComponentsInChildren<MenuButton>(true)).FirstOrDefault((Func<MenuButton, bool>)delegate(MenuButton button) { string mainMenuButtonLabel = GetMainMenuButtonLabel(button); return !string.IsNullOrWhiteSpace(mainMenuButtonLabel) && mainMenuButtonLabel.IndexOf(label2, StringComparison.OrdinalIgnoreCase) >= 0; }); } private string GetMainMenuButtonLabel(MenuButton? button) { if ((Object)(object)button == (Object)null) { return string.Empty; } if ((Object)(object)button.buttonText != (Object)null && !string.IsNullOrWhiteSpace(((TMP_Text)button.buttonText).text)) { return ((TMP_Text)button.buttonText).text.Trim(); } return button.buttonTextString?.Trim() ?? string.Empty; } private void OpenTruckEditorFromMenu() { if (GameManager.Multiplayer()) { SetStatus("Truck Editor launches from the singleplayer main menu."); return; } pendingTruckEditorLaunch = true; SetStatus("Loading the truck bay..."); if (!((Object)(object)RunManager.instance == (Object)null) && !((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobby)) { RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)0); } } private void HandleMainMenuOpenHotkey() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!truckSessionActive && !forgeModeActive && !pendingTruckEditorLaunch && !((Object)(object)RunManager.instance == (Object)null) && !((Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelMainMenu)) { KeyboardShortcut value = openEditorHotkeyConfig.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { OpenTruckEditorFromMenu(); } } } private void DrawMainMenuFallbackButton() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) if (showMainMenuFallbackButtonConfig.Value && !truckSessionActive && !((Object)(object)RunManager.instance == (Object)null) && selectedButtonStyle != null && smallStyle != null && !((Object)(object)injectedMainMenuButton != (Object)null) && !((Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelMainMenu)) { Rect val = default(Rect); if (!TryGetMainMenuButtonScreenRect("PRIVATE GAME", out var rect)) { ((Rect)(ref val))..ctor(72f, 280f, 300f, 44f); } else { ((Rect)(ref val))..ctor(((Rect)(ref rect)).x, Mathf.Max(32f, ((Rect)(ref rect)).y - ((Rect)(ref rect)).height - 10f), Mathf.Max(((Rect)(ref rect)).width, 300f), ((Rect)(ref rect)).height); } if (GUI.Button(val, "TRUCK EDITOR", selectedButtonStyle)) { OpenTruckEditorFromMenu(); } Rect val2 = new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y - 22f, ((Rect)(ref val)).width, 20f); KeyboardShortcut value = openEditorHotkeyConfig.Value; GUI.Label(val2, "Fallback hotkey: " + ((object)(KeyboardShortcut)(ref value)).ToString(), smallStyle); } } private bool TryGetMainMenuButtonScreenRect(string label, out Rect rect) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) rect = default(Rect); if ((Object)(object)MenuPageMain.instance == (Object)null) { return false; } MenuButton val = FindMainMenuButton(((Component)MenuPageMain.instance).transform, label); if ((Object)(object)val == (Object)null) { return false; } RectTransform val2 = (((Object)(object)val.rectTransform != (Object)null) ? val.rectTransform : ((Component)val).GetComponent<RectTransform>()); if ((Object)(object)val2 == (Object)null) { return false; } Vector3[] array = (Vector3[])(object)new Vector3[4]; val2.GetWorldCorners(array); Vector3 val3 = Vector2.op_Implicit(RectTransformUtility.WorldToScreenPoint((Camera)null, array[0])); Vector3 val4 = Vector2.op_Implicit(RectTransformUtility.WorldToScreenPoint((Camera)null, array[2])); rect = new Rect(val3.x, (float)Screen.height - val4.y, val4.x - val3.x, val4.y - val3.y); return true; } private bool TryGetInjectedMainMenuButtonScreenRect(out Rect rect) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) rect = default(Rect); if ((Object)(object)injectedMainMenuButton == (Object)null) { return false; } RectTransform val = (((Object)(object)injectedMainMenuButton.rectTransform != (Object)null) ? injectedMainMenuButton.rectTransform : ((Component)injectedMainMenuButton).GetComponent<RectTransform>()); if ((Object)(object)val == (Object)null) { return false; } Vector3[] array = (Vector3[])(object)new Vector3[4]; val.GetWorldCorners(array); Vector3 val2 = Vector2.op_Implicit(RectTransformUtility.WorldToScreenPoint((Camera)null, array[0])); Vector3 val3 = Vector2.op_Implicit(RectTransformUtility.WorldToScreenPoint((Camera)null, array[2])); rect = new Rect(val2.x, (float)Screen.height - val3.y, val3.x - val2.x, val3.y - val2.y); return ((Rect)(ref rect)).width > 1f && ((Rect)(ref rect)).height > 1f; } private bool ShouldHijackHostGameButton() { if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelMainMenu) { return false; } if (Time.unscaledTime <= hijackHostGameUntilTime) { return true; } if ((Object)(object)injectedMainMenuButton == (Object)null) { return false; } return injectedMainMenuButton.hovering || injectedMainMenuButton.clicked || injectedMainMenuButton.hoverTimer > 0f || injectedMainMenuButton.clickTimer > 0f; } private bool IsInjectedTruckEditorButton(MenuButton? button) { if ((Object)(object)button == (Object)null || (Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelMainMenu) { return false; } if (button == injectedMainMenuButton) { return true; } if ((Object)(object)injectedMainMenuButton == (Object)null) { return false; } string mainMenuButtonLabel = GetMainMenuButtonLabel(button); return !string.IsNullOrWhiteSpace(mainMenuButtonLabel) && string.Equals(mainMenuButtonLabel, "TRUCK EDITOR", StringComparison.OrdinalIgnoreCase) && (Object)(object)((Component)button).transform.parent == (Object)(object)((Component)injectedMainMenuButton).transform.parent; } private void DrawTruckSessionHint() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (smallStyle != null && overlayStyle != null) { Rect val = default(Rect); ((Rect)(ref val))..ctor(24f, 90f, Mathf.Min(760f, (float)Screen.width - 48f), 76f); GUI.Box(val, GUIContent.none, overlayStyle); GUI.Label(new Rect(((Rect)(ref val)).x + 12f, ((Rect)(ref val)).y + 10f, ((Rect)(ref val)).width - 24f, 18f), "Truck Editor live", subtitleStyle); GUI.Label(new Rect(((Rect)(ref val)).x + 12f, ((Rect)(ref val)).y + 30f, ((Rect)(ref val)).width - 24f, 34f), "Walk around normally, then press " + KeyLabel(toggleForgeModeKeyConfig) + " to enter forge mode. Press " + KeyLabel(exitToMenuKeyConfig) + " to return to the menu.", smallStyle); } } private void DrawStatusOverlay() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrWhiteSpace(statusText) && overlayStyle != null && bodyStyle != null) { Rect val = default(Rect); ((Rect)(ref val))..ctor(20f, (float)Screen.height - 64f, Mathf.Min((float)Screen.width - 40f, 760f), 40f); GUI.Box(val, GUIContent.none, overlayStyle); GUI.Label(new Rect(((Rect)(ref val)).x + 12f, ((Rect)(ref val)).y + 8f, ((Rect)(ref val)).width - 24f, ((Rect)(ref val)).height - 12f), statusText, bodyStyle); } } private void EnsureStyles() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Expected O, but got Unknown //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Expected O, but got Unknown //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Expected O, but got Unknown //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Expected O, but got Unknown //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Expected O, but got Unknown //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Expected O, but got Unknown //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Expected O, but got Unknown if ((Object)(object)pixel == (Object)null) { pixel = new Texture2D(1, 1, (TextureFormat)4, false); pixel.SetPixel(0, 0, new Color(0.07f, 0.06f, 0.07f, 0.96f)); pixel.Apply(); } if (titleStyle == null) { titleStyle = new GUIStyle(GUI.skin.label); titleStyle.fontSize = 28; titleStyle.fontStyle = (FontStyle)1; titleStyle.normal.textColor = new Color(0.95f, 0.95f, 0.97f, 1f); subtitleStyle = new GUIStyle(GUI.skin.label); subtitleStyle.fontSize = 16; subtitleStyle.fontStyle = (FontStyle)1; subtitleStyle.normal.textColor = new Color(0.92f, 0.34f, 0.3f, 1f); bodyStyle = new GUIStyle(GUI.skin.label); bodyStyle.fontSize = 14; bodyStyle.wordWrap = true; bodyStyle.normal.textColor = new Color(0.84f, 0.86f, 0.9f, 1f); smallStyle = new GUIStyle(bodyStyle); smallStyle.fontSize = 12; smallStyle.normal.textColor = new Color(0.66f, 0.69f, 0.77f, 1f); buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.fontSize = 14; buttonStyle.fontStyle = (FontStyle)1; buttonStyle.normal.textColor = Color.white; buttonStyle.hover.textColor = Color.white; buttonStyle.active.textColor = Color.white; buttonStyle.normal.background = MakeTexture(new Color(0.16f, 0.1f, 0.11f, 0.96f)); buttonStyle.hover.background = MakeTexture(new Color(0.24f, 0.12f, 0.14f, 0.98f)); buttonStyle.active.background = MakeTexture(new Color(0.35f, 0.15f, 0.17f, 1f)); buttonStyle.padding = new RectOffset(10, 10, 8, 8); buttonStyle.border = new RectOffset(1, 1, 1, 1); selectedButtonStyle = new GUIStyle(buttonStyle); selectedButtonStyle.normal.background = MakeTexture(new Color(0.64f, 0.22f, 0.18f, 1f)); selectedButtonStyle.hover.background = MakeTexture(new Color(0.76f, 0.27f, 0.2f, 1f)); selectedButtonStyle.active.background = MakeTexture(new Color(0.86f, 0.34f, 0.23f, 1f)); textFieldStyle = new GUIStyle(GUI.skin.textField); textFieldStyle.fontSize = 14; textFieldStyle.normal.textColor = new Color(0.96f, 0.96f, 0.96f, 1f); textFieldStyle.focused.textColor = new Color(0.98f, 0.98f, 0.98f, 1f); textFieldStyle.normal.background = MakeTexture(new Color(0.08f, 0.08f, 0.11f, 0.96f)); textFieldStyle.focused.background = MakeTexture(new Color(0.11f, 0.11f, 0.15f, 0.98f)); listButtonStyle = new GUIStyle(buttonStyle); listButtonStyle.alignment = (TextAnchor)3; listButtonStyle.normal.background = MakeTexture(new Color(0.11f, 0.11f, 0.15f, 0.96f)); listButtonStyle.hover.background = MakeTexture(new Color(0.2f, 0.12f, 0.15f, 0.98f)); listButtonStyle.active.background = MakeTexture(new Color(0.3f, 0.15f, 0.18f, 1f)); selectedListButtonStyle = new GUIStyle(listButtonStyle); selectedListButtonStyle.normal.background = MakeTexture(new Color(0.54f, 0.18f, 0.15f, 1f)); selectedListButtonStyle.hover.background = MakeTexture(new Color(0.66f, 0.23f, 0.18f, 1f)); selectedListButtonStyle.active.background = MakeTexture(new Color(0.76f, 0.29f, 0.21f, 1f)); overlayStyle = new GUIStyle(GUI.skin.box); overlayStyle.normal.background = MakeTexture(new Color(0.04f, 0.04f, 0.05f, 0.92f)); overlayStyle.border = new RectOffset(1, 1, 1, 1); overlayStyle.padding = new RectOffset(12, 12, 12, 12); } } private Texture2D MakeTexture(Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, color); val.Apply(); return val; } private void SetStatus(string message, float duration = 4f) { statusText = message; statusTimer = duration; } private string GetLayoutsDirectory() { string text = layoutDirectoryConfig.Value; if (string.IsNullOrWhiteSpace(text)) { text = Path.Combine(Paths.PluginPath, "Omniscye-TruckEditor", "Layouts"); layoutDirectoryConfig.Value = text; } Directory.CreateDirectory(text); return text; } private string GetLayoutPath(string layoutName) { string text = NormalizeLayoutName(layoutName); if (!text.EndsWith(".repotruck.json", StringComparison.OrdinalIgnoreCase)) { text += ".repotruck.json"; } return Path.Combine(GetLayoutsDirectory(), text); } private List<string> GetAvailableLayoutFiles() { string layoutsDirectory = GetLayoutsDirectory(); return Directory.GetFiles(layoutsDirectory, "*.repotruck.json", SearchOption.TopDirectoryOnly).OrderByDescending(File.GetLastWriteTimeUtc).Select(Path.GetFileNameWithoutExtension) .Select(delegate(string name) { string result; if (!name.EndsWith(".repotruck", StringComparison.OrdinalIgnoreCase)) { result = name; } else { result = name.Substring(0, name.Length - 10); } return result; }) .Distinct<string>(StringComparer.OrdinalIgnoreCase) .ToList(); } private string NormalizeLayoutName(string layoutName) { string text = (string.IsNullOrWhiteSpace(layoutName) ? "Untitled_Truck" : layoutName.Trim()); StringBuilder stringBuilder = new StringBuilder(text.Length); string text2 = text; foreach (char c in text2) { if (char.IsLetterOrDigit(c) || c == '_' || c == '-' || c == ' ') { stringBuilder.Append((c == ' ') ? '_' : c); } } if (stringBuilder.Length == 0) { stringBuilder.Append("Untitled_Truck"); } return stringBuilder.ToString(); } private void UpdateTruckEditorSessionLifecycle() { if (pendingTruckEditorLaunch && CanBeginTruckEditorSession()) { BeginTruckEditorSession(); } if (!truckSessionActive) { return; } if (!CanRemainInTruckEditorSession()) { EndTruckEditorSession(loadMainMenu: false); return; } EnsureSessionTruckAnchorRoot(); if (!forgeModeActive) { if (IsConfiguredKeyDown(toggleForgeModeKeyConfig)) { EnterForgeMode(); } else if (IsConfiguredKeyDown(exitToMenuKeyConfig)) { EndTruckEditorSession(loadMainMenu: true); } } else { UpdateForgeCursorMode(); KeepPlayerFrozenForEditor(); UpdateEditorCameraMotion(); UpdatePreviewInstance(); HandleEditorWorldInput(); } } private bool CanBeginTruckEditorSession() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 if (GameManager.Multiplayer()) { return false; } if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelLobby) { return false; } if ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated) { return false; } if ((Object)(object)GameDirector.instance == (Object)null || (Object)(object)GameDirector.instance.MainCamera == (Object)null) { return false; } if ((int)GameDirector.instance.currentState != 1 && (int)GameDirector.instance.currentState != 2) { return false; } TruckAnchorInfo anchor; return TryResolveTruckAnchor(out anchor); } private bool CanRemainInTruckEditorSession() { if (GameManager.Multiplayer()) { return false; } if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent != (Object)(object)RunManager.instance.levelLobby) { return false; } if ((Object)(object)GameDirector.instance == (Object)null || (Object)(object)GameDirector.instance.MainCamera == (Object)null) { return false; } return true; } private void BeginTruckEditorSession() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) pendingTruckEditorLaunch = false; truckSessionActive = true; forgeModeActive = false; editorCursorActive = false; editorUiVisible = true; selectedPlacedObjectId = string.Empty; placementRotationEuler = Vector3.zero; placementHeightOffset = 0f; previewDistance = 3.5f; EnsureSessionTruckAnchorRoot(); if (TryLoadLayout(selectedLayoutConfig.Value, out TruckLayoutData layoutData) && layoutData != null) { LoadLayoutIntoEditor(layoutData); } else { editorLayoutName = NormalizeLayoutName(selectedLayoutConfig.Value); editorCreatedUtc = string.Empty; loadedLayoutFileName = string.Empty; ClearEditorLayout(); } SetEditorObjectCollidersEnabled(value: false); SetStatus("Truck Editor live. Walk around your truck, then press " + KeyLabel(toggleForgeModeKeyConfig) + " for forge mode.", 5f); } private void EndTruckEditorSession(bool loadMainMenu) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (truckSessionActive || pendingTruckEditorLaunch) { ExitForgeMode(); truckSessionActive = false; pendingTruckEditorLaunch = false; sessionTruckRoom = null; ClearEditorLayout(); DestroyEditorPreviewInstance(); if ((Object)(object)sessionTruckAnchorRoot != (Object)null) { Object.Destroy((Object)(object)((Component)sessionTruckAnchorRoot).gameObject); sessionTruckAnchorRoot = null; } Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0); Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; if (loadMainMenu && (Object)(object)RunManager.instance != (Object)null) { RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)4); } } } private void EnterForgeMode() { if (truckSessionActive && !forgeModeActive) { if (!EnsureSessionTruckAnchorRoot()) { SetStatus("Truck anchor was not ready yet."); return; } forgeModeActive = true; editorCursorActive = false; editorUiVisible = true; selectedPlacedObjectId = string.Empty; DestroyEditorPreviewInstance(); SetEditorObjectCollidersEnabled(value: true); AttachEditorCamera(); AlignPlacementRotationToCurrentView(); SetStatus("Forge mode live. Hold " + KeyLabel(cursorModifierKeyConfig) + " for the cursor. Press " + KeyLabel(toggleForgeModeKeyConfig) + " to walk around again.", 5f); } } private void ExitForgeMode() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (forgeModeActive) { forgeModeActive = false; editorCursorActive = false; editorUiVisible = true; selectedPlacedObjectId = string.Empty; DestroyEditorPreviewInstance(); SetEditorObjectCollidersEnabled(value: false); RestoreMainCamera(); Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0); Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; } } private void AlignPlacementRotationToCurrentView() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)GameDirector.instance == (Object)null) && !((Object)(object)GameDirector.instance.MainCamera == (Object)null) && !((Object)(object)sessionTruckAnchorRoot == (Object)null)) { float num = ((Component)GameDirector.instance.MainCamera).transform.eulerAngles.y - sessionTruckAnchorRoot.eulerAngles.y; placementRotationEuler = new Vector3(0f, Mathf.Repeat(num, 360f), 0f); } } private void AttachEditorCamera() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown if (!((Object)(object)GameDirector.instance == (Object)null) && !((Object)(object)GameDirector.instance.MainCamera == (Object)null)) { Camera mainCamera = GameDirector.instance.MainCamera; if ((Object)(object)editorCameraRoot == (Object)null) { GameObject val = new GameObject("TruckEditor.CameraRoot"); ((Object)val).hideFlags = (HideFlags)61; editorCameraRoot = val.transform; } editorCameraRestoreParent = ((Component)mainCamera).transform.parent; editorCameraRestoreLocalPosition = ((Component)mainCamera).transform.localPosition; editorCameraRestoreLocalRotation = ((Component)mainCamera).transform.localRotation; editorCameraRoot.position = ((Component)mainCamera).transform.position; editorCameraRoot.rotation = ((Component)mainCamera).transform.rotation; editorYaw = editorCameraRoot.eulerAngles.y; editorPitch = NormalizePitch(editorCameraRoot.eulerAngles.x); ((Component)mainCamera).transform.SetParent(editorCameraRoot, false); ((Component)mainCamera).transform.localPosition = Vector3.zero; ((Component)mainCamera).transform.localRotation = Quaternion.identity; } } private void RestoreMainCamera() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)GameDirector.instance == (Object)null) && !((Object)(object)GameDirector.instance.MainCamera == (Object)null)) { Camera mainCamera = GameDirector.instance.MainCamera; if ((Object)(object)editorCameraRestoreParent != (Object)null) { ((Component)mainCamera).transform.SetParent(editorCameraRestoreParent, false); ((Component)mainCamera).transform.localPosition = editorCameraRestoreLocalPosition; ((Component)mainCamera).transform.localRotation = editorCameraRestoreLocalRotation; } if ((Object)(object)editorCameraRoot != (Object)null) { Object.Destroy((Object)(object)((Component)editorCameraRoot).gameObject); editorCameraRoot = null; } editorCameraRestoreParent = null; } } private float NormalizePitch(float rawPitch) { float num = rawPitch; if (num > 180f) { num -= 360f; } return Mathf.Clamp(num, -85f, 85f); } private void UpdateForgeCursorMode() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) bool flag = (editorCursorActive = IsConfiguredKeyHeld(cursorModifierKeyConfig)); SuppressEditorMenuCursor(); if ((Object)(object)CursorManager.instance != (Object)null) { CursorManager.instance.unlockTimer = -1234f; } if (flag) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; EnsureEditorCursorTexture(); Texture2D val = editorCursorTexture; Cursor.SetCursor(val, new Vector2((float)((Texture)val).width * 0.5f, (float)((Texture)val).height * 0.5f), (CursorMode)0); } else { Cursor.SetCursor((Texture2D)null, Vector2.zero, (CursorMode)0); Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; } } private void SuppressEditorMenuCursor() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)MenuCursor.instance == (Object)null)) { ((Behaviour)MenuCursor.instance).enabled = false; MenuCursor.instance.showTimer = 0f; MenuCursor.instance.overridePosTimer = 0f; if ((Object)(object)MenuCursor.instance.mesh != (Object)null) { MenuCursor.instance.mesh.SetActive(false); } ((Component)MenuCursor.instance).transform.localScale = Vector3.zero; } } private void EnsureEditorCursorTexture() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)editorCursorTexture != (Object)null) { return; } editorCursorTexture = new Texture2D(32, 32, (TextureFormat)4, false); ((Texture)editorCursorTexture).filterMode = (FilterMode)0; Color val = default(Color); ((Color)(ref val))..ctor(0f, 0f, 0f, 0f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.98f, 0.98f, 0.98f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(1f, 0.35f, 0.22f, 1f); for (int i = 0; i < ((Texture)editorCursorTexture).width; i++) { for (int j = 0; j < ((Texture)editorCursorTexture).height; j++) { editorCursorTexture.SetPixel(i, j, val); } } for (int k = 6; k <= 26; k++) { editorCursorTexture.SetPixel(k, 16, val2); editorCursorTexture.SetPixel(16, k, val2); } for (int l = 13; l <= 19; l++) { for (int m = 13; m <= 19; m++) { editorCursorTexture.SetPixel(l, m, val3); } } editorCursorTexture.Apply(); } private void KeepPlayerFrozenForEditor() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)PlayerController.instance == (Object)null)) { PlayerController.instance.InputDisable(0.2f); PlayerController.instance.Kinematic(0.2f); PlayerController.instance.rb.velocity = Vector3.zero; PlayerController.instance.rb.angularVelocity = Vector3.zero; if ((Object)(object)GameDirector.instance != (Object)null) { GameDirector.instance.DisableInput = true; GameDirector.instance.DisableInputTimer = 0.2f; } } } private void UpdateEditorCameraMotion() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)editorCameraRoot == (Object)null) && !editorCursorActive) { float num = (IsConfiguredKeyHeld(fastMoveModifierKeyConfig) ? fastMoveSpeedConfig.Value : moveSpeedConfig.Value); float num2 = 0f; if (IsConfiguredKeyHeld(moveRightKeyConfig)) { num2 += 1f; } if (IsConfiguredKeyHeld(moveLeftKeyConfig)) { num2 -= 1f; } float num3 = 0f; if (IsConfiguredKeyHeld(moveUpKeyConfig)) { num3 += 1f; } if (IsConfiguredKeyHeld(moveDownKeyConfig)) { num3 -= 1f; } float num4 = 0f; if (IsConfiguredKeyHeld(moveForwardKeyConfig)) { num4 += 1f; } if (IsConfiguredKeyHeld(moveBackwardKeyConfig)) { num4 -= 1f; } Vector3 val = editorCameraRoot.right * num2 + editorCameraRoot.forward * num4 + Vector3.up * num3; Vector3 normalized = ((Vector3)(ref val)).normalized; Transform? obj = editorCameraRoot; obj.position += normalized * (num * Time.deltaTime); float axis = Input.GetAxis("Mouse X"); float axis2 = Input.GetAxis("Mouse Y"); editorYaw += axis * 4.2f; editorPitch = Mathf.Clamp(editorPitch - axis2 * 4.2f, -85f, 85f); editorCameraRoot.rotation = Quaternion.Euler(editorPitch, editorYaw, 0f); } } private bool EnsureSessionTruckAnchorRoot() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if (!TryResolveTruckAnchor(out var anchor)) { return false; } sessionTruckRoom = anchor.Room; if ((Object)(object)sessionTruckAnchorRoot == (Object)null) { GameObject val = new GameObject("TruckEditor.SessionAnchor"); ((Object)val).hideFlags = (HideFlags)61; sessionTruckAnchorRoot = val.transform; } sessionTruckAnchorRoot.SetParent((Transform)null, false); sessionTruckAnchorRoot.position = anchor.WorldPosition; sessionTruckAnchorRoot.rotation = anchor.WorldRotation; sessionTruckAnchorRoot.localScale = Vector3.one; return true; } private bool TryResolveTruckAnchor(out TruckAnchorInfo anchor) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) anchor = default(TruckAnchorInfo); List<RoomVolume> list = (from volume in Object.FindObjectsOfType<RoomVolume>() where (Object)(object)volume != (Object)null && volume.Truck select volume).ToList(); if (list.Count == 0) { return false; } Vector3 val = Vector3.zero; if ((Object)(object)PlayerController.instance != (Object)null) { val = ((Component)PlayerController.instance).transform.position; } else if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.MainCamera != (Object)null) { val = ((Component)GameDirector.instance.MainCamera).transform.position; } Transform val2 = (((Object)(object)TruckSafetySpawnPoint.instance != (Object)null) ? ((Component)TruckSafetySpawnPoint.instance).transform : null); RoomVolume val3 = null; Bounds val4 = default(Bounds); float num = float.MinValue; float num2 = float.MaxValue; foreach (RoomVolume item in list) { if (!TryBuildTruckLocalBounds(item, out var bounds)) { ((Bounds)(ref bounds))..ctor(Vector3.zero, new Vector3(6f, 3f, 10f)); } float num3 = Mathf.Max(1f, ((Bounds)(ref bounds)).size.x * ((Bounds)(ref bounds)).size.y * ((Bounds)(ref bounds)).size.z); if ((Object)(object)((Component)item).GetComponentInChildren<TruckDoor>(true) != (Object)null) { num3 += 10000f; } if ((Object)(object)((Component)item).GetComponentInChildren<TruckScreenOpen>(true) != (Object)null || (Object)(object)((Component)item).GetComponentInChildren<TruckScreenText>(true) != (Object)null) { num3 += 5000f; } Vector3 val5 = ((Component)item).transform.position - val; float num4 = ((Vector3)(ref val5)).sqrMagnitude; if ((Object)(object)val2 != (Object)null) { if (val2.IsChildOf(((Component)item).transform)) { num3 += 50000f; } else if (IsPointInsideTruckBounds(item, bounds, val2.position, 0.35f)) { num3 += 30000f; } float num5 = num4; val5 = ((Component)item).transform.position - val2.position; num4 = Mathf.Min(num5, ((Vector3)(ref val5)).sqrMagnitude); } if ((Object)(object)val3 == (Object)null || num3 > num || (Mathf.Approximately(num3, num) && num4 < num2)) { val3 = item; val4 = bounds; num = num3; num2 = num4; } } if ((Object)(object)val3 == (Object)null) { return false; } float y = ((Bounds)(ref val4)).min.y; if ((Object)(object)val2 != (Object)null) { Vector3 val6 = ((Component)val3).transform.InverseTransformPoint(val2.position); if (val2.IsChildOf(((Component)val3).transform) || IsPointInsideTruckBounds(val3, val4, val2.position, 0.5f)) { y = val6.y; } } Vector3 val7 = default(Vector3); ((Vector3)(ref val7))..ctor(((Bounds)(ref val4)).center.x, y, ((Bounds)(ref val4)).center.z); Vector3 worldPosition = ((Component)val3).transform.TransformPoint(val7); Quaternion worldRotation = Quaternion.Euler(0f, ((Component)val3).transform.eulerAngles.y, 0f); anchor = new TruckAnchorInfo(val3, worldPosition, worldRotation, val4); return true; } private bool IsPointInsideTruckBounds(RoomVolume roomVolume, Bounds bounds, Vector3 worldPoint, float padding) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)roomVolume).transform.InverseTransformPoint(worldPoint); Bounds val2 = bounds; ((Bounds)(ref val2)).Expand(padding * 2f); return ((Bounds)(ref val2)).Contains(val); } private bool TryBuildTruckLocalBounds(RoomVolume roomVolume, out Bounds bounds) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); bool initialized = false; Collider[] componentsInChildren = ((Component)roomVolume).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { EncapsulateLocalBounds(((Component)roomVolume).transform, val.bounds, ref bounds, ref initialized); } if (initialized) { return true; } Renderer[] componentsInChildren2 = ((Component)roomVolume).GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren2) { EncapsulateLocalBounds(((Component)roomVolume).transform, val2.bounds, ref bounds, ref initialized); } return initialized; } private void EncapsulateLocalBounds(Transform root, Bounds worldBounds, ref Bounds localBounds, ref bool initialized) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) Vector3 center = ((Bounds)(ref worldBounds)).center; Vector3 extents = ((Bounds)(ref worldBounds)).extents; for (int i = -1; i <= 1; i += 2) { for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { Vector3 val = center + Vector3.Scale(extents, new Vector3((float)i, (float)j, (float)k)); Vector3 val2 = root.InverseTransformPoint(val); if (!initialized) { localBounds = new Bounds(val2, Vector3.zero); initialized = true; } else { ((Bounds)(ref localBounds)).Encapsulate(val2); } } } } } private bool IsGameplayRuntimeReady() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Invalid comparison between Unknown and I4 //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Invalid comparison between Unknown and I4 if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)GameDirector.instance == (Object)null || (Object)(object)LevelGenerator.Instance == (Object)null) { return false; } if (SemiFunc.MenuLevel() || SemiFunc.RunIsLobbyMenu() || SemiFunc.RunIsTutorial()) { return false; } if (!IsTruckDecorRuntimeScene()) { return false; } if (!LevelGenerator.Instance.Generated) { return false; } if ((int)GameDirector.instance.currentState != 1 && (int)GameDirector.instance.currentState != 2) { return false; } if (!GameManager.Multiplayer()) { return true; } if (!PhotonNetwork.InRoom || !PhotonNetwork.IsConnectedAndReady) { return false; } return true; } private bool ShouldResetRuntimeTracking() { if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)GameDirector.instance == (Object)null || (Object)(object)LevelGenerator.Instance == (Object)null) { return true; } if (SemiFunc.MenuLevel() || SemiFunc.RunIsLobbyMenu() || SemiFunc.RunIsTutorial()) { return true; } if (!IsTruckDecorRuntimeScene()) { return true; } if (GameManager.Multiplayer() && (!PhotonNetwork.InRoom || !PhotonNetwork.IsConnectedAndReady)) { return true; } return false; } private bool IsTruckDecorRuntimeScene() { return SemiFunc.RunIsLevel() || SemiFunc.RunIsLobby() || SemiFunc.RunIsShop(); } private bool ShouldForceEditorChargingStation() { return pendingTruckEditorLaunch || truckSessionActive || forgeModeActive; } private void PrepareEditorChargingStation(ChargingStation station) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown if ((Object)(object)station == (Object)null) { return; } ChargingStation.instance = station; ((Component)station).gameObject.SetActive(true); GameObject meshObject = station.meshObject; if (meshObject != null) { meshObject.SetActive(true); } station.chargeBar = (((Object)(object)station.chargeBar != (Object)null) ? station.chargeBar : ((Component)station).transform.Find("Charge")); if ((Object)(object)station.chargeBar != (Object)null) { ((Component)station.chargeBar).gameObject.SetActive(true); station.chargeBar.localScale = Vector3.one; } station.lockedTransform = (((Object)(object)station.lockedTransform != (Object)null) ? station.lockedTransform : ((Component)station).transform.Find("Locked")); if ((Object)(object)station.lockedTransform != (Object)null) { ((Component)station.lockedTransform).gameObject.SetActive(true); } station.chargeArea = (((Object)(object)station.chargeArea != (Object)null) ? station.chargeArea : ((Component)station).transform.Find("Charge Area")); if ((Object)(object)station.chargeArea != (Object)null) { Collider[] componentsInChildren = ((Component)station.chargeArea).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { val.enabled = false; } } object light; if (!((Object)(object)station.light1 != (Object)null)) { Transform obj = ((Component)station).transform.Find("Light1"); light = ((obj != null) ? ((Component)obj).GetComponent<Light>() : null); } else { light = station.light1; } station.light1 = (Light)light; object light2; if (!((Object)(object)station.light2 != (Object)null)) { Transform obj2 = ((Component)station).transform.Find("Light2"); light2 = ((obj2 != null) ? ((Component)obj2).GetComponent<Light>() : null); } else { light2 = station.light2; } station.light2 = (Light)light2; if ((Object)(object)station.light1 != (Object)null) { ((Behaviour)station.light1).enabled = true; } if ((Object)(object)station.light2 != (Object)null) { ((Behaviour)station.light2).enabled = true; } if ((Object)(object)station.subtleLight != (Object)null) { station.subtleLight.SetActive(true); Light component = station.subtleLight.GetComponent<Light>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = true; } } station.crystalCylinder = (((Object)(object)station.crystalCylinder != (Object)null) ? station.crystalCylinder : ((Component)station).transform.Find("Crystal Cylinder")); if ((Object)(object)station.crystalCylinder != (Object)null) { station.crystals.Clear(); foreach (Transform item in station.crystalCylinder) { Transform val2 = item; ((Component)val2).gameObject.SetActive(true); station.crystals.Add(val2); } } if ((Object)(object)station.meshObject != (Object)null) { Renderer component2 = station.meshObject.GetComponent<Renderer>(); if ((Object)(object)component2 != (Object)null) { station.chargingStationEmissionMaterial = component2.material; if (station.chargingStationEmissionMaterial.HasProperty("_EmissionColor")) { station.chargingStationEmissionMaterial.EnableKeyword("_EMISSION"); station.chargingStationEmissionMaterial.SetColor("_EmissionColor", new Color(0.35f, 0.28f, 0.08f, 1f)); } } } ((Behaviour)station).enabled = false; } private bool HasSelectedLayoutFile() { if (string.IsNullOrWhiteSpace(selectedLayoutConfig.Value)) { return false; } return File.Exists(GetLayoutPath(selectedLayoutConfig.Value)); } private bool TryLoadLayout(string layoutName, out TruckLayoutData? layoutData) { layoutData = null; string layoutPath = GetLayoutPath(layoutName); if (!File.Exists(layoutPath)) { return false; } try { layoutData = JsonConvert.DeserializeObject<TruckLayoutData>(File.ReadAllText(layoutPath), jsonSettings); if (layoutData == null) { return false; } layoutData.Name = (string.IsNullOrWhiteSpace(layoutData.Name) ? NormalizeLayoutName(layoutName) : NormalizeLayoutName(layoutData.Name)); TruckLayoutData truckLayoutData = layoutData; if (truckLayoutData.Objects == null) { truckLayoutData.Objects = new List<TruckObjectRecord>(); } return true; } catch (Exception ex) { Log.LogError((object)("[TruckEditor] Failed to load layout '" + layoutName + "': " + ex)); SetStatus("Could not load " + layoutName + ".", 5f); return false; } } private CatalogEntry? GetSelectedCatalogEntry() { if (string.IsNullOrWhiteSpace(selectedObjectId)) { return catalogEntries.FirstOrDefault(); } CatalogEntry catalogEntry = catalogEntries.FirstOrDefault((CatalogEntry entry) => string.Equals(entry.ResourcePath, selectedObjectId, StringComparison.OrdinalIgnoreCase)); return catalogEntry ?? catalogEntries.FirstOrDefault(); } private IEnumerable<CatalogEntry> GetVisibleCatalogEntries() { IEnumerable<CatalogEntry> source = catalogEntries; if (!string.Equals(selectedCategory, "All", StringComparison.OrdinalIgnoreCase)) { source = source.Where((CatalogEntry entry) => string.Equals(entry.Category, selectedCategory, StringComparison.OrdinalIgnoreCase)); } if (!string.IsNullOrWhiteSpace(editorSearch)) { string text = editorSearch.Trim(); source = source.Where((CatalogEntry entry) => entry.DisplayName.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0 || entry.Section.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0); } return source.OrderBy<CatalogEntry, string>((CatalogEntry entry) => entry.Section, StringComparer.OrdinalIgnoreCase).ThenBy<CatalogEntry, string>((CatalogEntry entry) => entry.DisplayName, StringComparer.OrdinalIgnoreCase); } private string NiceNameFromPath(string rawName) { string text = rawName ?? string.Empty; if (text.Contains("/")) { text = text.Split('/').Last(); } text = text.Replace('_', ' ').Replace('-', ' ').Trim(); if (string.IsNullOrWhiteSpace(text)) { text = "Decor Piece"; } StringBuilder stringBuilder = new StringBuilder(text.Length + 8); for (int i = 0; i < text.Length; i++) { char c = text[i]; if (i > 0 && char.IsUpper(c) && text[i - 1] != ' ' && !char.IsUpper(text[i - 1])) { stringBuilder.Append(' '); } stringBuilder.Append(c); } return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(stringBuilder.ToString().ToLowerInvariant()); } private void BuildCatalogIfNeeded(bool force) { if (!force && catalogEntries.Count > 0) { return; } catalogEntries.Clear(); categoryNames.Clear(); HashSet<string> knownPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase); if ((Object)(object)RunManager.instance != (Object)null) { IEnumerable<Level> levels = RunManager.instance.levels; foreach (Level item in levels ?? Enumerable.Empty<Level>()) { IEnumerable<LevelValuables> valuablePresets = item.ValuablePresets; foreach (LevelValuables item2 in valuablePresets ?? Enumerable.Empty<LevelValuables>()) { AddCatalogEntries(item2.tiny, "Valuable Decor", item.NarrativeName + " Tiny", knownPaths); AddCatalogEntries(item2.small, "Valuable Decor", item.NarrativeName + " Small", knownPaths); AddCatalogEntries(item2.medium, "Valuable Decor", item.NarrativeName + " Medium", knownPaths); AddCatalogEntries(item2.big, "Valuable Decor", item.NarrativeName + " Big", knownPaths); AddCatalogEntries(item2.wide, "Valuable Decor", item.NarrativeName + " Wide", knownPaths); AddCatalogEntries(item2.tall, "Valuable Decor", item.NarrativeName + " Tall", knownPaths); AddCatalogEntries(item2.veryTall, "Valuable Decor", item.NarrativeName + " Very Tall", knownPaths); } } } if ((Object)(object)StatsManager.instance != (Object)null) { foreach (Item item3 in StatsManager.instance.itemDictionary.Values.OrderBy<Item, string>((Item item) => item.itemName, StringComparer.OrdinalIgnoreCase)) { if (item3?.prefab != null && item3.prefab.IsValid() && item3.physicalItem) { AddCatalogEntry(item3.prefab, "Item Decor", "Physical Items", knownPaths, item3.itemName); } } } categoryNames.Add("All"); categoryNames.AddRange(catalogEntries.Select((CatalogEntry entry) => entry.Category).Distinct<string>(StringComparer.OrdinalIgnoreCase).OrderBy<string, string>((string category) => category, StringComparer.OrdinalIgnoreCase)); if (!categoryNames.Contains(selectedCategory)) { selectedCategory = "All"; } if (GetSelectedCatalogEntry() == null && catalogEntries.Count > 0) { selectedObjectId = catalogEntries[0].ResourcePath; } } private void AddCatalogEntries(IEnumerable<PrefabRef> prefabRefs, string category, string section, HashSet<string> knownPaths) { if (prefabRefs == null) { return; } foreach (PrefabRef prefabRef in prefabRefs) { AddCatalogEntry(prefabRef, category, section, knownPaths, null); } } private void AddCatalogEntry(PrefabRef prefabRef, string category, string section, HashSet<string> knownPaths, string? preferredName) { if (prefabRef != null && prefabRef.IsValid() && !string.IsNullOrWhiteSpace(prefabRef.ResourcePath) && knownPaths.Add(prefabRef.ResourcePath)) { catalogEntries.Add(new CatalogEntry { ResourcePath = prefabRef.ResourcePath, DisplayName = (string.IsNullOrWhiteSpace(preferredName) ? NiceNameFromPath(prefabRef.PrefabName) : preferredName), Category = category, Section = section }); } } private void HandleEditorWorldInput() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (!forgeModeActive || editorCursorActive || (Object)(object)GameDirector.instance == (Object)null || (Object)(object)GameDirector.instance.MainCamera == (Object)null) { return; } if (IsConfiguredKeyDown(toggleEditorUiKeyConfig)) { editorUiVisible = !editorUiVisible; SetStatus(editorUiVisible ? "Truck Editor UI shown." : ("Truck Editor UI hidden. Press " + KeyLabel(toggleEditorUiKeyConfig) + " to show it again."), 3f); } if (IsConfiguredKeyDown(toggleForgeModeKeyConfig)) { ExitForgeMode(); SetStatus("Back in normal truck view.", 3f); return; } if (IsConfiguredKeyDown(exitToMenuKeyConfig)) { EndTruckEditorSession(loadMainMenu: true); return; } float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) > 0.01f) { previewDistance = Mathf.Clamp(previewDistance + y * 0.4f, 0.8f, 12f); } if (IsConfiguredKeyDown(placementOffsetDownKeyConfig)) { placementHeightOffset -= 0.08f; SetStatus("Placement offset " + placementHeightOffset.ToString("0.00", CultureInfo.InvariantCulture) + "m", 2f); } if (IsConfiguredKeyDown(placementOffsetUpKeyConfig)) { placementHeightOffset += 0.08f; SetStatus("Placement offset " + placementHeightOffset.ToString("0.00", CultureInfo.InvariantCulture) + "m", 2f); } CatalogEntry selectedCatalogEntry = GetSelectedCatalogEntry(); if (selectedCatalogEntry != null && Input.GetMouseButtonDown(0)) { PlaceSelectedObject(selectedCatalogEntry); } UpdatePlacementRotationInput(); if (Input.GetMouseButtonDown(1)) { PickPlacedObject(); } if (!string.IsNullOrWhiteSpace(selectedPlacedObjectId)) { if (IsConfiguredKeyHeld(moveSelectedModifierKeyConfig) && Input.GetMouseButtonDown(0)) { MoveSelectedObjectToCrosshair(); } if (IsConfiguredKeyHeld(rotateSelectedKeyConfig)) { RotateSelectedPlacedObject(90f * Time.deltaTime); } if (IsConfiguredKeyDown(deleteSelectedKeyConfig)) { RemoveSelectedPlacedObject(); } if (IsConfiguredKeyDown(duplicateSelectedKeyConfig)) { DuplicateSelectedPlacedObject(); } if (IsConfiguredKeyDown(selectedHeightUpKeyConfig)) { AdjustSelectedPlacedHeight(0.08f); } if (IsConfiguredKeyDown(selectedHeightDownKeyConfig)) { AdjustSelectedPlacedHeight(-0.08f); } } } private void UpdatePlacementRotationInput() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) float num = 90f * Time.deltaTime; Vector3 val = placementRotationEuler; bool flag = false; if (IsConfiguredKeyHeld(placementRotateXKeyConfig)) { val.x = Mathf.Repeat(val.x + num, 360f); flag = true; } if (IsConfiguredKeyHeld(placementRotateYKeyConfig)) { val.y = Mathf.Repeat(val.y + num, 360f); flag = true; } if (IsConfiguredKeyHeld(placementRotateZKeyConfig)) { val.z = Mathf.Repeat(val.z + num, 360f); flag = true; } if (flag) { placementRotationEuler = val; } } private void PlaceSelectedObject(CatalogEntry entry) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sessionTruckAnchorRoot == (Object)null)) { PlacementState placementState = GetPlacementState(editorPreviewInstance); TruckObjectRecord obj = new TruckObjectRecord { Id = Guid.NewGuid().ToString("N"), ResourcePath = entry.ResourcePath, DisplayName = entry.DisplayName, Category = entry.Category, Section = entry.Section, Position = new SerializableVector3(sessionTruckAnchorRoot.InverseTransformPoint(placementState.Position)) }; Quaternion val = Quaternion.Inverse(sessionTruckAnchorRoot.rotation) * placementState.Rotation; obj.Rotation = new SerializableVector3(((Quaternion)(ref val)).eulerAngles); TruckObjectRecord truckObjectRecord = obj; editorObjects[truckObjectRecord.Id] = truckObjectRecord; GameObject val2 = InstantiateEditorObject(truckObjectRecord); if ((Object)(object)val2 == (Object)null) { editorObjects.Remove(truckObjectRecord.Id); SetStatus("Missing resource for " + entry.DisplayName + "."); } else { editorInstances[truckObjectRecord.Id] = val2; selectedPlacedObjectId = truckObjectRecord.Id; SetStatus("Placed " + entry.DisplayName + ".", 2f); } } } private GameObject? InstantiateEditorObject(TruckObjectRecord record) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sessionTruckAnchorRoot == (Object)null) { return null; } GameObject val = Resources.Load<GameObject>(record.ResourcePath); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = Object.Instantiate<GameObject>(val); ((Object)val2).name = "TruckEditor.Decor." + record.DisplayName; val2.transform.SetParent(sessionTruckAnchorRoot, false); val2.transform.localPosition = record.Position.ToVector3(); val2.transform.localRotation = Quaternion.Euler(record.Rotation.ToVector3()); PlacedMarker placedMarker = val2.GetComponent<PlacedMarker>(); if ((Object)(object)placedMarker == (Object)null) { placedMarker = val2.AddComponent<PlacedMarker>(); } placedMarker.Id = record.Id; MakeDecorativeInstanceDormant(val2, placedMarker, forgeModeActive); return val2; } private void MakeDecorativeInstanceDormant(GameObject instance, PlacedMarker? marker, bool collidersEnabled) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) Behaviour[] componentsInChildren = instance.GetComponentsInChildren<Behaviour>(true); foreach (Behaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)marker)) { val.enabled = false; } } Collider[] componentsInChildren2 = instance.GetComponentsInChildren<Collider>(true); foreach (Collider val2 in componentsInChildren2) { val2.enabled = collidersEnabled; } Rigidbody[] componentsInChildren3 = instance.GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val3 in componentsInChildren3) { val3.isKinematic = true; val3.useGravity = false; val3.detectCollisions = collidersEnabled; val3.velocity = Vector3.zero; val3.angularVelocity = Vector3.zero; } } private void SetEditorObjectCollidersEnabled(bool value) { foreach (GameObject value2 in editorInstances.Values) { if (!((Object)(object)value2 == (Object)null)) { Collider[] componentsInChildren = value2.GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { val.enabled = value; } Rigidbody[] componentsInChildren2 = value2.GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val2 in componentsInChildren2) { val2.detectCollisions = value; } } } } private void PickPlacedObject() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameDirector.instance == (Object)null || (Object)(object)GameDirector.instance.MainCamera == (Object)null) { return; } Camera mainCamera = GameDirector.instance.MainCamera; Ray val = default(Ray); ((Ray)(ref val))..ctor(((Component)mainCamera).transform.position, ((Component)mainCamera).transform.forward); RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(val, ref val2, 40f, -1, (QueryTriggerInteraction)2)) { selectedPlacedObjectId = string.Empty; return; } PlacedMarker componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<PlacedMarker>(); selectedPlacedObjectId = (((Object)(object)componentInParent != (Object)null) ? componentInParent.Id : string.Empty); if (!string.IsNullOrWhiteSpace(selectedPlacedObjectId) && editorObjects.TryGetValue(selectedPlacedObjectId, out TruckObjectRecord value)) { SetStatus("Selected " + value.DisplayName + ".", 2f); } } private void UpdatePreviewInstance() { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (!forgeModeActive || (Object)(object)sessionTruckAnchorRoot == (Object)null) { DestroyEditorPreviewInstance(); return; } CatalogEntry selectedCatalogEntry = GetSelectedCatalogEntry(); if (selectedCatalogEntry == null) { DestroyEditorPreviewInstance(); return; } if ((Object)(object)editorPreviewInstance == (Object)null || !string.Equals(previewResourcePath, selectedCatalogEntry.ResourcePath, StringComparison.OrdinalIgnoreCase)) { DestroyEditorPreviewInstance(); editorPreviewInstance = CreatePreviewInstance(selectedCatalogEntry); previewResourcePath = selectedCatalogEntry.ResourcePath; } if (!((Object)(object)editorPreviewInstance == (Object)null)) { PlacementState placementState = GetPlacementState(editorPreviewInstance); editorPreviewInstance.transform.SetPositionAndRotation(placementState.Position, placementState.Rotation); } } private GameObject? CreatePreviewInstance(CatalogEntry entry) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sessionTruckAnchorRoot == (Object)null) { return null; } GameObject val = Resources.Load<GameObject>(entry.ResourcePath); if ((Object)(object)val == (Object)null) { return null; } GameObject val2 = Object.Instantiate<GameObject>(val); ((Object)val2).name = "TruckEditor.Preview"; val2.transform.SetParent(sessionTruckAnchorRoot, true); Behaviour[] componentsInChildren = val2.GetComponentsInChildren<Behaviour>(true); foreach (Behaviour val3 in componentsInChildren) { val3.enabled = false; } Collider[] componentsInChildren2 = val2.GetComponentsInChildren<Collider>(true); foreach (Collider val4 in componentsInChildren2) { val4.enabled = false; } Rigidbody[] componentsInChildren3 = val2.GetComponentsInChildren<Rigidbody>(true); foreach (Rigidbody val5 in componentsInChildren3) { val5.isKinematic = true; val5.useGravity = false; val5.velocity = Vector3.zero; val5.angularVelocity = Vector3.zero; } Renderer[] componentsInChildren4 = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val6 in componentsInChildren4) { val6.material = CreatePreviewMaterial(val6.sharedMaterial); val6.shadowCastingMode = (ShadowCastingMode)0; val6.receiveShadows = false; } return val2; } private Material CreatePreviewMaterial(Material? sourceMaterial) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Standard"); Material val2 = new Material(val); Color color = default(Color); ((Color)(ref color))..ctor(0.9f, 0.4f, 0.24f, 0.28f); if ((Object)(object)sourceMaterial != (Object)null && sourceMaterial.HasProperty("_Color")) { color = sourceMaterial.color; color.a = 0.28f; } val2.color = color; val2.SetFloat("_Mode", 3f); val2.SetInt("_SrcBlend", 5); val2.SetInt("_DstBlend", 10); val2.SetInt("_ZWrite", 0); val2.DisableKeyword("_ALPHATEST_ON"); val2.EnableKeyword("_ALPHABLEND_ON"); val2.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val2.renderQueue = 3000; if (val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", new Color(0.17f, 0.06f, 0.03f, 1f)); } return val2; } private void DestroyEditorPreviewInstance() { if ((Object)(object)editorPreviewInstance != (Object)null) { Object.Destroy((Object)(object)editorPreviewInstance); editorPreviewInstance = null; } previewResourcePath = string.Empty; } private void MoveSelectedObjectToCrosshair() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sessionTruckAnchorRoot == (Object)null) && editorObjects.TryGetValue(selectedPlacedObjectId, out TruckObjectRecord value) && editorInstances.TryGetValue(selectedPlacedObjectId, out GameObject value2)) { PlacementState placementState = GetPlacementState(value2); value2.transform.SetPositionAndRotation(placementState.Position, placementState.Rotation); value.Position = new SerializableVector3(sessionTruckAnchorRoot.InverseTransformPoint(placementState.Position)); TruckObjectRecord truckObjectRecord = value; Quaternion val = Quaternion.Inverse(sessionTruckAnchorRoot.rotation) * placementState.Rotation; truckObjectRecord.Rotation = new SerializableVector3(((Quaternion)(ref val)).eulerAngles); SetStatus("Moved " + value.DisplayName + ".", 2f); } } private void RotateSelectedPlacedObject(float amount) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or mi