using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Mirror;
using PropStreaming;
using UnityEngine;
using VoidMOLE.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VoidMOLE")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VoidMOLE")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5e2a5319-de6a-4d7e-b47f-511570bcd808")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VoidMOLE
{
[BepInPlugin("com.equinox.VoidMOLE", "VoidMOLE", "1.0.0")]
public class VoidMOLEPlugin : BaseUnityPlugin
{
private const string MyGUID = "com.equinox.VoidMOLE";
private const string PluginName = "VoidMOLE";
private const string VersionString = "1.0.0";
private static readonly Harmony Harmony = new Harmony("com.equinox.VoidMOLE");
public static ManualLogSource Log = new ManualLogSource("VoidMOLE");
private const string voidLimestoneKey = "Void Limestone";
private const string voidPlantmatterKey = "Void Plantmatter";
public static ConfigEntry<bool> voidLimestone;
public static ConfigEntry<bool> voidPlantmatter;
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
voidLimestone = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Void Limestone", true, new ConfigDescription("Whether to void Limestone when using the M.O.L.E or Mining Charges", (AcceptableValueBase)null, Array.Empty<object>()));
voidPlantmatter = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Void Plantmatter", true, new ConfigDescription("Whether to void Plantmatter when using the M.O.L.E or Mining Charges", (AcceptableValueBase)null, Array.Empty<object>()));
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: VoidMOLE, VersionString: 1.0.0 is loading...");
Harmony.PatchAll();
Harmony.CreateAndPatchAll(typeof(MOLEActionPatch), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: VoidMOLE, VersionString: 1.0.0 is loaded.");
Log = ((BaseUnityPlugin)this).Logger;
}
}
}
namespace VoidMOLE.Patches
{
internal class MOLEActionPatch
{
[HarmonyPatch(typeof(MOLEAction), "PostTerrainManipulationHelper")]
[HarmonyPrefix]
private static bool voidItems(MOLEAction __instance, NetworkConnectionToClient sender, int tick, bool madeChanges, ref DigResultInfo digResultInfo)
{
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Expected O, but got Unknown
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Expected O, but got Unknown
//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_015b: 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_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: 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_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_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: 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_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
if (digResultInfo.resourceCounts != null && digResultInfo.resourceCounts.Count > 0)
{
InventoryWrapper inventoryForPlayer = NetworkMessageRelay.GetInventoryForPlayer(sender);
List<NetworkInventorySlot> list = new List<NetworkInventorySlot>();
foreach (KeyValuePair<ResourceInfo, int> resourceCount in digResultInfo.resourceCounts)
{
if ((!(resourceCount.Key.displayName == "Limestone") || !VoidMOLEPlugin.voidLimestone.Value) && (!(resourceCount.Key.displayName == "Plantmatter") || !VoidMOLEPlugin.voidPlantmatter.Value) && inventoryForPlayer.AddResources(resourceCount.Key, resourceCount.Value))
{
list.Add(NetworkInventorySlot.op_Implicit(resourceCount));
}
}
if (list.Count != 0)
{
NetworkMessageRelay.instance.NotifyInventoryAdd((NetworkConnection)(object)sender, list.ToArray());
}
}
if (digResultInfo.hitProtectedVoxel)
{
NetworkMessageRelay.instance.NotifyProtectedArea((NetworkConnection)(object)sender);
}
if (madeChanges)
{
List<InstanceLookup> list2 = new List<InstanceLookup>();
List<Vector3> list3 = new List<Vector3>();
float impactRadius = 1f;
int hitStrength = int.MaxValue;
Vector3 zero = Vector3.zero;
if (digResultInfo.coordsModified != null && digResultInfo.coordsModified.Count > 0)
{
VoxelManager instance = VoxelManager.instance;
List<InstanceLookup> list4 = default(List<InstanceLookup>);
foreach (Vector3Int item in digResultInfo.coordsModified)
{
if (!instance.GetAssociatedFrillsFromSurfaceVoxel(item, ref list4))
{
continue;
}
zero = Vector3Int.op_Implicit(item) + 0.5f * Vector3.one;
foreach (InstanceLookup item2 in list4)
{
list3.Add(zero);
list2.Add(item2);
}
}
}
if (digResultInfo.propsModified != null && digResultInfo.propsModified.Count > 0)
{
PropManager instance2 = PropManager.instance;
SpawnData val = default(SpawnData);
foreach (InstanceLookup item3 in digResultInfo.propsModified)
{
InstanceLookup current4 = item3;
if (!list2.Contains(current4) && instance2.GetPropData(ref current4, ref val))
{
zero = FHG_Utils.GetPositionFast(val.matrix) + 0.5f * Vector3.one;
list3.Add(zero);
list2.Add(current4);
}
}
}
if (list2.Count > 0)
{
HitDestructibleAction val2 = new HitDestructibleAction();
HitDestructibleInfo info = new HitDestructibleInfo
{
tick = tick,
actionID = ((NetworkAction)val2).actionID,
actionType = ((NetworkAction)val2).actionType,
hitStrength = hitStrength,
impactPos = list3.ToArray(),
impactRadius = impactRadius,
propLookups = list2.ToArray()
};
val2.info = info;
((NetworkAction)val2).ProcessOnHost(sender);
return false;
}
}
else
{
Debug.LogWarning((object)"Attempted to use terrain manipulator with a valid action but nothing happened!");
}
return false;
}
}
}