using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AskaShared; using AskaShared.Game; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using Fusion; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Microsoft.CodeAnalysis; using SSSGame; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("DigYerOwnHole")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.3")] [assembly: AssemblyInformationalVersion("1.2.3+504afdb0f26eed95e4109d752be9851ddb73667a")] [assembly: AssemblyProduct("Dig Yer Own Hole")] [assembly: AssemblyTitle("DigYerOwnHole")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AskaDigYerOwnHole { [HarmonyPatch(typeof(PlayerCharacter))] public static class CharacterSpawnPatch { [HarmonyPostfix] [HarmonyPatch("Spawned")] public static void Spawned(Character __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) LocalPlayerTool.AttachOnSpawn(__instance, Plugin.Log, "AskaDigYerOwnHole_Tool", new Vector3(0f, 0f, 2f), typeof(HeightmapTool), typeof(DigYerOwnHoleTool)); } } public class DigYerOwnHoleTool : MonoBehaviour { private HeightmapTool _heightmapTool; private void Start() { _heightmapTool = ((Component)this).GetComponent(); if ((Object)(object)_heightmapTool == (Object)null) { Plugin.Log.LogError((object)"DigYerOwnHoleTool: HeightmapTool component missing!"); } } private void Update() { //IL_0020: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0138: 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_01b0: 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_0233: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: 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_02f2: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: 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) if (!Plugin.ConfigEnabled.Value || (Object)(object)_heightmapTool == (Object)null || !Input.GetKeyDown(Plugin.ConfigKey.Value) || MenuGate.IsUiCapturingInput()) { return; } bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307)) { AdjustSize(flag ? (-0.5f) : 0.5f); return; } Vector3 position = ((Component)this).transform.position; float value = Plugin.ConfigWidth.Value; float value2 = Plugin.ConfigLength.Value; float value3 = Plugin.ConfigHeight.Value; float value4 = Plugin.ConfigBlendDistance.Value; float num = 0.5f * Mathf.Sqrt(value * value + value2 * value2); bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val; foreach (Collider item in (Il2CppArrayBase)(object)Physics.OverlapSphere(position, num)) { if (!((Component)item).CompareTag(Structure.c_FootprintTag)) { continue; } Structure componentInParent = ((Component)item).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { ManualLogSource log = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(83, 5, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Skipped dig/raise at "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(position); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": blocked by structure '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(componentInParent.GetName()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(footprint collider '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)((Component)item).gameObject).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' at "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Component)item).transform.position); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(Vector3.Distance(position, ((Component)item).transform.position), "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("m away)."); } log.LogInfo(val); return; } } bool flag3 = flag; _heightmapTool.requiresTerrainType = true; _heightmapTool.requiredTerrainType = (TerrainType)0; float y = ((Component)this).transform.eulerAngles.y; TerraformingToolOperation val2 = (TerraformingToolOperation)(!flag3); if (flag3) { _heightmapTool.digDepth = value3; } else { _heightmapTool.raiseHeight = value3; } TerraformingToolResult val3 = _heightmapTool.RunOnArea(val2, value, value2, value4, position, y); if ((int)val3 != 0) { Plugin.Log.LogInfo((object)($"{(flag3 ? "Dig" : "Raise")} at {position} did nothing (result {val3}): " + "the patch is likely not on NATURAL ground (road/path/dirt/bedrock).")); return; } ManualLogSource log2 = Plugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(48, 7, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(flag3 ? "Dug" : "Raised"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" a "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("m patch at "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(position); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(amount "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value3); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", blend "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value4); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", rotation "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(y, "F0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("deg)."); } log2.LogInfo(val); } private void AdjustSize(float delta) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown float num = Mathf.Clamp(Plugin.ConfigWidth.Value + delta, 0.5f, 30f); float num2 = Mathf.Clamp(Plugin.ConfigLength.Value + delta, 0.5f, 30f); Plugin.ConfigWidth.Value = num; Plugin.ConfigLength.Value = num2; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Brush size set to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num, "F1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" x "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num2, "F1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("m."); } log.LogInfo(val); ShowToast($"Brush: {num:F1} x {num2:F1}m"); } private static void ShowToast(string message) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown try { string text = message; NotificationMenu.Display((NotificationType)0, ref text, false); } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(50, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DigYerOwnHole: showing the notification '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } } } } internal static class MenuGate { internal static bool IsUiCapturingInput() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown try { return Cursor.visible || (int)Cursor.lockState != 1; } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DigYerOwnHole: reading the cursor state threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } return false; } } } [BepInPlugin("mugsy33.digyerownhole", "Dig Yer Own Hole", "1.3.0")] public class Plugin : BasePlugin { public const string PluginGuid = "mugsy33.digyerownhole"; public const string PluginName = "Dig Yer Own Hole"; public const string PluginVersion = "1.3.0"; internal static ManualLogSource Log; internal static ConfigEntry ConfigEnabled; internal static ConfigEntry ConfigKey; internal static ConfigEntry ConfigWidth; internal static ConfigEntry ConfigLength; internal static ConfigEntry ConfigHeight; internal static ConfigEntry ConfigBlendDistance; internal const float MinSize = 0.5f; internal const float MaxSize = 30f; internal const float SizeStep = 0.5f; internal static readonly bool DebugLogging; public override void Load() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown Log = ((BasePlugin)this).Log; ConfigMigration.Run(((BasePlugin)this).Config, Log); ConfigEnabled = ((BasePlugin)this).Config.Bind("DigYerOwnHole", "Enabled", true, "Master on/off switch for the dig/raise tool."); ConfigKey = ((BasePlugin)this).Config.Bind("DigYerOwnHole", "Key", (KeyCode)91, "Key that raises a dirt pile at your feet. Hold Shift to dig a hole instead; hold Alt to grow the brush (Alt+Shift to shrink it)."); ConfigWidth = ((BasePlugin)this).Config.Bind("DigYerOwnHole", "Width", 4f, new ConfigDescription("Width of the affected patch, in metres. Larger = bigger area. Adjust in-game with Alt + the dig key (Alt+Shift to shrink); changes are saved here.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 30f), Array.Empty())); ConfigLength = ((BasePlugin)this).Config.Bind("DigYerOwnHole", "Length", 4f, new ConfigDescription("Length (front-to-back) of the affected patch, in metres. Larger = bigger area. Adjust in-game with Alt + the dig key (Alt+Shift to shrink); changes are saved here.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 30f), Array.Empty())); ConfigHeight = ((BasePlugin)this).Config.Bind("DigYerOwnHole", "Height", 1f, "How far the ground is raised (or dug down, with Shift) each press, in metres."); ConfigBlendDistance = ((BasePlugin)this).Config.Bind("DigYerOwnHole", "BlendDistance", 0.3f, "Edge falloff of the patch, in metres. Smaller = sharper, more vertical walls; larger = softer, more sloped edges."); ClassInjector.RegisterTypeInIl2Cpp(); Harmony.CreateAndPatchAll(typeof(CharacterSpawnPatch), (string)null); ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("Dig Yer Own Hole"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.3.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded."); } log.LogInfo(val); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "DigYerOwnHole"; public const string PLUGIN_NAME = "Dig Yer Own Hole"; public const string PLUGIN_VERSION = "1.2.3"; } } namespace AskaShared.Game { public static class LocalPlayerTool { private static bool _failureLogged; public static Character LocalCharacter { get; private set; } public static GameObject AttachOnSpawn(Character character, ManualLogSource log, string objectName, Vector3 localPosition, params Type[] components) { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0082: 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_00d2: Expected O, but got Unknown bool flag = default(bool); try { if ((Object)(object)character == (Object)null) { return null; } if (!character.IsPlayer() || ((NetworkBehaviour)character).GetLocalAuthorityMask() != 1) { return null; } LocalCharacter = character; if (string.IsNullOrEmpty(objectName)) { throw new ArgumentException("objectName is required and must be unique to this mod.", "objectName"); } Transform transform = ((Component)character).gameObject.transform; if ((Object)(object)transform.Find(objectName) != (Object)null) { return null; } GameObject val = new GameObject(objectName); val.transform.SetParent(transform, false); val.transform.localPosition = localPosition; if (components != null) { foreach (Type type in components) { if (type != null) { val.AddComponent(Il2CppType.From(type)); } } } ManualLogSource val2 = log; if (val2 != null) { BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(29, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(objectName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" attached to local player '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((Object)((Component)character).gameObject).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'."); } val2.LogInfo(val3); } return val; } catch (Exception ex) { if (!_failureLogged) { _failureLogged = true; ManualLogSource val2 = log; if (val2 != null) { BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(121, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(objectName); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": attaching to the local player threw - this mod will do nothing this session, reported once rather than once per spawn: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex); } val2.LogError(val4); } } return null; } } } }