Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WidePickaxe v1.0.0
WidePickaxe.dll
Decompiled a day agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("WidePickaxe")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WidePickaxe")] [assembly: AssemblyTitle("WidePickaxe")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 WidePickaxe { internal static class DigMining { private class Target { public ZNetView View; public ZDOID Id; public IDestructible Destructible; public bool Whole; public readonly List<Collider> Areas = new List<Collider>(); } private class Area { private readonly Vector3 _center; private readonly float _radius; private readonly bool _square; private readonly float _bottom; private readonly float _top; public float Reach => _radius * 1.42f + 20f; public Vector3 Center => _center; public Area(Vector3 center, float radius, bool square, float depth) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) _center = center; _radius = radius; _square = square; _bottom = center.y - depth - 2f; _top = center.y + Mathf.Max(4f, radius); } public bool Contains(Vector3 p) { //IL_0000: 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_001e: 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) if (p.y < _bottom || p.y > _top) { return false; } float num = p.x - _center.x; float num2 = p.z - _center.z; if (_square) { if (Mathf.Abs(num) <= _radius) { return Mathf.Abs(num2) <= _radius; } return false; } return num * num + num2 * num2 <= _radius * _radius; } } private const float Damage = 100000f; private const float BelowMargin = 2f; private const float MinAbove = 4f; private const float SearchMargin = 20f; private const int Passes = 3; public static bool Busy { get; private set; } public static void MineArea(DigUndo.Step step, Player player, ItemData weapon, Vector3 center, float radius, bool square, float depth) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNetScene.instance == (Object)null || (Object)(object)player == (Object)null || weapon == null) { return; } Area area = new Area(center, radius, square, depth); HashSet<ZDOID> seen = new HashSet<ZDOID>(); int toolTier = weapon.m_shared.m_toolTier; for (int i = 0; i < 3; i++) { List<Target> list = FindTargets(area, seen, toolTier); if (list.Count == 0) { break; } foreach (Target item in list) { Mine(step, item, player, weapon, i > 0); } } } public static bool TryMineWhole(GameObject go, HitData hit) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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) if (Busy || (Object)(object)go == (Object)null || hit == null || !Plugin.Enabled.Value || !Plugin.WholeRockOnHit.Value) { return false; } Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer || (int)hit.m_skill != 12) { return false; } ItemData currentWeapon = ((Humanoid)val).GetCurrentWeapon(); if (!Plugin.IsPickaxe(currentWeapon)) { return false; } ZNetView component = go.GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return false; } Target target = MakeTarget(go, null, currentWeapon.m_shared.m_toolTier); if (target == null) { return false; } target.View = component; DigUndo.Step step = DigUndo.Begin(go.transform.position, 0f, terrain: false); try { Vector3 position = go.transform.position; bool flag = target.Destructible is Destructible; Mine(step, target, val, currentWeapon, spawned: false); HashSet<ZDOID> seen = new HashSet<ZDOID> { target.Id }; Area area = new Area(position, 4f, square: false, 3f); int num = 1; while (flag && num < 3) { List<Target> list = FindTargets(area, seen, currentWeapon.m_shared.m_toolTier, step.Spawned); if (list.Count == 0) { break; } foreach (Target item in list) { Mine(step, item, val, currentWeapon, spawned: true); } num++; } } finally { DigUndo.End(step, happened: true); } return true; } private static void Mine(DigUndo.Step step, Target target, Player player, ItemData weapon, bool spawned) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) ZNetView view = target.View; if ((Object)(object)view == (Object)null || !view.IsValid()) { return; } if (spawned) { step.Spawned.Add(target.Id); } else { step.Record(view); } view.ClaimOwnership(); if (target.Whole && DestroyWhole(target)) { return; } Busy = true; try { foreach (Collider area in target.Areas) { if ((Object)(object)view == (Object)null || !view.IsValid()) { break; } Vector3 val; if (!((Object)(object)area != (Object)null)) { val = ((Component)view).transform.position; } else { Bounds bounds = area.bounds; val = ((Bounds)(ref bounds)).center; } Vector3 point = val; target.Destructible.Damage(MakeHit(player, weapon, point, area)); } } finally { Busy = false; } } private static bool DestroyWhole(Target target) { //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_01a0: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)target.View).gameObject; int num = 0; MineRock5 component = gameObject.GetComponent<MineRock5>(); MineRock component2 = gameObject.GetComponent<MineRock>(); DropTable dropItems; EffectList destroyedEffect; if ((Object)(object)component != (Object)null) { Traverse obj = Traverse.Create((object)component); obj.Method("LoadHealth", Array.Empty<object>()).GetValue(); if (!(obj.Field("m_hitAreas").GetValue() is IList list)) { return false; } foreach (object item in list) { if (Traverse.Create(item).Field<float>("m_health").Value > 0f) { num++; } } dropItems = component.m_dropItems; destroyedEffect = component.m_destroyedEffect; } else { if (!((Object)(object)component2 != (Object)null)) { return false; } foreach (Collider area in target.Areas) { if ((Object)(object)area != (Object)null && ((Component)area).gameObject.activeInHierarchy) { num++; } } dropItems = component2.m_dropItems; destroyedEffect = component2.m_destroyedEffect; } Bounds bounds = Bounds(target, gameObject.transform.position); List<GameObject> list2 = new List<GameObject>(); int num2 = 0; while (dropItems != null && num2 < num) { list2.AddRange(dropItems.GetDropList()); num2++; } if (destroyedEffect != null) { destroyedEffect.Create(((Bounds)(ref bounds)).center, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); } ZNetScene.instance.Destroy(gameObject); SpawnDrops(list2, bounds); return true; } private static Bounds Bounds(Target target, Vector3 fallback) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_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) Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(fallback, Vector3.zero); bool flag = true; foreach (Collider area in target.Areas) { if (!((Object)(object)area == (Object)null)) { if (flag) { bounds = area.bounds; } else { ((Bounds)(ref bounds)).Encapsulate(area.bounds); } flag = false; } } return bounds; } private static void SpawnDrops(List<GameObject> drops, Bounds bounds) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0069: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0134: 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) Dictionary<GameObject, int> dictionary = new Dictionary<GameObject, int>(); foreach (GameObject drop in drops) { if (!((Object)(object)drop == (Object)null)) { dictionary.TryGetValue(drop, out var value); dictionary[drop] = value + 1; } } Vector3 center = ((Bounds)(ref bounds)).center; if ((Object)(object)ZoneSystem.instance != (Object)null) { center.y = Mathf.Max(center.y, ZoneSystem.instance.GetGroundHeight(center) + 0.5f); } float num = Mathf.Clamp(Mathf.Min(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z), 0.3f, 2f); foreach (KeyValuePair<GameObject, int> item in dictionary) { ItemDrop component = item.Key.GetComponent<ItemDrop>(); int num2 = Mathf.Max(1, (!((Object)(object)component != (Object)null)) ? 1 : component.m_itemData.m_shared.m_maxStackSize); for (int num3 = item.Value; num3 > 0; num3 -= num2) { Vector2 val = Random.insideUnitCircle * num; ItemDrop component2 = Object.Instantiate<GameObject>(item.Key, center + new Vector3(val.x, 0f, val.y), Quaternion.identity).GetComponent<ItemDrop>(); if ((Object)(object)component2 != (Object)null) { component2.m_itemData.m_stack = Mathf.Min(num3, num2); ItemDrop.OnCreateNew(component2, false); } } } } private static List<Target> FindTargets(Area area, HashSet<ZDOID> seen, int tier, List<ZDOID> skip = null) { //IL_0066: 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_006d: 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_0088: 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_00aa: 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_00b2: 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_00e7: 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_00ef: Unknown result type (might be due to invalid IL or missing references) List<Target> list = new List<Target>(); Dictionary<ZDO, ZNetView> value = Traverse.Create((object)ZNetScene.instance).Field<Dictionary<ZDO, ZNetView>>("m_instances").Value; if (value == null) { return list; } float reach = area.Reach; foreach (ZNetView value2 in value.Values) { if ((Object)(object)value2 == (Object)null || !value2.IsValid()) { continue; } Vector3 position = ((Component)value2).transform.position; if (Mathf.Abs(position.x - area.Center.x) > reach || Mathf.Abs(position.z - area.Center.z) > reach) { continue; } ZDOID uid = value2.GetZDO().m_uid; if (!seen.Contains(uid) && (skip == null || !skip.Contains(uid))) { Target target = MakeTarget(((Component)value2).gameObject, area, tier); if (target != null) { target.View = value2; target.Id = uid; seen.Add(uid); list.Add(target); } } } return list; } private static Target MakeTarget(GameObject go, Area area, int tier) { //IL_00a8: 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_011a: Invalid comparison between Unknown and I4 //IL_00dd: 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_0128: Invalid comparison between Unknown and I4 //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Invalid comparison between Unknown and I4 //IL_01a3: 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_01c1: 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_01c6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go.GetComponent<Piece>() != (Object)null || (Object)(object)go.GetComponent<WearNTear>() != (Object)null || (Object)(object)go.GetComponent<Character>() != (Object)null || (Object)(object)go.GetComponent<ItemDrop>() != (Object)null || (Object)(object)go.GetComponent<Container>() != (Object)null || (Object)(object)go.GetComponent<SpawnArea>() != (Object)null || (Object)(object)go.GetComponent<Pickable>() != (Object)null || (Object)(object)go.GetComponent<TreeBase>() != (Object)null || (Object)(object)go.GetComponent<TreeLog>() != (Object)null) { return null; } MineRock5 component = go.GetComponent<MineRock5>(); MineRock component2 = go.GetComponent<MineRock>(); Destructible component3 = go.GetComponent<Destructible>(); Target target; if ((Object)(object)component != (Object)null) { if (component.m_minToolTier > tier || Immune(component.m_damageModifiers)) { return null; } target = WithAreas((IDestructible)(object)component, go.GetComponentsInChildren<Collider>(false), area); } else if ((Object)(object)component2 != (Object)null) { if (component2.m_minToolTier > tier || Immune(component2.m_damageModifiers)) { return null; } target = WithAreas((IDestructible)(object)component2, Traverse.Create((object)component2).Field<Collider[]>("m_hitAreas").Value, area); } else { if (!((Object)(object)component3 != (Object)null) || (int)component3.m_destructibleType != 1 || (int)component3.m_damages.m_pickaxe == 3 || (int)component3.m_damages.m_pickaxe == 4 || component3.m_minToolTier > tier || (area != null && !area.Contains(go.transform.position))) { return null; } target = new Target { Destructible = (IDestructible)(object)component3 }; target.Areas.Add(null); } if (target != null) { Target target2 = target; ZNetView component4 = go.GetComponent<ZNetView>(); target2.Id = (ZDOID)(((??)((component4 == null) ? ((ZDOID?)null) : component4.GetZDO()?.m_uid)) ?? ZDOID.None); } return target; } private static Target WithAreas(IDestructible destructible, Collider[] colliders, Area area) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (colliders == null) { return null; } List<Collider> list = new List<Collider>(); bool flag = area == null; foreach (Collider val in colliders) { if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy && !val.isTrigger) { int num; if (area != null) { Bounds bounds = val.bounds; num = (area.Contains(((Bounds)(ref bounds)).center) ? 1 : 0); } else { num = 1; } bool flag2 = (byte)num != 0; flag = flag || flag2; if (flag2 || Plugin.WholeRocks.Value) { list.Add(val); } } } if (!flag || list.Count == 0) { return null; } Target target = new Target(); target.Destructible = destructible; target.Whole = list.Count == colliders.Length || area == null || Plugin.WholeRocks.Value; target.Areas.AddRange(list); return target; } private static bool Immune(DamageModifiers mods) { //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_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if ((int)mods.m_pickaxe != 3) { return (int)mods.m_pickaxe == 4; } return true; } private static HitData MakeHit(Player player, ItemData weapon, Vector3 point, Collider col) { //IL_0000: 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_0017: 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_002e: 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_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_0040: 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_0055: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown HitData val = new HitData { m_toolTier = (short)weapon.m_shared.m_toolTier, m_damage = { m_pickaxe = 100000f }, m_point = point, m_dir = Vector3.down, m_hitCollider = col, m_skill = (SkillType)12, m_itemLevel = (short)weapon.m_quality, m_hitType = (HitType)2 }; val.SetAttacker((Character)(object)player); return val; } } internal static class DigOps { private class Clone { public GameObject Prefab; public TerrainOp Op; public TerrainOp Source; } public const string Prefix = "WidePickaxe_"; private static readonly Dictionary<string, Clone> _clones = new Dictionary<string, Clone>(); private static GameObject _holder; public static bool IsOurs(Settings settings) { if (settings == null) { return false; } foreach (Clone value in _clones.Values) { if ((Object)(object)value.Op != (Object)null && value.Op.m_settings == settings) { return true; } } return false; } public static bool IsOurs(GameObject go) { if ((Object)(object)go != (Object)null) { return Utils.GetPrefabName(((Object)go).name).StartsWith("WidePickaxe_"); } return false; } public static void RegisterAll() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null) { return; } foreach (GameObject item in instance.m_items) { SharedData val = (((Object)(object)item != (Object)null) ? item.GetComponent<ItemDrop>() : null)?.m_itemData?.m_shared; if (val != null && (int)val.m_skillType == 12 && !((Object)(object)val.m_spawnOnHitTerrain == (Object)null)) { Get(val.m_spawnOnHitTerrain); } } foreach (Clone value in _clones.Values) { Register(value); } } public static GameObject Prepare(GameObject source) { Clone clone = Get(source); if (clone == null) { return null; } Register(clone); Apply(clone); return clone.Prefab; } private static Clone Get(GameObject source) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown if ((Object)(object)source == (Object)null || IsOurs(source)) { return null; } if (_clones.TryGetValue(((Object)source).name, out var value) && (Object)(object)value.Prefab != (Object)null && (Object)(object)value.Source != (Object)null) { return value; } TerrainOp componentInChildren = source.GetComponentInChildren<TerrainOp>(true); if ((Object)(object)componentInChildren == (Object)null) { return null; } if ((Object)(object)_holder == (Object)null) { _holder = new GameObject("WidePickaxe_Prefabs"); _holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_holder); } GameObject val = Object.Instantiate<GameObject>(source, _holder.transform); ((Object)val).name = "WidePickaxe_" + ((Object)source).name; TerrainOp componentInChildren2 = val.GetComponentInChildren<TerrainOp>(true); if ((Object)(object)((Component)componentInChildren2).gameObject != (Object)(object)val) { ((Object)((Component)componentInChildren2).gameObject).name = "WidePickaxe_" + ((Object)((Component)componentInChildren2).gameObject).name; } if ((Object)(object)val.GetComponent<ZNetView>() != (Object)null) { RegisterInScene(val); } value = new Clone { Prefab = val, Op = componentInChildren2, Source = componentInChildren }; _clones[((Object)source).name] = value; Plugin.InitDepth(0f - componentInChildren.m_settings.m_raiseDelta); Plugin.LogInfo($"Pickaxe dig '{((Object)source).name}': raise {componentInChildren.m_settings.m_raise} radius {componentInChildren.m_settings.m_raiseRadius} " + $"delta {componentInChildren.m_settings.m_raiseDelta} power {componentInChildren.m_settings.m_raisePower}, " + $"smooth {componentInChildren.m_settings.m_smooth}, paint {componentInChildren.m_settings.m_paintCleared} {componentInChildren.m_settings.m_paintRadius}, " + "spawn '" + (((Object)(object)componentInChildren.m_spawnOnPlaced != (Object)null) ? ((Object)componentInChildren.m_spawnOnPlaced).name : "-") + "' " + $"x{componentInChildren.m_maxSpawned} @{componentInChildren.m_chanceToSpawn}."); return value; } private static void Apply(Clone clone) { Settings settings = clone.Op.m_settings; Settings settings2 = clone.Source.m_settings; float currentRadius = Plugin.CurrentRadius; float currentDepth = Plugin.CurrentDepth; bool useSquare = Plugin.UseSquare; settings.m_level = false; settings.m_raise = true; settings.m_raiseRadius = currentRadius; settings.m_raiseDelta = 0f - currentDepth; settings.m_raisePower = (Plugin.FlatBottom.Value ? 0f : settings2.m_raisePower); settings.m_square = useSquare; settings.m_rotation = false; settings.m_smooth = Plugin.SmoothEdges.Value; settings.m_smoothRadius = currentRadius; settings.m_paintCleared = settings2.m_paintCleared; settings.m_paintRadius = currentRadius; TerrainOp op = clone.Op; TerrainOp source = clone.Source; op.m_chanceToSpawn = source.m_chanceToSpawn; op.m_maxSpawned = source.m_maxSpawned; if (Plugin.ScaleDropsWithArea.Value && (Object)(object)source.m_spawnOnPlaced != (Object)null) { float num = Mathf.Max(0.25f, settings2.m_raise ? settings2.m_raiseRadius : settings2.GetRadius()); float num2 = Mathf.Max(0.05f, 0f - settings2.m_raiseDelta); float num3 = (useSquare ? (4f * currentRadius * currentRadius) : ((float)Math.PI * currentRadius * currentRadius)) / ((float)Math.PI * num * num) * (currentDepth / num2); float num4 = Mathf.Clamp01(source.m_chanceToSpawn); if (num3 > 1f && num4 > 0f) { float num5 = Mathf.Min(1f, num4 * num3); float num6 = num3 * num4 / num5; int num7 = source.m_spawnOnPlaced.GetComponent<ItemDrop>()?.m_itemData?.m_shared?.m_maxStackSize ?? 50; op.m_chanceToSpawn = num5; op.m_maxSpawned = Mathf.Clamp(Mathf.RoundToInt(num6 * (float)(1 + source.m_maxSpawned) - 1f), 1, Mathf.Max(1, num7)); } } } private static void Register(Clone clone) { ObjectDB instance = ObjectDB.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)clone?.Op == (Object)null)) { if (!instance.m_terrainOps.Contains(clone.Op)) { instance.m_terrainOps.Add(clone.Op); } instance.m_terrainOpsByHash[instance.GetPrefabHash(((Component)clone.Op).gameObject)] = clone.Op; } } private static void RegisterInScene(GameObject prefab) { ZNetScene instance = ZNetScene.instance; if (!((Object)(object)instance == (Object)null)) { if (!instance.m_prefabs.Contains(prefab)) { instance.m_prefabs.Add(prefab); } Dictionary<int, GameObject> value = Traverse.Create((object)instance).Field<Dictionary<int, GameObject>>("m_namedPrefabs").Value; if (value != null) { value[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = prefab; } } } } internal static class DigPreview { public enum TargetState { None, Ok, TooFar, Protected } private const float Lift = 0.06f; private const float CellSize = 0.75f; private const int CircleSegments = 48; private const float RayDistance = 40f; private const float ReachSlack = 0.6f; private const float RebuildInterval = 0.2f; private static readonly Color OkFill = new Color(0.15f, 1f, 0.28f, 0.22f); private static readonly Color OkLine = new Color(0.25f, 1f, 0.35f, 0.95f); private static readonly Color BadFill = new Color(1f, 0.15f, 0.12f, 0.22f); private static readonly Color BadLine = new Color(1f, 0.2f, 0.15f, 0.95f); private static GameObject _root; private static Mesh _mesh; private static MeshRenderer _renderer; private static LineRenderer _border; private static Material _okFillMat; private static Material _okLineMat; private static Material _badFillMat; private static Material _badLineMat; private static bool _loggedShader; private static Vector3 _builtAt; private static float _builtRadius; private static bool _builtSquare; private static float _nextRebuild; public static TargetState State { get; private set; } public static Vector3 Target { get; private set; } public static bool IsValid => State == TargetState.Ok; public static void Update(Player player) { //IL_0028: 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_0066: 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_00c0: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_011c: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) State = TargetState.None; if (!Plugin.Enabled.Value || !Plugin.IsPickaxeActive() || !FindTarget(out var point)) { Hide(); return; } Target = point; State = Evaluate(player, point); if (!Plugin.ShowPreview.Value) { Hide(); return; } Ensure(); _root.SetActive(true); _root.transform.SetPositionAndRotation(point, Quaternion.identity); bool flag = State == TargetState.Ok; ((Renderer)_renderer).sharedMaterial = (flag ? _okFillMat : _badFillMat); ((Renderer)_border).sharedMaterial = (flag ? _okLineMat : _badLineMat); LineRenderer border = _border; Color startColor = (_border.endColor = (flag ? OkLine : BadLine)); border.startColor = startColor; float currentRadius = Plugin.CurrentRadius; bool useSquare = Plugin.UseSquare; if (!(Time.time >= _nextRebuild)) { Vector3 val2 = point - _builtAt; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.04f) && Mathf.Approximately(currentRadius, _builtRadius) && useSquare == _builtSquare) { return; } } Build(point, currentRadius, useSquare); } public static void Hide() { if ((Object)(object)_root != (Object)null && _root.activeSelf) { _root.SetActive(false); } } public static void Destroy() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; } private static bool FindTarget(out Vector3 point) { //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_0038: 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_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) point = Vector3.zero; GameCamera instance = GameCamera.instance; if ((Object)(object)instance == (Object)null) { return false; } Transform transform = ((Component)instance).transform; int mask = LayerMask.GetMask(new string[1] { "terrain" }); RaycastHit val = default(RaycastHit); if (!Physics.Raycast(transform.position, transform.forward, ref val, 40f, mask, (QueryTriggerInteraction)1)) { return false; } point = ((RaycastHit)(ref val)).point; return true; } private static TargetState Evaluate(Player player, Vector3 point) { //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_0052: 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_005c: 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_0092: Unknown result type (might be due to invalid IL or missing references) Attack val = ((Humanoid)player).GetCurrentWeapon()?.m_shared?.m_attack; float num = val?.m_attackRange ?? 2f; float num2 = val?.m_attackHeight ?? 1f; if (Vector3.Distance(((Component)player).transform.position + Vector3.up * num2, point) > num + 0.6f) { return TargetState.TooFar; } float num3 = Plugin.CurrentRadius * (Plugin.UseSquare ? 1.42f : 1f); if (!PrivateArea.CheckAccess(point, num3, false, false) || Location.IsInsideNoBuildLocation(point)) { return TargetState.Protected; } return TargetState.Ok; } private static void Build(Vector3 origin, float radius, bool square) { //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_0034: 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) _builtAt = origin; _builtRadius = radius; _builtSquare = square; _nextRebuild = Time.time + 0.2f; Vector3[] verts; int[] tris; Vector3[] ring; if (square) { BuildSquare(origin, radius, out verts, out tris, out ring); } else { BuildCircle(origin, radius, out verts, out tris, out ring); } _mesh.Clear(); _mesh.vertices = verts; _mesh.triangles = tris; _mesh.RecalculateNormals(); _mesh.RecalculateBounds(); _border.positionCount = ring.Length; _border.SetPositions(ring); } private static void BuildCircle(Vector3 origin, float radius, out Vector3[] verts, out int[] tris, out Vector3[] ring) { //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_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_0064: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) int num = Mathf.Max(1, Mathf.CeilToInt(radius / 0.75f)); int num2 = 48; verts = (Vector3[])(object)new Vector3[1 + num * num2]; verts[0] = Draped(origin, Vector3.zero); for (int i = 1; i <= num; i++) { float num3 = radius * (float)i / (float)num; for (int j = 0; j < num2; j++) { float num4 = (float)Math.PI * 2f * (float)j / (float)num2; verts[1 + (i - 1) * num2 + j] = Draped(origin, new Vector3(Mathf.Sin(num4) * num3, 0f, Mathf.Cos(num4) * num3)); } } tris = new int[num2 * 3 + (num - 1) * num2 * 6]; int num5 = 0; for (int k = 0; k < num2; k++) { tris[num5++] = 0; tris[num5++] = 1 + k; tris[num5++] = 1 + (k + 1) % num2; } for (int l = 1; l < num; l++) { int num6 = 1 + (l - 1) * num2; int num7 = 1 + l * num2; for (int m = 0; m < num2; m++) { int num8 = (m + 1) % num2; tris[num5++] = num6 + m; tris[num5++] = num7 + m; tris[num5++] = num7 + num8; tris[num5++] = num6 + m; tris[num5++] = num7 + num8; tris[num5++] = num6 + num8; } } ring = (Vector3[])(object)new Vector3[num2]; int num9 = 1 + (num - 1) * num2; for (int n = 0; n < num2; n++) { ring[n] = verts[num9 + n]; } } private static void BuildSquare(Vector3 origin, float radius, out Vector3[] verts, out int[] tris, out Vector3[] ring) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_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_0152: 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_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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(1, Mathf.CeilToInt(radius * 2f / 0.75f)); int num2 = num + 1; verts = (Vector3[])(object)new Vector3[num2 * num2]; Vector3 local = default(Vector3); for (int i = 0; i < num2; i++) { for (int j = 0; j < num2; j++) { ((Vector3)(ref local))..ctor(0f - radius + radius * 2f * (float)j / (float)num, 0f, 0f - radius + radius * 2f * (float)i / (float)num); verts[i * num2 + j] = Draped(origin, local); } } tris = new int[num * num * 6]; int num3 = 0; for (int k = 0; k < num; k++) { for (int l = 0; l < num; l++) { int num4 = k * num2 + l; tris[num3++] = num4; tris[num3++] = num4 + num2; tris[num3++] = num4 + num2 + 1; tris[num3++] = num4; tris[num3++] = num4 + num2 + 1; tris[num3++] = num4 + 1; } } ring = (Vector3[])(object)new Vector3[num * 4]; int num5 = 0; for (int m = 0; m < num; m++) { ring[num5++] = verts[m]; } for (int n = 0; n < num; n++) { ring[num5++] = verts[n * num2 + num]; } for (int num6 = num; num6 > 0; num6--) { ring[num5++] = verts[num * num2 + num6]; } for (int num7 = num; num7 > 0; num7--) { ring[num5++] = verts[num7 * num2]; } } private static Vector3 Draped(Vector3 origin, Vector3 local) { //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_0022: 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_0029: 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_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) Vector3 val = origin + local; float num = (((Object)(object)ZoneSystem.instance != (Object)null) ? ZoneSystem.instance.GetGroundHeight(val) : origin.y); return new Vector3(local.x, num - origin.y + 0.06f, local.z); } private static void Ensure() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_002c: 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_0041: Expected O, but got Unknown //IL_00ae: 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) if (!((Object)(object)_root != (Object)null)) { EnsureMaterials(); _root = new GameObject("WidePickaxe_Preview"); Object.DontDestroyOnLoad((Object)(object)_root); _mesh = new Mesh { name = "WidePickaxePreview" }; _mesh.MarkDynamic(); _root.AddComponent<MeshFilter>().sharedMesh = _mesh; _renderer = _root.AddComponent<MeshRenderer>(); ((Renderer)_renderer).sharedMaterial = _okFillMat; ((Renderer)_renderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_renderer).receiveShadows = false; ((Renderer)_renderer).lightProbeUsage = (LightProbeUsage)0; ((Renderer)_renderer).reflectionProbeUsage = (ReflectionProbeUsage)0; GameObject val = new GameObject("Border"); val.transform.SetParent(_root.transform, false); _border = val.AddComponent<LineRenderer>(); ((Renderer)_border).sharedMaterial = _okLineMat; _border.useWorldSpace = false; _border.loop = true; _border.widthMultiplier = 0.07f; _border.numCapVertices = 2; _border.numCornerVertices = 2; ((Renderer)_border).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)_border).receiveShadows = false; _border.textureMode = (LineTextureMode)0; _builtRadius = -1f; } } private static void EnsureMaterials() { //IL_0014: 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_0034: 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) if (!((Object)(object)_okFillMat != (Object)null)) { Shader shader = FindShader(); _okFillMat = MakeMaterial(shader, OkFill); _okLineMat = MakeMaterial(shader, OkLine); _badFillMat = MakeMaterial(shader, BadFill); _badLineMat = MakeMaterial(shader, BadLine); } } private static Material MakeMaterial(Shader shader, Color color) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0038: 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_006a: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader) { color = color }; val.SetInt("_ZWrite", 0); val.renderQueue = 3000; if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_TintColor")) { val.SetColor("_TintColor", color); } return val; } private static Shader FindShader() { string[] array = new string[8] { "Sprites/Default", "Legacy Shaders/Particles/Alpha Blended", "Particles/Standard Unlit", "Unlit/Color", "Legacy Shaders/Transparent/Diffuse", "UI/Default", "Universal Render Pipeline/Unlit", "Hidden/Internal-Colored" }; foreach (string text in array) { Shader val = Shader.Find(text); if (!((Object)(object)val == (Object)null)) { if (!_loggedShader) { _loggedShader = true; Plugin.LogInfo("Preview shader: " + text); } return val; } } return Shader.Find("Standard") ?? Shader.Find("Diffuse"); } } internal static class DigUndo { internal class TerrainPatch { public TerrainComp Comp; public int[] Indices; public float[] Level; public float[] Smooth; public bool[] ModifiedHeight; public Color[] Paint; public bool[] ModifiedPaint; } internal class PickedItem { public string Name; public int Quality; public int Amount; } internal class ObjectRecord { public ZDOID Id; public string Prefab; public Vector3 Position; public Quaternion Rotation; public Vector3 Scale; public float Health; public string AreaHealth; public readonly Dictionary<string, float> AreaFloats = new Dictionary<string, float>(); } public class Step { public Vector3 Center; public float Extent; public readonly List<TerrainPatch> Terrain = new List<TerrainPatch>(); public readonly List<ItemDrop> Drops = new List<ItemDrop>(); public readonly List<PickedItem> Picked = new List<PickedItem>(); public readonly List<ObjectRecord> Objects = new List<ObjectRecord>(); public readonly List<ZDOID> Spawned = new List<ZDOID>(); public void Record(ZNetView nview) { //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_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_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = nview.GetZDO(); GameObject gameObject = ((Component)nview).gameObject; ObjectRecord objectRecord = new ObjectRecord { Id = zDO.m_uid, Prefab = Utils.GetPrefabName(gameObject), Position = gameObject.transform.position, Rotation = gameObject.transform.rotation, Scale = gameObject.transform.localScale, Health = zDO.GetFloat(ZDOVars.s_health, float.NaN), AreaHealth = zDO.GetString(ZDOVars.s_health, "") }; MineRock component = gameObject.GetComponent<MineRock>(); Collider[] array = (((Object)(object)component != (Object)null) ? Traverse.Create((object)component).Field<Collider[]>("m_hitAreas").Value : null); if (array != null) { for (int i = 0; i < array.Length; i++) { string text = "Health" + i; float num = zDO.GetFloat(text, float.NaN); if (!float.IsNaN(num)) { objectRecord.AreaFloats[text] = num; } } } Objects.Add(objectRecord); } } public class PendingPickup { public Step Step; public ItemDrop Drop; public string Name; public int Quality; public int Stack; } private const float EdgeMargin = 2f; private static readonly List<Step> _history = new List<Step>(); private static readonly Dictionary<ItemDrop, Step> _dropOwner = new Dictionary<ItemDrop, Step>(); private static Step _capturing; public static int Count => _history.Count; public static void Clear() { _history.Clear(); _dropOwner.Clear(); _capturing = null; } public static Step Begin(Vector3 center, float radius, bool terrain = true) { //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) Step step = new Step { Center = center, Extent = radius * 1.42f + 2f }; if (terrain) { SnapshotTerrain(step); } _capturing = step; return step; } public static void End(Step step, bool happened) { if (_capturing == step) { _capturing = null; } if (step != null && happened) { _history.Add(step); int num = Mathf.Max(1, Plugin.UndoHistory.Value); while (_history.Count > num) { Forget(_history[0]); _history.RemoveAt(0); } } } public static void Abort() { _capturing = null; } public static void OnDropCreated(ItemDrop drop) { if (_capturing != null && !((Object)(object)drop == (Object)null)) { _capturing.Drops.Add(drop); _dropOwner[drop] = _capturing; } } public static PendingPickup BeforePickup(ItemDrop drop) { if ((Object)(object)drop == (Object)null || !_dropOwner.TryGetValue(drop, out var value)) { return null; } drop.Load(); ItemData itemData = drop.m_itemData; if (itemData?.m_shared == null) { return null; } return new PendingPickup { Step = value, Drop = drop, Name = itemData.m_shared.m_name, Quality = itemData.m_quality, Stack = itemData.m_stack }; } public static void AfterPickup(PendingPickup pending) { _dropOwner.Remove(pending.Drop); pending.Step.Drops.Remove(pending.Drop); pending.Step.Picked.Add(new PickedItem { Name = pending.Name, Quality = pending.Quality, Amount = pending.Stack }); } public static void Undo() { //IL_00ad: 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) Player localPlayer = Player.m_localPlayer; if (_history.Count == 0) { if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Loc.IsRussian ? "Нечего отменять" : "Nothing to undo", 0, (Sprite)null, false); } return; } Step step = _history[_history.Count - 1]; _history.RemoveAt(_history.Count - 1); Forget(step); foreach (TerrainPatch item in step.Terrain) { RestoreTerrain(item); } if ((Object)(object)ClutterSystem.instance != (Object)null) { ClutterSystem.instance.ResetGrass(step.Center, step.Extent); } foreach (ZDOID item2 in step.Spawned) { DestroyById(item2); } int num = 0; foreach (ObjectRecord @object in step.Objects) { if (RestoreObject(@object)) { num++; } } int num2 = 0; foreach (ItemDrop drop in step.Drops) { if (!((Object)(object)drop == (Object)null)) { ZNetView component = ((Component)drop).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && !((Object)(object)ZNetScene.instance == (Object)null)) { component.ClaimOwnership(); num2 += ((drop.m_itemData == null) ? 1 : drop.m_itemData.m_stack); ZNetScene.instance.Destroy(((Component)drop).gameObject); } } } Dictionary<string, int> dictionary = new Dictionary<string, int>(); int num3 = 0; Inventory val = (((Object)(object)localPlayer != (Object)null) ? ((Humanoid)localPlayer).GetInventory() : null); foreach (PickedItem item3 in step.Picked) { int num4 = Mathf.Min((val != null) ? val.CountItems(item3.Name, item3.Quality, false) : 0, item3.Amount); num3 += item3.Amount - num4; if (num4 > 0) { val.RemoveItem(item3.Name, num4, item3.Quality, false); dictionary.TryGetValue(item3.Name, out var value); dictionary[item3.Name] = value + num4; } } StringBuilder stringBuilder = new StringBuilder(Loc.IsRussian ? $"Отменено (осталось {_history.Count})" : $"Undone ({_history.Count} left)"); foreach (KeyValuePair<string, int> item4 in dictionary) { stringBuilder.Append($"\n-{item4.Value} {Loc.Localize(item4.Key)}"); } if (num3 > 0) { stringBuilder.Append(Loc.IsRussian ? $"\n{num3} шт. уже нет в инвентаре" : $"\n{num3} item(s) no longer in inventory"); } if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, stringBuilder.ToString(), 0, (Sprite)null, false); } Plugin.LogInfo($"Undo: terrain zones {step.Terrain.Count}, rocks restored {num}, items removed from ground {num2}, " + $"from inventory {SumValues(dictionary)}, missing {num3}."); } private static bool RestoreObject(ObjectRecord record) { //IL_001c: 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_0074: 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_00b9: 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) ZNetScene instance = ZNetScene.instance; ZDOMan instance2 = ZDOMan.instance; if ((Object)(object)instance == (Object)null || instance2 == null) { return false; } ZDO zDO = instance2.GetZDO(record.Id); if (zDO != null && !Changed(record, zDO)) { return false; } GameObject prefab = instance.GetPrefab(record.Prefab); if ((Object)(object)prefab == (Object)null) { Plugin.LogWarning("Undo: prefab '" + record.Prefab + "' not found."); return false; } DestroyById(record.Id); GameObject val = Object.Instantiate<GameObject>(prefab, record.Position, record.Rotation); ZNetView component = val.GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.m_syncInitialScale) { component.SetLocalScale(record.Scale); } else { val.transform.localScale = record.Scale; } ZDO val2 = (((Object)(object)component != (Object)null) ? component.GetZDO() : null); if (val2 != null) { if (!float.IsNaN(record.Health)) { val2.Set(ZDOVars.s_health, record.Health); } if (!string.IsNullOrEmpty(record.AreaHealth)) { val2.Set(ZDOVars.s_health, record.AreaHealth); } foreach (KeyValuePair<string, float> areaFloat in record.AreaFloats) { val2.Set(areaFloat.Key, areaFloat.Value); } } return true; } private static bool Changed(ObjectRecord record, ZDO zdo) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) float num = zdo.GetFloat(ZDOVars.s_health, float.NaN); if (float.IsNaN(num) != float.IsNaN(record.Health) || (!float.IsNaN(num) && !Mathf.Approximately(num, record.Health))) { return true; } if (zdo.GetString(ZDOVars.s_health, "") != (record.AreaHealth ?? string.Empty)) { return true; } GameObject val = ZNetScene.instance.FindInstance(record.Id); MineRock val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<MineRock>() : null); Collider[] array = (((Object)(object)val2 != (Object)null) ? Traverse.Create((object)val2).Field<Collider[]>("m_hitAreas").Value : null); if (array != null) { for (int i = 0; i < array.Length; i++) { string text = "Health" + i; float num2 = zdo.GetFloat(text, float.NaN); float value; bool flag = record.AreaFloats.TryGetValue(text, out value); if (float.IsNaN(num2) == flag || (flag && !Mathf.Approximately(num2, value))) { return true; } } } return false; } private static void DestroyById(ZDOID id) { //IL_000d: 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) ZDOMan instance = ZDOMan.instance; ZDO val = ((instance != null) ? instance.GetZDO(id) : null); if (val != null) { GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.FindInstance(id) : null); ZNetView val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<ZNetView>() : null); if ((Object)(object)val3 != (Object)null && val3.IsValid()) { val3.ClaimOwnership(); ZNetScene.instance.Destroy(val2); } else { val.SetOwner(ZDOMan.GetSessionID()); instance.DestroyZDO(val); } } } private static void Forget(Step step) { foreach (ItemDrop drop in step.Drops) { if ((Object)(object)drop != (Object)null) { _dropOwner.Remove(drop); } } List<ItemDrop> list = new List<ItemDrop>(); foreach (ItemDrop key in _dropOwner.Keys) { if ((Object)(object)key == (Object)null) { list.Add(key); } } foreach (ItemDrop item in list) { _dropOwner.Remove(item); } } private static int SumValues(Dictionary<string, int> values) { int num = 0; foreach (int value in values.Values) { num += value; } return num; } private static void SnapshotTerrain(Step step) { //IL_0007: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) List<Heightmap> list = new List<Heightmap>(); Heightmap.FindHeightmap(step.Center, step.Extent, list); foreach (Heightmap item in list) { TerrainComp andCreateTerrainCompiler = item.GetAndCreateTerrainCompiler(); if ((Object)(object)andCreateTerrainCompiler == (Object)null) { continue; } Traverse obj = Traverse.Create((object)andCreateTerrainCompiler); float[] value = obj.Field<float[]>("m_levelDelta").Value; float[] value2 = obj.Field<float[]>("m_smoothDelta").Value; bool[] value3 = obj.Field<bool[]>("m_modifiedHeight").Value; Color[] value4 = obj.Field<Color[]>("m_paintMask").Value; bool[] value5 = obj.Field<bool[]>("m_modifiedPaint").Value; int value6 = obj.Field<int>("m_pitch").Value; if (value == null || value4 == null || value6 <= 0) { continue; } int num = Mathf.Min(value.Length, value4.Length); List<int> list2 = new List<int>(); for (int i = 0; i < num; i++) { Vector3 val = item.VertexMaskToWorld(i % value6, i / value6); if (Mathf.Abs(val.x - step.Center.x) <= step.Extent && Mathf.Abs(val.z - step.Center.z) <= step.Extent) { list2.Add(i); } } if (list2.Count != 0) { TerrainPatch terrainPatch = new TerrainPatch { Comp = andCreateTerrainCompiler, Indices = list2.ToArray(), Level = new float[list2.Count], Smooth = new float[list2.Count], ModifiedHeight = new bool[list2.Count], Paint = (Color[])(object)new Color[list2.Count], ModifiedPaint = new bool[list2.Count] }; for (int j = 0; j < list2.Count; j++) { int num2 = list2[j]; terrainPatch.Level[j] = value[num2]; terrainPatch.Smooth[j] = value2[num2]; terrainPatch.ModifiedHeight[j] = value3[num2]; terrainPatch.Paint[j] = value4[num2]; terrainPatch.ModifiedPaint[j] = value5[num2]; } step.Terrain.Add(terrainPatch); } } } private static void RestoreTerrain(TerrainPatch patch) { //IL_0106: 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) if ((Object)(object)patch.Comp == (Object)null) { Plugin.LogWarning("Undo: terrain zone is no longer loaded, skipped."); return; } Traverse val = Traverse.Create((object)patch.Comp); ZNetView value = val.Field<ZNetView>("m_nview").Value; Heightmap value2 = val.Field<Heightmap>("m_hmap").Value; if (!((Object)(object)value == (Object)null) && value.IsValid() && !((Object)(object)value2 == (Object)null)) { value.ClaimOwnership(); float[] value3 = val.Field<float[]>("m_levelDelta").Value; float[] value4 = val.Field<float[]>("m_smoothDelta").Value; bool[] value5 = val.Field<bool[]>("m_modifiedHeight").Value; Color[] value6 = val.Field<Color[]>("m_paintMask").Value; bool[] value7 = val.Field<bool[]>("m_modifiedPaint").Value; for (int i = 0; i < patch.Indices.Length; i++) { int num = patch.Indices[i]; value3[num] = patch.Level[i]; value4[num] = patch.Smooth[i]; value5[num] = patch.ModifiedHeight[i]; value6[num] = patch.Paint[i]; value7[num] = patch.ModifiedPaint[i]; } val.Method("Save", new object[1] { false }).GetValue(); value2.Poke(0, false); } } } internal static class Loc { private static Localization Current => Traverse.Create(typeof(Localization)).Field<Localization>("m_instance").Value; public static bool IsRussian { get { Localization current = Current; if (current != null) { return current.GetSelectedLanguage() == "Russian"; } return false; } } public static string Localize(string token) { Localization current = Current; if (current == null) { return token; } return current.Localize(token); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class ObjectDbAwakePatch { private static void Postfix() { try { DigOps.RegisterAll(); } catch (Exception arg) { Plugin.LogError($"ObjectDB.Awake: {arg}"); } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] internal static class ObjectDbCopyPatch { private static void Postfix() { try { DigOps.RegisterAll(); } catch (Exception arg) { Plugin.LogError($"ObjectDB.CopyOtherDB: {arg}"); } } } [HarmonyPatch(typeof(ZNetScene), "OnDestroy")] internal static class ZNetSceneDestroyPatch { private static void Prefix() { try { DigUndo.Clear(); DigPreview.Hide(); } catch (Exception arg) { Plugin.LogError($"ZNetScene.OnDestroy: {arg}"); } } } [HarmonyPatch(typeof(Player), "Update")] internal static class PlayerUpdatePatch { private static float _repeat; private static void Postfix(Player __instance) { //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_0052: 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) try { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } if (!Plugin.IsPickaxeActive() || Plugin.IsUiBlocking()) { _repeat = 0f; DigPreview.Hide(); return; } KeyboardShortcut value = Plugin.UndoKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { DigUndo.Undo(); } value = Plugin.ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { Plugin.Toggle(); } DigPreview.Update(__instance); if (!Plugin.Enabled.Value) { _repeat = 0f; return; } if (ZInput.GetKeyDown((KeyCode)276, false)) { Plugin.SetSquare(square: true); } if (ZInput.GetKeyDown((KeyCode)275, false)) { Plugin.SetSquare(square: false); } HandleRepeat(); } catch (Exception arg) { Plugin.LogError($"Player.Update: {arg}"); } } private static void HandleRepeat() { bool key = ZInput.GetKey((KeyCode)273, false); bool key2 = ZInput.GetKey((KeyCode)274, false); bool key3 = ZInput.GetKey((KeyCode)280, false); bool key4 = ZInput.GetKey((KeyCode)281, false); if (!key && !key2 && !key3 && !key4) { _repeat = 0f; return; } bool flag = ZInput.GetKeyDown((KeyCode)273, false) || ZInput.GetKeyDown((KeyCode)274, false) || ZInput.GetKeyDown((KeyCode)280, false) || ZInput.GetKeyDown((KeyCode)281, false); _repeat -= Time.deltaTime; if (flag || !(_repeat > 0f)) { _repeat = (flag ? 0.25f : 0.07f); if (key) { Plugin.SetRadius(Plugin.CurrentRadius + Plugin.RadiusStep.Value); } if (key2) { Plugin.SetRadius(Plugin.CurrentRadius - Plugin.RadiusStep.Value); } if (key3) { Plugin.SetDepth(Plugin.CurrentDepth + Plugin.DepthStep.Value); } if (key4) { Plugin.SetDepth(Plugin.CurrentDepth - Plugin.DepthStep.Value); } } } } [HarmonyPatch(typeof(Attack), "SpawnOnHitTerrain")] internal static class SpawnOnHitTerrainPatch { private const float MaxAimShift = 3f; private static void Prefix(ref Vector3 hitPoint, ref GameObject prefab, Character character, ItemData weapon, out DigUndo.Step __state) { //IL_007e: 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_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) __state = null; try { if (!Plugin.Enabled.Value || (Object)(object)character == (Object)null || (Object)(object)character != (Object)(object)Player.m_localPlayer || !Plugin.IsPickaxe(weapon)) { return; } GameObject val = DigOps.Prepare(prefab); if (!((Object)(object)val == (Object)null)) { if (Plugin.DigAtCrosshair.Value && DigPreview.IsValid && Vector3.Distance(DigPreview.Target, hitPoint) <= 3f) { hitPoint = DigPreview.Target; } prefab = val; __state = DigUndo.Begin(hitPoint, Plugin.CurrentRadius); } } catch (Exception arg) { Plugin.LogError($"SpawnOnHitTerrain: {arg}"); } } private static void Postfix(GameObject __result, DigUndo.Step __state, Vector3 hitPoint, Character character, ItemData weapon) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (__state == null) { return; } try { if ((Object)(object)__result != (Object)null && Plugin.MineObjects.Value) { DigMining.MineArea(__state, (Player)(object)((character is Player) ? character : null), weapon, hitPoint, Plugin.CurrentRadius, Plugin.UseSquare, Plugin.CurrentDepth); } } catch (Exception arg) { Plugin.LogError($"Mining: {arg}"); } finally { DigUndo.End(__state, (Object)(object)__result != (Object)null); } } private static Exception Finalizer(Exception __exception) { if (__exception != null) { DigUndo.Abort(); } return __exception; } } [HarmonyPatch(typeof(Settings), "GetRadius")] internal static class SettingsRadiusPatch { private static void Postfix(Settings __instance, ref float __result) { if (__instance.m_square && DigOps.IsOurs(__instance)) { __result = Mathf.Max(__result, __instance.m_raiseRadius * 1.42f); } } } [HarmonyPatch(typeof(ItemDrop), "Awake")] internal static class ItemDropAwakePatch { private static void Postfix(ItemDrop __instance) { try { DigUndo.OnDropCreated(__instance); } catch (Exception arg) { Plugin.LogError($"ItemDrop.Awake: {arg}"); } } } [HarmonyPatch(typeof(Humanoid), "Pickup")] internal static class PickupPatch { private static void Prefix(Humanoid __instance, GameObject go, out DigUndo.PendingPickup __state) { __state = null; try { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && (Object)(object)go != (Object)null) { __state = DigUndo.BeforePickup(go.GetComponent<ItemDrop>()); } } catch (Exception arg) { Plugin.LogError($"Pickup: {arg}"); } } private static void Postfix(bool __result, DigUndo.PendingPickup __state) { if (__result && __state != null) { DigUndo.AfterPickup(__state); } } } [HarmonyPatch] internal static class WholeRockPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(MineRock5), "Damage", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(MineRock), "Damage", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Destructible), "Damage", (Type[])null, (Type[])null); } private static bool Prefix(Component __instance, HitData hit) { try { return !DigMining.TryMineWhole(__instance.gameObject, hit); } catch (Exception arg) { Plugin.LogError($"Whole rock: {arg}"); return true; } } } [HarmonyPatch(typeof(DamageText), "ShowText", new Type[] { typeof(DamageModifier), typeof(Vector3), typeof(float), typeof(bool) })] internal static class DamageTextPatch { private static bool Prefix() { return !DigMining.Busy; } } [BepInPlugin("com.valheimtools.pickaxeradius", "Wide Pickaxe", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string ModGuid = "com.valheimtools.pickaxeradius"; public const string ModName = "Wide Pickaxe"; public const string ModVersion = "1.0.0"; public static ConfigEntry<bool> Enabled; public static ConfigEntry<float> Radius; public static ConfigEntry<float> MinRadius; public static ConfigEntry<float> MaxRadius; public static ConfigEntry<float> RadiusStep; public static ConfigEntry<float> Depth; public static ConfigEntry<float> MinDepth; public static ConfigEntry<float> MaxDepth; public static ConfigEntry<float> DepthStep; public static ConfigEntry<bool> SquareShape; public static ConfigEntry<bool> FlatBottom; public static ConfigEntry<bool> SmoothEdges; public static ConfigEntry<bool> DigAtCrosshair; public static ConfigEntry<bool> ScaleDropsWithArea; public static ConfigEntry<bool> MineObjects; public static ConfigEntry<bool> WholeRocks; public static ConfigEntry<bool> WholeRockOnHit; public static ConfigEntry<bool> ShowHud; public static ConfigEntry<bool> ShowPreview; public static ConfigEntry<KeyboardShortcut> ToggleKey; public static ConfigEntry<KeyboardShortcut> UndoKey; public static ConfigEntry<int> UndoHistory; private Harmony _harmony; public static Plugin Instance { get; private set; } public static float CurrentRadius { get; private set; } public static float CurrentDepth { get; private set; } public static bool UseSquare { get; private set; } private void Awake() { //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Expected O, but got Unknown Instance = this; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Dig with the radius below. Toggle in-game with ToggleKey."); Radius = ((BaseUnityPlugin)this).Config.Bind<float>("Dig", "Radius", 3f, "Starting dig radius in meters. Change in-game with Up/Down arrows."); MinRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Dig", "MinRadius", 1f, "Minimum radius the Up/Down arrows can set."); MaxRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Dig", "MaxRadius", 12f, "Maximum radius the Up/Down arrows can set."); RadiusStep = ((BaseUnityPlugin)this).Config.Bind<float>("Dig", "RadiusStep", 0.5f, "Radius change per Up/Down arrow step."); Depth = ((BaseUnityPlugin)this).Config.Bind<float>("Dig", "Depth", 0f, "Starting depth dug per hit, in meters below the hit point. 0 = same as the vanilla pickaxe. Change in-game with PageUp/PageDown."); MinDepth = ((BaseUnityPlugin)this).Config.Bind<float>("Dig", "MinDepth", 0.1f, "Minimum depth PageUp/PageDown can set."); MaxDepth = ((BaseUnityPlugin)this).Config.Bind<float>("Dig", "MaxDepth", 4f, "Maximum depth PageUp/PageDown can set."); DepthStep = ((BaseUnityPlugin)this).Config.Bind<float>("Dig", "DepthStep", 0.25f, "Depth change per PageUp/PageDown step."); SquareShape = ((BaseUnityPlugin)this).Config.Bind<bool>("Dig", "SquareShape", false, "Starting shape. In-game: Left arrow = square, Right arrow = circle."); FlatBottom = ((BaseUnityPlugin)this).Config.Bind<bool>("Dig", "FlatBottom", true, "If true, the whole area is dug to the same depth (flat floor). If false, it fades out towards the edge like vanilla."); SmoothEdges = ((BaseUnityPlugin)this).Config.Bind<bool>("Dig", "SmoothEdges", false, "If true, also run the vanilla smoothing pass over the area."); DigAtCrosshair = ((BaseUnityPlugin)this).Config.Bind<bool>("Dig", "DigAtCrosshair", true, "If true, the hole is centered exactly on the preview under the crosshair (when it is green)."); ScaleDropsWithArea = ((BaseUnityPlugin)this).Config.Bind<bool>("Dig", "ScaleDropsWithArea", true, "If digging yields items (stone etc.), scale the amount by the dug area and depth (capped at one full stack)."); MineObjects = ((BaseUnityPlugin)this).Config.Bind<bool>("Dig", "MineObjects", true, "If true, rocks, ore veins and scrap piles inside the dug area are mined too and drop their usual loot. Ore your pickaxe is too weak for stays. Undo puts them back and takes the loot away."); WholeRocks = ((BaseUnityPlugin)this).Config.Bind<bool>("Dig", "WholeRocks", true, "If true, a boulder or vein the dug area touches is mined completely. If false, only its parts inside the area."); WholeRockOnHit = ((BaseUnityPlugin)this).Config.Bind<bool>("Dig", "WholeRockOnHit", true, "If true, hitting a boulder, ore vein or scrap pile directly removes all of it in one hit (with its usual loot)."); ShowHud = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowHud", true, "Show width, depth and shape next to the crosshair while holding a pickaxe."); ShowPreview = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowPreview", true, "Show the dig area on the ground: green = in reach, red = too far / protected."); ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "ToggleKey", new KeyboardShortcut((KeyCode)8, Array.Empty<KeyCode>()), "Switch between radius digging and the vanilla pickaxe."); UndoKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "UndoKey", new KeyboardShortcut((KeyCode)122, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Undo the last dig while holding a pickaxe: restores terrain and takes back the items it yielded (from the ground or from your inventory)."); UndoHistory = ((BaseUnityPlugin)this).Config.Bind<int>("Keys", "UndoHistory", 30, "How many digs can be undone."); CurrentRadius = Mathf.Clamp(Radius.Value, MinRadius.Value, MaxRadius.Value); CurrentDepth = ((Depth.Value > 0f) ? Mathf.Clamp(Depth.Value, MinDepth.Value, MaxDepth.Value) : 0f); UseSquare = SquareShape.Value; try { _harmony = new Harmony("com.valheimtools.pickaxeradius"); _harmony.PatchAll(); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Harmony patch failed: {arg}"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Wide Pickaxe 1.0.0 loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } DigPreview.Destroy(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void OnGUI() { //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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0195: 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_01a4: Expected O, but got Unknown //IL_01df: 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_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) if (ShowHud.Value && IsPickaxeActive()) { string text = ((object)ToggleKey.Value/*cast due to .constrained prefix*/).ToString(); string text2; if (!Enabled.Value) { text2 = (Loc.IsRussian ? ("Кирка: обычная (" + text + " — радиус)") : ("Pickaxe: vanilla (" + text + ": radius)")); } else { string text3 = ((!UseSquare) ? (Loc.IsRussian ? "круг" : "circle") : (Loc.IsRussian ? "квадрат" : "square")); string text4 = ((object)UndoKey.Value/*cast due to .constrained prefix*/).ToString(); string text5 = (Loc.IsRussian ? StateRu(DigPreview.State) : StateEn(DigPreview.State)); text2 = (Loc.IsRussian ? $"Ширина {CurrentRadius * 2f:0.0} м\nГлубина за удар {CurrentDepth:0.00} м\n{text3}{text5}\n↑↓ размер PgUp/PgDn глубина ← квадрат → круг\n{text} выкл {text4} отмена ({DigUndo.Count})" : $"Width {CurrentRadius * 2f:0.0} m\nDepth per hit {CurrentDepth:0.00} m\n{text3}{text5}\n↑↓ size PgUp/PgDn depth ← square → circle\n{text} off {text4} undo ({DigUndo.Count})"); } GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor((float)Screen.width / 2f + 28f, (float)Screen.height / 2f - 52f, 700f, 120f); val.normal.textColor = Color.black; GUI.Label(new Rect(((Rect)(ref val2)).x + 2f, ((Rect)(ref val2)).y + 2f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), text2, val); val.normal.textColor = new Color(1f, 0.15f, 0.12f); GUI.Label(val2, text2, val); } } private static string StateRu(DigPreview.TargetState state) { return state switch { DigPreview.TargetState.TooFar => " — слишком далеко", DigPreview.TargetState.Protected => " — здесь копать нельзя", _ => string.Empty, }; } private static string StateEn(DigPreview.TargetState state) { return state switch { DigPreview.TargetState.TooFar => " — too far", DigPreview.TargetState.Protected => " — can't dig here", _ => string.Empty, }; } public static void LogInfo(string message) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } } public static void LogWarning(string message) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)message); } } public static void LogError(string message) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogError((object)message); } } public static void SetRadius(float value) { CurrentRadius = Mathf.Clamp(value, MinRadius.Value, MaxRadius.Value); } public static void SetDepth(float value) { CurrentDepth = Mathf.Clamp(value, MinDepth.Value, MaxDepth.Value); } public static void InitDepth(float vanilla) { if (CurrentDepth <= 0f) { CurrentDepth = Mathf.Clamp((vanilla > 0f) ? vanilla : 0.5f, MinDepth.Value, MaxDepth.Value); } } public static void SetSquare(bool square) { UseSquare = square; SquareShape.Value = square; } public static void Toggle() { Enabled.Value = !Enabled.Value; Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, (!Enabled.Value) ? (Loc.IsRussian ? "Кирка: обычная" : "Pickaxe: vanilla") : (Loc.IsRussian ? "Кирка: радиус" : "Pickaxe: radius"), 0, (Sprite)null, false); } } public static bool IsPickaxe(ItemData weapon) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 if (weapon?.m_shared != null && (int)weapon.m_shared.m_skillType == 12) { return (Object)(object)weapon.m_shared.m_spawnOnHitTerrain != (Object)null; } return false; } public static bool IsPickaxeActive() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && !((Character)localPlayer).IsDead() && !((Character)localPlayer).InPlaceMode()) { return IsPickaxe(((Humanoid)localPlayer).GetCurrentWeapon()); } return false; } public static bool IsUiBlocking() { if (!Console.IsVisible() && !Menu.IsVisible() && !InventoryGui.IsVisible() && !TextInput.IsVisible() && !Minimap.IsOpen()) { if ((Object)(object)Chat.instance != (Object)null) { return Chat.instance.HasFocus(); } return false; } return true; } } }