using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using System.Timers;
using BepInEx;
using HarmonyLib;
using NaNNaVH.slib;
using Splatform;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NaNNaVH")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NaNNaVH")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("61d604dd-aa6b-408a-94bb-3ed50aa0844f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public static class ZNetExtensions
{
public enum ZNetInstanceType
{
Local,
Client,
Server
}
public static bool IsLocalInstance(this ZNet znet)
{
return znet.IsServer() && !znet.IsDedicated();
}
public static bool IsClientInstance(this ZNet znet)
{
return !znet.IsServer() && !znet.IsDedicated();
}
public static bool IsServerInstance(this ZNet znet)
{
return znet.IsServer() && znet.IsDedicated();
}
public static ZNetInstanceType GetInstanceType(this ZNet znet)
{
if (znet.IsLocalInstance())
{
return ZNetInstanceType.Local;
}
if (znet.IsClientInstance())
{
return ZNetInstanceType.Client;
}
return ZNetInstanceType.Server;
}
}
namespace NaNNaVH
{
[BepInPlugin("nb.wackjob.NaNNaVH", "NaNNaVH", "0.13.0")]
public class NaNNaVH : BaseUnityPlugin
{
public static Timer mapSyncSaveTimer = new Timer(TimeSpan.FromMinutes(5.0).TotalMilliseconds);
public static readonly string nVHDataDirectoryPath;
public static Harmony harmony;
private void Awake()
{
harmony.PatchAll();
if (!Directory.Exists(nVHDataDirectoryPath))
{
Directory.CreateDirectory(nVHDataDirectoryPath);
}
if (ZNet.m_isServer)
{
mapSyncSaveTimer.AutoReset = true;
mapSyncSaveTimer.Elapsed += delegate
{
MapSync.SaveMapDataToDisk();
};
}
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
static NaNNaVH()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
string bepInExRootPath = Paths.BepInExRootPath;
char directorySeparatorChar = Path.DirectorySeparatorChar;
nVHDataDirectoryPath = bepInExRootPath + directorySeparatorChar + "nvh-data";
harmony = new Harmony("nb.wackjob.NaNNaVH");
}
}
}
namespace NaNNaVH.slib
{
public class MapSync
{
public class MapRange
{
public int StartingX;
public int EndingX;
public int Y;
}
public static bool[] ServerMapData;
public static bool ShouldSyncOnSpawn = true;
public static void RPC_nVHMapSync(long sender, ZPackage mapPkg)
{
if (ZNet.m_isServer)
{
if (sender == ZRoutedRpc.instance.GetServerPeerID() || mapPkg == null)
{
return;
}
int num = mapPkg.ReadInt();
if (num > 0)
{
for (int i = 0; i < num; i++)
{
MapRange mapRange = mapPkg.ReadnVHMapRange();
for (int j = mapRange.StartingX; j < mapRange.EndingX; j++)
{
ServerMapData[mapRange.Y * Minimap.instance.m_textureSize + j] = true;
}
}
ZLog.Log((object)$"Received {num} map ranges from peer #{sender}.");
nVHAck.SendAck(sender);
}
if (!mapPkg.ReadBool())
{
return;
}
List<MapRange> list = ExplorationDataToMapRanges(ServerMapData);
List<ZPackage> list2 = ChunkMapData(list);
foreach (ZPackage item in list2)
{
RpcData rpcData = new RpcData();
rpcData.Name = "nVHMapSync";
rpcData.Payload = new object[1] { item };
rpcData.Target = ZRoutedRpc.Everybody;
RpcQueue.Enqueue(rpcData);
}
ZLog.Log((object)$"-------------------------- Packages: {list2.Count}");
ZLog.Log((object)$"Sent map updates to all clients ({list.Count} map ranges, {list2.Count} chunks)");
}
else
{
if (sender != ZRoutedRpc.instance.GetServerPeerID())
{
return;
}
if (mapPkg == null)
{
ZLog.LogWarning((object)"Warning: Got empty map sync package from server.");
return;
}
int num2 = mapPkg.ReadInt();
if (num2 > 0)
{
for (int k = 0; k < num2; k++)
{
MapRange mapRange2 = mapPkg.ReadnVHMapRange();
for (int l = mapRange2.StartingX; l < mapRange2.EndingX; l++)
{
Minimap.instance.Explore(l, mapRange2.Y);
}
}
Minimap.instance.m_fogTexture.Apply();
ZLog.Log((object)$"I got {num2} map ranges from the server!");
nVHAck.SendAck(sender);
}
else
{
ZLog.Log((object)"Server has no explored areas to sync, continuing.");
}
}
}
public static void SendMapToServer()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
ZLog.Log((object)"-------------------- SENDING NVHMAPSYNC DATA");
List<MapRange> list = ExplorationDataToMapRanges(Minimap.instance.m_explored);
if (list.Count == 0)
{
ZPackage val = new ZPackage();
val.Write(0);
val.Write(true);
ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "nVHMapSync", new object[1] { val });
return;
}
List<ZPackage> list2 = ChunkMapData(list);
foreach (ZPackage item in list2)
{
RpcData rpcData = new RpcData();
rpcData.Name = "nVHMapSync";
rpcData.Payload = new object[1] { item };
rpcData.Target = ZRoutedRpc.instance.GetServerPeerID();
RpcQueue.Enqueue(rpcData);
}
ZLog.Log((object)$"Sent my map data to the server ({list.Count} map ranges, {list2.Count} chunks)");
}
public static void LoadMapDataFromDisk()
{
if (ServerMapData == null)
{
return;
}
string nVHDataDirectoryPath = NaNNaVH.nVHDataDirectoryPath;
char directorySeparatorChar = Path.DirectorySeparatorChar;
if (!File.Exists(nVHDataDirectoryPath + directorySeparatorChar + ZNet.instance.GetWorldName() + "_mapSync.dat"))
{
return;
}
try
{
string nVHDataDirectoryPath2 = NaNNaVH.nVHDataDirectoryPath;
directorySeparatorChar = Path.DirectorySeparatorChar;
string text = File.ReadAllText(nVHDataDirectoryPath2 + directorySeparatorChar + ZNet.instance.GetWorldName() + "_mapSync.dat");
string[] array = text.Split(new char[1] { ',' });
string[] array2 = array;
foreach (string s in array2)
{
if (int.TryParse(s, out var result))
{
ServerMapData[result] = true;
}
}
ZLog.Log((object)$"Loaded {array.Length} map points from disk.");
}
catch (Exception ex)
{
ZLog.LogError((object)"Failed to load synchronized map data.");
ZLog.LogError((object)ex);
}
}
public static void SaveMapDataToDisk()
{
if (ServerMapData == null)
{
return;
}
List<int> list = new List<int>();
for (int i = 0; i < Minimap.instance.m_textureSize; i++)
{
for (int j = 0; j < Minimap.instance.m_textureSize; j++)
{
if (ServerMapData[i * Minimap.instance.m_textureSize + j])
{
list.Add(i * Minimap.instance.m_textureSize + j);
}
}
}
if (list.Count > 0)
{
string nVHDataDirectoryPath = NaNNaVH.nVHDataDirectoryPath;
char directorySeparatorChar = Path.DirectorySeparatorChar;
File.Delete(nVHDataDirectoryPath + directorySeparatorChar + ZNet.instance.GetWorldName() + "_mapSync.dat");
string nVHDataDirectoryPath2 = NaNNaVH.nVHDataDirectoryPath;
directorySeparatorChar = Path.DirectorySeparatorChar;
File.WriteAllText(nVHDataDirectoryPath2 + directorySeparatorChar + ZNet.instance.GetWorldName() + "_mapSync.dat", string.Join(",", list));
ZLog.Log((object)$"Saved {list.Count} map points to disk.");
}
}
private static List<MapRange> ExplorationDataToMapRanges(bool[] explorationData)
{
List<MapRange> list = new List<MapRange>();
for (int i = 0; i < Minimap.instance.m_textureSize; i++)
{
int num = -1;
int num2 = -1;
for (int j = 0; j < Minimap.instance.m_textureSize; j++)
{
if (explorationData[i * Minimap.instance.m_textureSize + j] && num == -1 && num2 == -1)
{
num = j;
}
else if (!explorationData[i * Minimap.instance.m_textureSize + j] && num > -1 && num2 == -1)
{
num2 = j - 1;
}
else if (num > -1 && num2 > -1)
{
list.Add(new MapRange
{
StartingX = num,
EndingX = num2,
Y = i
});
num = -1;
num2 = -1;
}
}
if (num > -1 && num2 == -1)
{
list.Add(new MapRange
{
StartingX = num,
EndingX = Minimap.instance.m_textureSize,
Y = i
});
}
}
return list;
}
private static List<ZPackage> ChunkMapData(List<MapRange> mapData, int chunkSize = 10000)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
if (mapData == null || mapData.Count == 0)
{
return null;
}
List<List<MapRange>> list = mapData.ChunkBy(chunkSize);
List<ZPackage> list2 = new List<ZPackage>();
foreach (List<MapRange> item in list)
{
ZPackage val = new ZPackage();
val.Write(item.Count);
foreach (MapRange item2 in item)
{
val.WritenVHMapRange(item2);
}
if (item == list.Last())
{
val.Write(true);
}
else
{
val.Write(false);
}
list2.Add(val);
}
return list2;
}
}
public static class ListExtensions
{
public static List<List<T>> ChunkBy<T>(this List<T> source, int chunkSize)
{
return (from x in source.Select((T x, int i) => new
{
Index = i,
Value = x
})
group x by x.Index / chunkSize into x
select x.Select(v => v.Value).ToList()).ToList();
}
}
public class nVHAck
{
public static void RPC_nVHAck(long sender)
{
RpcQueue.GotAck();
}
public static void SendAck(long target)
{
ZRoutedRpc.instance.InvokeRoutedRPC(target, "nVHAck", Array.Empty<object>());
}
}
public class RpcData
{
public string Name;
public long Target = ZRoutedRpc.Everybody;
public object[] Payload;
}
public static class RpcQueue
{
private static Queue<RpcData> _rpcQueue = new Queue<RpcData>();
private static bool _ack = true;
public static void Enqueue(RpcData rpc)
{
_rpcQueue.Enqueue(rpc);
}
public static bool SendNextRpc()
{
if (_rpcQueue.Count == 0 || !_ack)
{
return false;
}
RpcData rpcData = _rpcQueue.Dequeue();
if (Utility.IsNullOrWhiteSpace(rpcData.Name) || rpcData.Payload == null)
{
return false;
}
ZRoutedRpc.instance.InvokeRoutedRPC(rpcData.Target, rpcData.Name, rpcData.Payload);
_ack = false;
return true;
}
public static void GotAck()
{
_ack = true;
}
}
internal static class sFunc
{
public static float applyModifierValue(float targetValue, float value)
{
if (value <= -100f)
{
value = -100f;
}
float num = targetValue;
if (value >= 0f)
{
return targetValue + targetValue / 100f * value;
}
return targetValue - targetValue / 100f * (value * -1f);
}
public static IEnumerable<CodeInstruction> StripForcedCase(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count; i++)
{
if (list[i].opcode == OpCodes.Callvirt)
{
MethodBase methodBase = list[i].operand as MethodBase;
if (methodBase != null && (methodBase.Name == "ToLowerInvariant" || methodBase.Name == "ToUpper"))
{
list.RemoveRange(i - 1, 3);
i -= 2;
}
}
}
return list;
}
public static int Clamp(int value, int min, int max)
{
return Math.Min(max, Math.Max(min, value));
}
public static float Clamp(float value, float min, float max)
{
return Math.Min(max, Math.Max(min, value));
}
}
internal static class versionCheck
{
[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
private static class PatchZNetOnNewConnection
{
private static void Postfix(ZNet __instance, ZNetPeer peer)
{
if (__instance.IsServer())
{
ZLog.Log((object)("========== Server Client connected by the name of: " + peer.m_playerName));
}
}
}
public static void ReceiveClientVersion(long sender, string clientVersion)
{
string modVersion = GetModVersion();
ZNetPeer val = FindPeerBySenderID(sender);
if (val != null && clientVersion != modVersion)
{
ZLog.Log((object)("========== Version mismatch. Kicking peer: " + ((object)val).ToString()));
ZNet.instance.InternalKick(val);
}
}
public static ZNetPeer FindPeerBySenderID(long senderID)
{
foreach (ZNetPeer peer in ZNet.instance.m_peers)
{
if (peer.m_uid == senderID)
{
return peer;
}
}
return null;
}
public static string GetModVersion()
{
BepInPlugin customAttribute = ((MemberInfo)typeof(NaNNaVH)).GetCustomAttribute<BepInPlugin>();
return (customAttribute != null) ? customAttribute.Version.ToString() : "Unknown";
}
}
public static class ZDODataBuffer
{
[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
private class StartBufferingOnNewConnection
{
private static void Postfix(ZNet __instance, ZNetPeer peer)
{
if (!__instance.IsServer())
{
peer.m_rpc.Register<ZPackage>("ZDOData", (Action<ZRpc, ZPackage>)delegate(ZRpc _, ZPackage package)
{
packageBuffer.Add(package);
});
}
}
}
[HarmonyPatch(typeof(ZNet), "Shutdown")]
private class ClearPackageBufferOnShutdown
{
private static void Postfix()
{
packageBuffer.Clear();
}
}
[HarmonyPatch(typeof(ZDOMan), "AddPeer")]
private class EvaluateBufferedPackages
{
private static void Postfix(ZDOMan __instance, ZNetPeer netPeer)
{
foreach (ZPackage item in packageBuffer)
{
__instance.RPC_ZDOData(netPeer.m_rpc, item);
}
packageBuffer.Clear();
}
}
private static readonly List<ZPackage> packageBuffer = new List<ZPackage>();
}
public static class ZPackageExtensions
{
public static MapSync.MapRange ReadnVHMapRange(this ZPackage pkg)
{
return new MapSync.MapRange
{
StartingX = pkg.m_reader.ReadInt32(),
EndingX = pkg.m_reader.ReadInt32(),
Y = pkg.m_reader.ReadInt32()
};
}
public static void WritenVHMapRange(this ZPackage pkg, MapSync.MapRange mapRange)
{
pkg.m_writer.Write(mapRange.StartingX);
pkg.m_writer.Write(mapRange.EndingX);
pkg.m_writer.Write(mapRange.Y);
}
}
}
namespace NaNNaVH.mods
{
[HarmonyPatch]
internal static class AreaRepair
{
[HarmonyPatch(typeof(Player), "UpdatePlacement")]
public static class Player_UpdatePlacement_Transpiler
{
private static readonly MethodInfo method_Player_Repair = AccessTools.Method(typeof(Player), "Repair", (Type[])null, (Type[])null);
private static readonly FieldRef<Player, Piece> field_Player_m_hoveringPiece = AccessTools.FieldRefAccess<Player, Piece>("m_hoveringPiece");
private static readonly MethodInfo method_RepairNearby = AccessTools.Method(typeof(Player_UpdatePlacement_Transpiler), "RepairNearby", (Type[])null, (Type[])null);
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.Calls(list[i], method_Player_Repair))
{
list[i].operand = method_RepairNearby;
}
}
return list.AsEnumerable();
}
public static void RepairNearby(Player instance, ItemData toolItem, Piece _1)
{
//IL_0024: 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_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)
Piece hoveringPiece = instance.GetHoveringPiece();
Vector3 val = (((Object)(object)hoveringPiece != (Object)null) ? ((Component)hoveringPiece).transform.position : ((Component)instance).transform.position);
List<Piece> list = new List<Piece>();
Piece.GetAllPiecesInRadius(val, m_repair_radius, list);
m_repair_count = 0;
Piece val2 = field_Player_m_hoveringPiece.Invoke(instance);
MethodInfo methodInfo = AccessTools.Method(typeof(Player), "Repair", (Type[])null, (Type[])null);
foreach (Piece item in list)
{
if (!((Character)instance).HaveStamina(toolItem.m_shared.m_attack.m_attackStamina) || (toolItem.m_shared.m_useDurability && toolItem.m_durability <= 0f))
{
break;
}
field_Player_m_hoveringPiece.Invoke(instance) = item;
methodInfo.Invoke(instance, new object[2] { toolItem, _1 });
field_Player_m_hoveringPiece.Invoke(instance) = val2;
}
if (m_repair_count > 0)
{
((Character)instance).Message((MessageType)1, $"{m_repair_count} pieces repaired", 0, (Sprite)null);
}
}
}
[HarmonyPatch(typeof(Player), "Repair")]
public static class Player_Repair_Transpiler
{
private static readonly MethodInfo method_Character_Message = AccessTools.Method(typeof(Character), "Message", (Type[])null, (Type[])null);
private static readonly MethodInfo method_MessageNoop = AccessTools.Method(typeof(Player_Repair_Transpiler), "MessageNoop", (Type[])null, (Type[])null);
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
bool flag = true;
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.Calls(list[i], method_Character_Message))
{
list[i].operand = method_MessageNoop;
list.Insert(i++, new CodeInstruction(flag ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0, (object)null));
flag = false;
}
}
return list.AsEnumerable();
}
public static void MessageNoop(Character _0, MessageType _1, string _2, int _3, Sprite _4, int repaired)
{
m_repair_count += repaired;
}
}
private static int m_repair_count;
private static readonly float m_repair_radius = 10f;
}
internal class AutoFuel
{
[HarmonyPatch(typeof(Container), "Awake")]
private static class ContainerAwakePatch
{
private static void Postfix(Container __instance, ZNetView ___m_nview)
{
AddContainer(__instance, ___m_nview);
}
}
[HarmonyPatch(typeof(Container), "OnDestroyed")]
private static class ContainerOnDestroyedPatch
{
private static void Prefix(Container __instance)
{
ContainerList.Remove(__instance);
}
}
[HarmonyPatch(typeof(Smelter), "Awake")]
public class BlastFurnacePatch
{
private static void Prefix(ref Smelter __instance)
{
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_00df: Expected O, but got Unknown
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Expected O, but got Unknown
//IL_0117: 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_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Expected O, but got Unknown
//IL_014d: 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_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Expected O, but got Unknown
//IL_0183: 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_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Expected O, but got Unknown
if (__instance.m_name != "$piece_blastfurnace")
{
return;
}
ObjectDB instance = ObjectDB.instance;
List<ItemDrop> allItems = instance.GetAllItems((ItemType)1, "");
foreach (ItemDrop item in allItems)
{
if (metals.Keys.Contains(item.m_itemData.m_shared.m_name))
{
metals[item.m_itemData.m_shared.m_name] = item;
}
}
List<ItemConversion> list = new List<ItemConversion>
{
new ItemConversion
{
m_from = metals["$item_copperore"],
m_to = metals["$item_copper"]
},
new ItemConversion
{
m_from = metals["$item_tinore"],
m_to = metals["$item_tin"]
},
new ItemConversion
{
m_from = metals["$item_ironscrap"],
m_to = metals["$item_iron"]
},
new ItemConversion
{
m_from = metals["$item_silverore"],
m_to = metals["$item_silver"]
},
new ItemConversion
{
m_from = metals["$item_copperscrap"],
m_to = metals["$item_copper"]
}
};
foreach (ItemConversion item2 in list)
{
__instance.m_conversion.Add(item2);
}
}
}
[HarmonyPatch(typeof(Smelter), "UpdateSmelter")]
private static class Smelter_FixedUpdate_Patch
{
private static void Postfix(Smelter __instance, ZNetView ___m_nview)
{
if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !((Object)(object)___m_nview == (Object)null) && ___m_nview.IsOwner())
{
if ((double)(Time.time - lastFuel) < 0.1)
{
fuelCount++;
RefuelSmelter(__instance, ___m_nview, fuelCount * 33);
}
else
{
fuelCount = 0;
lastFuel = Time.time;
RefuelSmelter(__instance, ___m_nview, 0);
}
}
}
}
public static float lastFuel;
public static int fuelCount;
internal static string fuelDisallowTypes = "RoundLog,FineWood";
internal static string oreDisallowTypes = "RoundLog,FineWood";
internal static bool distributedFilling = true;
internal static readonly List<Container> ContainerList = new List<Container>();
private static Dictionary<string, ItemDrop> metals = new Dictionary<string, ItemDrop>
{
{ "$item_copperore", null },
{ "$item_copper", null },
{ "$item_ironscrap", null },
{ "$item_iron", null },
{ "$item_tinore", null },
{ "$item_tin", null },
{ "$item_silverore", null },
{ "$item_silver", null },
{ "$item_copperscrap", null }
};
private void OnDestroy()
{
}
public static string GetPrefabName(string name)
{
char[] anyOf = new char[2] { '(', ' ' };
int num = name.IndexOfAny(anyOf);
return (num >= 0) ? name.Substring(0, num) : name;
}
public static void AddContainer(Container container, ZNetView nview)
{
try
{
if (container.GetInventory() != null && ((nview != null) ? nview.GetZDO() : null) != null && (((Object)container).name.StartsWith("piece_", StringComparison.Ordinal) || ((Object)container).name.StartsWith("Container", StringComparison.Ordinal) || nview.GetZDO().GetLong(StringExtensionMethods.GetStableHashCode("creator"), 0L) != 0))
{
ContainerList.Add(container);
}
}
catch
{
}
}
public static List<Container> GetNearbyContainers(Vector3 center, float range)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
List<Container> list = new List<Container>();
foreach (Container item in ContainerList.Where((Container container) => (Object)(object)container != (Object)null && (Object)(object)((Component)container).GetComponentInParent<Piece>() != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)((container != null) ? ((Component)container).transform : null) != (Object)null && container.GetInventory() != null && (range <= 0f || Vector3.Distance(center, ((Component)container).transform.position) < range) && container.CheckAccess(Player.m_localPlayer.GetPlayerID()) && !container.IsInUse()))
{
Vector3 position = ((Component)item).transform.position;
if (PrivateArea.CheckAccess(position, 0f, false, false))
{
if (!PrivateArea.InsideFactionArea(((Component)item).transform.position, (Faction)0))
{
item.Load();
list.Add(item);
}
else
{
item.Load();
list.Add(item);
}
}
}
return list;
}
public static async void RefuelSmelter(Smelter __instance, ZNetView ___m_nview, int delay)
{
await Task.Delay(delay);
if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)___m_nview) || !___m_nview.IsValid())
{
return;
}
int maxOre = __instance.m_maxOre - Traverse.Create((object)__instance).Method("GetQueueSize", Array.Empty<object>()).GetValue<int>();
int maxFuel = __instance.m_maxFuel - Mathf.CeilToInt(___m_nview.GetZDO().GetFloat("fuel", 0f));
List<Container> nearbyOreContainers = GetNearbyContainers(((Component)__instance).transform.position, 10f);
List<Container> nearbyFuelContainers = GetNearbyContainers(((Component)__instance).transform.position, 10f);
if (((Object)__instance).name.Contains("charcoal_kiln"))
{
string outputName = __instance.m_conversion[0].m_to.m_itemData.m_shared.m_name;
int maxOutput = 50 - Traverse.Create((object)__instance).Method("GetQueueSize", Array.Empty<object>()).GetValue<int>();
foreach (Container c in nearbyOreContainers)
{
List<ItemData> itemList = new List<ItemData>();
c.GetInventory().GetAllItems(outputName, itemList);
foreach (ItemData outputItem in itemList)
{
if (outputItem != null)
{
maxOutput -= outputItem.m_stack;
}
}
}
if (maxOutput < 0)
{
maxOutput = 0;
}
if (maxOre > maxOutput)
{
maxOre = maxOutput;
}
}
bool fueled = false;
bool ored = false;
Vector3 position = ((Component)__instance).transform.position + Vector3.up;
Collider[] array = Physics.OverlapSphere(position, 10f);
foreach (Collider collider in array)
{
if (!Object.op_Implicit((Object)(object)((collider != null) ? collider.attachedRigidbody : null)))
{
continue;
}
ItemDrop item = ((Component)collider.attachedRigidbody).GetComponent<ItemDrop>();
int num;
if (item == null)
{
num = 1;
}
else
{
ZNetView component = ((Component)item).GetComponent<ZNetView>();
num = ((!((component != null) ? new bool?(component.IsValid()) : null).GetValueOrDefault()) ? 1 : 0);
}
if (num != 0)
{
continue;
}
string name = GetPrefabName(((Object)((Component)item).gameObject).name);
foreach (ItemConversion itemConversion in __instance.m_conversion)
{
if (ored)
{
break;
}
if (!(item.m_itemData.m_shared.m_name == itemConversion.m_from.m_itemData.m_shared.m_name) || maxOre <= 0 || oreDisallowTypes.Split(new char[1] { ',' }).Contains(name))
{
continue;
}
int amount2 = Mathf.Min(item.m_itemData.m_stack, maxOre);
maxOre -= amount2;
for (int j = 0; j < amount2; j++)
{
if (item.m_itemData.m_stack <= 1)
{
if (___m_nview.GetZDO() == null)
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
else
{
ZNetScene.instance.Destroy(((Component)item).gameObject);
}
___m_nview.InvokeRPC("RPC_AddOre", new object[1] { name });
if (distributedFilling)
{
ored = true;
}
break;
}
ItemData itemData = item.m_itemData;
itemData.m_stack--;
___m_nview.InvokeRPC("RPC_AddOre", new object[1] { name });
Traverse.Create((object)item).Method("Save", Array.Empty<object>()).GetValue();
if (distributedFilling)
{
ored = true;
}
}
}
if (!Object.op_Implicit((Object)(object)__instance.m_fuelItem) || !(item.m_itemData.m_shared.m_name == __instance.m_fuelItem.m_itemData.m_shared.m_name) || maxFuel <= 0 || fueled || fuelDisallowTypes.Split(new char[1] { ',' }).Contains(name))
{
continue;
}
int amount = Mathf.Min(item.m_itemData.m_stack, maxFuel);
maxFuel -= amount;
for (int i = 0; i < amount; i++)
{
if (item.m_itemData.m_stack <= 1)
{
if (___m_nview.GetZDO() == null)
{
Object.Destroy((Object)(object)((Component)item).gameObject);
}
else
{
ZNetScene.instance.Destroy(((Component)item).gameObject);
}
___m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
if (distributedFilling)
{
fueled = true;
}
break;
}
ItemData itemData2 = item.m_itemData;
itemData2.m_stack--;
___m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
Traverse.Create((object)item).Method("Save", Array.Empty<object>()).GetValue();
if (distributedFilling)
{
fueled = true;
break;
}
}
}
foreach (Container c3 in nearbyOreContainers)
{
foreach (ItemConversion itemConversion2 in __instance.m_conversion)
{
if (ored)
{
break;
}
List<ItemData> itemList3 = new List<ItemData>();
c3.GetInventory().GetAllItems(itemConversion2.m_from.m_itemData.m_shared.m_name, itemList3);
foreach (ItemData oreItem in itemList3)
{
if (oreItem != null && maxOre > 0 && !oreDisallowTypes.Split(new char[1] { ',' }).Contains(((Object)oreItem.m_dropPrefab).name))
{
maxOre--;
object[] array2 = new object[1];
GameObject dropPrefab = oreItem.m_dropPrefab;
array2[0] = ((dropPrefab != null) ? ((Object)dropPrefab).name : null);
___m_nview.InvokeRPC("RPC_AddOre", array2);
c3.GetInventory().RemoveItem(itemConversion2.m_from.m_itemData.m_shared.m_name, 1, -1, true);
typeof(Container).GetMethod("Save", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(c3, new object[0]);
typeof(Inventory).GetMethod("Changed", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(c3.GetInventory(), new object[0]);
if (distributedFilling)
{
ored = true;
break;
}
}
}
}
}
foreach (Container c2 in nearbyFuelContainers)
{
if (!Object.op_Implicit((Object)(object)__instance.m_fuelItem) || maxFuel <= 0 || fueled)
{
break;
}
List<ItemData> itemList2 = new List<ItemData>();
c2.GetInventory().GetAllItems(__instance.m_fuelItem.m_itemData.m_shared.m_name, itemList2);
foreach (ItemData fuelItem in itemList2)
{
if (fuelItem == null)
{
continue;
}
maxFuel--;
if (!fuelDisallowTypes.Split(new char[1] { ',' }).Contains(((Object)fuelItem.m_dropPrefab).name))
{
___m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
c2.GetInventory().RemoveItem(__instance.m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true);
typeof(Container).GetMethod("Save", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(c2, new object[0]);
typeof(Inventory).GetMethod("Changed", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(c2.GetInventory(), new object[0]);
if (distributedFilling)
{
fueled = true;
break;
}
}
}
}
}
}
[HarmonyPatch(typeof(Player), "Update")]
public static class PlayerUpdatePatch
{
private static void Postfix(Player __instance)
{
if ((Object)(object)Player.m_localPlayer != (Object)null)
{
ApplyModerBuff(__instance);
}
}
private static void ApplyModerBuff(Player player)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
SEMan sEMan = ((Character)player).GetSEMan();
int stableHashCode = StringExtensionMethods.GetStableHashCode("GP_Moder");
if (sEMan != null && !sEMan.HaveStatusEffect(stableHashCode))
{
StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(stableHashCode);
statusEffect.m_ttl = 0f;
statusEffect.m_startMessage = "";
statusEffect.m_startEffects = new EffectList();
sEMan.AddStatusEffect(statusEffect, false, 0, 0f);
}
}
}
[HarmonyPatch(typeof(ItemStand), "IsGuardianPowerActive")]
public static class ItemStandIsGuardianPowerActivePatch
{
private static void Postfix(ItemStand __instance, ref bool __result, Humanoid user)
{
if (((Object)__instance.m_guardianPower).name == "GP_Moder")
{
__result = true;
}
}
}
public static class PlayerExtensions
{
public static SEMan GetSEMan(this Player player)
{
return ((Component)player).GetComponent<SEMan>();
}
public static bool HaveStatusEffect(this SEMan seman, int effectHash)
{
foreach (StatusEffect statusEffect in seman.m_statusEffects)
{
if (statusEffect.m_nameHash == effectHash)
{
return true;
}
}
return false;
}
public static void AddStatusEffect(this SEMan seman, StatusEffect effect)
{
seman.AddStatusEffect(effect, false, 0, 0f);
}
}
[HarmonyPatch(typeof(Terminal))]
public static class Chat_MixedCase_Terminal_Patch
{
[HarmonyPatch("AddString", new Type[]
{
typeof(string),
typeof(string),
typeof(Type),
typeof(bool)
})]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> AddString_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return sFunc.StripForcedCase(instructions);
}
}
[HarmonyPatch(typeof(Chat))]
public static class Chat_MixedCase_Chat_Patch
{
[HarmonyPatch("AddInworldText")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> AddInworldText_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return sFunc.StripForcedCase(instructions);
}
}
[HarmonyPatch(typeof(Chat))]
public static class Chat_Shout_Patch
{
[CompilerGenerated]
private sealed class <InputText_Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private IEnumerator<CodeInstruction> <>s__1;
private CodeInstruction <instruction>5__2;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InputText_Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__1 = null;
<instruction>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>s__1 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
<instruction>5__2 = null;
break;
}
if (<>s__1.MoveNext())
{
<instruction>5__2 = <>s__1.Current;
if (<instruction>5__2.opcode == OpCodes.Ldstr && <instruction>5__2.operand.Equals("say "))
{
<instruction>5__2.operand = "s ";
}
<>2__current = <instruction>5__2;
<>1__state = 1;
return true;
}
<>m__Finally1();
<>s__1 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__1 != null)
{
<>s__1.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<InputText_Transpiler>d__0 <InputText_Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<InputText_Transpiler>d__ = this;
}
else
{
<InputText_Transpiler>d__ = new <InputText_Transpiler>d__0(0);
}
<InputText_Transpiler>d__.instructions = <>3__instructions;
return <InputText_Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<InputText_Transpiler>d__0))]
[HarmonyPatch("InputText")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> InputText_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InputText_Transpiler>d__0(-2)
{
<>3__instructions = instructions
};
}
}
[HarmonyPatch(typeof(Minimap))]
public static class Minimap_Patches
{
[HarmonyPatch("UpdateDynamicPins")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count - 1; i++)
{
if (list[i + 1].opcode == OpCodes.Call)
{
MethodBase methodBase = (MethodBase)list[i + 1].operand;
if (methodBase.Name == "UpdateShoutPins")
{
list.RemoveRange(i, 2);
break;
}
}
}
return list;
}
}
[HarmonyPatch(typeof(Player), "Update")]
public static class Player_Update_Patch
{
private static GameObject timeObj = null;
private static double savedEnvMinutes = -1.0;
private const float ColorRatio = 0.5882353f;
private const float AlphaRatio = 44f / 51f;
private const int FontSize = 24;
private static void Postfix(ref Player __instance)
{
if (((Character)__instance).m_nview.IsValid() && ((Character)__instance).m_nview.IsOwner())
{
Hud instance = Hud.instance;
if ((Object)(object)timeObj == (Object)null)
{
InitializeTimeObject(instance);
}
UpdateTimeText(instance, EnvMan.instance);
}
}
private static void InitializeTimeObject(Hud hud)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
MessageHud instance = MessageHud.instance;
timeObj = new GameObject("TimeText");
timeObj.transform.SetParent(((Component)hud.m_statusEffectListRoot).transform.parent);
timeObj.AddComponent<RectTransform>();
TMP_Text val = (TMP_Text)(object)timeObj.AddComponent<TextMeshProUGUI>();
((Graphic)val).color = new Color(0.5882353f, 0.5882353f, 0.5882353f, 44f / 51f);
val.font = instance.m_messageCenterText.font;
val.fontSize = 24f;
val.alignment = (TextAlignmentOptions)514;
val.overflowMode = (TextOverflowModes)0;
((Behaviour)val).enabled = true;
}
private static void UpdateTimeText(Hud hud, EnvMan env)
{
double num = env.m_totalSeconds / 60.0;
if (savedEnvMinutes != num)
{
TMP_Text component = timeObj.GetComponent<TMP_Text>();
int currentDay = env.GetCurrentDay();
float num2 = Mathf.Lerp(0f, 24f, env.GetDayFraction());
int num3 = Mathf.FloorToInt(num2);
int num4 = Mathf.FloorToInt((num2 - (float)num3) * 60f);
string text = ((num3 < 12) ? " AM" : " PM");
if (num3 > 12)
{
num3 -= 12;
}
component.text = $"Day {currentDay}, {num3:00}:{num4:00}{text}";
PositionTimeText(hud);
savedEnvMinutes = num;
}
}
private static void PositionTimeText(Hud hud)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)hud.m_staminaBar2Root).transform;
RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
Transform transform2 = ((Component)hud.m_statusEffectListRoot).transform;
RectTransform val2 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
RectTransform component = timeObj.GetComponent<RectTransform>();
((Transform)component).position = Vector2.op_Implicit(new Vector2(((Transform)val).position.x, ((Transform)val2).position.y));
timeObj.SetActive(true);
}
}
public class Crops
{
public static KeyCode MassActionHotkey = (KeyCode)304;
public static KeyCode ControllerPickupHotkey = (KeyCode)334;
public static float MassInteractRange = 5f;
public static int PlantGridWidth = 5;
public static int PlantGridLength = 5;
public static bool IgnoreStamina = false;
public static bool IgnoreDurability = false;
public static bool GridAnchorWidth = true;
public static bool GridAnchorLength = true;
}
[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
public static class MassPlant
{
private static readonly FieldInfo m_noPlacementCostField = AccessTools.Field(typeof(Player), "m_noPlacementCost");
private static readonly FieldInfo m_placementGhostField = AccessTools.Field(typeof(Player), "m_placementGhost");
private static readonly FieldInfo m_buildPiecesField = AccessTools.Field(typeof(Player), "m_buildPieces");
private static readonly MethodInfo _GetRightItemMethod = AccessTools.Method(typeof(Humanoid), "GetRightItem", (Type[])null, (Type[])null);
private static Vector3 placedPosition;
private static Quaternion placedRotation;
private static Piece placedPiece;
private static bool placeSuccessful = false;
private static int? massFarmingRotation = null;
private static readonly int _plantSpaceMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid" });
private static GameObject[] _placementGhosts = (GameObject[])(object)new GameObject[1];
private static readonly Piece _fakeResourcePiece;
private static bool IsHotKeyPressed => Input.GetKey(Crops.ControllerPickupHotkey) || Input.GetKey(Crops.MassActionHotkey);
[HarmonyPrefix]
[HarmonyPatch(typeof(Player), "PlacePiece")]
public static void PlacePiecePrefix(int ___m_placeRotation)
{
if (IsHotKeyPressed)
{
int? num = massFarmingRotation;
if (!num.HasValue)
{
massFarmingRotation = ___m_placeRotation;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Player), "PlacePiece")]
public static void PlacePiecePostfix(Player __instance, Piece piece, ref int ___m_placeRotation)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//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_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)
placeSuccessful = true;
GameObject val = (GameObject)m_placementGhostField.GetValue(__instance);
if (Object.op_Implicit((Object)(object)val))
{
placedPosition = val.transform.position;
placedRotation = val.transform.rotation;
placedPiece = piece;
}
if (IsHotKeyPressed && massFarmingRotation.HasValue)
{
___m_placeRotation = massFarmingRotation.Value;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Player), "UpdatePlacement")]
public static void UpdatePlacementPrefix(bool takeInput, float dt, ref int ___m_placeRotation)
{
placeSuccessful = false;
if (IsHotKeyPressed && massFarmingRotation.HasValue)
{
___m_placeRotation = massFarmingRotation.Value;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Player), "UpdatePlacement")]
public static void UpdatePlacementPostfix(Player __instance, bool takeInput, float dt, int ___m_placeRotation)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
if (IsHotKeyPressed)
{
massFarmingRotation = ___m_placeRotation;
}
if (!placeSuccessful)
{
return;
}
Plant component = ((Component)placedPiece).gameObject.GetComponent<Plant>();
if (!Object.op_Implicit((Object)(object)component) || !IsHotKeyPressed)
{
return;
}
Heightmap val = Heightmap.FindHeightmap(placedPosition);
if (!Object.op_Implicit((Object)(object)val))
{
return;
}
foreach (Vector3 item in BuildPlantingGridPositions(placedPosition, component, placedRotation))
{
if ((placedPiece.m_cultivatedGroundOnly && !val.IsCultivated(item)) || placedPosition == item)
{
continue;
}
object? obj = _GetRightItemMethod.Invoke(__instance, Array.Empty<object>());
ItemData val2 = (ItemData)((obj is ItemData) ? obj : null);
if (val2 == null)
{
continue;
}
if (!Crops.IgnoreStamina && !((Character)__instance).HaveStamina(val2.m_shared.m_attack.m_attackStamina))
{
Hud.instance.StaminaBarUppgradeFlash();
break;
}
if (!(bool)m_noPlacementCostField.GetValue(__instance) && !__instance.HaveRequirements(placedPiece, (RequirementMode)0))
{
break;
}
if (!HasGrowSpace(item, ((Component)placedPiece).gameObject))
{
continue;
}
GameObject val3 = Object.Instantiate<GameObject>(((Component)placedPiece).gameObject, item, placedRotation);
Piece component2 = val3.GetComponent<Piece>();
if (Object.op_Implicit((Object)(object)component2))
{
component2.SetCreator(__instance.GetPlayerID());
}
placedPiece.m_placeEffect.Create(item, placedRotation, val3.transform, 1f, -1);
Game.instance.IncrementPlayerStat((PlayerStatType)2, 1f);
__instance.ConsumeResources(placedPiece.m_resources, 0, -1, 1);
if (!Crops.IgnoreStamina)
{
((Character)__instance).UseStamina(val2.m_shared.m_attack.m_attackStamina);
}
if (!Crops.IgnoreDurability && val2.m_shared.m_useDurability)
{
val2.m_durability -= val2.m_shared.m_useDurabilityDrain;
if (val2.m_durability <= 0f)
{
break;
}
}
}
}
private static List<Vector3> BuildPlantingGridPositions(Vector3 originPos, Plant placedPlant, Quaternion rotation)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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_0031: 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_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
float num = placedPlant.m_growRadius * 2f;
List<Vector3> list = new List<Vector3>(Crops.PlantGridWidth * Crops.PlantGridLength);
Vector3 val = rotation * Vector3.left * num;
Vector3 val2 = rotation * Vector3.forward * num;
Vector3 val3 = originPos;
if (Crops.GridAnchorLength)
{
val3 -= val2 * (float)(Crops.PlantGridLength / 2);
}
if (Crops.GridAnchorWidth)
{
val3 -= val * (float)(Crops.PlantGridWidth / 2);
}
for (int i = 0; i < Crops.PlantGridLength; i++)
{
Vector3 val4 = val3;
for (int j = 0; j < Crops.PlantGridWidth; j++)
{
val4.y = ZoneSystem.instance.GetGroundHeight(val4);
list.Add(val4);
val4 += val;
}
val3 += val2;
}
return list;
}
private static bool HasGrowSpace(Vector3 newPos, GameObject go)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Plant component = go.GetComponent<Plant>();
if (component != null)
{
Collider[] array = Physics.OverlapSphere(newPos, component.m_growRadius, _plantSpaceMask);
return array.Length == 0;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Player), "SetupPlacementGhost")]
public static void SetupPlacementGhostPrefix(Player __instance, int ___m_placeRotation)
{
if (IsHotKeyPressed)
{
int? num = massFarmingRotation;
if (!num.HasValue)
{
massFarmingRotation = ___m_placeRotation;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Player), "SetupPlacementGhost")]
public static void SetupPlacementGhostPostfix(Player __instance, ref int ___m_placeRotation)
{
if (IsHotKeyPressed && massFarmingRotation.HasValue)
{
___m_placeRotation = massFarmingRotation.Value;
}
DestroyGhosts();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
public static void UpdatePlacementGhostPostfix(Player __instance, bool flashGuardStone)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: 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_0234: Unknown result type (might be due to invalid IL or missing references)
GameObject val = (GameObject)m_placementGhostField.GetValue(__instance);
if (!Object.op_Implicit((Object)(object)val) || !val.activeSelf)
{
SetGhostsActive(active: false);
return;
}
if (!Input.GetKey(Crops.ControllerPickupHotkey) && !Input.GetKey(Crops.MassActionHotkey))
{
SetGhostsActive(active: false);
return;
}
Plant component = val.GetComponent<Plant>();
if (!Object.op_Implicit((Object)(object)component))
{
SetGhostsActive(active: false);
return;
}
if (!EnsureGhostsBuilt(__instance))
{
SetGhostsActive(active: false);
return;
}
Requirement val2 = ((IEnumerable<Requirement>)val.GetComponent<Piece>().m_resources).FirstOrDefault((Func<Requirement, bool>)((Requirement r) => Object.op_Implicit((Object)(object)r.m_resItem) && r.m_amount > 0));
_fakeResourcePiece.m_resources[0].m_resItem = val2.m_resItem;
_fakeResourcePiece.m_resources[0].m_amount = val2.m_amount;
float num = __instance.GetStamina();
object? obj = _GetRightItemMethod.Invoke(__instance, Array.Empty<object>());
ItemData val3 = (ItemData)((obj is ItemData) ? obj : null);
if (val3 == null)
{
return;
}
Heightmap val4 = Heightmap.FindHeightmap(val.transform.position);
List<Vector3> list = BuildPlantingGridPositions(val.transform.position, component, val.transform.rotation);
for (int i = 0; i < _placementGhosts.Length; i++)
{
Vector3 val5 = list[i];
if (val.transform.position == val5)
{
_placementGhosts[i].SetActive(false);
continue;
}
Requirement obj2 = _fakeResourcePiece.m_resources[0];
obj2.m_amount += val2.m_amount;
_placementGhosts[i].transform.position = val5;
_placementGhosts[i].transform.rotation = val.transform.rotation;
_placementGhosts[i].SetActive(true);
bool invalidPlacementHeightlight = false;
if (val.GetComponent<Piece>().m_cultivatedGroundOnly && !val4.IsCultivated(val5))
{
invalidPlacementHeightlight = true;
}
else if (!HasGrowSpace(val5, val.gameObject))
{
invalidPlacementHeightlight = true;
}
else if (!Crops.IgnoreStamina && num < val3.m_shared.m_attack.m_attackStamina)
{
Hud.instance.StaminaBarUppgradeFlash();
invalidPlacementHeightlight = true;
}
else if (!(bool)m_noPlacementCostField.GetValue(__instance) && !__instance.HaveRequirements(_fakeResourcePiece, (RequirementMode)0))
{
invalidPlacementHeightlight = true;
}
num -= val3.m_shared.m_attack.m_attackStamina;
_placementGhosts[i].GetComponent<Piece>().SetInvalidPlacementHeightlight(invalidPlacementHeightlight);
}
}
private static bool EnsureGhostsBuilt(Player player)
{
int num = Crops.PlantGridWidth * Crops.PlantGridLength;
if (!Object.op_Implicit((Object)(object)_placementGhosts[0]) || _placementGhosts.Length != num)
{
DestroyGhosts();
if (_placementGhosts.Length != num)
{
_placementGhosts = (GameObject[])(object)new GameObject[num];
}
object? value = m_buildPiecesField.GetValue(player);
PieceTable val = (PieceTable)((value is PieceTable) ? value : null);
if (val != null)
{
GameObject selectedPrefab = val.GetSelectedPrefab();
if (selectedPrefab != null)
{
if (selectedPrefab.GetComponent<Piece>().m_repairPiece)
{
return false;
}
for (int i = 0; i < _placementGhosts.Length; i++)
{
_placementGhosts[i] = SetupMyGhost(player, selectedPrefab);
}
goto IL_00d6;
}
}
return false;
}
goto IL_00d6;
IL_00d6:
return true;
}
private static void DestroyGhosts()
{
for (int i = 0; i < _placementGhosts.Length; i++)
{
if (Object.op_Implicit((Object)(object)_placementGhosts[i]))
{
Object.Destroy((Object)(object)_placementGhosts[i]);
_placementGhosts[i] = null;
}
}
}
private static void SetGhostsActive(bool active)
{
GameObject[] placementGhosts = _placementGhosts;
foreach (GameObject val in placementGhosts)
{
if (val != null)
{
val.SetActive(active);
}
}
}
private static GameObject SetupMyGhost(Player player, GameObject prefab)
{
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Expected O, but got Unknown
ZNetView.m_forceDisableInit = true;
GameObject val = Object.Instantiate<GameObject>(prefab);
ZNetView.m_forceDisableInit = false;
((Object)val).name = ((Object)prefab).name;
Joint[] componentsInChildren = val.GetComponentsInChildren<Joint>();
foreach (Joint val2 in componentsInChildren)
{
Object.Destroy((Object)(object)val2);
}
Rigidbody[] componentsInChildren2 = val.GetComponentsInChildren<Rigidbody>();
foreach (Rigidbody val3 in componentsInChildren2)
{
Object.Destroy((Object)(object)val3);
}
int layer = LayerMask.NameToLayer("ghost");
Transform[] componentsInChildren3 = val.GetComponentsInChildren<Transform>();
foreach (Transform val4 in componentsInChildren3)
{
((Component)val4).gameObject.layer = layer;
}
TerrainModifier[] componentsInChildren4 = val.GetComponentsInChildren<TerrainModifier>();
foreach (TerrainModifier val5 in componentsInChildren4)
{
Object.Destroy((Object)(object)val5);
}
GuidePoint[] componentsInChildren5 = val.GetComponentsInChildren<GuidePoint>();
foreach (GuidePoint val6 in componentsInChildren5)
{
Object.Destroy((Object)(object)val6);
}
Light[] componentsInChildren6 = val.GetComponentsInChildren<Light>();
foreach (Light val7 in componentsInChildren6)
{
Object.Destroy((Object)(object)val7);
}
Transform val8 = val.transform.Find("_GhostOnly");
if (Object.op_Implicit((Object)(object)val8))
{
((Component)val8).gameObject.SetActive(true);
}
MeshRenderer[] componentsInChildren7 = val.GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer val9 in componentsInChildren7)
{
if (!((Object)(object)((Renderer)val9).sharedMaterial == (Object)null))
{
Material[] sharedMaterials = ((Renderer)val9).sharedMaterials;
for (int num2 = 0; num2 < sharedMaterials.Length; num2++)
{
Material val10 = new Material(sharedMaterials[num2]);
val10.SetFloat("_RippleDistance", 0f);
val10.SetFloat("_ValueNoise", 0f);
sharedMaterials[num2] = val10;
}
((Renderer)val9).sharedMaterials = sharedMaterials;
((Renderer)val9).shadowCastingMode = (ShadowCastingMode)0;
}
}
return val;
}
static MassPlant()
{
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
Piece val = new Piece();
val.m_dlc = string.Empty;
val.m_resources = (Requirement[])(object)new Requirement[1]
{
new Requirement()
};
_fakeResourcePiece = val;
}
}
[HarmonyPatch(typeof(Player), "Interact")]
public static class MassPickup
{
private static FieldInfo m_interactMaskField = AccessTools.Field(typeof(Player), "m_interactMask");
private static MethodInfo _ExtractMethod = AccessTools.Method(typeof(Beehive), "Extract", (Type[])null, (Type[])null);
[HarmonyPrefix]
public static void Prefix(Player __instance, GameObject go, bool hold, bool alt)
{
//IL_0027: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
if (((Character)__instance).InAttack() || ((Character)__instance).InDodge() || hold || (!Input.GetKey(Crops.ControllerPickupHotkey) && !Input.GetKey(Crops.MassActionHotkey)))
{
return;
}
Interactable componentInParent = go.GetComponentInParent<Interactable>();
Pickable val = (Pickable)(object)((componentInParent is Pickable) ? componentInParent : null);
if (val != null)
{
int num = (int)m_interactMaskField.GetValue(__instance);
Collider[] array = Physics.OverlapSphere(go.transform.position, Crops.MassInteractRange, num);
Collider[] array2 = array;
foreach (Collider val2 in array2)
{
object obj;
if (val2 == null)
{
obj = null;
}
else
{
GameObject gameObject = ((Component)val2).gameObject;
obj = ((gameObject != null) ? gameObject.GetComponentInParent<Pickable>() : null);
}
Pickable val3 = (Pickable)obj;
if (val3 != null && (Object)(object)val3 != (Object)(object)val && ((Object)val3.m_itemPrefab).name == ((Object)val.m_itemPrefab).name)
{
val3.Interact((Humanoid)(object)__instance, false, alt);
}
}
return;
}
Beehive val4 = (Beehive)(object)((componentInParent is Beehive) ? componentInParent : null);
if (val4 == null)
{
return;
}
int num2 = (int)m_interactMaskField.GetValue(__instance);
Collider[] array3 = Physics.OverlapSphere(go.transform.position, Crops.MassInteractRange, num2);
Collider[] array4 = array3;
foreach (Collider val5 in array4)
{
object obj2;
if (val5 == null)
{
obj2 = null;
}
else
{
GameObject gameObject2 = ((Component)val5).gameObject;
obj2 = ((gameObject2 != null) ? gameObject2.GetComponentInParent<Beehive>() : null);
}
Beehive val6 = (Beehive)obj2;
if (val6 != null && (Object)(object)val6 != (Object)(object)val4 && PrivateArea.CheckAccess(((Component)val6).transform.position, 0f, true, false))
{
_ExtractMethod.Invoke(val6, null);
}
}
}
}
internal class Demister
{
[HarmonyPatch(typeof(Mister), "OnEnable")]
internal static class MisterOnEnablePatch
{
private static bool Prefix()
{
return false;
}
}
[HarmonyPatch(typeof(ParticleMist), "Awake")]
internal static class ParticleMistAwakePatch
{
private static void Postfix(ParticleMist __instance)
{
try
{
if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.m_ps != (Object)null)
{
MistEmitter component = ((Component)__instance).GetComponent<MistEmitter>();
if ((Object)(object)component != (Object)null)
{
component.SetEmit(false);
}
}
}
catch (Exception ex)
{
ZLog.LogWarning((object)ex);
}
}
}
}
[HarmonyPatch(typeof(Player), "StartGuardianPower")]
public static class Player_StartGuardianPower_Patch
{
private static bool Prefix(ref Player __instance, ref bool __result)
{
if ((Object)(object)__instance.m_guardianSE == (Object)null)
{
__result = false;
return false;
}
if (__instance.m_guardianPowerCooldown > 0f)
{
((Character)__instance).Message((MessageType)2, "$hud_powernotready", 0, (Sprite)null);
__result = false;
return false;
}
__instance.ActivateGuardianPower();
__result = true;
return false;
}
}
[HarmonyPatch(typeof(EnvMan), "SetEnv")]
public static class AshlandsEnvOverride
{
private static readonly string targetEnvironment = "Mistlands_clear";
[HarmonyPrefix]
public static void Prefix(EnvMan __instance, ref EnvSetup env)
{
if (env.m_name.StartsWith("Ashlands"))
{
EnvSetup val = __instance.m_environments.Find((EnvSetup e) => e.m_name == targetEnvironment);
if (val != null)
{
env = val;
}
}
}
}
[HarmonyPatch(typeof(InventoryGui), "RepairOneItem")]
public static class InventoryGui_RepairOneItem_Transpiler
{
private static readonly MethodInfo method_EffectList_Create = AccessTools.Method(typeof(EffectList), "Create", (Type[])null, (Type[])null);
private static readonly MethodInfo method_CreateNoop = AccessTools.Method(typeof(InventoryGui_RepairOneItem_Transpiler), "CreateNoop", (Type[])null, (Type[])null);
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.Calls(list[i], method_EffectList_Create))
{
list[i] = new CodeInstruction(OpCodes.Call, (object)method_CreateNoop);
}
}
return list.AsEnumerable();
}
private static GameObject[] CreateNoop(Vector3 _0, Quaternion _1, Transform _2, float _3, int _4)
{
return null;
}
}
[HarmonyPatch(typeof(InventoryGui), "UpdateRepair")]
public static class InventoryGui_UpdateRepair_Patch
{
[HarmonyPrefix]
public static void Prefix(InventoryGui __instance)
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = Player.m_localPlayer;
CraftingStation currentCraftingStation = localPlayer.GetCurrentCraftingStation();
if ((Object)(object)currentCraftingStation == (Object)null)
{
return;
}
int num = 0;
foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems())
{
if (ItemRepair.CanRepair(allItem) && allItem.m_durability < allItem.GetMaxDurability())
{
allItem.m_durability = allItem.GetMaxDurability();
num++;
}
}
if (num > 0)
{
currentCraftingStation.m_repairItemDoneEffects.Create(((Component)currentCraftingStation).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
}
}
}
public static class ItemRepair
{
public static bool CanRepair(ItemData item)
{
Recipe recipe = ObjectDB.instance.GetRecipe(item);
CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation();
if ((Object)(object)recipe == (Object)null || (Object)(object)currentCraftingStation == (Object)null)
{
return false;
}
return (((Object)(object)recipe.m_repairStation != (Object)null && recipe.m_repairStation.m_name == currentCraftingStation.m_name) || ((Object)(object)recipe.m_craftingStation != (Object)null && recipe.m_craftingStation.m_name == currentCraftingStation.m_name)) && currentCraftingStation.GetLevel(true) >= recipe.m_minStationLevel;
}
}
[HarmonyPatch(typeof(Game), "Start")]
public static class Game_Start_Patch
{
private static void Prefix()
{
ZRoutedRpc.instance.Register<ZPackage>("nVHMapSync", (Action<long, ZPackage>)MapSync.RPC_nVHMapSync);
ZRoutedRpc.instance.Register("nVHAck", (Action<long>)nVHAck.RPC_nVHAck);
}
}
[HarmonyPatch(typeof(Minimap))]
public class HookExplore
{
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(Minimap), "Explore", new Type[]
{
typeof(Vector3),
typeof(float)
})]
public static void call_Explore(object instance, Vector3 p, float radius)
{
throw new NotImplementedException();
}
}
[HarmonyPatch(typeof(Minimap), "UpdateExplore")]
public static class ChangeMapBehavior
{
private static void Prefix(ref float dt, ref Player player, ref Minimap __instance, ref float ___m_exploreTimer, ref float ___m_exploreInterval)
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
float num = ___m_exploreTimer;
num += Time.deltaTime;
float radius = 200f;
if (num > ___m_exploreInterval && ZNet.instance.m_players.Any())
{
foreach (PlayerInfo player2 in ZNet.instance.m_players)
{
HookExplore.call_Explore(__instance, player2.m_position, radius);
}
}
HookExplore.call_Explore(__instance, ((Component)player).transform.position, radius);
}
}
[HarmonyPatch(typeof(Minimap), "Awake")]
public static class MinimapAwake
{
private static void Postfix()
{
if (ZNet.m_isServer)
{
MapSync.ServerMapData = new bool[Minimap.instance.m_textureSize * Minimap.instance.m_textureSize];
MapSync.LoadMapDataFromDisk();
NaNNaVH.mapSyncSaveTimer.Start();
}
}
}
[HarmonyPatch(typeof(ZNet))]
public class HookZNet
{
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(ZNet), "GetOtherPublicPlayers", new Type[] { typeof(List<PlayerInfo>) })]
public static void GetOtherPublicPlayers(object instance, List<PlayerInfo> playerList)
{
throw new NotImplementedException();
}
}
[HarmonyPatch(typeof(ZNet), "SendPeriodicData")]
public static class PeriodicDataHandler
{
private static void Postfix()
{
RpcQueue.SendNextRpc();
}
}
[HarmonyPatch(typeof(ZNet), "Shutdown")]
public static class OnErrorLoadOwnIni
{
private static void Prefix(ref ZNet __instance)
{
if (!__instance.IsServer())
{
NaNNaVH.harmony.UnpatchSelf();
NaNNaVH.harmony.PatchAll();
MapSync.ShouldSyncOnSpawn = true;
}
else
{
MapSync.SaveMapDataToDisk();
}
}
}
[HarmonyPatch(typeof(ZNet), "SetPublicReferencePosition")]
public static class PreventPublicPositionToggle
{
private static void Postfix(ref bool pub, ref bool ___m_publicReferencePosition)
{
___m_publicReferencePosition = true;
}
}
[HarmonyPatch(typeof(ZNet), "RPC_ServerSyncedPlayerData")]
public static class PlayerPositionWatcher
{
private static void Postfix(ref ZNet __instance, ZRpc rpc)
{
//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_003a: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.IsServer())
{
return;
}
ZNetPeer peer = __instance.GetPeer(rpc);
if (peer == null)
{
return;
}
Vector3 refPos = peer.m_refPos;
int num = default(int);
int num2 = default(int);
Minimap.instance.WorldToPixel(refPos, ref num, ref num2);
int num3 = (int)Mathf.Ceil(200f / Minimap.instance.m_pixelSize);
for (int i = num2 - num3; i <= num2 + num3; i++)
{
for (int j = num - num3; j <= num + num3; j++)
{
if (j >= 0 && i >= 0 && j < Minimap.instance.m_textureSize && i < Minimap.instance.m_textureSize)
{
Vector2 val = new Vector2((float)(j - num), (float)(i - num2));
if ((double)((Vector2)(ref val)).magnitude <= (double)num3)
{
MapSync.ServerMapData[i * Minimap.instance.m_textureSize + j] = true;
}
}
}
}
}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
public static class Player_OnSpawned_Patch
{
private static void Prefix(ref Player __instance)
{
MapSync.SendMapToServer();
MapSync.ShouldSyncOnSpawn = false;
}
}
public class DisplayCartsAndBoatsOnMap
{
[HarmonyPatch(typeof(Minimap), "OnDestroy")]
public static class Minimap_OnDestroy_Patch
{
private static void Postfix()
{
customPins.Clear();
icons.Clear();
}
}
[HarmonyPatch(typeof(Minimap), "UpdateMap")]
public static class Minimap_UpdateMap_Patch
{
private static float timeCounter = updateInterval;
private static void FindIcons()
{
GameObject val = ObjectDB.instance.m_itemByHash[hammerHashCode];
if (!Object.op_Implicit((Object)(object)val))
{
return;
}
ItemDrop component = val.GetComponent<ItemDrop>();
if (!Object.op_Implicit((Object)(object)component))
{
return;
}
PieceTable buildPieces = component.m_itemData.m_shared.m_buildPieces;
foreach (GameObject piece in buildPieces.m_pieces)
{
Piece component2 = piece.GetComponent<Piece>();
icons.Add(StringExtensionMethods.GetStableHashCode(((Object)component2).name), component2.m_icon);
}
}
private static bool CheckPin(Minimap __instance, Player player, ZDO zdo, int hashCode, string pinName)
{
//IL_003c: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
if (zdo.m_prefab != hashCode)
{
return false;
}
PinData value;
bool flag = customPins.TryGetValue(zdo, out value);
Ship controlledShip = player.GetControlledShip();
if (Object.op_Implicit((Object)(object)controlledShip) && Vector3.Distance(((Component)controlledShip).transform.position, zdo.m_position) < 0.01f)
{
if (flag)
{
__instance.RemovePin(value);
customPins.Remove(zdo);
}
return true;
}
if (!flag)
{
value = __instance.AddPin(zdo.m_position, (PinType)4, pinName, false, false, 0L, default(PlatformUserID));
if (icons.TryGetValue(hashCode, out var value2))
{
value.m_icon = value2;
}
value.m_doubleSize = true;
customPins.Add(zdo, value);
}
else
{
value.m_pos = zdo.m_position;
}
return true;
}
public static void Postfix(ref Minimap __instance, Player player, float dt, bool takeInput)
{
timeCounter += dt;
if (timeCounter < updateInterval)
{
return;
}
timeCounter -= updateInterval;
if (icons.Count == 0)
{
FindIcons();
}
List<ZDO>[] objectsBySector = ZDOMan.instance.m_objectsBySector;
foreach (List<ZDO> list in objectsBySector)
{
if (list == null)
{
continue;
}
foreach (ZDO item in list)
{
for (int j = 0; j < HashCodes.Length && !CheckPin(__instance, player, item, HashCodes[j], PinNames[j]); j++)
{
}
}
}
List<ZDO> list2 = new List<ZDO>();
foreach (KeyValuePair<ZDO, PinData> customPin in customPins)
{
if (!customPin.Key.IsValid())
{
__instance.RemovePin(customPin.Value);
list2.Add(customPin.Key);
}
}
foreach (ZDO item2 in list2)
{
customPins.Remove(item2);
}
}
}
private static Dictionary<ZDO, PinData> customPins = new Dictionary<ZDO, PinData>();
private static Dictionary<int, Sprite> icons = new Dictionary<int, Sprite>();
private static int[] HashCodes = new int[4]
{
StringExtensionMethods.GetStableHashCode("Cart"),
StringExtensionMethods.GetStableHashCode("Raft"),
StringExtensionMethods.GetStableHashCode("Karve"),
StringExtensionMethods.GetStableHashCode("VikingShip")
};
private static string[] PinNames = new string[4] { "Cart", "Raft", "Karve", "Longship" };
private static int hammerHashCode = StringExtensionMethods.GetStableHashCode("Hammer");
private static float updateInterval = 5f;
}
public class Network
{
[HarmonyPatch(typeof(ZSteamSocket), "RegisterGlobalCallbacks")]
private static class IncreaseSendingLimit
{
[CompilerGenerated]
private sealed class <Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private IEnumerator<CodeInstruction> <>s__1;
private CodeInstruction <instruction>5__2;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Transpiler>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>s__1 = null;
<instruction>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>s__1 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
<instruction>5__2 = null;
break;
}
if (<>s__1.MoveNext())
{
<instruction>5__2 = <>s__1.Current;
if (<instruction>5__2.opcode == OpCodes.Ldc_I4 && CodeInstructionExtensions.OperandIs(<instruction>5__2, (object)153600))
{
<instruction>5__2.operand = 50000000;
}
<>2__current = <instruction>5__2;
<>1__state = 1;
return true;
}
<>m__Finally1();
<>s__1 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__1 != null)
{
<>s__1.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<Transpiler>d__0 <Transpiler>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<Transpiler>d__ = this;
}
else
{
<Transpiler>d__ = new <Transpiler>d__0(0);
}
<Transpiler>d__.instructions = <>3__instructions;
return <Transpiler>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
[IteratorStateMachine(typeof(<Transpiler>d__0))]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Transpiler>d__0(-2)
{
<>3__instructions = instructions
};
}
private static void Postfix()
{
if (!(CSteamAPIContext.GetSteamClient() != IntPtr.Zero))
{
return;
}
GCHandle gCHandle = default(GCHandle);
try
{
gCHandle = GCHandle.Alloc(100000000, GCHandleType.Pinned);
SteamNetworkingUtils.SetConfigValue((ESteamNetworkingConfigValue)9, (ESteamNetworkingConfigScope)1, IntPtr.Zero, (ESteamNetworkingConfigDataType)1, gCHandle.AddrOfPinnedObject());
}
finally
{
if (gCHandle.IsAllocated)
{
gCHandle.Free();
}
}
}
}
private const int NewLimit = 50000000;
private const int BufferSize = 100000000;
}
[HarmonyPatch(typeof(EnvMan), "SetEnv")]
public static class EnvMan_SetEnv_Patch
{
private const float NightBrightnessMultiplier = 1.5f;
private static void Prefix(ref EnvMan __instance, ref EnvSetup env)
{
env.m_fogDensityNight = 0f;
env.m_fogDensityMorning = 0f;
env.m_fogDensityEvening = 0f;
ApplyEnvModifier(env);
}
private static void ApplyEnvModifier(EnvSetup env)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
env.m_ambColorNight = ApplyBrightnessModifier(env.m_ambColorNight, 1.5f);
env.m_fogColorNight = ApplyBrightnessModifier(env.m_fogColorNight, 1.5f);
env.m_fogColorSunNight = ApplyBrightnessModifier(env.m_fogColorSunNight, 1.5f);
env.m_sunColorNight = ApplyBrightnessModifier(env.m_sunColorNight, 1.5f);
}
private static Color ApplyBrightnessModifier(Color color, float multiplier)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
float num = default(float);
float num2 = default(float);
float num3 = default(float);
Color.RGBToHSV(color, ref num, ref num2, ref num3);
float num4 = ((multiplier >= 0f) ? (Mathf.Sqrt(multiplier) * 0.00010699527f + 1f) : (1f - Mathf.Sqrt(Mathf.Abs(multiplier)) * 0.00010699527f));
num3 = Mathf.Clamp01(num3 * num4);
return Color.HSVToRGB(num, num2, num3);
}
}
[HarmonyPatch(typeof(EnvMan), "SetParticleArrayEnabled")]
public static class EnvMan_SetParticleArrayEnabled_Patch
{
private static void Postfix(GameObject[] psystems, bool enabled)
{
foreach (GameObject val in psystems)
{
MistEmitter componentInChildren = val.GetComponentInChildren<MistEmitter>();
if (Object.op_Implicit((Object)(object)componentInChildren))
{
((Behaviour)componentInChildren).enabled = false;
}
}
}
}
[HarmonyPatch(typeof(Piece), "DropResources")]
public static class PieceDropResourcesTranspiler
{
private static MethodInfo _methodPieceIsPlacedByPlayer = AccessTools.Method(typeof(Piece), "IsPlacedByPlayer", (Type[])null, (Type[])null);
private static FieldInfo _fieldRequirementMRecover = AccessTools.Field(typeof(Requirement), "m_recover");
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
bool flag = false;
bool flag2 = false;
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.Calls(list[i], _methodPieceIsPlacedByPlayer) && !flag)
{
list[i] = new CodeInstruction(OpCodes.Ldc_I4_1, (object)null);
list.RemoveAt(i - 1);
flag = true;
}
if (CodeInstructionExtensions.LoadsField(list[i], _fieldRequirementMRecover, false) && !flag2)
{
list.RemoveRange(i - 1, 3);
flag2 = true;
}
}
return list.AsEnumerable();
}
}
[HarmonyPatch(typeof(ItemData), "GetMaxDurability", new Type[] { typeof(int) })]
public static class ItemDrop_GetMaxDurability_Patch
{
private static readonly HashSet<string> ItemsToChangeDurability = new HashSet<string> { "hammer", "cultivator", "hoe", "torch" };
private static bool Prefix(ItemData __instance, int quality, ref float __result)
{
string text = __instance.m_shared.m_name.ToLower();
foreach (string item in ItemsToChangeDurability)
{
if (text.Contains(item))
{
float targetValue = __instance.m_shared.m_maxDurability + (float)Mathf.Max(0, quality - 1) * __instance.m_shared.m_durabilityPerLevel;
__result = sFunc.applyModifierValue(targetValue, 200f);
return false;
}
}
return true;
}
}
[HarmonyPatch(typeof(Player), "EatFood")]
public static class Player_EatFood_Transpiler
{
private static readonly FieldInfo field_ItemDrop_ItemData_SharedData_m_foodBurnTime = AccessTools.Field(typeof(SharedData), "m_foodBurnTime");
private static readonly MethodInfo method_ComputeModifiedFoodBurnTime = AccessTools.Method(typeof(Player_EatFood_Transpiler), "ComputeModifiedFoodBurnTime", (Type[])null, (Type[])null);
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.LoadsField(list[i], field_ItemDrop_ItemData_SharedData_m_foodBurnTime, false))
{
list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)method_ComputeModifiedFoodBurnTime));
i++;
}
}
return list.AsEnumerable();
}
private static float ComputeModifiedFoodBurnTime(float foodBurnTime)
{
return sFunc.applyModifierValue(foodBurnTime, 300f);
}
}
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
public static class Player_GetTotalFoodValue_Transpiler
{
private static readonly FieldInfo field_Food_m_health = AccessTools.Field(typeof(Food), "m_health");
private static readonly FieldInfo field_Food_m_stamina = AccessTools.Field(typeof(Food), "m_stamina");
private static readonly FieldInfo field_Food_m_item = AccessTools.Field(typeof(Food), "m_item");
private static readonly FieldInfo field_ItemData_m_shared = AccessTools.Field(typeof(ItemData), "m_shared");
private static readonly FieldInfo field_SharedData_m_food = AccessTools.Field(typeof(SharedData), "m_food");
private static readonly FieldInfo field_SharedData_m_foodStamina = AccessTools.Field(typeof(SharedData), "m_foodStamina");
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.LoadsField(list[i], field_Food_m_health, false) || CodeInstructionExtensions.LoadsField(list[i], field_Food_m_stamina, false))
{
bool flag = CodeInstructionExtensions.LoadsField(list[i], field_Food_m_health, false);
list[i].operand = field_Food_m_item;
list.Insert(++i, new CodeInstruction(OpCodes.Ldfld, (object)field_ItemData_m_shared));
list.Insert(++i, new CodeInstruction(OpCodes.Ldfld, (object)(flag ? field_SharedData_m_food : field_SharedData_m_foodStamina)));
}
}
return list.AsEnumerable();
}
}
public class Fuel
{
[HarmonyPatch(typeof(Fireplace), "UpdateFireplace")]
private class Fireplace_UpdateFireplace_Patch
{
[HarmonyPrefix]
private static void Prefix(Fireplace __instance, ref ZNetView ___m_nview)
{
___m_nview.GetZDO().Set("fuel", __instance.m_maxFuel);
}
}
[HarmonyPatch(typeof(CookingStation), "SetFuel")]
private class CookingStation_SetFuel_Patch
{
[HarmonyPrefix]
private static void Prefix(CookingStation __instance, ref float fuel)
{
fuel = __instance.m_maxFuel;
}
}
[HarmonyPatch(typeof(CookingStation), "Awake")]
private class CookingStation_Awake_Patch
{
[HarmonyPostfix]
private static void Postfix(CookingStation __instance, ref ZNetView ___m_nview)
{
if (!((Object)(object)Player.m_localPlayer == (Object)null) && !((Character)Player.m_localPlayer).IsTeleporting())
{
RefuelAsync(___m_nview);
}
}
}
private static async void RefuelAsync(ZNetView nview)
{
if (!((Object)(object)nview == (Object)null) && ((Behaviour)nview).isActiveAndEnabled)
{
await Task.Delay(33);
nview.InvokeRPC("AddFuel", Array.Empty<object>());
}
}
}
[HarmonyPatch(typeof(DropTable), "GetDropList", new Type[] { typeof(int) })]
public static class DropTable_GetDropList_Patch
{
private static void Postfix(ref DropTable __instance, ref List<GameObject> __result, int amount)
{
__instance.m_dropChance = 1f;
List<string> list = new List<string> { "Wood", "RoundLog", "Stone", "FineWood" };
Dictionary<string, Tuple<int, GameObject>> dictionary = new Dictionary<string, Tuple<int, GameObject>>();
List<GameObject> list2 = new List<GameObject>();
foreach (GameObject item2 in __result)
{
if (list.Contains(((Object)item2).name))
{
if (!dictionary.ContainsKey(((Object)item2).name))
{
dictionary.Add(((Object)item2).name, new Tuple<int, GameObject>(1, item2));
continue;
}
int item = dictionary[((Object)item2).name].Item1;
dictionary[((Object)item2).name] = new Tuple<int, GameObject>(item + 1, item2);
}
else
{
list2.Add(item2);
}
}
__result.Clear();
__result.AddRange(list2);
foreach (KeyValuePair<string, Tuple<int, GameObject>> item3 in dictionary)
{
float num = sFunc.applyModifierValue(item3.Value.Item1, 200f);
int num2 = Mathf.RoundToInt(num);
for (int i = 0; i < num2; i++)
{
__result.Add(item3.Value.Item2);
}
}
}
}
[HarmonyPatch]
internal class Recipes
{
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
public static class ObjectDB_CopyOtherDB_Patch
{
private static void Postfix()
{
ModifyCosts("ObjectDB.CopyOtherDB");
}
}
protected static bool PatchingHasAlreadySucceeded;
internal static void ModifyCosts(string debugInfo)
{
if ((Object)(object)ObjectDB.instance == (Object)null || PatchingHasAlreadySucceeded)
{
return;
}
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Hammer");
ItemDrop val = default(ItemDrop);
if ((Object)(object)itemPrefab == (Object)null || !itemPrefab.TryGetComponent<ItemDrop>(ref val))
{
return;
}
PieceTable val2 = val.m_itemData?.m_shared?.m_buildPieces;
if ((Object)(object)val2 == (Object)null)
{
return;
}
GameObject val3 = val2.m_pieces.Find((GameObject piece) => ((Object)piece).name == "piece_stonecutter");
Piece val4 = default(Piece);
if ((Object)(object)val3 == (Object)null || !val3.TryGetComponent<Piece>(ref val4) || val4.m_resources == null || val4.m_resources.Length == 0)
{
return;
}
Requirement[] resources = val4.m_resources;
ItemDrop resItem = default(ItemDrop);
foreach (Requirement val5 in resources)
{
if (((Object)val5.m_resItem).name == "Iron")
{
GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab("Bronze");
if (!((Object)(object)itemPrefab2 == (Object)null) && itemPrefab2.TryGetComponent<ItemDrop>(ref resItem))
{
val5.m_resItem = resItem;
PatchingHasAlreadySucceeded = true;
}
break;
}
}
}
}
[HarmonyPatch(typeof(SE_Rested), "UpdateTTL")]
public static class SE_Rested_UpdateTTL_Patch
{
[HarmonyPrefix]
public static void Prefix(ref float ___m_baseTTL, ref float ___m_TTLPerComfortLevel)
{
___m_baseTTL = 960f;
___m_TTLPerComfortLevel = 120f;
}
}
[HarmonyPatch(typeof(Player), "UseStamina")]
public static class Player_UseStamina_Patch
{
private static void Prefix(ref Player __instance, ref float v)
{
string name = new StackTrace().GetFrame(2).GetMethod().Name;
if (name.Contains("UpdatePlacement") || name.Contains("Repair") || name.Contains("RemovePiece"))
{
string item = ((Humanoid)__instance).GetRightItem()?.m_shared.m_name;
HashSet<string> hashSet = new HashSet<string> { "$item_hammer", "$item_hoe", "$item_cultivator" };
if (hashSet.Contains(item))
{
v = sFunc.applyModifierValue(v, -100f);
}
}
}
}
[HarmonyPatch(typeof(Attack), "GetAttackStamina")]
public static class Attack_GetAttackStamina_Patch
{
private static void Postfix(ref Attack __instance, ref float __result)
{
//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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Invalid comparison between Unknown and I4
if (((Character)__instance.m_character).IsPlayer())
{
ItemData currentWeapon = __instance.m_character.GetCurrentWeapon();
SkillType val = (SkillType)((currentWeapon == null) ? 11 : ((int)currentWeapon.m_shared.m_skillType));
if ((int)val == 12)
{
__result = sFunc.applyModifierValue(__result, -100f);
}
}
}
}
[HarmonyPatch(typeof(WearNTear), "HaveRoof")]
public static class RemoveWearNTear
{
private static void Postfix(ref bool __result)
{
__result = true;
}
}
[HarmonyPatch(typeof(WearNTear), "IsUnderWater")]
public static class RemoveWearNTearFromUnderWater
{
private static void Postfix(ref bool __result)
{
__result = false;
}
}
[HarmonyPatch(typeof(CraftingStation), "CheckUsable")]
public static class WorkbenchRemoveRestrictions
{
private static bool Prefix(ref CraftingStation __instance, ref Player player, ref bool showMessage, ref bool __result)
{
__instance.m_craftRequireRoof = false;
return true;
}
}
}