using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Fusion;
using HarmonyLib;
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("AskaDigYerOwnHole")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.2")]
[assembly: AssemblyInformationalVersion("0.2.2+8edde25dd5244eb2a60169a7a69309ac44f0660f")]
[assembly: AssemblyProduct("Aska Dig Yer Own Hole")]
[assembly: AssemblyTitle("AskaDigYerOwnHole")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.2.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(Character))]
public static class CharacterSpawnPatch
{
[HarmonyPostfix]
[HarmonyPatch("Spawned")]
public static void Spawned(Character __instance)
{
//IL_0026: 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_0042: 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_0061: Unknown result type (might be due to invalid IL or missing references)
if (__instance.IsPlayer() && ((NetworkBehaviour)__instance).GetLocalAuthorityMask() == 1 && !((Object)(object)((Component)__instance).GetComponentInChildren<DigYerOwnHoleTool>() != (Object)null))
{
GameObject val = new GameObject("AskaDigYerOwnHole_Tool");
val.transform.SetParent(((Component)__instance).gameObject.transform, false);
val.transform.localPosition = new Vector3(0f, 0f, 2f);
val.AddComponent<HeightmapTool>();
val.AddComponent<DigYerOwnHoleTool>();
Plugin.Log.LogInfo((object)"DigYerOwnHoleTool attached to local player.");
}
}
}
public class DigYerOwnHoleTool : MonoBehaviour
{
private HeightmapTool _heightmapTool;
private void Start()
{
_heightmapTool = ((Component)this).GetComponent<HeightmapTool>();
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_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_007a: 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_00cf: Expected O, but got Unknown
//IL_00e4: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: 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_01f7: 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_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Expected O, but got Unknown
//IL_0291: 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))
{
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 flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val;
foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(position, num))
{
if (!((Component)item).CompareTag(Structure.c_FootprintTag))
{
continue;
}
Structure componentInParent = ((Component)item).GetComponentInParent<Structure>();
if ((Object)(object)componentInParent != (Object)null)
{
ManualLogSource log = Plugin.Log;
val = new BepInExInfoLogInterpolatedStringHandler(83, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Skipped dig/raise at ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(position);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": blocked by structure '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(componentInParent.GetName());
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(footprint collider '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)((Component)item).gameObject).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' at ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Component)item).transform.position);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(Vector3.Distance(position, ((Component)item).transform.position), "F2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("m away).");
}
log.LogInfo(val);
return;
}
}
bool flag2 = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303);
_heightmapTool.requiresTerrainType = true;
_heightmapTool.requiredTerrainType = (TerrainType)0;
float y = ((Component)this).transform.eulerAngles.y;
TerraformingToolOperation val2 = (TerraformingToolOperation)(!flag2);
if (flag2)
{
_heightmapTool.digDepth = value3;
}
else
{
_heightmapTool.raiseHeight = value3;
}
_heightmapTool.RunOnArea(val2, value, value2, value4, position, y);
ManualLogSource log2 = Plugin.Log;
val = new BepInExInfoLogInterpolatedStringHandler(48, 7, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(flag2 ? "Dug" : "Raised");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" a ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(value2);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("m patch at ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(position);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(amount ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(value3);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", blend ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(value4);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", rotation ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(y, "F0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("deg).");
}
log2.LogInfo(val);
}
}
[BepInPlugin("smithio.aska.digyerownhole", "Aska Dig Yer Own Hole", "0.2.2")]
public class Plugin : BasePlugin
{
public const string PluginGuid = "smithio.aska.digyerownhole";
public const string PluginName = "Aska Dig Yer Own Hole";
public const string PluginVersion = "0.2.2";
internal static ManualLogSource Log;
internal static ConfigEntry<bool> ConfigEnabled;
internal static ConfigEntry<KeyCode> ConfigKey;
internal static ConfigEntry<float> ConfigWidth;
internal static ConfigEntry<float> ConfigLength;
internal static ConfigEntry<float> ConfigHeight;
internal static ConfigEntry<float> ConfigBlendDistance;
internal static readonly bool DebugLogging;
public override void Load()
{
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
ConfigEnabled = ((BasePlugin)this).Config.Bind<bool>("DigYerOwnHole", "Enabled", true, "Master on/off switch for the dig/raise tool.");
ConfigKey = ((BasePlugin)this).Config.Bind<KeyCode>("DigYerOwnHole", "Key", (KeyCode)91, "Key that raises a dirt pile at your feet. Hold Shift to dig a hole instead.");
ConfigWidth = ((BasePlugin)this).Config.Bind<float>("DigYerOwnHole", "Width", 4f, "Width of the affected patch, in metres. Larger = bigger area.");
ConfigLength = ((BasePlugin)this).Config.Bind<float>("DigYerOwnHole", "Length", 4f, "Length (front-to-back) of the affected patch, in metres. Larger = bigger area.");
ConfigHeight = ((BasePlugin)this).Config.Bind<float>("DigYerOwnHole", "Height", 1f, "How far the ground is raised (or dug down, with Shift) each press, in metres.");
ConfigBlendDistance = ((BasePlugin)this).Config.Bind<float>("DigYerOwnHole", "BlendDistance", 0.3f, "Edge falloff of the patch, in metres. Smaller = sharper, more vertical walls; larger = softer, more sloped edges.");
ClassInjector.RegisterTypeInIl2Cpp<DigYerOwnHoleTool>();
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<string>("Aska Dig Yer Own Hole");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.2.2");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded.");
}
log.LogInfo(val);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "AskaDigYerOwnHole";
public const string PLUGIN_NAME = "Aska Dig Yer Own Hole";
public const string PLUGIN_VERSION = "0.2.2";
}
}