using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Build Ease")] [assembly: AssemblyDescription("Easy UE-style building for Valheim.")] [assembly: AssemblyCompany("Obelisk")] [assembly: AssemblyProduct("Build Ease")] [assembly: AssemblyFileVersion("0.3.10.0")] [assembly: ComVisible(false)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.3.10.0")] namespace Obelisk.UEPlacementEditor; internal enum EditMode { Translate, Rotate } internal enum CoordinateSpace { World, Local } internal sealed class EditorController : MonoBehaviour { private enum TargetStatusKind { NoGhost, SpecialPiece, Piece } private struct PlacementRotationSnapshot { internal int PlaceRotation; internal float ScrollCurrentAmount; internal float RotatePieceTimer; internal bool PerfectPlacementAvailable; internal bool PerfectPlacementHadEntry; internal Vector3 PerfectPlacementRotation; } internal sealed class DemolitionPickupTransaction { internal readonly HashSet ExistingDropIds = new HashSet(); internal readonly Dictionary RemainingResources = new Dictionary(); internal Vector3 Center; internal float ExpiresAt; } private static readonly FieldRef PlacementGhost = AccessTools.FieldRefAccess("m_placementGhost"); private static readonly FieldRef PlacementMarker = AccessTools.FieldRefAccess("m_placementMarkerInstance"); private static readonly FieldRef PlacementStatus = AccessTools.FieldRefAccess("m_placementStatus"); private static readonly FieldRef PlaceRayMask = AccessTools.FieldRefAccess("m_placeRayMask"); private static readonly FieldRef RemoveRayMask = AccessTools.FieldRefAccess("m_removeRayMask"); private static readonly FieldRef MaximumPlaceDistance = AccessTools.FieldRefAccess("m_maxPlaceDistance"); private static readonly FieldRef PlaceRotation = AccessTools.FieldRefAccess("m_placeRotation"); private static readonly FieldRef EnableAutoPickup = AccessTools.StaticFieldRefAccess(AccessTools.Field(typeof(Player), "m_enableAutoPickup")); private static readonly FieldRef ScrollCurrentAmount = AccessTools.FieldRefAccess("m_scrollCurrAmount"); private static readonly FieldRef RotatePieceTimer = AccessTools.FieldRefAccess("m_rotatePieceTimer"); private static readonly MethodInfo UpdatePlacementMethod = AccessTools.Method(typeof(Player), "UpdatePlacement", new Type[2] { typeof(bool), typeof(float) }, (Type[])null); private static readonly Action UpdatePlacementInvoker = CreateUpdatePlacementInvoker(); private static readonly string[] HotbarButtons = new string[8] { "Hotbar1", "Hotbar2", "Hotbar3", "Hotbar4", "Hotbar5", "Hotbar6", "Hotbar7", "Hotbar8" }; private static readonly KeyCode[] HotbarKeys; private static bool _externalModeResolversInitialized; private static Func _perfectPlacementBuildingMode; private static Func _perfectPlacementEditingMode; private static Func _buildCameraMode; private static bool _moveBuildPiecesPresent; private static bool _moveBuildPiecesResolved; private static Func _moveBuildPiecesEnabled; private static Func _moveBuildPiecesBlocksBuildAction; private static Func _moveBuildPiecesBuildModeHotkey; private static Func _moveBuildPiecesWorldModeHotkey; private static Func _moveBuildPiecesMixedModeHotkey; private static FieldInfo _moveBuildPiecesPendingRequest; private static IDictionary _perfectPlacementPlayersData; private static FieldRef _perfectPlacementPlaceRotation; private const float RightMouseClickTime = 0.28f; private const float RightMouseLookThreshold = 0.35f; private const float BuildSnapDistance = 0.5f; private const float BuildSnapSearchRadius = 10f; private const int MaximumSnapPieceBufferSize = 16384; private const int MaximumClippingBufferSize = 32768; private const float DemolitionPickupRadius = 3f; private const float DemolitionPickupInterval = 0.1f; private const float DemolitionPickupDuration = 5f; private const float HammerEquipTimeout = 8f; private const int ToolbarWindowId = 20260714; private static readonly Color CameraLightColor; private static readonly GUILayoutOption HeaderWidth; private static readonly GUILayoutOption TranslateWidth; private static readonly GUILayoutOption RotateWidth; private static readonly GUILayoutOption SpaceWidth; private static readonly GUILayoutOption SnapWidth; private static readonly GUILayoutOption CameraLightWidth; private static readonly GUILayoutOption ResetWidth; private static readonly GUILayoutOption ExitWidth; private static readonly Rect ToolbarDragRect; private readonly List _nearbyCharacters = new List(16); private readonly List _sourceSnapPoints = new List(16); private readonly List _destinationSnapPoints = new List(128); private readonly List _nearbyPieces = new List(64); private readonly HashSet _nearbyPieceSet = new HashSet(); private readonly HashSet _demolitionPickupDrops = new HashSet(); private readonly List _demolitionPickupTransactions = new List(8); private readonly PlacementGhostVisual _placementGhostVisual = new PlacementGhostVisual(); private Collider[] _targetColliders = Array.Empty(); private Collider[] _snapPieceBuffer = (Collider[])(object)new Collider[256]; private Collider[] _clippingBuffer = (Collider[])(object)new Collider[256]; private Collider[] _demolitionPickupBuffer = (Collider[])(object)new Collider[128]; private RaycastHit[] _surfaceRaycastBuffer = (RaycastHit[])(object)new RaycastHit[64]; private int _itemLayerMask; private int _pieceLayerMask; private GizmoRenderer _gizmo; private Camera _editorCamera; private GameObject _targetGhost; private Piece _targetPiece; private Piece _targetSelectedPiece; private Piece _observedSelectedPiece; private bool _observedSelectedPieceCompatible; private bool _hasCachedPlacementStatus; private PlacementStatus _cachedPlacementStatus; private Vector3 _desiredPosition; private Quaternion _desiredRotation; private bool _copiedPieceThisPlacementUpdate; private bool _hasSampledPlacementRotation; private bool _sampledCopySucceededThisPlacementUpdate; private int _sampledPlaceRotation; private Quaternion _sampledPlacementRotation; private EditMode _mode; private CoordinateSpace _space; private bool _surfaceSnapEnabled; private bool _hasTemporaryPivot; private bool _surfaceSupportInvalid; private Vector3 _temporaryPivotLocal; private bool _active; private bool _placementUpdateFailed; private bool _editorEntryPending; private bool _pendingEquipIssued; private bool _pendingOwnEquipAction; private Player _pendingEntryPlayer; private Inventory _pendingEntryInventory; private ItemData _pendingEntryHammer; private float _pendingEntryDeadline; private bool _rightMouseActive; private bool _rightMouseMoved; private bool _rightMouseMenuWasVisible; private float _rightMouseDownTime; private float _rightMouseLookMagnitude; private Vector3 _rightMouseStartCameraPosition; private float _rightMouseStartYaw; private float _rightMouseStartPitch; private bool _cameraCapturedLastFrame; private bool _cameraPositionDirty; private Vector3 _cameraPosition; private float _cameraYaw; private float _cameraPitch; private float _cameraSpeedScale = 1f; private Light _cameraLight; private volatile bool _cameraLightSettingsDirty; private volatile bool _ghostPreviewSettingsDirty; private bool _blueGhostPreviewEnabled; private volatile bool _toolbarLabelsDirty; private EditorLanguage _language = EditorLanguage.English; private bool _languageInitialized; private float _nextDemolitionPickupTime; private float _lastDemolitionPickupErrorTime = float.NegativeInfinity; private Player _distancePlayer; private bool _insidePlacementUpdate; private float _originalPlaceDistance; private float _appliedPlaceDistance; private int _uiInputBlockedThroughFrame = -1; private int _placementInputBlockedThroughFrame = -1; private int _reserveHotkeysThroughFrame = -1; private Rect _toolbarRect = new Rect(10f, 10f, 1290f, 86f); private WindowFunction _toolbarWindowFunction; private bool _toolbarDragging; private TargetStatusKind _targetStatusKind; private string _targetStatusPieceToken; private string _targetStatusText = string.Empty; private string _spaceButtonLabel; private string _surfaceSnapButtonLabel; private string _cameraLightButtonLabel; private string _exitButtonLabel; private GizmoAxis _dragAxis; private Plane _dragPlane; private Vector3 _dragWorldAxis; private Vector3 _dragStartRootPosition; private Vector3 _dragStartPivot; private Vector3 _dragStartPlanePoint; private Quaternion _dragStartRotation; private float _dragStartAxisParameter; private Vector3 _dragStartVector; private bool _dragUsesScreenSpace; private Vector2 _dragStartMouse; private Vector2 _dragScreenDirection; private float _dragScreenScale; private static int _suppressMenuFrame; private static int _buildMenuConsumedEscapeFrame; internal bool IsActive => _active; internal bool HasGizmoTarget { get { if ((Object)(object)_targetGhost != (Object)null) { return (Object)(object)_targetPiece != (Object)null; } return false; } } internal Transform TargetTransform { get { if (!HasGizmoTarget) { return null; } return _targetGhost.transform; } } internal Vector3 GizmoPivot { get { //IL_0029: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (!HasGizmoTarget || !_hasTemporaryPivot) { if (!HasGizmoTarget) { return Vector3.zero; } return _targetGhost.transform.position; } return _targetGhost.transform.TransformPoint(_temporaryPivotLocal); } } internal Camera EditorCamera { get { if ((Object)(object)_editorCamera == (Object)null) { _editorCamera = ResolveGameCamera(); } return _editorCamera; } } internal EditMode Mode => _mode; internal CoordinateSpace Space => _space; internal float ActiveEditorRange => GetEditorRange(); internal bool ShouldExtendBuildStationRange { get { if (!_active || !_insidePlacementUpdate || (Object)(object)Player.m_localPlayer == (Object)null) { return false; } Piece selectedPiece = Player.m_localPlayer.GetSelectedPiece(); if ((Object)(object)selectedPiece != (Object)null && !selectedPiece.m_repairPiece) { return !selectedPiece.m_removePiece; } return false; } } internal bool ShouldRenderEditorOverlay { get { if (_active && !IsGameUiBlockingEditorInput()) { return !Hud.IsPieceSelectionVisible(); } return false; } } private bool ShouldRenderToolbar { get { if (ShouldRenderEditorOverlay) { return Plugin.ShowToolbar.Value; } return false; } } internal bool ShouldReserveEditorHotkeys { get { if (!_active && !_editorEntryPending) { return Time.frameCount <= _reserveHotkeysThroughFrame; } return true; } } internal bool ShouldOwnEscapeInput => ShouldRenderEditorOverlay; internal static bool SuppressMenuThisFrame => Time.frameCount == _suppressMenuFrame; internal static bool BuildMenuConsumedEscapeThisFrame => Time.frameCount == _buildMenuConsumedEscapeFrame; private bool IsEditorInputSuppressed { get { if (!IsGameUiBlockingEditorInput()) { return Time.frameCount <= _uiInputBlockedThroughFrame; } return true; } } private bool IsCameraCaptured { get { if (_active && !IsEditorInputSuppressed) { return _rightMouseActive; } return false; } } private void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown _itemLayerMask = LayerMask.GetMask(new string[1] { "item" }); _pieceLayerMask = LayerMask.GetMask(new string[2] { "piece", "piece_nonsolid" }); _toolbarWindowFunction = new WindowFunction(DrawToolbarWindow); _gizmo = ((Component)this).gameObject.AddComponent(); _gizmo.Controller = this; ((Behaviour)_gizmo).enabled = false; Plugin.ToggleEditorKey.SettingChanged += OnToolbarHotkeySettingChanged; Plugin.ToggleSurfaceSnapKey.SettingChanged += OnToolbarHotkeySettingChanged; Plugin.ToggleCoordinateSpaceKey.SettingChanged += OnToolbarHotkeySettingChanged; Plugin.ToggleCameraLightKey.SettingChanged += OnToolbarHotkeySettingChanged; Plugin.CameraLightRange.SettingChanged += OnCameraLightSettingChanged; Plugin.CameraLightIntensity.SettingChanged += OnCameraLightSettingChanged; Plugin.BlueGhostPreview.SettingChanged += OnGhostPreviewSettingChanged; _blueGhostPreviewEnabled = Plugin.BlueGhostPreview.Value; Localization.OnLanguageChange = (Action)Delegate.Combine(Localization.OnLanguageChange, new Action(OnGameLanguageChanged)); } private void OnDestroy() { Localization.OnLanguageChange = (Action)Delegate.Remove(Localization.OnLanguageChange, new Action(OnGameLanguageChanged)); CancelPendingEditorEntry(removeOwnedEquipAction: true); _placementGhostVisual.Restore(); DestroyCameraLight(); Plugin.ToggleEditorKey.SettingChanged -= OnToolbarHotkeySettingChanged; Plugin.ToggleSurfaceSnapKey.SettingChanged -= OnToolbarHotkeySettingChanged; Plugin.ToggleCoordinateSpaceKey.SettingChanged -= OnToolbarHotkeySettingChanged; Plugin.ToggleCameraLightKey.SettingChanged -= OnToolbarHotkeySettingChanged; Plugin.CameraLightRange.SettingChanged -= OnCameraLightSettingChanged; Plugin.CameraLightIntensity.SettingChanged -= OnCameraLightSettingChanged; Plugin.BlueGhostPreview.SettingChanged -= OnGhostPreviewSettingChanged; _toolbarWindowFunction = null; } private void Update() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (_toolbarDragging && (!Plugin.ShowToolbar.Value || !Input.GetMouseButton(0))) { _toolbarDragging = false; } if (_cameraLightSettingsDirty) { _cameraLightSettingsDirty = false; ApplyCameraLightSettings(); } if (_ghostPreviewSettingsDirty) { _ghostPreviewSettingsDirty = false; ApplyGhostPreviewSetting(); } if (_toolbarLabelsDirty) { _toolbarLabelsDirty = false; RefreshToolbarLabels(); } UpdateDemolitionAutoPickupSafe(); if (EditorInputFirewall.IsEditorShortcutDown(Plugin.ToggleEditorKey.Value) && !IsGameUiBlockingEditorInput()) { _reserveHotkeysThroughFrame = Time.frameCount; if (_active) { ExitEditor(); } else if (_editorEntryPending) { CancelPendingEditorEntry(removeOwnedEquipAction: true); } else { BeginEditorEntry(); } return; } if (_editorEntryPending) { UpdatePendingEditorEntry(); } if (!_active) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)GameCamera.instance == (Object)null || ((Character)localPlayer).IsDead() || ((Character)localPlayer).InCutscene() || ((Character)localPlayer).IsTeleporting() || !((Character)localPlayer).InPlaceMode()) { ExitEditor(); return; } if (IsConflictingEditorActive()) { ExitEditor(); ((Character)localPlayer).Message((MessageType)1, _language.DisableConflictingEditor, 0, (Sprite)null); return; } if (IsGameUiBlockingEditorInput()) { _uiInputBlockedThroughFrame = Time.frameCount + 1; SuspendEditorInput(); return; } if (Time.frameCount <= _uiInputBlockedThroughFrame) { SuspendEditorInput(); return; } RefreshPlacementGhostReference(localPlayer); if (Input.GetKeyDown((KeyCode)27)) { if (!BuildMenuConsumedEscapeThisFrame && !Hud.IsPieceSelectionVisible()) { ReserveEscapeInput(); ExitEditor(); } return; } UpdateRightMouseGesture(); if (Hud.IsPieceSelectionVisible()) { CancelDrag(); return; } bool flag = HandleCameraLightShortcut(); if (IsCameraCaptured) { CancelDrag(); return; } if (!flag) { HandleEditorShortcuts(); } HandlePointer(); } private void SuspendEditorInput() { _toolbarDragging = false; _rightMouseActive = false; _rightMouseMoved = false; _cameraCapturedLastFrame = false; CancelDrag(); if ((Object)(object)_gizmo != (Object)null) { _gizmo.HoveredAxis = GizmoAxis.None; } } private void UpdateRightMouseGesture() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (Input.GetMouseButtonDown(1)) { _rightMouseActive = true; _rightMouseMoved = false; _rightMouseMenuWasVisible = Hud.IsPieceSelectionVisible(); _rightMouseDownTime = Time.unscaledTime; _rightMouseLookMagnitude = 0f; _rightMouseStartCameraPosition = _cameraPosition; _rightMouseStartYaw = _cameraYaw; _rightMouseStartPitch = _cameraPitch; if (_rightMouseMenuWasVisible) { Hud.HidePieceSelection(); } } if (!_rightMouseActive || !Input.GetMouseButtonUp(1)) { return; } float num = Time.unscaledTime - _rightMouseDownTime; bool num2 = !_rightMouseMoved && num <= 0.28f; _rightMouseActive = false; _cameraCapturedLastFrame = false; if (num2) { _cameraPosition = _rightMouseStartCameraPosition; _cameraYaw = _rightMouseStartYaw; _cameraPitch = _rightMouseStartPitch; _cameraPositionDirty = true; if (!_rightMouseMenuWasVisible) { ToggleBuildMenu(); } } _rightMouseMenuWasVisible = false; } private void HandleEditorShortcuts() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (EditorInputFirewall.IsEditorShortcutDown(Plugin.ToggleCoordinateSpaceKey.Value)) { ToggleCoordinateSpace(); } else if (EditorInputFirewall.IsEditorShortcutDown(Plugin.ToggleSurfaceSnapKey.Value)) { ToggleSurfaceSnapping(); } else if (Input.GetKeyDown((KeyCode)119)) { SetEditMode(EditMode.Translate); } else if (Input.GetKeyDown((KeyCode)101) || Input.GetKeyDown((KeyCode)114)) { SetEditMode(EditMode.Rotate); } } private bool HandleCameraLightShortcut() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!EditorInputFirewall.IsEditorShortcutDown(Plugin.ToggleCameraLightKey.Value)) { return false; } ToggleCameraLight(); return true; } private void SetEditMode(EditMode mode) { if (_mode != mode) { CancelDrag(); _mode = mode; } } private void ToggleCoordinateSpace() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_003f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0077: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0106: Unknown result type (might be due to invalid IL or missing references) Transform val = (HasGizmoTarget ? _targetGhost.transform : null); Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : Vector3.zero); Quaternion val3 = (((Object)(object)val != (Object)null) ? val.rotation : Quaternion.identity); int num; int num2; if ((Object)(object)val != (Object)null && IsFinite(val2)) { num = (IsFinite(val3) ? 1 : 0); if (num != 0) { num2 = (_hasTemporaryPivot ? 1 : 0); goto IL_006b; } } else { num = 0; } num2 = 0; goto IL_006b; IL_006b: bool flag = (byte)num2 != 0; bool flag2 = flag; Vector3 val4 = (flag2 ? GizmoPivot : val2); if (flag2 && !IsFinite(val4)) { flag2 = false; val4 = val2; } if (num != 0) { _desiredPosition = val2; _desiredRotation = val3; } CancelDrag(); _space = ((_space == CoordinateSpace.World) ? CoordinateSpace.Local : CoordinateSpace.World); RefreshToolbarLabels(); _placementInputBlockedThroughFrame = Mathf.Max(_placementInputBlockedThroughFrame, Time.frameCount); if (num != 0 && HasGizmoTarget) { _targetGhost.transform.SetPositionAndRotation(val2, val3); _desiredPosition = val2; _desiredRotation = val3; if (flag2) { SetTemporaryPivot(val4); } else if (flag) { ClearTemporaryPivot(clearSurfaceSupport: false); } } } private void ToggleSurfaceSnapping() { CancelDrag(); _surfaceSnapEnabled = !_surfaceSnapEnabled; _placementInputBlockedThroughFrame = Mathf.Max(_placementInputBlockedThroughFrame, Time.frameCount); if (!_surfaceSnapEnabled) { ClearTemporaryPivot(clearSurfaceSupport: false); if (HasGizmoTarget && (Object)(object)Player.m_localPlayer != (Object)null) { ValidateEditedGhost(Player.m_localPlayer, _targetPiece, flashGuardStone: false); } } RefreshToolbarLabels(); } private void ToggleCameraLight() { if ((Object)(object)_cameraLight != (Object)null) { DestroyCameraLight(); } else { CreateCameraLight(); } RefreshToolbarLabels(); } private void CreateCameraLight() { //IL_0028: 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_0036: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) DestroyCameraLight(); Camera editorCamera = EditorCamera; if ((Object)(object)editorCamera == (Object)null) { Plugin.LogError("Could not create camera light: editor camera is unavailable"); return; } GameObject val = null; try { val = new GameObject("Build Ease Camera Light") { hideFlags = (HideFlags)61 }; val.transform.SetParent(((Component)editorCamera).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; _cameraLight = val.AddComponent(); ((Behaviour)_cameraLight).enabled = false; _cameraLight.type = (LightType)2; _cameraLight.color = CameraLightColor; _cameraLight.renderMode = (LightRenderMode)0; ApplyCameraLightSettings(); ((Behaviour)_cameraLight).enabled = true; } catch (Exception arg) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } _cameraLight = null; Plugin.LogError($"Could not create camera light: {arg}"); } } private void DestroyCameraLight() { GameObject val = null; if ((Object)(object)_cameraLight != (Object)null) { ((Behaviour)_cameraLight).enabled = false; val = ((Component)_cameraLight).gameObject; } _cameraLight = null; if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } private void ApplyCameraLightSettings() { if (!((Object)(object)_cameraLight == (Object)null)) { _cameraLight.range = GetSafeConfigValue(Plugin.CameraLightRange.Value, 100f, 1f, 100f); _cameraLight.intensity = GetSafeConfigValue(Plugin.CameraLightIntensity.Value, 1.5f, 0f, 10f); _cameraLight.shadows = (LightShadows)0; _cameraLight.shadowStrength = 0f; } } private void HandlePointer() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) Camera editorCamera = EditorCamera; if ((Object)(object)editorCamera == (Object)null) { return; } if (_dragAxis != GizmoAxis.None) { if (Input.GetMouseButton(0)) { ContinueDrag(editorCamera); } else { CancelDrag(); } } else if (!IsPointerOverToolbar()) { _gizmo.HoveredAxis = (HasGizmoTarget ? _gizmo.HitTest(editorCamera, Input.mousePosition) : GizmoAxis.None); if (Input.GetMouseButtonDown(0) && _gizmo.HoveredAxis != GizmoAxis.None) { BeginDrag(editorCamera, _gizmo.HoveredAxis); } } } private bool BeginDrag(Camera camera, GizmoAxis axis) { //IL_0019: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) //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_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) //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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0284: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0320: 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_0330: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0233: 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_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) if (!HasGizmoTarget) { return false; } if (axis == GizmoAxis.Center && _mode != EditMode.Translate) { return false; } Vector3 gizmoPivot = GizmoPivot; _dragStartRootPosition = _targetGhost.transform.position; _dragStartPivot = gizmoPivot; _dragStartRotation = _targetGhost.transform.rotation; _dragUsesScreenSpace = false; _dragStartMouse = Vector2.op_Implicit(Input.mousePosition); Ray val = camera.ScreenPointToRay(Input.mousePosition); if (axis == GizmoAxis.Center) { _dragPlane = new Plane(((Component)camera).transform.forward, gizmoPivot); float num = default(float); if (!((Plane)(ref _dragPlane)).Raycast(val, ref num)) { return false; } _dragStartPlanePoint = ((Ray)(ref val)).GetPoint(num); _dragAxis = axis; _gizmo.ActiveAxis = axis; return true; } _dragWorldAxis = GetWorldAxis(axis); if (_mode == EditMode.Translate) { if (Mathf.Abs(Vector3.Dot(_dragWorldAxis, ((Component)camera).transform.forward)) > 0.96f) { float num2 = Mathf.Max(0.5f, camera.WorldToScreenPoint(gizmoPivot).z); float num3 = 2f * num2 * Mathf.Tan(camera.fieldOfView * ((float)Math.PI / 180f) * 0.5f); _dragUsesScreenSpace = true; _dragScreenDirection = Vector2.up * ((Vector3.Dot(_dragWorldAxis, ((Component)camera).transform.forward) >= 0f) ? 1f : (-1f)); _dragScreenScale = num3 / Mathf.Max(1f, (float)Screen.height); } if (_dragUsesScreenSpace) { _dragAxis = axis; _gizmo.ActiveAxis = axis; return true; } Vector3 val2 = Vector3.Cross(_dragWorldAxis, Vector3.Cross(((Component)camera).transform.forward, _dragWorldAxis)); if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.Cross(_dragWorldAxis, ((Component)camera).transform.up); } if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { return false; } _dragPlane = new Plane(((Vector3)(ref val2)).normalized, gizmoPivot); float num4 = default(float); if (!((Plane)(ref _dragPlane)).Raycast(val, ref num4)) { return false; } _dragStartAxisParameter = Vector3.Dot(((Ray)(ref val)).GetPoint(num4) - gizmoPivot, _dragWorldAxis); } else { if (Mathf.Abs(Vector3.Dot(_dragWorldAxis, ((Component)camera).transform.forward)) < 0.12f) { Vector3 val3 = camera.WorldToScreenPoint(gizmoPivot); Vector3 val4 = camera.WorldToScreenPoint(gizmoPivot + _dragWorldAxis) - val3; Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(val4.x, val4.y); _dragUsesScreenSpace = true; Vector2 dragScreenDirection; if (!(((Vector2)(ref val5)).sqrMagnitude > 0.001f)) { dragScreenDirection = Vector2.right; } else { Vector2 val6 = new Vector2(0f - val5.y, val5.x); dragScreenDirection = ((Vector2)(ref val6)).normalized; } _dragScreenDirection = dragScreenDirection; _dragScreenScale = 0.35f; } if (_dragUsesScreenSpace) { _dragAxis = axis; _gizmo.ActiveAxis = axis; return true; } _dragPlane = new Plane(_dragWorldAxis, gizmoPivot); float num5 = default(float); if (!((Plane)(ref _dragPlane)).Raycast(val, ref num5)) { return false; } Vector3 val7 = ((Ray)(ref val)).GetPoint(num5) - gizmoPivot; if (((Vector3)(ref val7)).sqrMagnitude < 0.0001f) { return false; } _dragStartVector = ((Vector3)(ref val7)).normalized; } _dragAxis = axis; _gizmo.ActiveAxis = axis; return true; } private void ContinueDrag(Camera camera) { //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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_012d: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008e: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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_020f: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0288: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) if (!HasGizmoTarget) { CancelDrag(); return; } bool flag; Vector3 val3; if (_dragAxis == GizmoAxis.Center) { flag = ContinueCenterDrag(camera); } else if (_mode == EditMode.Translate) { float num; if (_dragUsesScreenSpace) { num = Vector2.Dot(Vector2.op_Implicit(Input.mousePosition) - _dragStartMouse, _dragScreenDirection) * _dragScreenScale; } else { Ray val = camera.ScreenPointToRay(Input.mousePosition); float num2 = default(float); if (!((Plane)(ref _dragPlane)).Raycast(val, ref num2)) { return; } num = Vector3.Dot(((Ray)(ref val)).GetPoint(num2) - _dragStartPivot, _dragWorldAxis) - _dragStartAxisParameter; } Vector3 val2 = _dragStartRootPosition + _dragWorldAxis * num; flag = false; if (IsFinite(val2)) { val3 = _targetGhost.transform.position - val2; if (((Vector3)(ref val3)).sqrMagnitude > 1E-08f) { _targetGhost.transform.position = val2; _desiredPosition = val2; _surfaceSupportInvalid = false; flag = true; } } } else { float num3; if (_dragUsesScreenSpace) { num3 = Vector2.Dot(Vector2.op_Implicit(Input.mousePosition) - _dragStartMouse, _dragScreenDirection) * _dragScreenScale; } else { Ray val4 = camera.ScreenPointToRay(Input.mousePosition); float num4 = default(float); if (!((Plane)(ref _dragPlane)).Raycast(val4, ref num4)) { return; } Vector3 val5 = ((Ray)(ref val4)).GetPoint(num4) - _dragStartPivot; if (((Vector3)(ref val5)).sqrMagnitude <= 0.0001f) { return; } num3 = Vector3.SignedAngle(_dragStartVector, ((Vector3)(ref val5)).normalized, _dragWorldAxis); } float rotationStep = GetRotationStep(); if (rotationStep > 0f) { num3 = Mathf.Round(num3 / rotationStep) * rotationStep; } Quaternion val6 = Quaternion.AngleAxis(num3, _dragWorldAxis); Quaternion val7 = val6 * _dragStartRotation; Vector3 val8 = _dragStartPivot + val6 * (_dragStartRootPosition - _dragStartPivot); flag = false; if (IsFinite(val7) && IsFinite(val8)) { if (!(Quaternion.Angle(_targetGhost.transform.rotation, val7) > 0.001f)) { val3 = _targetGhost.transform.position - val8; if (!(((Vector3)(ref val3)).sqrMagnitude > 1E-08f)) { goto IL_029e; } } _targetGhost.transform.SetPositionAndRotation(val8, val7); _desiredPosition = val8; _desiredRotation = val7; if (!_hasTemporaryPivot) { _surfaceSupportInvalid = false; } flag = true; } } goto IL_029e; IL_029e: if (flag && (Object)(object)Player.m_localPlayer != (Object)null) { ValidateEditedGhost(Player.m_localPlayer, _targetPiece, flashGuardStone: false); } } private bool ContinueCenterDrag(Camera camera) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0098: 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) if (_surfaceSnapEnabled) { return TryUpdateSurfaceSnap(camera); } Ray val = camera.ScreenPointToRay(Input.mousePosition); float num = default(float); if (!((Plane)(ref _dragPlane)).Raycast(val, ref num)) { return false; } Vector3 val2 = ((Ray)(ref val)).GetPoint(num) - _dragStartPlanePoint; Vector3 val3 = _dragStartRootPosition + val2; if (IsFinite(val3)) { Vector3 val4 = _targetGhost.transform.position - val3; if (!(((Vector3)(ref val4)).sqrMagnitude <= 1E-08f)) { ClearTemporaryPivot(); _targetGhost.transform.position = val3; _desiredPosition = val3; return true; } } return false; } private bool TryUpdateSurfaceSnap(Camera camera) { //IL_0012: 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_0035: 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_003c: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_00ab: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0143: 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_0149: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0246: 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_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_027f: 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_0286: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !TryGetSurfaceHit(localPlayer, camera.ScreenPointToRay(Input.mousePosition), camera, out var result)) { return false; } Transform transform = _targetGhost.transform; Vector3 position = transform.position; Vector3 gizmoPivot = GizmoPivot; bool surfaceSupportInvalid = _surfaceSupportInvalid; Quaternion dragStartRotation = _dragStartRotation; Piece val = (((Object)(object)((RaycastHit)(ref result)).collider != (Object)null) ? ((Component)((RaycastHit)(ref result)).collider).GetComponentInParent() : null); WearNTear val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); bool flag = (Object)(object)val2 != (Object)null && !val2.m_supports; Vector3 val3 = ((RaycastHit)(ref result)).point + ((RaycastHit)(ref result)).normal * 50f; transform.SetPositionAndRotation(val3, dragStartRotation); bool flag2 = false; float num = float.MaxValue; Vector3 val4 = ((RaycastHit)(ref result)).point; Collider[] targetColliders = _targetColliders; Vector3 val8; foreach (Collider val5 in targetColliders) { if ((Object)(object)val5 == (Object)null || !val5.enabled || !((Component)val5).gameObject.activeInHierarchy || val5.isTrigger) { continue; } MeshCollider val6 = (MeshCollider)(object)((val5 is MeshCollider) ? val5 : null); if (val6 == null || val6.convex) { Vector3 val7 = val5.ClosestPoint(((RaycastHit)(ref result)).point); val8 = val7 - ((RaycastHit)(ref result)).point; float sqrMagnitude = ((Vector3)(ref val8)).sqrMagnitude; if (IsFinite(val7) && sqrMagnitude < num) { flag2 = true; num = sqrMagnitude; val4 = val7; } } } Vector3 val9 = (flag2 ? (((RaycastHit)(ref result)).point + (val3 - val4)) : ((RaycastHit)(ref result)).point); if (!IsFinite(val9)) { transform.SetPositionAndRotation(position, dragStartRotation); return false; } if (!IsPositionWithinEditorRange(localPlayer, val9)) { transform.SetPositionAndRotation(position, dragStartRotation); return false; } transform.SetPositionAndRotation(val9, dragStartRotation); Vector3 val10 = ((RaycastHit)(ref result)).point; if (TryFindClosestBuildSnap(out var source, out var destination)) { Vector3 val11 = destination.position - (source.position - val9); if (IsFinite(val11) && IsPositionWithinEditorRange(localPlayer, val11) && !IsOverlappingOtherPiece(val11, dragStartRotation)) { val9 = (transform.position = val11); val10 = destination.position; } } _desiredPosition = val9; _desiredRotation = dragStartRotation; SetTemporaryPivot(val10); _surfaceSupportInvalid = flag; val8 = position - val9; if (!(((Vector3)(ref val8)).sqrMagnitude > 1E-08f)) { val8 = gizmoPivot - val10; if (!(((Vector3)(ref val8)).sqrMagnitude > 1E-08f)) { return surfaceSupportInvalid != flag; } } return true; } private bool TryGetSurfaceHit(Player player, Ray ray, Camera camera, out RaycastHit result) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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) float num = (((Object)(object)_targetPiece != (Object)null) ? Mathf.Max(0f, (float)_targetPiece.m_extraPlacementDistance) : 0f); float num2 = Mathf.Clamp(Vector3.Distance(((Component)camera).transform.position, ((Component)player).transform.position) + GetEditorRange() + num + 5f, 10f, 500f); int num3; while (true) { num3 = Physics.RaycastNonAlloc(ray, _surfaceRaycastBuffer, num2, PlaceRayMask.Invoke(player), (QueryTriggerInteraction)0); if (num3 < _surfaceRaycastBuffer.Length || _surfaceRaycastBuffer.Length >= 2048) { break; } Array.Resize(ref _surfaceRaycastBuffer, _surfaceRaycastBuffer.Length * 2); } bool result2 = false; float num4 = float.MaxValue; result = default(RaycastHit); for (int i = 0; i < num3; i++) { RaycastHit val = _surfaceRaycastBuffer[i]; Collider collider = ((RaycastHit)(ref val)).collider; if (!((Object)(object)collider == (Object)null) && !((Object)(object)collider.attachedRigidbody != (Object)null) && !((Object)(object)((Component)collider).transform == (Object)(object)_targetGhost.transform) && !((Component)collider).transform.IsChildOf(_targetGhost.transform) && !(((RaycastHit)(ref val)).distance >= num4)) { result = val; num4 = ((RaycastHit)(ref val)).distance; result2 = true; } } return result2; } private bool TryFindClosestBuildSnap(out Transform source, out Transform destination) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) _sourceSnapPoints.Clear(); _destinationSnapPoints.Clear(); _nearbyPieces.Clear(); _nearbyPieceSet.Clear(); _targetPiece.GetSnapPoints(_sourceSnapPoints); int num = FillSnapPieceBuffer(_targetGhost.transform.position); for (int i = 0; i < num; i++) { Collider val = _snapPieceBuffer[i]; Piece val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInParent() : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)_targetPiece) && _nearbyPieceSet.Add(val2)) { val2.GetSnapPoints(_destinationSnapPoints); _nearbyPieces.Add(val2); } } source = null; destination = null; float num2 = 0.25f; float num3 = float.MaxValue; foreach (Transform sourceSnapPoint in _sourceSnapPoints) { if ((Object)(object)sourceSnapPoint == (Object)null) { continue; } foreach (Transform destinationSnapPoint in _destinationSnapPoints) { if (!((Object)(object)destinationSnapPoint == (Object)null) && !((Object)(object)destinationSnapPoint == (Object)(object)sourceSnapPoint) && !destinationSnapPoint.IsChildOf(_targetGhost.transform)) { Vector3 val3 = sourceSnapPoint.position - destinationSnapPoint.position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude <= num2 && sqrMagnitude < num3) { num3 = sqrMagnitude; source = sourceSnapPoint; destination = destinationSnapPoint; } } } } if ((Object)(object)source != (Object)null) { return (Object)(object)destination != (Object)null; } return false; } private int FillSnapPieceBuffer(Vector3 center) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) int num; while (true) { num = Physics.OverlapSphereNonAlloc(center, 10f, _snapPieceBuffer, _pieceLayerMask, (QueryTriggerInteraction)0); if (num < _snapPieceBuffer.Length || _snapPieceBuffer.Length >= 16384) { break; } Array.Resize(ref _snapPieceBuffer, Mathf.Min(_snapPieceBuffer.Length * 2, 16384)); } return num; } private bool IsOverlappingOtherPiece(Vector3 position, Quaternion rotation) { //IL_0030: 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_0041: 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_0085: Unknown result type (might be due to invalid IL or missing references) foreach (Piece nearbyPiece in _nearbyPieces) { if (!((Object)(object)nearbyPiece == (Object)null) && !((Object)(object)nearbyPiece == (Object)(object)_targetPiece)) { Vector3 val = position - ((Component)nearbyPiece).transform.position; if (!(((Vector3)(ref val)).sqrMagnitude >= 0.0025f) && Utils.CustomStartsWith(((Object)((Component)nearbyPiece).gameObject).name, ((Object)_targetGhost).name) && (!_targetPiece.m_allowRotatedOverlap || Quaternion.Angle(((Component)nearbyPiece).transform.rotation, rotation) <= 10f)) { return true; } } } return false; } private void SetTemporaryPivot(Vector3 worldPosition) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) if (!HasGizmoTarget || !IsFinite(worldPosition)) { ClearTemporaryPivot(); return; } Vector3 val = _targetGhost.transform.InverseTransformPoint(worldPosition); if (!IsFinite(val)) { ClearTemporaryPivot(); return; } _temporaryPivotLocal = val; _hasTemporaryPivot = true; } private void ClearTemporaryPivot(bool clearSurfaceSupport = true) { //IL_0012: 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) _hasTemporaryPivot = false; if (clearSurfaceSupport) { _surfaceSupportInvalid = false; } _temporaryPivotLocal = Vector3.zero; } private static bool IsPositionWithinEditorRange(Player player, Vector3 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) //IL_0020: Unknown result type (might be due to invalid IL or missing references) float editorRange = GetEditorRange(); if ((Object)(object)player != (Object)null) { Vector3 val = position - ((Component)player).transform.position; return ((Vector3)(ref val)).sqrMagnitude <= editorRange * editorRange; } return false; } private static float GetRotationStep() { float value = Plugin.RotationSnap.Value; if (float.IsNaN(value) || float.IsInfinity(value)) { return 5f; } if (value <= 0f) { return 0f; } return Mathf.Clamp(value, 0.1f, 360f); } private void CancelDrag() { _dragAxis = GizmoAxis.None; _dragUsesScreenSpace = false; if ((Object)(object)_gizmo != (Object)null) { _gizmo.ActiveAxis = GizmoAxis.None; } } internal void UpdatePlayerPlacement(Player player, float dt) { //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) _copiedPieceThisPlacementUpdate = false; _hasSampledPlacementRotation = false; _sampledCopySucceededThisPlacementUpdate = false; if (!_active || (Object)(object)player != (Object)(object)Player.m_localPlayer || _placementUpdateFailed || IsGameUiBlockingEditorInput() || Time.frameCount <= _uiInputBlockedThroughFrame || Time.frameCount <= _placementInputBlockedThroughFrame) { return; } HandlePlayerHotkeys(player); if (!((Character)player).InPlaceMode()) { ExitEditor(); return; } bool flag = IsVanillaCopyRequested(); if (Input.GetMouseButton(1) || _rightMouseActive || _dragAxis != GizmoAxis.None || IsPointerOverToolbar() || (!flag && IsPointerOverGizmo())) { return; } if (UpdatePlacementInvoker == null) { _placementUpdateFailed = true; Plugin.LogError("Player.UpdatePlacement(bool,float) was not found"); ExitEditor(); return; } try { bool flag2 = HasGizmoTarget && !Hud.IsPieceSelectionVisible(); PlacementRotationSnapshot snapshot = (flag2 ? CapturePlacementRotation(player) : default(PlacementRotationSnapshot)); Transform val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform : null); Quaternion rotation = default(Quaternion); bool flag3 = false; if ((Object)(object)val != (Object)null && ShouldRenderEditorOverlay && !Hud.IsPieceSelectionVisible()) { Camera editorCamera = EditorCamera; if ((Object)(object)editorCamera != (Object)null) { Ray val2 = editorCamera.ScreenPointToRay(Input.mousePosition); if (IsFinite(((Ray)(ref val2)).direction)) { Vector3 direction = ((Ray)(ref val2)).direction; if (((Vector3)(ref direction)).sqrMagnitude > 0.0001f) { rotation = val.rotation; val.rotation = Quaternion.LookRotation(((Ray)(ref val2)).direction, ((Component)editorCamera).transform.up); flag3 = true; } } } } _insidePlacementUpdate = true; try { UpdatePlacementInvoker(player, arg2: true, dt); } finally { _insidePlacementUpdate = false; if (_sampledCopySucceededThisPlacementUpdate && _hasSampledPlacementRotation) { FinalizeSampledPlacementState(player); } else if (flag2 && !_copiedPieceThisPlacementUpdate) { RestorePlacementRotation(player, snapshot); } _copiedPieceThisPlacementUpdate = false; _hasSampledPlacementRotation = false; _sampledCopySucceededThisPlacementUpdate = false; if (flag3 && (Object)(object)val != (Object)null) { val.rotation = rotation; } } } catch (Exception arg) { _placementUpdateFailed = true; Plugin.LogError($"Player.UpdatePlacement failed: {arg}"); ((Character)player).Message((MessageType)1, _language.PlacementError, 0, (Sprite)null); ExitEditor(); } } private static void HandlePlayerHotkeys(Player player) { for (int i = 0; i < HotbarButtons.Length; i++) { if (Input.GetKeyDown(HotbarKeys[i]) || ZInput.GetButtonDown(HotbarButtons[i])) { player.UseHotbarItem(i + 1); break; } } if ((ZInput.GetButtonDown("Hide") || ZInput.GetButtonDown("JoyHide")) && !((Character)player).InAttack()) { ((Humanoid)player).HideHandItems(false, true); } } private static bool IsVanillaCopyRequested() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) bool num = (ZInput.GetButtonDown("Remove") || ZInput.GetButtonDown("JoyRemove")) && (ZInput.GetButton("AltPlace") || ZInput.GetButton("JoyAltKeys")) && ((int)ZInput.InputLayout == 0 || !ZInput.IsGamepadActive()); bool flag = ZInput.GetButton("JoyAltKeys") && (ZInput.GetButtonDown("Attack") || ZInput.GetButtonDown("JoyPlace")) && !Hud.InRadial(); return num || flag; } internal bool ShouldBlockVanillaPlacement(Player player) { if (!_active || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return false; } if (IsCurrentGhostOutsideEditorRange(player)) { ((Character)player).Message((MessageType)2, "$msg_invalidplacement", 0, (Sprite)null); return true; } if (IsCameraCaptured || _dragAxis != GizmoAxis.None || IsPointerOverToolbar() || IsPointerOverGizmo()) { return true; } return false; } internal void OnVanillaPlacementSucceeded(Player player) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0056: Unknown result type (might be due to invalid IL or missing references) if (_active && !((Object)(object)player != (Object)(object)Player.m_localPlayer) && HasGizmoTarget) { Transform transform = _targetGhost.transform; Vector3 position = transform.position; Quaternion rotation = transform.rotation; if (!IsFinite(position) || !IsFinite(rotation)) { ClearPlacementGhostTarget(); return; } _desiredPosition = position; _desiredRotation = rotation; CancelDrag(); _hasCachedPlacementStatus = false; ValidateEditedGhost(player, _targetPiece, flashGuardStone: false); } } internal bool TryCaptureSampledPiecePose(Player player, Piece source, out Vector3 position, out Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; rotation = Quaternion.identity; if (!_active || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer || (Object)(object)source == (Object)null) { return false; } position = ((Component)source).transform.position; rotation = ((Component)source).transform.rotation; if (IsFinite(position)) { return IsFinite(rotation); } return false; } internal void OnVanillaPieceSampled(Player player, Vector3 position, Quaternion rotation) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0086: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (!_active || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer || !IsFinite(position) || !IsFinite(rotation)) { return; } _copiedPieceThisPlacementUpdate = true; _hasSampledPlacementRotation = true; _sampledPlacementRotation = rotation; ClearPlacementGhostTarget(); GameObject placementGhost = GetPlacementGhost(player); Piece selectedPiece = player.GetSelectedPiece(); if (!((Object)(object)placementGhost == (Object)null) && !((Object)(object)selectedPiece == (Object)null) && IsSelectedPieceGizmoCompatible(selectedPiece)) { SetPlacementGhostTarget(placementGhost, selectedPiece); if (HasGizmoTarget) { _desiredPosition = position; _desiredRotation = rotation; _surfaceSupportInvalid = false; _hasCachedPlacementStatus = false; _targetGhost.transform.SetPositionAndRotation(position, rotation); } } } internal void OnVanillaCopyCompleted(Player player, bool succeeded) { if (succeeded && _hasSampledPlacementRotation && _active && !((Object)(object)player == (Object)null) && !((Object)(object)player != (Object)(object)Player.m_localPlayer)) { _sampledPlaceRotation = PlaceRotation.Invoke(player); _sampledCopySucceededThisPlacementUpdate = true; if (!_insidePlacementUpdate) { FinalizeSampledPlacementState(player); _copiedPieceThisPlacementUpdate = false; _hasSampledPlacementRotation = false; _sampledCopySucceededThisPlacementUpdate = false; } } } private void FinalizeSampledPlacementState(Player player) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) PlaceRotation.Invoke(player) = _sampledPlaceRotation; ScrollCurrentAmount.Invoke(player) = 0f; RotatePieceTimer.Invoke(player) = 0f; SynchronizePerfectPlacementRotation(player, _sampledPlacementRotation); } private void RefreshPlacementGhostReference(Player player) { GameObject placementGhost = GetPlacementGhost(player); Piece selectedPiece = player.GetSelectedPiece(); if ((Object)(object)_targetSelectedPiece != (Object)null && (Object)(object)selectedPiece != (Object)(object)_targetSelectedPiece) { ClearPlacementGhostTarget(); } else if ((Object)(object)_targetSelectedPiece != (Object)null && (Object)(object)placementGhost != (Object)null && (Object)(object)placementGhost != (Object)(object)_targetGhost && !TryRetargetPlacementGhost(placementGhost, selectedPiece)) { ClearPlacementGhostTarget(); } else if ((Object)(object)_targetSelectedPiece != (Object)null && (Object)(object)placementGhost == (Object)null && (Object)(object)_targetGhost == (Object)null && _targetGhost != null) { DetachDestroyedPlacementGhost(); } if ((Object)(object)_targetSelectedPiece == (Object)null && (Object)(object)placementGhost == (Object)null) { SetTargetStatus(TargetStatusKind.NoGhost); } } internal void ApplyGhostOverride(Player player, bool flashGuardStone) { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Invalid comparison between Unknown and I4 //IL_0135: 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) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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) if (!_active || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return; } GameObject placementGhost = GetPlacementGhost(player); if (_blueGhostPreviewEnabled) { _placementGhostVisual.Sync(placementGhost); } Piece selectedPiece = player.GetSelectedPiece(); if ((Object)(object)_targetSelectedPiece != (Object)null && (Object)(object)_targetSelectedPiece != (Object)(object)selectedPiece) { ClearPlacementGhostTarget(); } else if ((Object)(object)_targetSelectedPiece != (Object)null && (Object)(object)placementGhost != (Object)(object)_targetGhost) { if ((Object)(object)placementGhost == (Object)null) { return; } if (!TryRetargetPlacementGhost(placementGhost, selectedPiece)) { ClearPlacementGhostTarget(); } } else if ((Object)(object)_targetSelectedPiece != (Object)null && (Object)(object)_targetGhost == (Object)null && _targetGhost != null) { DetachDestroyedPlacementGhost(); } bool flag = IsSelectedPieceGizmoCompatible(selectedPiece); if ((Object)(object)_targetSelectedPiece == (Object)null && (Object)(object)placementGhost != (Object)null && flag && (int)player.GetPlacementStatus() != 12) { SetPlacementGhostTarget(placementGhost, selectedPiece); } if (!HasGizmoTarget || (Object)(object)placementGhost != (Object)(object)_targetGhost) { if ((Object)(object)placementGhost != (Object)null && (Object)(object)selectedPiece != (Object)null && !flag) { SetTargetStatus(TargetStatusKind.SpecialPiece); } return; } Transform transform = _targetGhost.transform; Vector3 val = transform.position - _desiredPosition; if (((Vector3)(ref val)).sqrMagnitude > 1E-08f || Quaternion.Angle(transform.rotation, _desiredRotation) > 0.001f) { transform.SetPositionAndRotation(_desiredPosition, _desiredRotation); } if (!_targetGhost.activeSelf) { _targetGhost.SetActive(true); } GameObject val2 = PlacementMarker.Invoke(player); if ((Object)(object)val2 != (Object)null && val2.activeSelf) { val2.SetActive(false); } if (!_hasCachedPlacementStatus || flashGuardStone) { ValidateEditedGhost(player, _targetPiece, flashGuardStone); } else { RestoreCachedPlacementStatus(player, _targetPiece); } } internal bool ShouldSkipVanillaGhostUpdate(Player player) { if (_active && (Object)(object)player == (Object)(object)Player.m_localPlayer && HasGizmoTarget && (Object)(object)GetPlacementGhost(player) == (Object)(object)_targetGhost) { return (Object)(object)player.GetSelectedPiece() == (Object)(object)_targetSelectedPiece; } return false; } internal bool TryGetFinalPlacementPose(Player player, Piece selectedPiece, out Vector3 position, out Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; rotation = Quaternion.identity; if (!_active || (Object)(object)player != (Object)(object)Player.m_localPlayer || !HasGizmoTarget || (Object)(object)selectedPiece == (Object)null || (Object)(object)selectedPiece != (Object)(object)_targetSelectedPiece || (Object)(object)GetPlacementGhost(player) != (Object)(object)_targetGhost || !IsFinite(_desiredPosition) || !IsFinite(_desiredRotation)) { return false; } position = _desiredPosition; rotation = _desiredRotation; return true; } internal void EnforceEditorRange(Player player) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (_active && !((Object)(object)player != (Object)(object)Player.m_localPlayer) && IsCurrentGhostOutsideEditorRange(player)) { PlacementStatus.Invoke(player) = (PlacementStatus)1; GameObject placementGhost = GetPlacementGhost(player); Piece val = (((Object)(object)placementGhost != (Object)null) ? placementGhost.GetComponent() : null); if ((Object)(object)val != (Object)null) { val.SetInvalidPlacementHeightlight(true); } if ((Object)(object)placementGhost == (Object)(object)_targetGhost) { _cachedPlacementStatus = (PlacementStatus)1; _hasCachedPlacementStatus = true; } } } private void SetPlacementGhostTarget(GameObject ghost, Piece selectedPiece) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) ClearTemporaryPivot(); _targetGhost = ghost; _targetPiece = ghost.GetComponent(); _targetSelectedPiece = selectedPiece; if ((Object)(object)_targetPiece == (Object)null) { ClearPlacementGhostTarget(); return; } _desiredPosition = ghost.transform.position; _desiredRotation = ghost.transform.rotation; _targetColliders = ghost.GetComponentsInChildren(true); SetTargetStatus(TargetStatusKind.Piece, GetPieceStatusToken(_targetPiece, ghost)); CancelDrag(); } private bool TryRetargetPlacementGhost(GameObject ghost, Piece selectedPiece) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ghost == (Object)null || (Object)(object)_targetSelectedPiece == (Object)null || (Object)(object)selectedPiece != (Object)(object)_targetSelectedPiece || !IsFinite(_desiredPosition) || !IsFinite(_desiredRotation)) { return false; } Piece component = ghost.GetComponent(); if ((Object)(object)component == (Object)null || !IsSelectedPieceGizmoCompatible(selectedPiece)) { return false; } _targetGhost = ghost; _targetPiece = component; _targetColliders = ghost.GetComponentsInChildren(true); ghost.transform.SetPositionAndRotation(_desiredPosition, _desiredRotation); _hasCachedPlacementStatus = false; SetTargetStatus(TargetStatusKind.Piece, GetPieceStatusToken(_targetPiece, ghost)); CancelDrag(); return true; } private void ReleasePlacementGhost() { ClearPlacementGhostTarget(); } private void DetachDestroyedPlacementGhost() { _targetGhost = null; _targetPiece = null; _targetColliders = Array.Empty(); _hasCachedPlacementStatus = false; CancelDrag(); if ((Object)(object)_gizmo != (Object)null) { _gizmo.HoveredAxis = GizmoAxis.None; } } private void ClearPlacementGhostTarget() { ClearTemporaryPivot(); _targetGhost = null; _targetPiece = null; _targetSelectedPiece = null; _hasCachedPlacementStatus = false; _targetColliders = Array.Empty(); SetTargetStatus(TargetStatusKind.NoGhost); CancelDrag(); if ((Object)(object)_gizmo != (Object)null) { _gizmo.HoveredAxis = GizmoAxis.None; } } private void SetTargetStatus(TargetStatusKind kind, string pieceToken = null) { if (_targetStatusKind != kind || !string.Equals(_targetStatusPieceToken, pieceToken, StringComparison.Ordinal)) { _targetStatusKind = kind; _targetStatusPieceToken = pieceToken; RefreshTargetStatusText(); } } private void RefreshTargetStatusText() { string text; switch (_targetStatusKind) { case TargetStatusKind.SpecialPiece: text = _language.SpecialPiece; break; case TargetStatusKind.Piece: { string text2 = _targetStatusPieceToken ?? string.Empty; if (text2.IndexOf('$') >= 0) { string text3 = Localization.instance.Localize(text2); if (!string.IsNullOrEmpty(text3)) { text2 = text3; } } text = _language.PiecePrefix + text2; break; } default: text = _language.NoGhost; break; } _targetStatusText = text + _language.ToolbarHelp; } private static string GetPieceStatusToken(Piece piece, GameObject ghost) { if ((Object)(object)piece != (Object)null && !string.IsNullOrEmpty(piece.m_name)) { return piece.m_name; } if (!((Object)(object)ghost != (Object)null)) { return string.Empty; } return ((Object)ghost).name.Replace("(Clone)", string.Empty); } private void ValidateEditedGhost(Player player, Piece piece, bool flashGuardStone) { //IL_0010: 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_0017: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0085: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00fd: 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_0116: Expected I4, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Invalid comparison between Unknown and I4 //IL_00fa: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)piece == (Object)null)) { Vector3 position = ((Component)piece).transform.position; PlacementStatus val = (PlacementStatus)0; float editorRange = GetEditorRange(); Vector3 val2 = position - ((Component)player).transform.position; if (((Vector3)(ref val2)).sqrMagnitude > editorRange * editorRange) { val = (PlacementStatus)1; } if (_surfaceSupportInvalid) { val = (PlacementStatus)1; } if (!piece.m_allowedInDungeons && ((Character)player).InInterior() && !EnvMan.instance.CheckInteriorBuildingOverride() && !ZoneSystem.instance.GetGlobalKey((GlobalKeys)29)) { val = (PlacementStatus)11; } if ((int)piece.m_onlyInBiome != 0 && (Heightmap.FindBiome(position) & piece.m_onlyInBiome) == 0) { val = (PlacementStatus)8; } if (Location.IsInsideNoBuildLocation(position)) { val = (PlacementStatus)3; } PrivateArea component = ((Component)piece).GetComponent(); float num = (((Object)(object)component != (Object)null) ? component.m_radius : 0f); if (!PrivateArea.CheckAccess(position, num, flashGuardStone, (Object)(object)component != (Object)null)) { val = (PlacementStatus)4; } if (CheckEditedGhostVsCharacters(((Component)piece).gameObject, position)) { val = (PlacementStatus)2; } if (piece.m_noClipping && TestEditedGhostClipping(player, ((Component)piece).gameObject, 0.2f)) { val = (PlacementStatus)1; } _cachedPlacementStatus = val; _hasCachedPlacementStatus = true; PlacementStatus.Invoke(player) = (PlacementStatus)(int)val; piece.SetInvalidPlacementHeightlight((int)val > 0); } } private void RestoreCachedPlacementStatus(Player player, Piece piece) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown //IL_0019: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 PlacementStatus placementStatus = player.GetPlacementStatus(); PlacementStatus.Invoke(player) = (PlacementStatus)(int)_cachedPlacementStatus; bool num = (int)placementStatus > 0; bool flag = (int)_cachedPlacementStatus > 0; if (num != flag) { piece.SetInvalidPlacementHeightlight(flag); } } private bool CheckEditedGhostVsCharacters(GameObject ghost, Vector3 position) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) _nearbyCharacters.Clear(); Character.GetCharactersInRange(position, 30f, _nearbyCharacters); Collider[] targetColliders = _targetColliders; Vector3 val4 = default(Vector3); float num = default(float); foreach (Collider val in targetColliders) { if ((Object)(object)val == (Object)null || !val.enabled || !((Component)val).gameObject.activeInHierarchy || val.isTrigger || (Object)(object)((Component)val).gameObject == (Object)(object)ghost) { continue; } MeshCollider val2 = (MeshCollider)(object)((val is MeshCollider) ? val : null); if (val2 != null && !val2.convex) { continue; } foreach (Character nearbyCharacter in _nearbyCharacters) { CapsuleCollider val3 = (((Object)(object)nearbyCharacter != (Object)null) ? nearbyCharacter.GetCollider() : null); if (!((Object)(object)val3 == (Object)null) && ((Collider)val3).enabled && ((Component)val3).gameObject.activeInHierarchy && Physics.ComputePenetration(val, ((Component)val).transform.position, ((Component)val).transform.rotation, (Collider)(object)val3, ((Component)val3).transform.position, ((Component)val3).transform.rotation, ref val4, ref num)) { return true; } } } return false; } private bool TestEditedGhostClipping(Player player, GameObject ghost, float maxPenetration) { //IL_0006: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) int num; while (true) { num = Physics.OverlapSphereNonAlloc(ghost.transform.position, 10f, _clippingBuffer, PlaceRayMask.Invoke(player), (QueryTriggerInteraction)0); if (num < _clippingBuffer.Length || _clippingBuffer.Length >= 32768) { break; } Array.Resize(ref _clippingBuffer, Mathf.Min(_clippingBuffer.Length * 2, 32768)); } Collider[] array = _clippingBuffer; if (num == _clippingBuffer.Length) { array = Physics.OverlapSphere(ghost.transform.position, 10f, PlaceRayMask.Invoke(player), (QueryTriggerInteraction)0); num = array.Length; int newSize = num + Mathf.Max(256, num / 2); Array.Resize(ref array, newSize); _clippingBuffer = array; } Collider[] targetColliders = _targetColliders; Vector3 val3 = default(Vector3); float num2 = default(float); foreach (Collider val in targetColliders) { if ((Object)(object)val == (Object)null || !val.enabled || !((Component)val).gameObject.activeInHierarchy) { continue; } for (int j = 0; j < num; j++) { Collider val2 = array[j]; if (!((Object)(object)val2 == (Object)null) && val2.enabled && ((Component)val2).gameObject.activeInHierarchy && !((Object)(object)((Component)val2).transform == (Object)(object)ghost.transform) && !((Component)val2).transform.IsChildOf(ghost.transform) && Physics.ComputePenetration(val, ((Component)val).transform.position, ((Component)val).transform.rotation, val2, ((Component)val2).transform.position, ((Component)val2).transform.rotation, ref val3, ref num2) && num2 > maxPenetration) { return true; } } } return false; } internal static bool IsGizmoCompatiblePiece(Piece piece) { if ((Object)(object)piece != (Object)null && !piece.m_groundPiece && !piece.m_groundOnly && !piece.m_cultivatedGroundOnly && !piece.m_vegetationGroundOnly && !piece.m_waterPiece && !piece.m_onlyInTeleportArea && (!(piece.m_blockRadius > 0f) || piece.m_blockingPieces == null || piece.m_blockingPieces.Count <= 0) && (Object)(object)piece.m_mustConnectTo == (Object)null && !piece.m_repairPiece && !piece.m_removePiece && !piece.m_isUpgrade && !piece.m_harvest && (Object)(object)((Component)piece).GetComponentInChildren(true) == (Object)null && (Object)(object)((Component)piece).GetComponentInChildren(true) == (Object)null) { return (Object)(object)((Component)piece).GetComponentInChildren(true) == (Object)null; } return false; } private bool IsSelectedPieceGizmoCompatible(Piece piece) { if ((Object)(object)_observedSelectedPiece != (Object)(object)piece) { _observedSelectedPiece = piece; _observedSelectedPieceCompatible = IsGizmoCompatiblePiece(piece); } return _observedSelectedPieceCompatible; } private void BeginEditorEntry() { Player localPlayer = Player.m_localPlayer; RefreshEditorLanguage(); if ((Object)(object)localPlayer == (Object)null || (Object)(object)GameCamera.instance == (Object)null || (Object)(object)ResolveGameCamera() == (Object)null || ((Character)localPlayer).IsDead() || ((Character)localPlayer).InCutscene() || ((Character)localPlayer).IsTeleporting() || IsGameUiBlockingEditorInput()) { return; } if (IsConflictingEditorActive()) { ((Character)localPlayer).Message((MessageType)1, _language.DisableConflictingEditor, 0, (Sprite)null); return; } if (IsBuildingHammer(((Humanoid)localPlayer).RightItem) && ((Character)localPlayer).InPlaceMode()) { EnterEditor(); return; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); ItemData val = FindBuildingHammer(inventory); if (val == null) { ((Character)localPlayer).Message((MessageType)1, _language.NoBuildingHammer, 0, (Sprite)null); return; } _editorEntryPending = true; _pendingEquipIssued = false; _pendingOwnEquipAction = false; _pendingEntryPlayer = localPlayer; _pendingEntryInventory = inventory; _pendingEntryHammer = val; _pendingEntryDeadline = Time.unscaledTime + 8f; UpdatePendingEditorEntry(); } private void UpdatePendingEditorEntry() { if (!_editorEntryPending) { return; } Player pendingEntryPlayer = _pendingEntryPlayer; Inventory pendingEntryInventory = _pendingEntryInventory; ItemData pendingEntryHammer = _pendingEntryHammer; if ((Object)(object)pendingEntryPlayer == (Object)null || Player.m_localPlayer != pendingEntryPlayer || ((Character)pendingEntryPlayer).IsDead() || ((Character)pendingEntryPlayer).InCutscene() || ((Character)pendingEntryPlayer).IsTeleporting() || IsGameUiBlockingEditorInput()) { CancelPendingEditorEntry(removeOwnedEquipAction: true); } else if (IsConflictingEditorActive()) { CancelPendingEditorEntry(removeOwnedEquipAction: true); ((Character)pendingEntryPlayer).Message((MessageType)1, _language.DisableConflictingEditor, 0, (Sprite)null); } else if (pendingEntryInventory == null || pendingEntryHammer == null || !pendingEntryInventory.ContainsItem(pendingEntryHammer) || !IsBuildingHammer(pendingEntryHammer)) { FailPendingEditorEntry(pendingEntryPlayer); } else if (IsHammerEquippedForBuilding(pendingEntryPlayer, pendingEntryHammer)) { CompletePendingEditorEntry(pendingEntryPlayer); } else if (Time.unscaledTime >= _pendingEntryDeadline) { FailPendingEditorEntry(pendingEntryPlayer); } else if (!_pendingEquipIssued) { if (!((Character)pendingEntryPlayer).InAttack() && !((Character)pendingEntryPlayer).InDodge() && (!((Character)pendingEntryPlayer).IsSwimming() || ((Character)pendingEntryPlayer).IsOnGround())) { bool num = pendingEntryPlayer.IsEquipActionQueued(pendingEntryHammer); _pendingEquipIssued = true; if (!num) { ((Humanoid)pendingEntryPlayer).UseItem(pendingEntryInventory, pendingEntryHammer, true); _pendingOwnEquipAction = pendingEntryPlayer.IsEquipActionQueued(pendingEntryHammer); } if (IsHammerEquippedForBuilding(pendingEntryPlayer, pendingEntryHammer)) { CompletePendingEditorEntry(pendingEntryPlayer); } else if (!pendingEntryPlayer.IsEquipActionQueued(pendingEntryHammer)) { FailPendingEditorEntry(pendingEntryPlayer); } } } else if (!pendingEntryPlayer.IsEquipActionQueued(pendingEntryHammer)) { FailPendingEditorEntry(pendingEntryPlayer); } } private void CompletePendingEditorEntry(Player player) { CancelPendingEditorEntry(removeOwnedEquipAction: false); if (Player.m_localPlayer == player && IsBuildingHammer(((Humanoid)player).RightItem) && ((Character)player).InPlaceMode()) { EnterEditor(); } } private void FailPendingEditorEntry(Player player) { CancelPendingEditorEntry(removeOwnedEquipAction: true); if (player != null) { ((Character)player).Message((MessageType)1, _language.HammerEquipFailed, 0, (Sprite)null); } } private void CancelPendingEditorEntry(bool removeOwnedEquipAction) { if (removeOwnedEquipAction && _pendingOwnEquipAction && (Object)(object)_pendingEntryPlayer != (Object)null && _pendingEntryHammer != null && _pendingEntryPlayer.IsEquipActionQueued(_pendingEntryHammer)) { ((Humanoid)_pendingEntryPlayer).RemoveEquipAction(_pendingEntryHammer); } _editorEntryPending = false; _pendingEquipIssued = false; _pendingOwnEquipAction = false; _pendingEntryPlayer = null; _pendingEntryInventory = null; _pendingEntryHammer = null; _pendingEntryDeadline = 0f; } private static ItemData FindBuildingHammer(Inventory inventory) { if (inventory == null) { return null; } List allItemsInGridOrder = inventory.GetAllItemsInGridOrder(); for (int i = 0; i < allItemsInGridOrder.Count; i++) { if (IsBuildingHammer(allItemsInGridOrder[i])) { return allItemsInGridOrder[i]; } } return null; } private static bool IsBuildingHammer(ItemData item) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if (item != null && item.m_shared != null && (int)item.m_shared.m_itemType == 19 && (Object)(object)item.m_shared.m_buildPieces != (Object)null && item.m_shared.m_buildPieces.m_canRemovePieces) { if (item.m_shared.m_useDurability) { return item.m_durability > 0f; } return true; } return false; } private static bool IsHammerEquippedForBuilding(Player player, ItemData hammer) { if ((Object)(object)player != (Object)null && ((Humanoid)player).RightItem == hammer && hammer.m_equipped) { return ((Character)player).InPlaceMode(); } return false; } private void EnterEditor() { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Camera val = ResolveGameCamera(); if ((Object)(object)localPlayer == (Object)null || (Object)(object)GameCamera.instance == (Object)null || (Object)(object)val == (Object)null) { return; } RefreshEditorLanguage(); if (!IsGameUiBlockingEditorInput()) { if (!((Character)localPlayer).InPlaceMode()) { ((Character)localPlayer).Message((MessageType)1, _language.EnterBuildModeFirst, 0, (Sprite)null); return; } if (IsConflictingEditorActive()) { ((Character)localPlayer).Message((MessageType)1, _language.DisableConflictingEditor, 0, (Sprite)null); return; } DestroyCameraLight(); _active = true; _placementUpdateFailed = false; _surfaceSnapEnabled = Plugin.StartWithSnap.Value; RefreshToolbarLabels(); _rightMouseActive = false; _rightMouseMoved = false; _cameraCapturedLastFrame = false; _cameraSpeedScale = 1f; _nextDemolitionPickupTime = 0f; _uiInputBlockedThroughFrame = -1; _placementInputBlockedThroughFrame = -1; _editorCamera = val; _observedSelectedPiece = null; _observedSelectedPieceCompatible = false; ClearPlacementGhostTarget(); Transform transform = ((Component)GameCamera.instance).transform; _cameraPosition = transform.position; Quaternion rotation = transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; _cameraYaw = eulerAngles.y; _cameraPitch = NormalizePitch(eulerAngles.x); _cameraPositionDirty = true; ((Behaviour)_gizmo).enabled = true; _distancePlayer = localPlayer; _originalPlaceDistance = MaximumPlaceDistance.Invoke(localPlayer); _appliedPlaceDistance = Mathf.Max(_originalPlaceDistance, GetEditorRange() + 2f); MaximumPlaceDistance.Invoke(localPlayer) = _appliedPlaceDistance; ((Character)localPlayer).Message((MessageType)1, _language.EditorEnabled, 0, (Sprite)null); } } private void ExitEditor() { DestroyCameraLight(); if (_active) { _placementGhostVisual.Restore(); ClearPlacementGhostTarget(); _reserveHotkeysThroughFrame = Time.frameCount; _active = false; _toolbarDragging = false; _rightMouseActive = false; _rightMouseMoved = false; _cameraCapturedLastFrame = false; _cameraPositionDirty = false; _insidePlacementUpdate = false; ((Behaviour)_gizmo).enabled = false; _editorCamera = null; if ((Object)(object)_distancePlayer != (Object)null && Mathf.Abs(MaximumPlaceDistance.Invoke(_distancePlayer) - _appliedPlaceDistance) < 0.01f) { MaximumPlaceDistance.Invoke(_distancePlayer) = _originalPlaceDistance; } _distancePlayer = null; if (Hud.IsPieceSelectionVisible() || IsGameUiBlockingEditorInput()) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } else { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, _language.EditorDisabled, 0, (Sprite)null); } } } internal void ForceExit() { CancelPendingEditorEntry(removeOwnedEquipAction: true); ExitEditor(); _demolitionPickupTransactions.Clear(); _demolitionPickupDrops.Clear(); } internal void UpdateMouseCapture() { //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_002a: 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) if (_active) { bool flag = IsCameraCaptured && !Hud.IsPieceSelectionVisible(); CursorLockMode val = (CursorLockMode)(flag ? 1 : 0); if (Cursor.lockState != val) { Cursor.lockState = val; } if (Cursor.visible == flag) { Cursor.visible = !flag; } } } internal void UpdateFreeCamera(float dt) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_023d: 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_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) if (!_active) { return; } bool flag = IsCameraCaptured && !Hud.IsPieceSelectionVisible(); Quaternion val = Quaternion.Euler(_cameraPitch, _cameraYaw, 0f); if (flag) { if (_cameraCapturedLastFrame) { float num = PlayerController.m_mouseSens * GetSafeConfigValue(Plugin.MouseSensitivity.Value, 2f, 0.01f, 20f); float axis = Input.GetAxis("Mouse X"); float axis2 = Input.GetAxis("Mouse Y"); if (Mathf.Abs(axis) > 0.0001f || Mathf.Abs(axis2) > 0.0001f) { if (_rightMouseActive) { float rightMouseLookMagnitude = _rightMouseLookMagnitude; Vector2 val2 = new Vector2(axis, axis2); _rightMouseLookMagnitude = rightMouseLookMagnitude + ((Vector2)(ref val2)).magnitude; if (_rightMouseLookMagnitude >= 0.35f) { _rightMouseMoved = true; } } float num2 = (PlayerController.m_invertMouse ? (-1f) : 1f); _cameraYaw += axis * num; _cameraPitch = Mathf.Clamp(_cameraPitch - axis2 * num * num2, -89f, 89f); val = Quaternion.Euler(_cameraPitch, _cameraYaw, 0f); } } Vector3 val3 = Vector3.zero; if (ZInput.GetButton("Forward") || Input.GetKey((KeyCode)119)) { val3 += Vector3.forward; } if (ZInput.GetButton("Backward") || Input.GetKey((KeyCode)115)) { val3 += Vector3.back; } if (ZInput.GetButton("Right") || Input.GetKey((KeyCode)100)) { val3 += Vector3.right; } if (ZInput.GetButton("Left") || Input.GetKey((KeyCode)97)) { val3 += Vector3.left; } Vector3 val4 = val * val3; if (Input.GetKey((KeyCode)101) || Input.GetKey((KeyCode)32) || ZInput.GetButton("Jump")) { val4 += Vector3.up; } if (Input.GetKey((KeyCode)113) || Input.GetKey((KeyCode)306) || ZInput.GetButton("Crouch")) { val4 += Vector3.down; } if (((Vector3)(ref val4)).sqrMagnitude > 1f) { ((Vector3)(ref val4)).Normalize(); } float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) > 0.01f) { _cameraSpeedScale = Mathf.Clamp(_cameraSpeedScale * Mathf.Pow(1.2f, y), 0.2f, 10f); if (_rightMouseActive) { _rightMouseMoved = true; } } float num3 = GetSafeConfigValue(Plugin.CameraSpeed.Value, 12f, 0.1f, 500f) * _cameraSpeedScale; if (ZInput.GetButton("Run") || Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { num3 *= GetSafeConfigValue(Plugin.FastCameraMultiplier.Value, 3f, 1f, 20f); } if (((Vector3)(ref val4)).sqrMagnitude > 0f) { _cameraPosition += val4 * num3 * dt; _cameraPositionDirty = true; if (_rightMouseActive) { _rightMouseMoved = true; } } } _cameraCapturedLastFrame = flag; if (_cameraPositionDirty) { _cameraPosition = ConstrainCameraPosition(_cameraPosition); _cameraPositionDirty = false; } } internal void ApplyFinalCameraTransform(GameCamera gameCamera) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //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) if (_active && !((Object)(object)gameCamera == (Object)null)) { Quaternion val = Quaternion.Euler(_cameraPitch, _cameraYaw, 0f); ((Component)gameCamera).transform.SetPositionAndRotation(_cameraPosition, val); } } internal DemolitionPickupTransaction CaptureDemolitionPickup(Player player) { //IL_0039: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) if (!_active || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer || (Object)(object)GameCamera.instance == (Object)null) { return null; } Transform transform = ((Component)GameCamera.instance).transform; RaycastHit val = default(RaycastHit); if (!Physics.Raycast(transform.position, transform.forward, ref val, 50f, RemoveRayMask.Invoke(player)) || Vector3.Distance(((RaycastHit)(ref val)).point, ((Character)player).m_eye.position) >= MaximumPlaceDistance.Invoke(player)) { return null; } Piece val2 = (((Object)(object)((RaycastHit)(ref val)).collider != (Object)null) ? ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() : null); if ((Object)(object)val2 == (Object)null && (Object)(object)((RaycastHit)(ref val)).collider != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent() != (Object)null) { val2 = TerrainModifier.FindClosestModifierPieceInRange(((RaycastHit)(ref val)).point, 2.5f); } if ((Object)(object)val2 == (Object)null) { return null; } if ((Object)(object)val2.m_destroyedLootPrefab != (Object)null || ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGlobalKey(val2.FreeBuildKey()))) { return null; } DemolitionPickupTransaction demolitionPickupTransaction = new DemolitionPickupTransaction { Center = ((Component)val2).transform.position + Vector3.up * val2.m_returnResourceHeightOffset }; Feast component = ((Component)val2).GetComponent(); Requirement[] resources = val2.m_resources; foreach (Requirement val3 in resources) { if ((Object)(object)val3.m_resItem == (Object)null || !val3.m_recover) { continue; } int num = val3.m_amount; if ((Object)(object)component != (Object)null) { num = (int)Math.Floor((float)num * component.GetStackPercentige()); } if (num > 0) { if (!val2.IsPlacedByPlayer()) { num = Mathf.Max(1, num / 3); } string name = val3.m_resItem.m_itemData.m_shared.m_name; demolitionPickupTransaction.RemainingResources.TryGetValue(name, out var value); demolitionPickupTransaction.RemainingResources[name] = value + num; } } if (demolitionPickupTransaction.RemainingResources.Count == 0) { return null; } int num2 = FillDemolitionPickupBuffer(demolitionPickupTransaction.Center); for (int j = 0; j < num2; j++) { ItemDrop val4 = ResolveItemDrop(_demolitionPickupBuffer[j]); if ((Object)(object)val4 != (Object)null) { demolitionPickupTransaction.ExistingDropIds.Add(((Object)val4).GetInstanceID()); } } return demolitionPickupTransaction; } internal void CommitDemolitionPickup(DemolitionPickupTransaction transaction) { if (transaction != null) { transaction.ExpiresAt = Time.unscaledTime + 5f; if (_demolitionPickupTransactions.Count >= 32) { _demolitionPickupTransactions.RemoveAt(0); } _demolitionPickupTransactions.Add(transaction); _nextDemolitionPickupTime = 0f; UpdateDemolitionAutoPickupSafe(); } } private void UpdateDemolitionAutoPickupSafe() { if (_demolitionPickupTransactions.Count == 0 || Time.unscaledTime < _nextDemolitionPickupTime) { return; } try { UpdateDemolitionAutoPickup(); } catch (Exception arg) { _nextDemolitionPickupTime = Time.unscaledTime + 0.5f; if (Time.unscaledTime - _lastDemolitionPickupErrorTime >= 5f) { _lastDemolitionPickupErrorTime = Time.unscaledTime; Plugin.LogError($"Demolition resource pickup failed: {arg}"); } } } private void UpdateDemolitionAutoPickup() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) _nextDemolitionPickupTime = Time.unscaledTime + 0.1f; Player localPlayer = Player.m_localPlayer; for (int num = _demolitionPickupTransactions.Count - 1; num >= 0; num--) { if (Time.unscaledTime >= _demolitionPickupTransactions[num].ExpiresAt) { _demolitionPickupTransactions.RemoveAt(num); } } if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsTeleporting() || !EnableAutoPickup.Invoke() || _demolitionPickupTransactions.Count == 0) { return; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); _demolitionPickupDrops.Clear(); for (int num2 = _demolitionPickupTransactions.Count - 1; num2 >= 0; num2--) { DemolitionPickupTransaction demolitionPickupTransaction = _demolitionPickupTransactions[num2]; int num3 = FillDemolitionPickupBuffer(demolitionPickupTransaction.Center); for (int i = 0; i < num3; i++) { ItemDrop val = ResolveItemDrop(_demolitionPickupBuffer[i]); if ((Object)(object)val == (Object)null || demolitionPickupTransaction.ExistingDropIds.Contains(((Object)val).GetInstanceID()) || !val.m_autoPickup || val.IsPiece()) { continue; } ZNetView component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { continue; } val.Load(); string name = val.m_itemData.m_shared.m_name; int stack = val.m_itemData.m_stack; if (((Humanoid)localPlayer).HaveUniqueKey(name) || !demolitionPickupTransaction.RemainingResources.TryGetValue(name, out var value) || stack <= 0 || stack > value || !_demolitionPickupDrops.Add(val)) { continue; } if (!val.CanPickup(false)) { val.RequestOwn(); } else { if (val.InTar() || !inventory.CanAddItem(val.m_itemData, -1) || val.m_itemData.GetWeight(-1) + inventory.GetTotalWeight() > localPlayer.GetMaxCarryWeight()) { continue; } GameObject gameObject = ((Component)val).gameObject; if (((Humanoid)localPlayer).Pickup(gameObject, false, false)) { if ((Object)(object)gameObject != (Object)null) { gameObject.SetActive(false); } if (stack == value) { demolitionPickupTransaction.RemainingResources.Remove(name); } else { demolitionPickupTransaction.RemainingResources[name] = value - stack; } } } } if (demolitionPickupTransaction.RemainingResources.Count == 0) { _demolitionPickupTransactions.RemoveAt(num2); } } } private int FillDemolitionPickupBuffer(Vector3 center) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) int num; while (true) { num = Physics.OverlapSphereNonAlloc(center, 3f, _demolitionPickupBuffer, _itemLayerMask, (QueryTriggerInteraction)0); if (num < _demolitionPickupBuffer.Length || _demolitionPickupBuffer.Length >= 2048) { break; } Array.Resize(ref _demolitionPickupBuffer, _demolitionPickupBuffer.Length * 2); } return num; } private static ItemDrop ResolveItemDrop(Collider collider) { Rigidbody val = (((Object)(object)collider != (Object)null) ? collider.attachedRigidbody : null); if ((Object)(object)val == (Object)null) { return null; } ItemDrop component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { FloatingTerrainDummy component2 = ((Component)val).GetComponent(); if ((Object)(object)component2 != (Object)null && (Object)(object)component2.m_parent != (Object)null) { component = ((Component)component2.m_parent).gameObject.GetComponent(); } } return component; } private static Vector3 ConstrainCameraPosition(Vector3 position) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_001f: 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_000f: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return position; } Vector3 position2 = ((Component)localPlayer).transform.position; Vector3 val = position - position2; float editorRange = GetEditorRange(); if (((Vector3)(ref val)).sqrMagnitude > editorRange * editorRange) { position = position2 + ((Vector3)(ref val)).normalized * editorRange; } float num = default(float); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(position, ref num) && position.y < num + 0.1f) { position.y = num + 0.1f; } return position; } private void ToggleBuildMenu() { if ((Object)(object)Hud.instance != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null && ((Character)Player.m_localPlayer).InPlaceMode()) { Hud.instance.TogglePieceSelection(); } } private Vector3 GetWorldAxis(GizmoAxis axis) { //IL_0016: 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) //IL_000f: 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_002d: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (Vector3)(axis switch { GizmoAxis.Y => Vector3.up, GizmoAxis.X => Vector3.right, _ => Vector3.forward, }); if (_space != CoordinateSpace.Local || !HasGizmoTarget) { return val; } return _targetGhost.transform.rotation * val; } internal Vector3 GetDisplayAxis(GizmoAxis axis) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return GetWorldAxis(axis); } private bool IsPointerOverToolbar() { //IL_0014: 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) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!ShouldRenderToolbar) { return false; } if (_toolbarDragging) { return true; } Vector3 mousePosition = Input.mousePosition; return ((Rect)(ref _toolbarRect)).Contains(new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y)); } private bool IsPointerOverGizmo() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!ShouldRenderEditorOverlay) { return false; } Camera editorCamera = EditorCamera; if ((Object)(object)editorCamera != (Object)null && HasGizmoTarget) { return _gizmo.HitTest(editorCamera, Input.mousePosition) != GizmoAxis.None; } return false; } internal bool IsGameUiBlockingEditorInput() { if (!InventoryGui.IsVisible() && !Menu.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible() && !StoreGui.IsVisible() && !Minimap.IsOpen() && (!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && (!((Object)(object)TextViewer.instance != (Object)null) || !TextViewer.instance.IsVisible()) && !PlayerCustomizaton.IsBarberGuiVisible() && !UnifiedPopup.IsVisible() && !Hud.InRadial()) { return Game.IsPaused(); } return true; } internal bool ShouldConsumeEditorShortcutForExternalHotkeys(Player player) { if (!_active || (Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return false; } return EditorInputFirewall.IsAnyReservedInputHeld(); } internal void ReserveEscapeInput() { _suppressMenuFrame = Time.frameCount; } internal static void ReserveBuildMenuEscapeInput() { _buildMenuConsumedEscapeFrame = Time.frameCount; } private static float GetEditorRange() { return GetSafeConfigValue(Plugin.EditorRange.Value, 100f, 20f, 200f); } private static float GetSafeConfigValue(float value, float fallback, float minimum, float maximum) { if (!float.IsNaN(value) && !float.IsInfinity(value)) { return Mathf.Clamp(value, minimum, maximum); } return fallback; } private bool IsCurrentGhostOutsideEditorRange(Player player) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) GameObject placementGhost = GetPlacementGhost(player); if ((Object)(object)placementGhost == (Object)null || !placementGhost.activeInHierarchy) { return false; } float editorRange = GetEditorRange(); Vector3 val = placementGhost.transform.position - ((Component)player).transform.position; return ((Vector3)(ref val)).sqrMagnitude > editorRange * editorRange; } private static PlacementRotationSnapshot CapturePlacementRotation(Player player) { //IL_0085: 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) PlacementRotationSnapshot result = new PlacementRotationSnapshot { PlaceRotation = PlaceRotation.Invoke(player), ScrollCurrentAmount = ScrollCurrentAmount.Invoke(player), RotatePieceTimer = RotatePieceTimer.Invoke(player) }; EnsureExternalModeResolvers(); if (_perfectPlacementPlayersData == null || _perfectPlacementPlaceRotation == null) { return result; } try { result.PerfectPlacementAvailable = true; object obj = _perfectPlacementPlayersData[player]; if (obj != null) { result.PerfectPlacementHadEntry = true; result.PerfectPlacementRotation = _perfectPlacementPlaceRotation.Invoke(obj); } } catch { _perfectPlacementPlayersData = null; _perfectPlacementPlaceRotation = null; result.PerfectPlacementAvailable = false; } return result; } private static void RestorePlacementRotation(Player player, PlacementRotationSnapshot snapshot) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0084: 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_0091: Unknown result type (might be due to invalid IL or missing references) PlaceRotation.Invoke(player) = snapshot.PlaceRotation; ScrollCurrentAmount.Invoke(player) = snapshot.ScrollCurrentAmount; RotatePieceTimer.Invoke(player) = snapshot.RotatePieceTimer; if (!snapshot.PerfectPlacementAvailable || _perfectPlacementPlayersData == null || _perfectPlacementPlaceRotation == null) { return; } try { object obj = _perfectPlacementPlayersData[player]; if (obj != null) { Vector3 val = (snapshot.PerfectPlacementHadEntry ? snapshot.PerfectPlacementRotation : (Vector3.up * ((float)snapshot.PlaceRotation * 22.5f))); _perfectPlacementPlaceRotation.Invoke(obj) = val; } } catch { _perfectPlacementPlayersData = null; _perfectPlacementPlaceRotation = null; } } private static void SynchronizePerfectPlacementRotation(Player player, Quaternion sampledRotation) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) EnsureExternalModeResolvers(); if (_perfectPlacementPlayersData == null || _perfectPlacementPlaceRotation == null || !IsFinite(sampledRotation)) { return; } try { object obj = _perfectPlacementPlayersData[player]; if (obj != null) { _perfectPlacementPlaceRotation.Invoke(obj) = ((Quaternion)(ref sampledRotation)).eulerAngles; } } catch { _perfectPlacementPlayersData = null; _perfectPlacementPlaceRotation = null; } } private static float NormalizePitch(float angle) { if (!(angle > 180f)) { return angle; } return angle - 360f; } private static bool IsFinite(Vector3 value) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0041: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(value.x) && !float.IsInfinity(value.x) && !float.IsNaN(value.y) && !float.IsInfinity(value.y) && !float.IsNaN(value.z)) { return !float.IsInfinity(value.z); } return false; } private static bool IsFinite(Quaternion value) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) //IL_0070: 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_007d: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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) if (float.IsNaN(value.x) || float.IsInfinity(value.x) || float.IsNaN(value.y) || float.IsInfinity(value.y) || float.IsNaN(value.z) || float.IsInfinity(value.z) || float.IsNaN(value.w) || float.IsInfinity(value.w)) { return false; } float num = value.x * value.x + value.y * value.y + value.z * value.z + value.w * value.w; if (num > 0.5f) { return num < 1.5f; } return false; } private static Action CreateUpdatePlacementInvoker() { try { return (UpdatePlacementMethod == null) ? null : AccessTools.MethodDelegate>(UpdatePlacementMethod, (object)null, true); } catch { return null; } } private static bool IsConflictingEditorActive() { EnsureExternalModeResolvers(); if (!InvokeModeResolver(_perfectPlacementBuildingMode) && !InvokeModeResolver(_perfectPlacementEditingMode) && !InvokeModeResolver(_buildCameraMode)) { return IsMoveBuildPiecesConflictActive(); } return true; } private static void EnsureExternalModeResolvers() { if (!_externalModeResolversInitialized) { _externalModeResolversInitialized = true; _perfectPlacementBuildingMode = CreateStaticBoolResolver("PerfectPlacement.Patches.ABM", "IsInAbmMode"); _perfectPlacementEditingMode = CreateStaticBoolResolver("PerfectPlacement.Patches.AEM", "IsInAemMode"); _buildCameraMode = CreateStaticBoolResolver("Valheim_Build_Camera.Utils", "InBuildMode"); ResolveMoveBuildPiecesState(); ResolvePerfectPlacementRotationState(); } } private static void ResolveMoveBuildPiecesState() { Type type = AccessTools.TypeByName("Obelisk.MoveBuildPieces.MoveBuildPiecesPlugin"); if (type == null) { return; } _moveBuildPiecesPresent = true; try { Type type2 = AccessTools.TypeByName("Obelisk.MoveBuildPieces.MoveController"); _moveBuildPiecesEnabled = CreateStaticGetter(type, "IsEnabled"); _moveBuildPiecesBuildModeHotkey = CreateStaticGetter(type, "BuildModeMoveHotkey"); _moveBuildPiecesWorldModeHotkey = CreateStaticGetter(type, "WorldModeMoveHotkey"); _moveBuildPiecesMixedModeHotkey = CreateStaticGetter(type, "MixedModeMoveHotkey"); MethodInfo methodInfo = ((type2 == null) ? null : AccessTools.Method(type2, "ShouldBlockBuildAction", new Type[1] { typeof(Player) }, (Type[])null)); _moveBuildPiecesBlocksBuildAction = ((methodInfo == null) ? null : AccessTools.MethodDelegate>(methodInfo, (object)null, true)); _moveBuildPiecesPendingRequest = ((type2 == null) ? null : AccessTools.Field(type2, "_pendingRequest")); _moveBuildPiecesResolved = _moveBuildPiecesEnabled != null && _moveBuildPiecesBlocksBuildAction != null && _moveBuildPiecesBuildModeHotkey != null && _moveBuildPiecesWorldModeHotkey != null && _moveBuildPiecesMixedModeHotkey != null && _moveBuildPiecesPendingRequest != null; } catch { _moveBuildPiecesResolved = false; } } private static Func CreateStaticGetter(Type type, string propertyName) { MethodInfo methodInfo = ((type == null) ? null : AccessTools.PropertyGetter(type, propertyName)); if (!(methodInfo == null)) { return AccessTools.MethodDelegate>(methodInfo, (object)null, true); } return null; } private static bool IsMoveBuildPiecesConflictActive() { if (!_moveBuildPiecesPresent) { return false; } if (!_moveBuildPiecesResolved) { return true; } try { Player localPlayer = Player.m_localPlayer; return (Object)(object)localPlayer == (Object)null || _moveBuildPiecesPendingRequest.GetValue(null) != null || _moveBuildPiecesBlocksBuildAction(localPlayer); } catch { return true; } } internal unsafe static bool IsMoveBuildPiecesActivationShortcut(KeyboardShortcut shortcut) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) EnsureExternalModeResolvers(); if (!_moveBuildPiecesPresent || !_moveBuildPiecesResolved) { return false; } try { int result; if (_moveBuildPiecesEnabled()) { object obj = _moveBuildPiecesBuildModeHotkey(); if (!((object)(*(KeyboardShortcut*)(&shortcut))/*cast due to .constrained prefix*/).Equals(obj)) { object obj2 = _moveBuildPiecesWorldModeHotkey(); if (!((object)(*(KeyboardShortcut*)(&shortcut))/*cast due to .constrained prefix*/).Equals(obj2)) { object obj3 = _moveBuildPiecesMixedModeHotkey(); result = (((object)(*(KeyboardShortcut*)(&shortcut))/*cast due to .constrained prefix*/).Equals(obj3) ? 1 : 0); goto IL_0080; } } result = 1; } else { result = 0; } goto IL_0080; IL_0080: return (byte)result != 0; } catch { return false; } } private static void ResolvePerfectPlacementRotationState() { try { Type type = AccessTools.TypeByName("PerfectPlacement.PerfectPlacementPlugin"); Type type2 = ((type == null) ? null : AccessTools.Inner(type, "PlayerData")); _perfectPlacementPlayersData = ((type == null) ? null : AccessTools.Field(type, "PlayersData"))?.GetValue(null) as IDictionary; _perfectPlacementPlaceRotation = ((type2 == null) ? null : AccessTools.FieldRefAccess(type2, "PlaceRotation")); } catch { _perfectPlacementPlayersData = null; _perfectPlacementPlaceRotation = null; } } private static Func CreateStaticBoolResolver(string typeName, string methodName) { try { Type type = AccessTools.TypeByName(typeName); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, methodName, Type.EmptyTypes, (Type[])null)); return (methodInfo == null) ? null : AccessTools.MethodDelegate>(methodInfo, (object)null, true); } catch { return null; } } private static bool InvokeModeResolver(Func resolver) { if (resolver == null) { return false; } try { return resolver(); } catch { return false; } } private static Camera ResolveGameCamera() { Camera val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).GetComponent() : null); if (!((Object)(object)val != (Object)null)) { return Camera.main; } return val; } internal static GameObject GetPlacementGhost(Player player) { if (!((Object)(object)player == (Object)null)) { return PlacementGhost.Invoke(player); } return null; } private void OnGUI() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (ShouldRenderToolbar) { GUI.depth = -100; ((Rect)(ref _toolbarRect)).width = Mathf.Min(1290f, Mathf.Max(1000f, (float)Screen.width - 20f)); _toolbarRect = GUILayout.Window(20260714, _toolbarRect, _toolbarWindowFunction, string.Empty, GUI.skin.box, Array.Empty()); ((Rect)(ref _toolbarRect)).x = Mathf.Clamp(((Rect)(ref _toolbarRect)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _toolbarRect)).width)); ((Rect)(ref _toolbarRect)).y = Mathf.Clamp(((Rect)(ref _toolbarRect)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _toolbarRect)).height)); } } private void DrawToolbarWindow(int windowId) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_0025: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; bool flag = !IsCameraCaptured && Cursor.visible; if (!flag) { _toolbarDragging = false; } if (flag && (int)current.type == 0 && current.button == 0) { Rect toolbarDragRect = ToolbarDragRect; if (((Rect)(ref toolbarDragRect)).Contains(current.mousePosition)) { _toolbarDragging = true; } } if ((int)current.rawType == 1 && current.button == 0) { _toolbarDragging = false; } GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(_language.Header, (GUILayoutOption[])(object)new GUILayoutOption[1] { HeaderWidth }); if (GUILayout.Toggle(_mode == EditMode.Translate, _language.Translate, GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { TranslateWidth })) { SetEditMode(EditMode.Translate); } if (GUILayout.Toggle(_mode == EditMode.Rotate, _language.Rotate, GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { RotateWidth })) { SetEditMode(EditMode.Rotate); } if (GUILayout.Button(_spaceButtonLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { SpaceWidth })) { ToggleCoordinateSpace(); } if (GUILayout.Button(_surfaceSnapButtonLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { SnapWidth })) { ToggleSurfaceSnapping(); } if (GUILayout.Button(_cameraLightButtonLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { CameraLightWidth })) { ToggleCameraLight(); } GUI.enabled = HasGizmoTarget; if (GUILayout.Button(_language.ResetToRay, (GUILayoutOption[])(object)new GUILayoutOption[1] { ResetWidth })) { ReleasePlacementGhost(); } GUI.enabled = true; if (GUILayout.Button(_exitButtonLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { ExitWidth })) { ExitEditor(); } GUILayout.EndHorizontal(); GUILayout.Label(_targetStatusText, Array.Empty()); if (flag) { GUI.DragWindow(ToolbarDragRect); } } private void OnToolbarHotkeySettingChanged(object sender, EventArgs eventArgs) { _toolbarLabelsDirty = true; } private void OnCameraLightSettingChanged(object sender, EventArgs eventArgs) { _cameraLightSettingsDirty = true; } private void OnGhostPreviewSettingChanged(object sender, EventArgs eventArgs) { _ghostPreviewSettingsDirty = true; } private void ApplyGhostPreviewSetting() { _blueGhostPreviewEnabled = Plugin.BlueGhostPreview.Value; if (!_active || !_blueGhostPreviewEnabled) { _placementGhostVisual.Restore(); return; } Player localPlayer = Player.m_localPlayer; _placementGhostVisual.Sync(((Object)(object)localPlayer != (Object)null) ? GetPlacementGhost(localPlayer) : null); } private void OnGameLanguageChanged() { RefreshEditorLanguage(); } private void RefreshEditorLanguage() { EditorLanguage editorLanguage = EditorLanguage.FromGameLanguage(); bool num = !_languageInitialized || _language != editorLanguage; _language = editorLanguage; _languageInitialized = true; if (num) { RefreshToolbarLabels(); } RefreshTargetStatusText(); } private void RefreshToolbarLabels() { //IL_002b: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) _spaceButtonLabel = ((_space == CoordinateSpace.World) ? _language.World : _language.Local) + " (" + FormatShortcut(Plugin.ToggleCoordinateSpaceKey.Value) + ")"; _surfaceSnapButtonLabel = (_surfaceSnapEnabled ? _language.SurfaceOn : _language.SurfaceOff) + " (" + FormatShortcut(Plugin.ToggleSurfaceSnapKey.Value) + ")"; _cameraLightButtonLabel = (((Object)(object)_cameraLight != (Object)null) ? _language.LightOn : _language.LightOff) + " (" + FormatShortcut(Plugin.ToggleCameraLightKey.Value) + ")"; _exitButtonLabel = _language.Exit + " (" + FormatShortcut(Plugin.ToggleEditorKey.Value) + ")"; } private unsafe static string FormatShortcut(KeyboardShortcut shortcut) { string text = ((object)(*(KeyboardShortcut*)(&shortcut))/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrEmpty(text)) { return text; } return "—"; } static EditorController() { //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) KeyCode[] array = new KeyCode[8]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); HotbarKeys = (KeyCode[])(object)array; CameraLightColor = new Color(1f, 0.92f, 0.78f, 1f); HeaderWidth = GUILayout.Width(220f); TranslateWidth = GUILayout.Width(120f); RotateWidth = GUILayout.Width(105f); SpaceWidth = GUILayout.Width(165f); SnapWidth = GUILayout.Width(185f); CameraLightWidth = GUILayout.Width(165f); ResetWidth = GUILayout.Width(105f); ExitWidth = GUILayout.Width(125f); ToolbarDragRect = new Rect(0f, 0f, 220f, 28f); _suppressMenuFrame = -1; _buildMenuConsumedEscapeFrame = -1; } } internal static class EditorInputFirewall { private sealed class ReservedKeySnapshot { internal readonly HashSet Lookup; internal readonly KeyCode[] PollingOrder; internal ReservedKeySnapshot(HashSet lookup, KeyCode[] pollingOrder) { Lookup = lookup; PollingOrder = pollingOrder; } } [ThreadStatic] private static int _editorShortcutReadDepth; private static readonly KeyCode[] FixedReservedKeys; private static ReservedKeySnapshot _reservedKeys; private static bool _initialized; internal static void Initialize() { if (!_initialized) { Subscribe(Plugin.ToggleEditorKey); Subscribe(Plugin.ToggleSurfaceSnapKey); Subscribe(Plugin.ToggleCoordinateSpaceKey); Subscribe(Plugin.ToggleCameraLightKey); _reservedKeys = BuildReservedKeySnapshot(); _initialized = true; } } internal static void Shutdown() { if (_initialized) { Unsubscribe(Plugin.ToggleEditorKey); Unsubscribe(Plugin.ToggleSurfaceSnapKey); Unsubscribe(Plugin.ToggleCoordinateSpaceKey); Unsubscribe(Plugin.ToggleCameraLightKey); _reservedKeys = BuildFixedReservedKeySnapshot(); _initialized = false; } } internal static bool IsEditorShortcutDown(KeyboardShortcut shortcut) { _editorShortcutReadDepth++; try { return ((KeyboardShortcut)(ref shortcut)).IsDown(); } finally { _editorShortcutReadDepth--; } } internal static bool ShouldBlockExternalShortcut(KeyboardShortcut shortcut) { //IL_0011: 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_0047: 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_0053: Unknown result type (might be due to invalid IL or missing references) if (_editorShortcutReadDepth > 0 || !IsReservationActive()) { return false; } if (EditorController.IsMoveBuildPiecesActivationShortcut(shortcut)) { return true; } ReservedKeySnapshot reservedKeys = _reservedKeys; if (reservedKeys.Lookup.Contains(((KeyboardShortcut)(ref shortcut)).MainKey)) { return true; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if (reservedKeys.Lookup.Contains(modifier)) { return true; } } return false; } internal static bool IsAnyReservedInputHeld() { if (!IsReservationActive()) { return false; } KeyCode[] pollingOrder = _reservedKeys.PollingOrder; for (int i = 0; i < pollingOrder.Length; i++) { if (Input.GetKey(pollingOrder[i])) { return true; } } return false; } private static bool IsReservationActive() { EditorController controller = Plugin.Controller; if ((Object)(object)controller != (Object)null) { return controller.ShouldReserveEditorHotkeys; } return false; } private static void Subscribe(ConfigEntry configEntry) { if (configEntry != null) { configEntry.SettingChanged += OnShortcutSettingChanged; } } private static void Unsubscribe(ConfigEntry configEntry) { if (configEntry != null) { configEntry.SettingChanged -= OnShortcutSettingChanged; } } private static void OnShortcutSettingChanged(object sender, EventArgs eventArgs) { _reservedKeys = BuildReservedKeySnapshot(); } private static ReservedKeySnapshot BuildReservedKeySnapshot() { List list = new List(FixedReservedKeys.Length + 12); HashSet lookup = new HashSet(); for (int i = 0; i < FixedReservedKeys.Length; i++) { AddReservedKey(FixedReservedKeys[i], lookup, list); } AddShortcut(Plugin.ToggleEditorKey, lookup, list); AddShortcut(Plugin.ToggleSurfaceSnapKey, lookup, list); AddShortcut(Plugin.ToggleCoordinateSpaceKey, lookup, list); AddShortcut(Plugin.ToggleCameraLightKey, lookup, list); return new ReservedKeySnapshot(lookup, list.ToArray()); } private static ReservedKeySnapshot BuildFixedReservedKeySnapshot() { List list = new List(FixedReservedKeys.Length); HashSet lookup = new HashSet(); for (int i = 0; i < FixedReservedKeys.Length; i++) { AddReservedKey(FixedReservedKeys[i], lookup, list); } return new ReservedKeySnapshot(lookup, list.ToArray()); } private static void AddShortcut(ConfigEntry configEntry, HashSet lookup, List pollingOrder) { //IL_0005: 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_000d: 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) if (configEntry == null) { return; } KeyboardShortcut value = configEntry.Value; AddReservedKey(((KeyboardShortcut)(ref value)).MainKey, lookup, pollingOrder); foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers) { AddReservedKey(modifier, lookup, pollingOrder); } } private static void AddReservedKey(KeyCode key, HashSet lookup, List pollingOrder) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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) if ((int)key != 0 && lookup.Add(key)) { pollingOrder.Add(key); } } static EditorInputFirewall() { KeyCode[] array = new KeyCode[24]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); FixedReservedKeys = (KeyCode[])(object)array; _reservedKeys = BuildReservedKeySnapshot(); } } internal sealed class EditorLanguage { internal static readonly EditorLanguage English = new EditorLanguage { Header = "EXTENDED BUILDING", Translate = "W Move", Rotate = "E/R Rotate", ResetToRay = "Reset to ray", World = "World", Local = "Local", SurfaceOn = "Surface: ON", SurfaceOff = "Surface: OFF", LightOn = "Light: ON", LightOff = "Light: OFF", Exit = "Exit", NoGhost = "Piece: select an object in the build menu", SpecialPiece = "Special piece: vanilla Valheim placement", PiecePrefix = "Piece: ", ToolbarHelp = " | LMB: build | MMB: dismantle | Shift+MMB: sample | RMB: click — menu, hold + WASD — camera", DisableConflictingEditor = "Disable the active PerfectPlacement, Build Camera or MoveBuildPieces mode first", PlacementError = "Building editor error; see the log for details", EnterBuildModeFirst = "Equip a building tool and enter building mode first", NoBuildingHammer = "No building hammer found in the inventory", HammerEquipFailed = "Unable to equip the building hammer", EditorEnabled = "Extended building enabled", EditorDisabled = "Extended building disabled" }; internal static readonly EditorLanguage Russian = new EditorLanguage { Header = "РАСШИРЕННОЕ СТРОИТЕЛЬСТВО", Translate = "W Перемещение", Rotate = "E/R Поворот", ResetToRay = "Сброс к лучу", World = "Мировые", Local = "Локальные", SurfaceOn = "Поверхность: ВКЛ", SurfaceOff = "Поверхность: ВЫКЛ", LightOn = "Свет: ВКЛ", LightOff = "Свет: ВЫКЛ", Exit = "Выход", NoGhost = "Деталь: выберите объект в меню строительства", SpecialPiece = "Специальная деталь: штатное размещение Valheim", PiecePrefix = "Деталь: ", ToolbarHelp = " | ЛКМ: построить | СКМ: снести | Shift+СКМ: проба | ПКМ: клик — меню, удержание + WASD — камера", DisableConflictingEditor = "Сначала выключите активный режим PerfectPlacement, Build Camera или MoveBuildPieces", PlacementError = "Ошибка режима строительства; подробности в журнале", EnterBuildModeFirst = "Сначала возьмите строительный инструмент и войдите в режим строительства", NoBuildingHammer = "В инвентаре не найден строительный молоток", HammerEquipFailed = "Не удалось взять строительный молоток", EditorEnabled = "Расширенное строительство включено", EditorDisabled = "Расширенное строительство выключено" }; internal string Header { get; private set; } internal string Translate { get; private set; } internal string Rotate { get; private set; } internal string ResetToRay { get; private set; } internal string World { get; private set; } internal string Local { get; private set; } internal string SurfaceOn { get; private set; } internal string SurfaceOff { get; private set; } internal string LightOn { get; private set; } internal string LightOff { get; private set; } internal string Exit { get; private set; } internal string NoGhost { get; private set; } internal string SpecialPiece { get; private set; } internal string PiecePrefix { get; private set; } internal string ToolbarHelp { get; private set; } internal string DisableConflictingEditor { get; private set; } internal string PlacementError { get; private set; } internal string EnterBuildModeFirst { get; private set; } internal string NoBuildingHammer { get; private set; } internal string HammerEquipFailed { get; private set; } internal string EditorEnabled { get; private set; } internal string EditorDisabled { get; private set; } private EditorLanguage() { } internal static EditorLanguage FromGameLanguage() { if (!string.Equals(Localization.instance.GetSelectedLanguage(), "Russian", StringComparison.OrdinalIgnoreCase)) { return English; } return Russian; } } internal enum GizmoAxis { None, Center, X, Y, Z } internal sealed class GizmoRenderer : MonoBehaviour { private static readonly Color XColor = new Color(0.95f, 0.15f, 0.12f, 1f); private static readonly Color YColor = new Color(0.2f, 0.85f, 0.2f, 1f); private static readonly Color ZColor = new Color(0.18f, 0.45f, 1f, 1f); private static readonly Color CenterColor = new Color(0.82f, 0.62f, 0.05f, 1f); private static readonly Color HighlightColor = new Color(1f, 0.78f, 0.08f, 1f); private const float DesiredPixelSize = 105f; private const float HitRadiusPixels = 13f; private const float CenterHalfSizePixels = 12.5f; private const int RingSegments = 72; private const int RingHitStep = 2; private static readonly GizmoAxis[] Axes = new GizmoAxis[3] { GizmoAxis.X, GizmoAxis.Y, GizmoAxis.Z }; private static readonly Vector2[] RingPoints = CreateRingPoints(); private Material _lineMaterial; private float _halfLineWidth; private Vector3 _renderCameraForward; private Vector3 _renderCameraUp; private Vector3 _renderCameraRight; private int _hitTestFrame = -1; private Camera _hitTestCamera; private Transform _hitTestTarget; private Vector3 _hitTestMouse; private Vector3 _hitTestPivot; private Quaternion _hitTestTargetRotation; private EditMode _hitTestMode; private CoordinateSpace _hitTestSpace; private GizmoAxis _hitTestResult; internal EditorController Controller { private get; set; } internal GizmoAxis HoveredAxis { get; set; } internal GizmoAxis ActiveAxis { get; set; } private void Awake() { //IL_0028: 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_003a: Expected O, but got Unknown Shader val = Shader.Find("Hidden/Internal-Colored"); if ((Object)(object)val == (Object)null) { Plugin.LogError("Hidden/Internal-Colored shader was not found; gizmo disabled"); ((Behaviour)this).enabled = false; return; } _lineMaterial = new Material(val) { hideFlags = (HideFlags)61 }; _lineMaterial.SetInt("_SrcBlend", 5); _lineMaterial.SetInt("_DstBlend", 10); _lineMaterial.SetInt("_Cull", 0); _lineMaterial.SetInt("_ZWrite", 0); _lineMaterial.SetInt("_ZTest", 8); ((Behaviour)this).enabled = false; } private void OnDestroy() { if ((Object)(object)_lineMaterial != (Object)null) { Object.Destroy((Object)(object)_lineMaterial); } } private void OnRenderObject() { //IL_0065: 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) //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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_00df: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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) if ((Object)(object)_lineMaterial == (Object)null || (Object)(object)Controller == (Object)null) { return; } Camera current = Camera.current; Camera editorCamera = Controller.EditorCamera; if (!((Object)(object)current == (Object)null) && !((Object)(object)current != (Object)(object)editorCamera) && Controller.ShouldRenderEditorOverlay && Controller.HasGizmoTarget) { Transform transform = ((Component)current).transform; _renderCameraForward = transform.forward; _renderCameraUp = transform.up; _renderCameraRight = transform.right; Vector3 gizmoPivot = Controller.GizmoPivot; float num = CalculateWorldSize(current, gizmoPivot); _halfLineWidth = num / 105f * 0.9f; _lineMaterial.SetPass(0); GL.PushMatrix(); GL.Begin(1); if (Controller.Mode == EditMode.Translate) { DrawCenterHandle(gizmoPivot, num); DrawTranslationAxis(gizmoPivot, Controller.GetDisplayAxis(GizmoAxis.X), num, AxisColor(GizmoAxis.X), GizmoAxis.X); DrawTranslationAxis(gizmoPivot, Controller.GetDisplayAxis(GizmoAxis.Y), num, AxisColor(GizmoAxis.Y), GizmoAxis.Y); DrawTranslationAxis(gizmoPivot, Controller.GetDisplayAxis(GizmoAxis.Z), num, AxisColor(GizmoAxis.Z), GizmoAxis.Z); } else { DrawRing(gizmoPivot, Controller.GetDisplayAxis(GizmoAxis.X), num * 0.82f, AxisColor(GizmoAxis.X), GizmoAxis.X); DrawRing(gizmoPivot, Controller.GetDisplayAxis(GizmoAxis.Y), num * 0.82f, AxisColor(GizmoAxis.Y), GizmoAxis.Y); DrawRing(gizmoPivot, Controller.GetDisplayAxis(GizmoAxis.Z), num * 0.82f, AxisColor(GizmoAxis.Z), GizmoAxis.Z); } GL.End(); GL.PopMatrix(); } } internal GizmoAxis HitTest(Camera camera, Vector3 mousePosition) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: 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_01cf: 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) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0160: 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_008f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_lineMaterial == (Object)null || (Object)(object)Controller == (Object)null || !Controller.HasGizmoTarget) { return GizmoAxis.None; } Transform targetTransform = Controller.TargetTransform; Vector3 gizmoPivot = Controller.GizmoPivot; if (_hitTestFrame == Time.frameCount && (Object)(object)_hitTestCamera == (Object)(object)camera && (Object)(object)_hitTestTarget == (Object)(object)targetTransform && _hitTestMouse == mousePosition && _hitTestPivot == gizmoPivot && _hitTestTargetRotation == targetTransform.rotation && _hitTestMode == Controller.Mode && _hitTestSpace == Controller.Space) { return _hitTestResult; } float num = CalculateWorldSize(camera, gizmoPivot); GizmoAxis gizmoAxis = GizmoAxis.None; float num2 = 13f; Vector3 val = camera.WorldToScreenPoint(gizmoPivot); if (Controller.Mode == EditMode.Translate && val.z > 0f && Mathf.Abs(mousePosition.x - val.x) <= 12.5f && Mathf.Abs(mousePosition.y - val.y) <= 12.5f) { gizmoAxis = GizmoAxis.Center; } else { GizmoAxis[] axes = Axes; foreach (GizmoAxis gizmoAxis2 in axes) { float num3 = ((Controller.Mode == EditMode.Translate) ? DistanceToTranslationAxis(camera, mousePosition, gizmoPivot, Controller.GetDisplayAxis(gizmoAxis2), num) : DistanceToRing(camera, mousePosition, gizmoPivot, Controller.GetDisplayAxis(gizmoAxis2), num * 0.82f)); if (num3 < num2) { num2 = num3; gizmoAxis = gizmoAxis2; } } } _hitTestFrame = Time.frameCount; _hitTestCamera = camera; _hitTestTarget = targetTransform; _hitTestMouse = mousePosition; _hitTestPivot = gizmoPivot; _hitTestTargetRotation = targetTransform.rotation; _hitTestMode = Controller.Mode; _hitTestSpace = Controller.Space; _hitTestResult = gizmoAxis; return gizmoAxis; } private void DrawCenterHandle(Vector3 pivot, float size) { //IL_000f: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0036: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0047: 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_004d: 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) //IL_0054: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0081: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) float num = size * 12.5f / 105f; Vector3 val = _renderCameraRight * num; Vector3 val2 = _renderCameraUp * num; Vector3 val3 = pivot - val - val2; Vector3 val4 = pivot + val - val2; Vector3 val5 = pivot + val + val2; Vector3 val6 = pivot - val + val2; Color color = DisplayColor(CenterColor, GizmoAxis.Center); DrawLine(val3, val4, color); DrawLine(val4, val5, color); DrawLine(val5, val6, color); DrawLine(val6, val3, color); } private void DrawTranslationAxis(Vector3 pivot, Vector3 axis, float size, Color color, GizmoAxis gizmoAxis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_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_001a: 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) //IL_001c: 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) //IL_0024: 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_002e: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_007d: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00ac: 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) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007b: Unknown result type (might be due to invalid IL or missing references) Color color2 = DisplayColor(color, gizmoAxis); Vector3 val = pivot + axis * size; DrawLine(pivot, val, color2); Vector3 val2 = Vector3.Cross(axis, _renderCameraForward); Vector3 val3 = ((Vector3)(ref val2)).normalized * size * 0.07f; if (((Vector3)(ref val3)).sqrMagnitude < 0.001f) { val2 = Vector3.Cross(axis, _renderCameraUp); val3 = ((Vector3)(ref val2)).normalized * size * 0.07f; } Vector3 val4 = val - axis * size * 0.16f; DrawLine(val, val4 + val3, color2); DrawLine(val, val4 - val3, color2); } private void DrawRing(Vector3 pivot, Vector3 axis, float radius, Color color, GizmoAxis gizmoAxis) { //IL_0000: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) //IL_0058: 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) //IL_006b: 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_0082: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) GetRingBasis(axis, out var u, out var v); Color color2 = DisplayColor(color, gizmoAxis); Vector3 start = pivot + (u * RingPoints[0].x + v * RingPoints[0].y) * radius; for (int i = 1; i <= 72; i++) { Vector3 val = pivot + (u * RingPoints[i].x + v * RingPoints[i].y) * radius; DrawLine(start, val, color2); start = val; } } private Color DisplayColor(Color baseColor, GizmoAxis axis) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (axis != ActiveAxis && axis != HoveredAxis) { return baseColor; } return HighlightColor; } private static float DistanceToTranslationAxis(Camera camera, Vector3 mouse, Vector3 pivot, Vector3 axis, float size) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_0014: 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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Vector3 val = camera.WorldToScreenPoint(pivot + axis * size * 0.15f); Vector3 val2 = camera.WorldToScreenPoint(pivot + axis * size * 1.08f); if (val.z <= 0f || val2.z <= 0f) { return float.MaxValue; } return DistancePointToSegment(mouse, val, val2); } private static float DistanceToRing(Camera camera, Vector3 mouse, Vector3 pivot, Vector3 axis, float radius) { //IL_0000: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //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 missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_006e: 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_0085: 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_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) GetRingBasis(axis, out var u, out var v); float num = float.MaxValue; Vector3 val = camera.WorldToScreenPoint(pivot + (u * RingPoints[0].x + v * RingPoints[0].y) * radius); for (int i = 2; i <= 72; i += 2) { Vector3 val2 = camera.WorldToScreenPoint(pivot + (u * RingPoints[i].x + v * RingPoints[i].y) * radius); if (val.z > 0f && val2.z > 0f) { num = Mathf.Min(num, DistancePointToSegment(mouse, val, val2)); } val = val2; } return num; } private static Vector2[] CreateRingPoints() { //IL_002f: 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) Vector2[] array = (Vector2[])(object)new Vector2[73]; for (int i = 0; i <= 72; i++) { float num = (float)i * (float)Math.PI * 2f / 72f; array[i] = new Vector2(Mathf.Cos(num), Mathf.Sin(num)); } return array; } private static void GetRingBasis(Vector3 axis, out Vector3 u, out Vector3 v) { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0035: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_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) Vector3 val = ((Mathf.Abs(Vector3.Dot(((Vector3)(ref axis)).normalized, Vector3.up)) > 0.9f) ? Vector3.right : Vector3.up); Vector3 val2 = Vector3.Cross(axis, val); u = ((Vector3)(ref val2)).normalized; val2 = Vector3.Cross(axis, u); v = ((Vector3)(ref val2)).normalized; } private static float CalculateWorldSize(Camera camera, Vector3 position) { //IL_0006: 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) float num = Mathf.Max(0.5f, camera.WorldToScreenPoint(position).z); return 2f * num * Mathf.Tan(camera.fieldOfView * ((float)Math.PI / 180f) * 0.5f) * 105f / Mathf.Max(1f, (float)Screen.height); } private static float DistancePointToSegment(Vector3 point, Vector3 a, Vector3 b) { //IL_0002: 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_0015: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0057: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(point.x, point.y); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(a.x, a.y); Vector2 val3 = new Vector2(b.x, b.y) - val2; float sqrMagnitude = ((Vector2)(ref val3)).sqrMagnitude; if (sqrMagnitude < 0.001f) { return Vector2.Distance(val, val2); } float num = Mathf.Clamp01(Vector2.Dot(val - val2, val3) / sqrMagnitude); return Vector2.Distance(val, val2 + val3 * num); } private static Color AxisColor(GizmoAxis axis) { //IL_0014: 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_0008: Unknown result type (might be due to invalid IL or missing references) return (Color)(axis switch { GizmoAxis.Y => YColor, GizmoAxis.X => XColor, _ => ZColor, }); } private void DrawLine(Vector3 start, Vector3 end, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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_0009: 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_0014: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0055: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; Vector3 val2 = Vector3.Cross(_renderCameraForward, val); Vector3 val3 = ((Vector3)(ref val2)).normalized * _halfLineWidth; GL.Color(color); GL.Vertex(start); GL.Vertex(end); if (((Vector3)(ref val3)).sqrMagnitude > 0f) { GL.Vertex(start + val3); GL.Vertex(end + val3); GL.Vertex(start - val3); GL.Vertex(end - val3); } } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] internal static class GameCameraUpdatePatch { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "Azumatt.BuildCameraCHE", "Azumatt.FirstPersonMode" })] private static bool Prefix(float dt, GameCamera __instance) { EditorController controller = Plugin.Controller; if ((Object)(object)controller == (Object)null || !controller.IsActive) { return true; } controller.UpdateFreeCamera(dt); return false; } [HarmonyPriority(0)] [HarmonyAfter(new string[] { "Azumatt.BuildCameraCHE", "Azumatt.FirstPersonMode" })] private static void Postfix(GameCamera __instance) { EditorController controller = Plugin.Controller; if ((Object)(object)controller != (Object)null && controller.IsActive) { controller.ApplyFinalCameraTransform(__instance); } } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class GameCameraMouseCapturePatch { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "Azumatt.BuildCameraCHE" })] private static bool Prefix() { EditorController controller = Plugin.Controller; if ((Object)(object)controller == (Object)null || !controller.IsActive) { return true; } controller.UpdateMouseCapture(); return false; } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class PlayerControllerInputPatch { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "Azumatt.BuildCameraCHE" })] private static bool Prefix(ref bool __result) { if ((Object)(object)Plugin.Controller == (Object)null || !Plugin.Controller.IsActive) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(KeyboardShortcut), "ModifierKeyTest")] internal static class KeyboardShortcutInputFirewallPatch { [HarmonyPriority(800)] private static bool Prefix(ref KeyboardShortcut __instance, ref bool __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!EditorInputFirewall.ShouldBlockExternalShortcut(__instance)) { return true; } __result = false; return false; } } [HarmonyPatch] internal static class InventorySlotsQuickSlotHotkeysPatch { private static MethodBase FindTargetMethod() { Type type = AccessTools.TypeByName("InventorySlots.InventorySlotsPlugin"); if (!(type == null)) { return AccessTools.Method(type, "HandleQuickSlotHotkeys", new Type[1] { typeof(Player) }, (Type[])null); } return null; } private static bool Prepare() { return FindTargetMethod() != null; } private static MethodBase TargetMethod() { return FindTargetMethod(); } [HarmonyPriority(800)] private static bool Prefix(Player __0) { EditorController controller = Plugin.Controller; if (!((Object)(object)controller == (Object)null)) { return !controller.ShouldConsumeEditorShortcutForExternalHotkeys(__0); } return true; } } [HarmonyPatch(typeof(Player), "Update")] internal static class PlayerUpdatePatch { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "Azumatt.BuildCameraCHE" })] private static bool Prefix(Player __instance) { EditorController controller = Plugin.Controller; if ((Object)(object)controller == (Object)null || !controller.IsActive || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } controller.UpdatePlayerPlacement(__instance, Time.deltaTime); return false; } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] internal static class PlacementGhostPatch { [HarmonyPriority(0)] private static bool Prefix(Player __instance) { EditorController controller = Plugin.Controller; if (!((Object)(object)controller == (Object)null)) { return !controller.ShouldSkipVanillaGhostUpdate(__instance); } return true; } [HarmonyPriority(400)] [HarmonyAfter(new string[] { "Azumatt_and_ValheimPlusDevs.PerfectPlacement" })] [HarmonyBefore(new string[] { "aedenthorn.BuildRestrictionTweaks" })] private static void Postfix(Player __instance, bool flashGuardStone) { Plugin.Controller?.ApplyGhostOverride(__instance, flashGuardStone); } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] internal static class PlacementGhostHardRangePatch { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "aedenthorn.BuildRestrictionTweaks" })] private static void Postfix(Player __instance) { Plugin.Controller?.EnforceEditorRange(__instance); } } [HarmonyPatch(typeof(Player), "TryPlacePiece")] internal static class TryPlacePiecePatch { [ThreadStatic] private static int _depth; internal static bool IsVanillaPlacementCall => _depth > 0; private static bool Prefix(Player __instance, ref bool __result, out bool __state) { EditorController controller = Plugin.Controller; __state = (Object)(object)controller != (Object)null && controller.IsActive && (Object)(object)__instance == (Object)(object)Player.m_localPlayer; if (__state) { _depth++; } if ((Object)(object)controller == (Object)null || !controller.ShouldBlockVanillaPlacement(__instance)) { return true; } __result = false; return false; } private static void Postfix(Player __instance, bool __result) { if (__result) { Plugin.Controller?.OnVanillaPlacementSucceeded(__instance); } } private static Exception Finalizer(Exception __exception, bool __state) { if (__state && _depth > 0) { _depth--; } return __exception; } } [HarmonyPatch(typeof(Player), "PlacePiece")] internal static class PlacePieceFinalPosePatch { [HarmonyPriority(0)] private static void Prefix(Player __instance, Piece __0, ref Vector3 __1, ref Quaternion __2) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) EditorController controller = Plugin.Controller; if (TryPlacePiecePatch.IsVanillaPlacementCall && (Object)(object)controller != (Object)null && controller.TryGetFinalPlacementPose(__instance, __0, out var position, out var rotation)) { __1 = position; __2 = rotation; } } } [HarmonyPatch(typeof(Player), "CopyPiece")] internal static class CopyPieceExecutionContextPatch { [ThreadStatic] private static int _depth; internal static bool IsCopyPieceCall => _depth > 0; private static void Prefix() { _depth++; } private static void Postfix(Player __instance, bool __result) { Plugin.Controller?.OnVanillaCopyCompleted(__instance, __result); } private static Exception Finalizer(Exception __exception) { if (_depth > 0) { _depth--; } return __exception; } } [HarmonyPatch(typeof(Player), "SetSelectedPiece", new Type[] { typeof(Piece) })] internal static class CopiedPieceSelectionPatch { private struct SampledPoseState { internal bool Valid; internal Vector3 Position; internal Quaternion Rotation; } private static void Prefix(Player __instance, Piece __0, out SampledPoseState __state) { //IL_0034: 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) //IL_003b: 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) __state = default(SampledPoseState); EditorController controller = Plugin.Controller; if (CopyPieceExecutionContextPatch.IsCopyPieceCall && !((Object)(object)controller == (Object)null) && controller.TryCaptureSampledPiecePose(__instance, __0, out var position, out var rotation)) { __state.Valid = true; __state.Position = position; __state.Rotation = rotation; } } private static void Postfix(Player __instance, bool __result, SampledPoseState __state) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (__result && __state.Valid) { Plugin.Controller?.OnVanillaPieceSampled(__instance, __state.Position, __state.Rotation); } } } [HarmonyPatch(typeof(CraftingStation), "HaveBuildStationInRange")] internal static class BuildStationRangePatch { [HarmonyPriority(0)] private static void Postfix(string name, Vector3 point, ref CraftingStation __result) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) EditorController controller = Plugin.Controller; if ((Object)(object)__result == (Object)null && (Object)(object)controller != (Object)null && controller.ShouldExtendBuildStationRange) { __result = CraftingStation.FindClosestStationInRange(name, point, controller.ActiveEditorRange); } } } [HarmonyPatch(typeof(Player), "RemovePiece")] internal static class RemovePieceExecutionContextPatch { [ThreadStatic] private static bool _isEditorRemoval; internal static bool IsEditorRemoval => _isEditorRemoval; private static void Prefix(Player __instance, out EditorController.DemolitionPickupTransaction __state) { __state = null; EditorController controller = Plugin.Controller; _isEditorRemoval = (Object)(object)controller != (Object)null && controller.IsActive && (Object)(object)__instance == (Object)(object)Player.m_localPlayer; if (!_isEditorRemoval) { return; } try { __state = controller.CaptureDemolitionPickup(__instance); } catch (Exception arg) { Plugin.LogError($"Could not prepare demolition resource pickup: {arg}"); } } private static void Postfix(bool __result, EditorController.DemolitionPickupTransaction __state) { try { if (__result) { Plugin.Controller?.CommitDemolitionPickup(__state); } } finally { _isEditorRemoval = false; } } private static Exception Finalizer(Exception __exception) { _isEditorRemoval = false; return __exception; } } [HarmonyPatch(typeof(Player), "CheckCanRemovePiece")] internal static class RemovePieceStationRequirementPatch { [HarmonyPriority(800)] private static bool Prefix(Player __instance, ref bool __result) { EditorController controller = Plugin.Controller; if ((Object)(object)controller == (Object)null || !controller.IsActive || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || !RemovePieceExecutionContextPatch.IsEditorRemoval) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(Player), "UpdateBuildGuiInput")] internal static class BuildMenuEscapeOwnershipPatch { private static void Prefix() { if ((Object)(object)Plugin.Controller != (Object)null && Plugin.Controller.IsActive && Hud.IsPieceSelectionVisible() && Input.GetKeyDown((KeyCode)27)) { EditorController.ReserveBuildMenuEscapeInput(); } } } [HarmonyPatch(typeof(Menu), "Update")] internal static class MenuInputOwnershipPatch { private static bool Prefix() { if (!Input.GetKeyDown((KeyCode)27)) { return true; } EditorController controller = Plugin.Controller; if ((Object)(object)controller != (Object)null && controller.IsActive && Hud.IsPieceSelectionVisible()) { return false; } if (EditorController.BuildMenuConsumedEscapeThisFrame || EditorController.SuppressMenuThisFrame) { return false; } if ((Object)(object)controller != (Object)null && controller.ShouldOwnEscapeInput) { controller.ReserveEscapeInput(); return false; } return true; } } [HarmonyPatch(typeof(ZNet), "Shutdown")] internal static class ZNetShutdownPatch { private static void Prefix() { Plugin.Controller?.ForceExit(); } } [HarmonyPatch(typeof(ZNet), "ShutdownWithoutSave")] internal static class ZNetShutdownWithoutSavePatch { private static void Prefix() { Plugin.Controller?.ForceExit(); } } [HarmonyPatch(typeof(ZNet), "OnDestroy")] internal static class ZNetDestroyPatch { private static void Prefix() { Plugin.Controller?.ForceExit(); } } internal sealed class PlacementGhostVisual { private struct MaterialState { internal Material Material; internal bool HadColor; internal Color Color; internal bool HadBaseColor; internal Color BaseColor; internal bool HadTintColor; internal Color TintColor; internal bool HadEmissionColor; internal Color EmissionColor; internal bool EmissionKeywordEnabled; } private const string ColorProperty = "_Color"; private const string BaseColorProperty = "_BaseColor"; private const string TintColorProperty = "_TintColor"; private const string EmissionColorProperty = "_EmissionColor"; private const string EmissionKeyword = "_EMISSION"; private static readonly Color GhostColor = new Color(0.22f, 0.66f, 1f, 0.75f); private static readonly Color GhostEmissionColor = new Color(0.05f, 0.42f, 0.9f, 0.9f); private readonly List _materialStates = new List(32); private readonly HashSet _seenMaterials = new HashSet(); private GameObject _ghost; internal void Sync(GameObject ghost) { if (_ghost != ghost) { Restore(); if (!((Object)(object)ghost == (Object)null)) { _ghost = ghost; Apply(ghost.GetComponentsInChildren()); Apply(ghost.GetComponentsInChildren()); _seenMaterials.Clear(); } } } internal void Restore() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) for (int i = 0; i < _materialStates.Count; i++) { MaterialState materialState = _materialStates[i]; Material material = materialState.Material; if (!((Object)(object)material == (Object)null)) { RestoreColor(material, "_Color", materialState.HadColor, materialState.Color); RestoreColor(material, "_BaseColor", materialState.HadBaseColor, materialState.BaseColor); RestoreColor(material, "_TintColor", materialState.HadTintColor, materialState.TintColor); RestoreColor(material, "_EmissionColor", materialState.HadEmissionColor, materialState.EmissionColor); if (materialState.EmissionKeywordEnabled) { material.EnableKeyword("_EMISSION"); } else { material.DisableKeyword("_EMISSION"); } } } _materialStates.Clear(); _seenMaterials.Clear(); _ghost = null; } private void Apply(T[] renderers) where T : Renderer { //IL_0088: 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_00aa: 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) foreach (T val in renderers) { if ((Object)(object)val == (Object)null || (Object)(object)((Renderer)val).sharedMaterial == (Object)null) { continue; } Material[] sharedMaterials = ((Renderer)val).sharedMaterials; foreach (Material val2 in sharedMaterials) { if (!((Object)(object)val2 == (Object)null) && _seenMaterials.Add(val2)) { MaterialState item = Capture(val2); _materialStates.Add(item); SetColor(val2, "_Color", GhostColor); SetColor(val2, "_BaseColor", GhostColor); SetColor(val2, "_TintColor", GhostColor); SetColor(val2, "_EmissionColor", GhostEmissionColor); if (item.HadEmissionColor) { val2.EnableKeyword("_EMISSION"); } } } } } private static MaterialState Capture(Material material) { MaterialState result = new MaterialState { Material = material, EmissionKeywordEnabled = material.IsKeywordEnabled("_EMISSION") }; CaptureColor(material, "_Color", out result.HadColor, out result.Color); CaptureColor(material, "_BaseColor", out result.HadBaseColor, out result.BaseColor); CaptureColor(material, "_TintColor", out result.HadTintColor, out result.TintColor); CaptureColor(material, "_EmissionColor", out result.HadEmissionColor, out result.EmissionColor); return result; } private static void CaptureColor(Material material, string property, out bool exists, out Color color) { //IL_001b: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) exists = material.HasProperty(property); color = (Color)(exists ? material.GetColor(property) : default(Color)); } private static void SetColor(Material material, string property, Color color) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(property)) { material.SetColor(property, color); } } private static void RestoreColor(Material material, string property, bool existed, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (existed && material.HasProperty(property)) { material.SetColor(property, color); } } } [BepInPlugin("Obelisk.UEPlacementEditor", "Build Ease", "0.3.10")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string ModGuid = "Obelisk.UEPlacementEditor"; public const string ModName = "Build Ease"; public const string ModVersion = "0.3.10"; internal static ConfigEntry ToggleEditorKey; internal static ConfigEntry ToggleSurfaceSnapKey; internal static ConfigEntry ToggleCoordinateSpaceKey; internal static ConfigEntry ToggleCameraLightKey; internal static ConfigEntry CameraSpeed; internal static ConfigEntry FastCameraMultiplier; internal static ConfigEntry MouseSensitivity; internal static ConfigEntry CameraLightRange; internal static ConfigEntry CameraLightIntensity; internal static ConfigEntry EditorRange; internal static ConfigEntry RotationSnap; internal static ConfigEntry StartWithSnap; internal static ConfigEntry BlueGhostPreview; internal static ConfigEntry ShowToolbar; private Harmony _harmony; private static ManualLogSource _log; internal static EditorController Controller { get; private set; } internal static void LogError(string message) { ManualLogSource log = _log; if (log != null) { log.LogError((object)message); } } private void Awake() { //IL_0022: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0298: 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_02fc: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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) _log = ((BaseUnityPlugin)this).Logger; ToggleEditorKey = ((BaseUnityPlugin)this).Config.Bind("General", "Toggle editor", new KeyboardShortcut((KeyCode)98, Array.Empty()), "Enter or leave the extended placement editor. If needed, equips a building hammer from the player's inventory first."); ConfigEntry val = ((BaseUnityPlugin)this).Config.Bind("Internal", "Input defaults schema", 0, "Internal one-time migration marker for default hotkeys."); if (val.Value < 1) { if (((object)ToggleEditorKey.Value/*cast due to .constrained prefix*/).Equals((object)new KeyboardShortcut((KeyCode)271, Array.Empty()))) { ToggleEditorKey.Value = new KeyboardShortcut((KeyCode)98, Array.Empty()); } val.Value = 1; } ToggleSurfaceSnapKey = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "Toggle surface snapping", new KeyboardShortcut((KeyCode)103, Array.Empty()), "Enable or disable surface and vanilla build-point snapping for the centre translation handle."); ToggleCoordinateSpaceKey = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "Toggle coordinate space", new KeyboardShortcut((KeyCode)120, Array.Empty()), "Switch the gizmo between world and local axes."); ToggleCameraLightKey = ((BaseUnityPlugin)this).Config.Bind("Hotkeys", "Toggle camera light", new KeyboardShortcut((KeyCode)102, Array.Empty()), "Create or remove a shadowless point light at the free camera while the editor is active. Do not reuse a camera movement or editor action key."); CameraSpeed = ((BaseUnityPlugin)this).Config.Bind("Camera", "Move speed", 12f, "Free camera movement speed."); FastCameraMultiplier = ((BaseUnityPlugin)this).Config.Bind("Camera", "Fast multiplier", 3f, "Camera speed multiplier while Shift is held."); MouseSensitivity = ((BaseUnityPlugin)this).Config.Bind("Camera", "Mouse sensitivity", 2f, "Free camera look sensitivity."); CameraLightRange = ((BaseUnityPlugin)this).Config.Bind("Lighting", "Camera light range", 100f, "Radius of the temporary camera light in metres (1-100)."); CameraLightIntensity = ((BaseUnityPlugin)this).Config.Bind("Lighting", "Camera light intensity", 1.5f, "Intensity of the temporary camera light (0-10). Shadows are always disabled."); EditorRange = ((BaseUnityPlugin)this).Config.Bind("Safety", "Maximum editor range", 100f, "Maximum free-camera, construction and removal distance from the player in metres (20-200)."); RotationSnap = ((BaseUnityPlugin)this).Config.Bind("Snapping", "Rotation step", 5f, "Rotation step in degrees. Set to 0 for continuous rotation."); StartWithSnap = ((BaseUnityPlugin)this).Config.Bind("Snapping", "Enabled by default", true, "Start each editor session with surface and vanilla build-point snapping enabled."); BlueGhostPreview = ((BaseUnityPlugin)this).Config.Bind("Visuals", "Blue ghost preview", false, "Tint the selected placement preview blue with emission while the extended editor is active."); ShowToolbar = ((BaseUnityPlugin)this).Config.Bind("Interface", "Show toolbar", true, "Show the editor toolbar at the top of the screen. The gizmo and controls remain active when it is hidden."); RemoveObsoleteSetting("General", "Toggle cursor capture", new KeyboardShortcut((KeyCode)308, Array.Empty())); RemoveObsoleteSetting("Snapping", "Position step", 0.5f); RemoveObsoleteSetting("Safety", "Existing piece edit range", 50f); ((BaseUnityPlugin)this).Config.Save(); EditorInputFirewall.Initialize(); Controller = ((Component)this).gameObject.AddComponent(); _harmony = new Harmony("Obelisk.UEPlacementEditor"); _harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Build Ease 0.3.10 loaded"); } private void RemoveObsoleteSetting(string section, string key, T defaultValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown ConfigDefinition val = new ConfigDefinition(section, key); ((BaseUnityPlugin)this).Config.Bind(val, defaultValue, new ConfigDescription("Obsolete setting retained only for one-time config cleanup.", (AcceptableValueBase)null, Array.Empty())); ((BaseUnityPlugin)this).Config.Remove(val); } private void OnDestroy() { Controller?.ForceExit(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } EditorInputFirewall.Shutdown(); Controller = null; _log = null; } }