using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using IBelieveICanFly.Patches; using IBelieveICanFly.Registration; using ItemManager; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using PieceManager; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.SceneManagement; 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("IBelieveICanFly")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Yggdrah")] [assembly: AssemblyProduct("IBelieveICanFly")] [assembly: AssemblyCopyright("Copyright \ufffd 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")] [assembly: AssemblyFileVersion("1.0.5")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace IBelieveICanFly { [BepInPlugin("Yggdrah.IBelieveICanFly", "IBelieveICanFly", "1.0.5")] public class IBelieveICanFlyPlugin : BaseUnityPlugin { private class ConfigurationManagerAttributes { public int? Order; public bool? Browsable; public string? Category; public Action? CustomDrawer; } private class AcceptableShortcuts : AcceptableValueBase { public AcceptableShortcuts() : base(typeof(KeyboardShortcut)) { } public override object Clamp(object value) { return value; } public override bool IsValid(object value) { return true; } public override string ToDescriptionString() { return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes); } } internal const string ModName = "IBelieveICanFly"; internal const string ModVersion = "1.0.5"; internal const string Author = "Yggdrah"; private const string ModGUID = "Yggdrah.IBelieveICanFly"; private static readonly string ConfigFileName = "Yggdrah.IBelieveICanFly.cfg"; private static readonly string ConfigFileFullPath; internal static string ConnectionError; private readonly Harmony _harmony = new Harmony("Yggdrah.IBelieveICanFly"); internal static IBelieveICanFlyPlugin? context; public static readonly ManualLogSource IBelieveICanFlyLogger; private static readonly ConfigSync ConfigSync; private static readonly Dictionary _assetBundleCache; public const string bundleName = "ibelieveicanfly"; private static ConfigEntry? _serverConfigLocked; public void Awake() { bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; context = this; _serverConfigLocked = config("01 - ServerSync", "01 - Lock Configuration", value: true, "Whether to enable or disable if the configuration is locked in which only server admins can change"); ConfigSync.AddLockingConfigEntry(_serverConfigLocked); GetAssetBundle("ibelieveicanfly"); Config.RegisterAllConfigs(((BaseUnityPlugin)this).Config, "Yggdrah.IBelieveICanFly"); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); SetupWatcher(); GliderSystem.Initialize(); IBelieveICanFly.Registration.Item.RegisterAll("ibelieveicanfly"); if (saveOnConfigSet) { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet; ((BaseUnityPlugin)this).Config.Save(); } } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); GliderSystem.OnModUnload(); GliderSystem.CleanupRemotePlayerGliders(); } public static AssetBundle? GetAssetBundle(string filename) { string filename2 = filename; if (_assetBundleCache.TryGetValue(filename2, out AssetBundle value)) { return value; } AssetBundle val = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((AssetBundle a) => ((Object)a).name == filename2)); if ((Object)(object)val != (Object)null) { _assetBundleCache[filename2] = val; return val; } try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename2)); using Stream stream = executingAssembly.GetManifestResourceStream(name); AssetBundle val2 = AssetBundle.LoadFromStream(stream); _assetBundleCache[filename2] = val2; return val2; } catch (Exception) { return null; } } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (File.Exists(ConfigFileFullPath)) { ((BaseUnityPlugin)this).Config.Reload(); } } internal ConfigEntry config(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags); ConfigEntry val2 = ((BaseUnityPlugin)this).Config.Bind(group, name, value, val); SyncedConfigEntry syncedConfigEntry = ConfigSync.AddConfigEntry(val2); syncedConfigEntry.SynchronizedConfig = synchronizedSetting; return val2; } internal ConfigEntry config(string group, string name, T value, string description, bool synchronizedSetting = true) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty()), synchronizedSetting); } static IBelieveICanFlyPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; ConnectionError = ""; IBelieveICanFlyLogger = Logger.CreateLogSource("IBelieveICanFly"); ConfigSync = new ConfigSync("Yggdrah.IBelieveICanFly") { DisplayName = "IBelieveICanFly", CurrentVersion = "1.0.5", MinimumRequiredVersion = "1.0.5", ModRequired = true }; _assetBundleCache = new Dictionary(); } } public static class KeyboardExtensions { public static bool IsKeyDown(this KeyboardShortcut shortcut) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func)Input.GetKey); } public static bool IsKeyHeld(this KeyboardShortcut shortcut) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKey(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func)Input.GetKey); } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] public static class RegisterAndCheckVersion { private static void Prefix(ZNetPeer peer, ref ZNet __instance) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown peer.m_rpc.Register("IBelieveICanFly_VersionCheck", (Action)RpcHandlers.RPC_IBelieveICanFly_Version); ZPackage val = new ZPackage(); val.Write("1.0.5"); peer.m_rpc.Invoke("IBelieveICanFly_VersionCheck", new object[1] { val }); } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] public static class VerifyClient { private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance) { if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc)) { return true; } rpc.Invoke("Error", new object[1] { 3 }); return false; } private static void Postfix(ZNet __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RequestAdminSync", new object[1] { (object)new ZPackage() }); } } [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] public class ShowConnectionError { private static void Postfix(FejdStartup __instance) { if (__instance.m_connectionFailedPanel.activeSelf) { __instance.m_connectionFailedError.fontSizeMax = 25f; __instance.m_connectionFailedError.fontSizeMin = 15f; TMP_Text connectionFailedError = __instance.m_connectionFailedError; connectionFailedError.text = connectionFailedError.text + "\n" + IBelieveICanFlyPlugin.ConnectionError; } } } [HarmonyPatch(typeof(ZNet), "Disconnect")] public static class RemoveDisconnectedPeerFromVerified { private static void Prefix(ZNetPeer peer, ref ZNet __instance) { if (__instance.IsServer()) { RpcHandlers.ValidatedPeers.Remove(peer.m_rpc); } } } public static class RpcHandlers { public static readonly List ValidatedPeers = new List(); public static void RPC_IBelieveICanFly_Version(ZRpc rpc, ZPackage pkg) { string text = pkg.ReadString(); if (text != "1.0.5") { IBelieveICanFlyPlugin.ConnectionError = "IBelieveICanFly Installed: 1.0.5\n Needed: " + text; if (ZNet.instance.IsServer()) { rpc.Invoke("Error", new object[1] { 3 }); } } else if (ZNet.instance.IsServer()) { ValidatedPeers.Add(rpc); } } } } namespace IBelieveICanFly.Registration { public static class Config { public static ConfigEntry ToggleMode { get; private set; } public static ConfigEntry Wings1Enabled { get; private set; } public static ConfigEntry Wings1ItemName { get; private set; } public static ConfigEntry Wings1CheckRightHand { get; private set; } public static ConfigEntry Wings1CheckLeftHand { get; private set; } public static ConfigEntry Wings1CheckUtility { get; private set; } public static ConfigEntry Wings1UseFallReset { get; private set; } public static ConfigEntry Wings1Animation { get; private set; } public static ConfigEntry Wings1MinActivationFallSpeed { get; private set; } public static ConfigEntry Wings1ForwardSpeed { get; private set; } public static ConfigEntry Wings1ForwardForce { get; private set; } public static ConfigEntry Wings1DescentSpeed { get; private set; } public static ConfigEntry Wings1AirTurnSpeed { get; private set; } public static ConfigEntry Wings1LateralDamp { get; private set; } public static ConfigEntry Wings1GroundProbeDistance { get; private set; } public static ConfigEntry Wings1CushionDescentSpeed { get; private set; } public static ConfigEntry Wings1CushionLerp { get; private set; } public static ConfigEntry Wings1UpDownOffset { get; private set; } public static ConfigEntry Wings1LeftRightOffset { get; private set; } public static ConfigEntry Wings1ForwardBackOffset { get; private set; } public static ConfigEntry Wings1RotationX { get; private set; } public static ConfigEntry Wings1RotationY { get; private set; } public static ConfigEntry Wings1RotationZ { get; private set; } public static ConfigEntry Wings1Scale { get; private set; } public static ConfigEntry Wings1SFX { get; private set; } public static ConfigEntry Wings1AttachSFXToPlayer { get; private set; } public static ConfigEntry Wings1StartSFX { get; private set; } public static ConfigEntry Wings1LoopSFX { get; private set; } public static ConfigEntry Wings1StopSFX { get; private set; } public static ConfigEntry Wings1VFX { get; private set; } public static ConfigEntry Wings1AttachEffectsToPlayer { get; private set; } public static ConfigEntry Wings1StartVFX { get; private set; } public static ConfigEntry Wings1LoopVFX { get; private set; } public static ConfigEntry Wings1StopVFX { get; private set; } public static ConfigEntry Wings1VFXPosition { get; private set; } public static ConfigEntry Wings1VFXScale { get; private set; } public static ConfigEntry Wings1VFXCustomX { get; private set; } public static ConfigEntry Wings1VFXCustomY { get; private set; } public static ConfigEntry Wings1VFXCustomZ { get; private set; } public static ConfigEntry Wings1VisualPrefab { get; private set; } public static ConfigEntry Wings1TiltMaxPitch { get; private set; } public static ConfigEntry Wings1TiltMaxRoll { get; private set; } public static ConfigEntry Wings1TiltPitchSmoothTime { get; private set; } public static ConfigEntry Wings1TiltRollSmoothTime { get; private set; } public static ConfigEntry Wings2Enabled { get; private set; } public static ConfigEntry Wings2ItemName { get; private set; } public static ConfigEntry Wings2CheckRightHand { get; private set; } public static ConfigEntry Wings2CheckLeftHand { get; private set; } public static ConfigEntry Wings2CheckUtility { get; private set; } public static ConfigEntry Wings2UseFallReset { get; private set; } public static ConfigEntry Wings2Animation { get; private set; } public static ConfigEntry Wings2MinActivationFallSpeed { get; private set; } public static ConfigEntry Wings2ForwardSpeed { get; private set; } public static ConfigEntry Wings2ForwardForce { get; private set; } public static ConfigEntry Wings2DescentSpeed { get; private set; } public static ConfigEntry Wings2AirTurnSpeed { get; private set; } public static ConfigEntry Wings2LateralDamp { get; private set; } public static ConfigEntry Wings2GroundProbeDistance { get; private set; } public static ConfigEntry Wings2CushionDescentSpeed { get; private set; } public static ConfigEntry Wings2CushionLerp { get; private set; } public static ConfigEntry Wings2UpDownOffset { get; private set; } public static ConfigEntry Wings2LeftRightOffset { get; private set; } public static ConfigEntry Wings2ForwardBackOffset { get; private set; } public static ConfigEntry Wings2RotationX { get; private set; } public static ConfigEntry Wings2RotationY { get; private set; } public static ConfigEntry Wings2RotationZ { get; private set; } public static ConfigEntry Wings2Scale { get; private set; } public static ConfigEntry Wings2SFX { get; private set; } public static ConfigEntry Wings2AttachSFXToPlayer { get; private set; } public static ConfigEntry Wings2StartSFX { get; private set; } public static ConfigEntry Wings2LoopSFX { get; private set; } public static ConfigEntry Wings2StopSFX { get; private set; } public static ConfigEntry Wings2VFX { get; private set; } public static ConfigEntry Wings2AttachEffectsToPlayer { get; private set; } public static ConfigEntry Wings2StartVFX { get; private set; } public static ConfigEntry Wings2LoopVFX { get; private set; } public static ConfigEntry Wings2StopVFX { get; private set; } public static ConfigEntry Wings2VFXPosition { get; private set; } public static ConfigEntry Wings2VFXScale { get; private set; } public static ConfigEntry Wings2VFXCustomX { get; private set; } public static ConfigEntry Wings2VFXCustomY { get; private set; } public static ConfigEntry Wings2VFXCustomZ { get; private set; } public static ConfigEntry Wings2VisualPrefab { get; private set; } public static ConfigEntry Wings2TiltMaxPitch { get; private set; } public static ConfigEntry Wings2TiltMaxRoll { get; private set; } public static ConfigEntry Wings2TiltPitchSmoothTime { get; private set; } public static ConfigEntry Wings2TiltRollSmoothTime { get; private set; } public static ConfigEntry Wings3Enabled { get; private set; } public static ConfigEntry Wings3ItemName { get; private set; } public static ConfigEntry Wings3CheckRightHand { get; private set; } public static ConfigEntry Wings3CheckLeftHand { get; private set; } public static ConfigEntry Wings3CheckUtility { get; private set; } public static ConfigEntry Wings3UseFallReset { get; private set; } public static ConfigEntry Wings3Animation { get; private set; } public static ConfigEntry Wings3MinActivationFallSpeed { get; private set; } public static ConfigEntry Wings3ForwardSpeed { get; private set; } public static ConfigEntry Wings3ForwardForce { get; private set; } public static ConfigEntry Wings3DescentSpeed { get; private set; } public static ConfigEntry Wings3AirTurnSpeed { get; private set; } public static ConfigEntry Wings3LateralDamp { get; private set; } public static ConfigEntry Wings3GroundProbeDistance { get; private set; } public static ConfigEntry Wings3CushionDescentSpeed { get; private set; } public static ConfigEntry Wings3CushionLerp { get; private set; } public static ConfigEntry Wings3UpDownOffset { get; private set; } public static ConfigEntry Wings3LeftRightOffset { get; private set; } public static ConfigEntry Wings3ForwardBackOffset { get; private set; } public static ConfigEntry Wings3RotationX { get; private set; } public static ConfigEntry Wings3RotationY { get; private set; } public static ConfigEntry Wings3RotationZ { get; private set; } public static ConfigEntry Wings3Scale { get; private set; } public static ConfigEntry Wings3SFX { get; private set; } public static ConfigEntry Wings3AttachSFXToPlayer { get; private set; } public static ConfigEntry Wings3StartSFX { get; private set; } public static ConfigEntry Wings3LoopSFX { get; private set; } public static ConfigEntry Wings3StopSFX { get; private set; } public static ConfigEntry Wings3VFX { get; private set; } public static ConfigEntry Wings3AttachEffectsToPlayer { get; private set; } public static ConfigEntry Wings3StartVFX { get; private set; } public static ConfigEntry Wings3LoopVFX { get; private set; } public static ConfigEntry Wings3StopVFX { get; private set; } public static ConfigEntry Wings3VFXPosition { get; private set; } public static ConfigEntry Wings3VFXScale { get; private set; } public static ConfigEntry Wings3VFXCustomX { get; private set; } public static ConfigEntry Wings3VFXCustomY { get; private set; } public static ConfigEntry Wings3VFXCustomZ { get; private set; } public static ConfigEntry Wings3VisualPrefab { get; private set; } public static ConfigEntry Wings3TiltMaxPitch { get; private set; } public static ConfigEntry Wings3TiltMaxRoll { get; private set; } public static ConfigEntry Wings3TiltPitchSmoothTime { get; private set; } public static ConfigEntry Wings3TiltRollSmoothTime { get; private set; } public static ConfigEntry Wings4Enabled { get; private set; } public static ConfigEntry Wings4ItemName { get; private set; } public static ConfigEntry Wings4CheckRightHand { get; private set; } public static ConfigEntry Wings4CheckLeftHand { get; private set; } public static ConfigEntry Wings4CheckUtility { get; private set; } public static ConfigEntry Wings4UseFallReset { get; private set; } public static ConfigEntry Wings4Animation { get; private set; } public static ConfigEntry Wings4MinActivationFallSpeed { get; private set; } public static ConfigEntry Wings4ForwardSpeed { get; private set; } public static ConfigEntry Wings4ForwardForce { get; private set; } public static ConfigEntry Wings4DescentSpeed { get; private set; } public static ConfigEntry Wings4AirTurnSpeed { get; private set; } public static ConfigEntry Wings4LateralDamp { get; private set; } public static ConfigEntry Wings4GroundProbeDistance { get; private set; } public static ConfigEntry Wings4CushionDescentSpeed { get; private set; } public static ConfigEntry Wings4CushionLerp { get; private set; } public static ConfigEntry Wings4UpDownOffset { get; private set; } public static ConfigEntry Wings4LeftRightOffset { get; private set; } public static ConfigEntry Wings4ForwardBackOffset { get; private set; } public static ConfigEntry Wings4RotationX { get; private set; } public static ConfigEntry Wings4RotationY { get; private set; } public static ConfigEntry Wings4RotationZ { get; private set; } public static ConfigEntry Wings4Scale { get; private set; } public static ConfigEntry Wings4SFX { get; private set; } public static ConfigEntry Wings4AttachSFXToPlayer { get; private set; } public static ConfigEntry Wings4StartSFX { get; private set; } public static ConfigEntry Wings4LoopSFX { get; private set; } public static ConfigEntry Wings4StopSFX { get; private set; } public static ConfigEntry Wings4VFX { get; private set; } public static ConfigEntry Wings4AttachEffectsToPlayer { get; private set; } public static ConfigEntry Wings4StartVFX { get; private set; } public static ConfigEntry Wings4LoopVFX { get; private set; } public static ConfigEntry Wings4StopVFX { get; private set; } public static ConfigEntry Wings4VFXPosition { get; private set; } public static ConfigEntry Wings4VFXScale { get; private set; } public static ConfigEntry Wings4VFXCustomX { get; private set; } public static ConfigEntry Wings4VFXCustomY { get; private set; } public static ConfigEntry Wings4VFXCustomZ { get; private set; } public static ConfigEntry Wings4VisualPrefab { get; private set; } public static ConfigEntry Wings4TiltMaxPitch { get; private set; } public static ConfigEntry Wings4TiltMaxRoll { get; private set; } public static ConfigEntry Wings4TiltPitchSmoothTime { get; private set; } public static ConfigEntry Wings4TiltRollSmoothTime { get; private set; } public static ConfigEntry Wings5Enabled { get; private set; } public static ConfigEntry Wings5ItemName { get; private set; } public static ConfigEntry Wings5CheckRightHand { get; private set; } public static ConfigEntry Wings5CheckLeftHand { get; private set; } public static ConfigEntry Wings5CheckUtility { get; private set; } public static ConfigEntry Wings5UseFallReset { get; private set; } public static ConfigEntry Wings5Animation { get; private set; } public static ConfigEntry Wings5MinActivationFallSpeed { get; private set; } public static ConfigEntry Wings5ForwardSpeed { get; private set; } public static ConfigEntry Wings5ForwardForce { get; private set; } public static ConfigEntry Wings5DescentSpeed { get; private set; } public static ConfigEntry Wings5AirTurnSpeed { get; private set; } public static ConfigEntry Wings5LateralDamp { get; private set; } public static ConfigEntry Wings5GroundProbeDistance { get; private set; } public static ConfigEntry Wings5CushionDescentSpeed { get; private set; } public static ConfigEntry Wings5CushionLerp { get; private set; } public static ConfigEntry Wings5UpDownOffset { get; private set; } public static ConfigEntry Wings5LeftRightOffset { get; private set; } public static ConfigEntry Wings5ForwardBackOffset { get; private set; } public static ConfigEntry Wings5RotationX { get; private set; } public static ConfigEntry Wings5RotationY { get; private set; } public static ConfigEntry Wings5RotationZ { get; private set; } public static ConfigEntry Wings5Scale { get; private set; } public static ConfigEntry Wings5SFX { get; private set; } public static ConfigEntry Wings5AttachSFXToPlayer { get; private set; } public static ConfigEntry Wings5StartSFX { get; private set; } public static ConfigEntry Wings5LoopSFX { get; private set; } public static ConfigEntry Wings5StopSFX { get; private set; } public static ConfigEntry Wings5VFX { get; private set; } public static ConfigEntry Wings5AttachEffectsToPlayer { get; private set; } public static ConfigEntry Wings5StartVFX { get; private set; } public static ConfigEntry Wings5LoopVFX { get; private set; } public static ConfigEntry Wings5StopVFX { get; private set; } public static ConfigEntry Wings5VFXPosition { get; private set; } public static ConfigEntry Wings5VFXScale { get; private set; } public static ConfigEntry Wings5VFXCustomX { get; private set; } public static ConfigEntry Wings5VFXCustomY { get; private set; } public static ConfigEntry Wings5VFXCustomZ { get; private set; } public static ConfigEntry Wings5VisualPrefab { get; private set; } public static ConfigEntry Wings5TiltMaxPitch { get; private set; } public static ConfigEntry Wings5TiltMaxRoll { get; private set; } public static ConfigEntry Wings5TiltPitchSmoothTime { get; private set; } public static ConfigEntry Wings5TiltRollSmoothTime { get; private set; } public static ConfigEntry Wings6Enabled { get; private set; } public static ConfigEntry Wings6ItemName { get; private set; } public static ConfigEntry Wings6CheckRightHand { get; private set; } public static ConfigEntry Wings6CheckLeftHand { get; private set; } public static ConfigEntry Wings6CheckUtility { get; private set; } public static ConfigEntry Wings6UseFallReset { get; private set; } public static ConfigEntry Wings6Animation { get; private set; } public static ConfigEntry Wings6MinActivationFallSpeed { get; private set; } public static ConfigEntry Wings6ForwardSpeed { get; private set; } public static ConfigEntry Wings6ForwardForce { get; private set; } public static ConfigEntry Wings6DescentSpeed { get; private set; } public static ConfigEntry Wings6AirTurnSpeed { get; private set; } public static ConfigEntry Wings6LateralDamp { get; private set; } public static ConfigEntry Wings6GroundProbeDistance { get; private set; } public static ConfigEntry Wings6CushionDescentSpeed { get; private set; } public static ConfigEntry Wings6CushionLerp { get; private set; } public static ConfigEntry Wings6UpDownOffset { get; private set; } public static ConfigEntry Wings6LeftRightOffset { get; private set; } public static ConfigEntry Wings6ForwardBackOffset { get; private set; } public static ConfigEntry Wings6RotationX { get; private set; } public static ConfigEntry Wings6RotationY { get; private set; } public static ConfigEntry Wings6RotationZ { get; private set; } public static ConfigEntry Wings6Scale { get; private set; } public static ConfigEntry Wings6SFX { get; private set; } public static ConfigEntry Wings6AttachSFXToPlayer { get; private set; } public static ConfigEntry Wings6StartSFX { get; private set; } public static ConfigEntry Wings6LoopSFX { get; private set; } public static ConfigEntry Wings6StopSFX { get; private set; } public static ConfigEntry Wings6VFX { get; private set; } public static ConfigEntry Wings6AttachEffectsToPlayer { get; private set; } public static ConfigEntry Wings6StartVFX { get; private set; } public static ConfigEntry Wings6LoopVFX { get; private set; } public static ConfigEntry Wings6StopVFX { get; private set; } public static ConfigEntry Wings6VFXPosition { get; private set; } public static ConfigEntry Wings6VFXScale { get; private set; } public static ConfigEntry Wings6VFXCustomX { get; private set; } public static ConfigEntry Wings6VFXCustomY { get; private set; } public static ConfigEntry Wings6VFXCustomZ { get; private set; } public static ConfigEntry Wings6VisualPrefab { get; private set; } public static ConfigEntry Wings6TiltMaxPitch { get; private set; } public static ConfigEntry Wings6TiltMaxRoll { get; private set; } public static ConfigEntry Wings6TiltPitchSmoothTime { get; private set; } public static ConfigEntry Wings6TiltRollSmoothTime { get; private set; } public static void RegisterAllConfigs(ConfigFile config, string modGuid) { if ((Object)(object)IBelieveICanFlyPlugin.context != (Object)null) { ToggleMode = IBelieveICanFlyPlugin.context.config("02 - General Settings", "01 - Toggle Mode", value: true, "Whether to enable or disable if pressing Space will toggle gliding. When disabled, hold Space to glide."); RegisterWings1(); RegisterWings2(); RegisterWings3(); RegisterWings4(); RegisterWings5(); RegisterWings6(); } } private static void RegisterWings1() { Wings1Enabled = IBelieveICanFlyPlugin.context.config("02.01 - Wings 1", "01 - Enabled", value: true, "Whether to enable or disable Wings 1. When enabled, this wings configuration will be active."); Wings1ItemName = IBelieveICanFlyPlugin.context.config("02.01 - Wings 1", "02 - Item Name", "Glider_BackPack_Ygg", "Item prefab name that triggers Wings 1. Use vanilla item names like 'SwordIron' or custom item names."); Wings1VisualPrefab = IBelieveICanFlyPlugin.context.config("02.01 - Wings 1", "03 - Visual Prefab Override", "DragonWings_Ygg", "Optional: Override the visual prefab shown when gliding. If empty, uses the trigger item's model. Use this to show wings while having a ring/amulet as the trigger item."); Wings1CheckRightHand = IBelieveICanFlyPlugin.context.config("02.02 - Wings 1", "01 - Check Right Hand", value: false, "Whether to enable or disable checking the right hand slot for Wings 1 item."); Wings1CheckLeftHand = IBelieveICanFlyPlugin.context.config("02.02 - Wings 1", "02 - Check Left Hand", value: false, "Whether to enable or disable checking the left hand slot for Wings 1 item."); Wings1CheckUtility = IBelieveICanFlyPlugin.context.config("02.02 - Wings 1", "03 - Check Utility Slot", value: true, "Whether to enable or disable checking the utility/belt slot for Wings 1 item."); Wings1UseFallReset = IBelieveICanFlyPlugin.context.config("02.02 - Wings 1", "04 - Prevent Fall Damage", value: true, "Whether to enable or disable fall damage when landing after gliding with Wings 1."); Wings1Animation = IBelieveICanFlyPlugin.context.config("02.02 - Wings 1", "05 - Use Animation", value: true, "Whether to enable or disable using animation while gliding with Wings 1."); Wings1MinActivationFallSpeed = IBelieveICanFlyPlugin.context.config("02.03 - Wings 1", "01 - Min Activation Fall Speed", -0.5f, "Prevent glide trigger if you barely left ground for Wings 1."); Wings1ForwardSpeed = IBelieveICanFlyPlugin.context.config("02.03 - Wings 1", "02 - Max Forward Speed", 10f, "Maximum forward speed while gliding with Wings 1."); Wings1ForwardForce = IBelieveICanFlyPlugin.context.config("02.03 - Wings 1", "03 - Forward Force", 5f, "Forward acceleration while gliding with Wings 1."); Wings1DescentSpeed = IBelieveICanFlyPlugin.context.config("02.03 - Wings 1", "04 - Max Descent Speed", -4f, "How fast you can fall while gliding with Wings 1 (more negative = faster fall)."); Wings1AirTurnSpeed = IBelieveICanFlyPlugin.context.config("02.03 - Wings 1", "05 - Air Turn Speed", 120f, "Yaw control while gliding with Wings 1 (deg/sec)."); Wings1LateralDamp = IBelieveICanFlyPlugin.context.config("02.03 - Wings 1", "06 - Lateral Damping", 0.15f, "Slight damping to stabilize lateral drift for Wings 1."); Wings1GroundProbeDistance = IBelieveICanFlyPlugin.context.config("02.03 - Wings 1", "07 - Ground Probe Distance", 2.5f, "Start cushioning this far from ground for Wings 1."); Wings1CushionDescentSpeed = IBelieveICanFlyPlugin.context.config("02.03 - Wings 1", "08 - Cushion Descent Speed", -0.7f, "Final descent cap near ground for Wings 1."); Wings1CushionLerp = IBelieveICanFlyPlugin.context.config("02.03 - Wings 1", "09 - Cushion Lerp", 0.6f, "How quickly we clamp toward the cushion speed for Wings 1."); Wings1TiltMaxPitch = IBelieveICanFlyPlugin.context.config("02.04 - Wings 1", "01 - Max Pitch", 25f, "Maximum pitch angle (nose up/down) in degrees for Wings 1."); Wings1TiltMaxRoll = IBelieveICanFlyPlugin.context.config("02.04 - Wings 1", "02 - Max Roll", 35f, "Maximum roll angle (banking) in degrees for Wings 1."); Wings1TiltPitchSmoothTime = IBelieveICanFlyPlugin.context.config("02.04 - Wings 1", "03 - Pitch Smooth Time", 0.15f, "How quickly pitch changes (lower = faster response) for Wings 1."); Wings1TiltRollSmoothTime = IBelieveICanFlyPlugin.context.config("02.04 - Wings 1", "04 - Roll Smooth Time", 0.1f, "How quickly roll/banking changes (lower = faster response) for Wings 1."); Wings1UpDownOffset = IBelieveICanFlyPlugin.context.config("02.05 - Wings 1", "01 - Up/Down Offset", 0.3f, "Adjust Wings 1 vertical position on the player's back. Higher values move it up."); Wings1LeftRightOffset = IBelieveICanFlyPlugin.context.config("02.05 - Wings 1", "02 - Left/Right Offset", 0f, "Adjust Wings 1 horizontal position on the player's back. Positive values move it to the right."); Wings1ForwardBackOffset = IBelieveICanFlyPlugin.context.config("02.05 - Wings 1", "03 - Forward/Back Offset", 0.7f, "Adjust Wings 1 position front-to-back on the player. Negative values move it backward."); Wings1RotationX = IBelieveICanFlyPlugin.context.config("02.06 - Wings 1", "01 - X Rotation", 10f, "Adjust Wings 1 pitch rotation in degrees. Controls tilt forward/backward."); Wings1RotationY = IBelieveICanFlyPlugin.context.config("02.06 - Wings 1", "02 - Y Rotation", 160f, "Adjust Wings 1 yaw rotation in degrees. Controls left/right facing."); Wings1RotationZ = IBelieveICanFlyPlugin.context.config("02.06 - Wings 1", "03 - Z Rotation", 0f, "Adjust Wings 1 roll rotation in degrees. Controls tilt to sides."); Wings1Scale = IBelieveICanFlyPlugin.context.config("02.06 - Wings 1", "04 - Scale", 0.3f, "Adjust the overall size of Wings 1. 1.0 is normal size."); Wings1SFX = IBelieveICanFlyPlugin.context.config("02.07 - Wings 1", "01 - SFX", value: true, "Whether to enable or disable SFX when gliding with Wings 1."); Wings1AttachSFXToPlayer = IBelieveICanFlyPlugin.context.config("02.07 - Wings 1", "02 - Attach SFX To Player", value: false, "Whether to enable or disable SFX for Wings 1 will be attached to the player and follow their movement."); Wings1StartSFX = IBelieveICanFlyPlugin.context.config("02.07 - Wings 1", "03 - Start SFX", "sfx_flap_glider_Ygg", "Sound effect to play when starting to glide with Wings 1. Use vanilla sound effect names."); Wings1LoopSFX = IBelieveICanFlyPlugin.context.config("02.07 - Wings 1", "04 - Loop SFX", "", "Sound effect to play continuously while gliding with Wings 1. Use vanilla sound effect names."); Wings1StopSFX = IBelieveICanFlyPlugin.context.config("02.07 - Wings 1", "05 - Stop SFX", "sfx_flap_glider_Ygg", "Sound effect to play when stopping gliding with Wings 1. Use vanilla sound effect names."); Wings1VFX = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "01 - VFX", value: false, "Whether to enable or disable VFX when gliding with Wings 1."); Wings1AttachEffectsToPlayer = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "02 - Attach VFX To Player", value: false, "Whether to enable or disable VFX for Wings 1 will be attached to the player and follow their movement."); Wings1StartVFX = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "03 - Start VFX", "", "Visual effect to play when starting to glide with Wings 1. Use vanilla VFX names."); Wings1LoopVFX = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "04 - Loop VFX", "", "Visual effect to play continuously while gliding with Wings 1. Use vanilla VFX names."); Wings1StopVFX = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "05 - Stop VFX", "", "Visual effect to play when stopping gliding with Wings 1. Use vanilla VFX names."); Wings1VFXPosition = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "06 - VFX Position", "Root", "Position for VFX for Wings 1: 'Root' (at player's feet), 'Middle' (at player's center), or 'Custom' (use custom coordinates)."); Wings1VFXScale = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "07 - VFX Scale", 1f, "Scale factor for VFX for Wings 1. 1.0 is normal size."); Wings1VFXCustomX = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "08 - Custom X Offset", 0f, "X offset for custom VFX position for Wings 1 (only used when VFX Position is set to 'Custom')."); Wings1VFXCustomY = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "09 - Custom Y Offset", 1f, "Y offset for custom VFX position for Wings 1 (only used when VFX Position is set to 'Custom')."); Wings1VFXCustomZ = IBelieveICanFlyPlugin.context.config("02.08 - Wings 1", "10 - Custom Z Offset", 0f, "Z offset for custom VFX position for Wings 1 (only used when VFX Position is set to 'Custom')."); } private static void RegisterWings2() { Wings2Enabled = IBelieveICanFlyPlugin.context.config("03.01 - Wings 2", "01 - Enabled", value: true, "Whether to enable or disable Wings 2. When enabled, this wings configuration will be active."); Wings2ItemName = IBelieveICanFlyPlugin.context.config("03.01 - Wings 2", "02 - Item Name", "Glider_BackPack_DragonModer_Ygg", "Item prefab name that triggers Wings 2. Use vanilla item names like 'SwordBronze' or custom item names."); Wings2VisualPrefab = IBelieveICanFlyPlugin.context.config("03.01 - Wings 2", "03 - Visual Prefab Override", "DragonWings_Ygg1", "Optional: Override the visual prefab shown when gliding. If empty, uses the trigger item's model. Use this to show wings while having a ring/amulet as the trigger item."); Wings2CheckRightHand = IBelieveICanFlyPlugin.context.config("03.02 - Wings 2", "01 - Check Right Hand", value: false, "Whether to enable or disable checking the right hand slot for Wings 2 item."); Wings2CheckLeftHand = IBelieveICanFlyPlugin.context.config("03.02 - Wings 2", "02 - Check Left Hand", value: false, "Whether to enable or disable checking the left hand slot for Wings 2 item."); Wings2CheckUtility = IBelieveICanFlyPlugin.context.config("03.02 - Wings 2", "03 - Check Utility Slot", value: true, "Whether to enable or disable checking the utility/belt slot for Wings 2 item."); Wings2UseFallReset = IBelieveICanFlyPlugin.context.config("03.02 - Wings 2", "04 - Prevent Fall Damage", value: true, "Whether to enable or disable fall damage when landing after gliding with Wings 2."); Wings2Animation = IBelieveICanFlyPlugin.context.config("03.02 - Wings 2", "05 - Use Animation", value: true, "Whether to enable or disable using animation while gliding with Wings 2."); Wings2MinActivationFallSpeed = IBelieveICanFlyPlugin.context.config("03.03 - Wings 2", "01 - Min Activation Fall Speed", -0.5f, "Prevent glide trigger if you barely left ground for Wings 2."); Wings2ForwardSpeed = IBelieveICanFlyPlugin.context.config("03.03 - Wings 2", "02 - Max Forward Speed", 12f, "Maximum forward speed while gliding with Wings 2."); Wings2ForwardForce = IBelieveICanFlyPlugin.context.config("03.03 - Wings 2", "03 - Forward Force", 8f, "Forward acceleration while gliding with Wings 2."); Wings2DescentSpeed = IBelieveICanFlyPlugin.context.config("03.03 - Wings 2", "04 - Max Descent Speed", -3.5f, "How fast you can fall while gliding with Wings 2 (more negative = faster fall)."); Wings2AirTurnSpeed = IBelieveICanFlyPlugin.context.config("03.03 - Wings 2", "05 - Air Turn Speed", 100f, "Yaw control while gliding with Wings 2 (deg/sec)."); Wings2LateralDamp = IBelieveICanFlyPlugin.context.config("03.03 - Wings 2", "06 - Lateral Damping", 0.15f, "Slight damping to stabilize lateral drift for Wings 2."); Wings2GroundProbeDistance = IBelieveICanFlyPlugin.context.config("03.03 - Wings 2", "07 - Ground Probe Distance", 2.5f, "Start cushioning this far from ground for Wings 2."); Wings2CushionDescentSpeed = IBelieveICanFlyPlugin.context.config("03.03 - Wings 2", "08 - Cushion Descent Speed", -0.7f, "Final descent cap near ground for Wings 2."); Wings2CushionLerp = IBelieveICanFlyPlugin.context.config("03.03 - Wings 2", "09 - Cushion Lerp", 0.6f, "How quickly we clamp toward the cushion speed for Wings 2."); Wings2TiltMaxPitch = IBelieveICanFlyPlugin.context.config("03.04 - Wings 2", "01 - Max Pitch", 25f, "Maximum pitch angle (nose up/down) in degrees for Wings 2."); Wings2TiltMaxRoll = IBelieveICanFlyPlugin.context.config("03.04 - Wings 2", "02 - Max Roll", 35f, "Maximum roll angle (banking) in degrees for Wings 2."); Wings2TiltPitchSmoothTime = IBelieveICanFlyPlugin.context.config("03.04 - Wings 2", "03 - Pitch Smooth Time", 0.15f, "How quickly pitch changes (lower = faster response) for Wings 2."); Wings2TiltRollSmoothTime = IBelieveICanFlyPlugin.context.config("03.04 - Wings 2", "04 - Roll Smooth Time", 0.1f, "How quickly roll/banking changes (lower = faster response) for Wings 2."); Wings2UpDownOffset = IBelieveICanFlyPlugin.context.config("03.05 - Wings 2", "01 - Up/Down Offset", -0.18f, "Adjust Wings 2 vertical position on the player's back. Higher values move it up."); Wings2LeftRightOffset = IBelieveICanFlyPlugin.context.config("03.05 - Wings 2", "02 - Left/Right Offset", 0f, "Adjust Wings 2 horizontal position on the player's back. Positive values move it to the right."); Wings2ForwardBackOffset = IBelieveICanFlyPlugin.context.config("03.05 - Wings 2", "03 - Forward/Back Offset", -0.15f, "Adjust Wings 2 position front-to-back on the player. Negative values move it backward."); Wings2RotationX = IBelieveICanFlyPlugin.context.config("03.06 - Wings 2", "01 - X Rotation", 0f, "Adjust Wings 2 pitch rotation in degrees. Controls tilt forward/backward."); Wings2RotationY = IBelieveICanFlyPlugin.context.config("03.06 - Wings 2", "02 - Y Rotation", 0f, "Adjust Wings 2 yaw rotation in degrees. Controls left/right facing."); Wings2RotationZ = IBelieveICanFlyPlugin.context.config("03.06 - Wings 2", "03 - Z Rotation", 0f, "Adjust Wings 2 roll rotation in degrees. Controls tilt to sides."); Wings2Scale = IBelieveICanFlyPlugin.context.config("03.06 - Wings 2", "04 - Scale", 0.3f, "Adjust the overall size of Wings 2. 1.0 is normal size."); Wings2SFX = IBelieveICanFlyPlugin.context.config("03.07 - Wings 2", "01 - SFX", value: true, "Whether to enable or disable SFX when gliding with Wings 2."); Wings2AttachSFXToPlayer = IBelieveICanFlyPlugin.context.config("03.07 - Wings 2", "02 - Attach SFX To Player", value: false, "Whether to enable or disable SFX for Wings 2 will be attached to the player and follow their movement."); Wings2StartSFX = IBelieveICanFlyPlugin.context.config("03.07 - Wings 2", "03 - Start SFX", "sfx_flap_glider_Ygg", "Sound effect to play when starting to glide with Wings 2. Use vanilla sound effect names."); Wings2LoopSFX = IBelieveICanFlyPlugin.context.config("03.07 - Wings 2", "04 - Loop SFX", "", "Sound effect to play continuously while gliding with Wings 2. Use vanilla sound effect names."); Wings2StopSFX = IBelieveICanFlyPlugin.context.config("03.07 - Wings 2", "05 - Stop SFX", "sfx_flap_glider_Ygg", "Sound effect to play when stopping gliding with Wings 2. Use vanilla sound effect names."); Wings2VFX = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "01 - VFX", value: false, "Whether to enable or disable VFX when gliding with Wings 2."); Wings2AttachEffectsToPlayer = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "02 - Attach VFX To Player", value: false, "Whether to enable or disable VFX for Wings 2 will be attached to the player and follow their movement."); Wings2StartVFX = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "03 - Start VFX", "", "Visual effect to play when starting to glide with Wings 2. Use vanilla VFX names."); Wings2LoopVFX = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "04 - Loop VFX", "", "Visual effect to play continuously while gliding with Wings 2. Use vanilla VFX names."); Wings2StopVFX = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "05 - Stop VFX", "", "Visual effect to play when stopping gliding with Wings 2. Use vanilla VFX names."); Wings2VFXPosition = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "06 - VFX Position", "Root", "Position for VFX for Wings 2: 'Root' (at player's feet), 'Middle' (at player's center), or 'Custom' (use custom coordinates)."); Wings2VFXScale = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "07 - VFX Scale", 1f, "Scale factor for VFX for Wings 2. 1.0 is normal size."); Wings2VFXCustomX = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "08 - Custom X Offset", 0f, "X offset for custom VFX position for Wings 2 (only used when VFX Position is set to 'Custom')."); Wings2VFXCustomY = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "09 - Custom Y Offset", 1f, "Y offset for custom VFX position for Wings 2 (only used when VFX Position is set to 'Custom')."); Wings2VFXCustomZ = IBelieveICanFlyPlugin.context.config("03.08 - Wings 2", "10 - Custom Z Offset", 0f, "Z offset for custom VFX position for Wings 2 (only used when VFX Position is set to 'Custom')."); } private static void RegisterWings3() { Wings3Enabled = IBelieveICanFlyPlugin.context.config("04.01 - Wings 3", "01 - Enabled", value: true, "Whether to enable or disable Wings 3. When enabled, this wings configuration will be active."); Wings3ItemName = IBelieveICanFlyPlugin.context.config("04.01 - Wings 3", "02 - Item Name", "Glider_BackPack_BlackDragon_Ygg", "Item prefab name that triggers Wings 3. Use vanilla item names like 'SwordBlackmetal' or custom item names."); Wings3VisualPrefab = IBelieveICanFlyPlugin.context.config("04.01 - Wings 3", "03 - Visual Prefab Override", "DragonWings_Ygg2", "Optional: Override the visual prefab shown when gliding. If empty, uses the trigger item's model. Use this to show wings while having a ring/amulet as the trigger item."); Wings3CheckRightHand = IBelieveICanFlyPlugin.context.config("04.02 - Wings 3", "01 - Check Right Hand", value: false, "Whether to enable or disable checking the right hand slot for Wings 3 item."); Wings3CheckLeftHand = IBelieveICanFlyPlugin.context.config("04.02 - Wings 3", "02 - Check Left Hand", value: false, "Whether to enable or disable checking the left hand slot for Wings 3 item."); Wings3CheckUtility = IBelieveICanFlyPlugin.context.config("04.02 - Wings 3", "03 - Check Utility Slot", value: true, "Whether to enable or disable checking the utility/belt slot for Wings 3 item."); Wings3UseFallReset = IBelieveICanFlyPlugin.context.config("04.02 - Wings 3", "04 - Prevent Fall Damage", value: true, "Whether to enable or disable fall damage when landing after gliding with Wings 3."); Wings3Animation = IBelieveICanFlyPlugin.context.config("04.02 - Wings 3", "05 - Use Animation", value: true, "Whether to enable or disable using animation while gliding with Wings 3."); Wings3MinActivationFallSpeed = IBelieveICanFlyPlugin.context.config("04.03 - Wings 3", "01 - Min Activation Fall Speed", -0.5f, "Prevent glide trigger if you barely left ground for Wings 3."); Wings3ForwardSpeed = IBelieveICanFlyPlugin.context.config("04.03 - Wings 3", "02 - Max Forward Speed", 20f, "Maximum forward speed while gliding with Wings 3."); Wings3ForwardForce = IBelieveICanFlyPlugin.context.config("04.03 - Wings 3", "03 - Forward Force", 12f, "Forward acceleration while gliding with Wings 3."); Wings3DescentSpeed = IBelieveICanFlyPlugin.context.config("04.03 - Wings 3", "04 - Max Descent Speed", -2.5f, "How fast you can fall while gliding with Wings 3 (more negative = faster fall)."); Wings3AirTurnSpeed = IBelieveICanFlyPlugin.context.config("04.03 - Wings 3", "05 - Air Turn Speed", 100f, "Yaw control while gliding with Wings 3 (deg/sec)."); Wings3LateralDamp = IBelieveICanFlyPlugin.context.config("04.03 - Wings 3", "06 - Lateral Damping", 0.15f, "Slight damping to stabilize lateral drift for Wings 3."); Wings3GroundProbeDistance = IBelieveICanFlyPlugin.context.config("04.03 - Wings 3", "07 - Ground Probe Distance", 2.5f, "Start cushioning this far from ground for Wings 3."); Wings3CushionDescentSpeed = IBelieveICanFlyPlugin.context.config("04.03 - Wings 3", "08 - Cushion Descent Speed", -0.7f, "Final descent cap near ground for Wings 3."); Wings3CushionLerp = IBelieveICanFlyPlugin.context.config("04.03 - Wings 3", "09 - Cushion Lerp", 0.6f, "How quickly we clamp toward the cushion speed for Wings 3."); Wings3TiltMaxPitch = IBelieveICanFlyPlugin.context.config("04.04 - Wings 3", "01 - Max Pitch", 25f, "Maximum pitch angle (nose up/down) in degrees for Wings 3."); Wings3TiltMaxRoll = IBelieveICanFlyPlugin.context.config("04.04 - Wings 3", "02 - Max Roll", 35f, "Maximum roll angle (banking) in degrees for Wings 3."); Wings3TiltPitchSmoothTime = IBelieveICanFlyPlugin.context.config("04.04 - Wings 3", "03 - Pitch Smooth Time", 0.15f, "How quickly pitch changes (lower = faster response) for Wings 3."); Wings3TiltRollSmoothTime = IBelieveICanFlyPlugin.context.config("04.04 - Wings 3", "04 - Roll Smooth Time", 0.1f, "How quickly roll/banking changes (lower = faster response) for Wings 3."); Wings3UpDownOffset = IBelieveICanFlyPlugin.context.config("04.05 - Wings 3", "01 - Up/Down Offset", -0.1f, "Adjust Wings 3 vertical position on the player's back. Higher values move it up."); Wings3LeftRightOffset = IBelieveICanFlyPlugin.context.config("04.05 - Wings 3", "02 - Left/Right Offset", 0f, "Adjust Wings 3 horizontal position on the player's back. Positive values move it to the right."); Wings3ForwardBackOffset = IBelieveICanFlyPlugin.context.config("04.05 - Wings 3", "03 - Forward/Back Offset", -0.2f, "Adjust Wings 3 position front-to-back on the player. Negative values move it backward."); Wings3RotationX = IBelieveICanFlyPlugin.context.config("04.06 - Wings 3", "01 - X Rotation", 0f, "Adjust Wings 3 pitch rotation in degrees. Controls tilt forward/backward."); Wings3RotationY = IBelieveICanFlyPlugin.context.config("04.06 - Wings 3", "02 - Y Rotation", 0f, "Adjust Wings 3 yaw rotation in degrees. Controls left/right facing."); Wings3RotationZ = IBelieveICanFlyPlugin.context.config("04.06 - Wings 3", "03 - Z Rotation", 0f, "Adjust Wings 3 roll rotation in degrees. Controls tilt to sides."); Wings3Scale = IBelieveICanFlyPlugin.context.config("04.06 - Wings 3", "04 - Scale", 0.3f, "Adjust the overall size of Wings 3. 1.0 is normal size."); Wings3SFX = IBelieveICanFlyPlugin.context.config("04.07 - Wings 3", "01 - SFX", value: true, "Whether to enable or disable SFX when gliding with Wings 3."); Wings3AttachSFXToPlayer = IBelieveICanFlyPlugin.context.config("04.07 - Wings 3", "02 - Attach SFX To Player", value: false, "Whether to enable or disable SFX for Wings 3 will be attached to the player and follow their movement."); Wings3StartSFX = IBelieveICanFlyPlugin.context.config("04.07 - Wings 3", "03 - Start SFX", "sfx_flap_glider_Ygg", "Sound effect to play when starting to glide with Wings 3. Use vanilla sound effect names."); Wings3LoopSFX = IBelieveICanFlyPlugin.context.config("04.07 - Wings 3", "04 - Loop SFX", "sfx_flap_glider_Ygg", "Sound effect to play continuously while gliding with Wings 3. Use vanilla sound effect names."); Wings3StopSFX = IBelieveICanFlyPlugin.context.config("04.07 - Wings 3", "05 - Stop SFX", "sfx_flap_glider_Ygg", "Sound effect to play when stopping gliding with Wings 3. Use vanilla sound effect names."); Wings3VFX = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "01 - VFX", value: false, "Whether to enable or disable VFX when gliding with Wings 3."); Wings3AttachEffectsToPlayer = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "02 - Attach VFX To Player", value: false, "Whether to enable or disable VFX for Wings 3 will be attached to the player and follow their movement."); Wings3StartVFX = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "03 - Start VFX", "", "Visual effect to play when starting to glide with Wings 3. Use vanilla VFX names."); Wings3LoopVFX = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "04 - Loop VFX", "", "Visual effect to play continuously while gliding with Wings 3. Use vanilla VFX names."); Wings3StopVFX = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "05 - Stop VFX", "", "Visual effect to play when stopping gliding with Wings 3. Use vanilla VFX names."); Wings3VFXPosition = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "06 - VFX Position", "Root", "Position for VFX for Wings 3: 'Root' (at player's feet), 'Middle' (at player's center), or 'Custom' (use custom coordinates)."); Wings3VFXScale = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "07 - VFX Scale", 1f, "Scale factor for VFX for Wings 3. 1.0 is normal size."); Wings3VFXCustomX = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "08 - Custom X Offset", 0f, "X offset for custom VFX position for Wings 3 (only used when VFX Position is set to 'Custom')."); Wings3VFXCustomY = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "09 - Custom Y Offset", 1f, "Y offset for custom VFX position for Wings 3 (only used when VFX Position is set to 'Custom')."); Wings3VFXCustomZ = IBelieveICanFlyPlugin.context.config("04.08 - Wings 3", "10 - Custom Z Offset", 0f, "Z offset for custom VFX position for Wings 3 (only used when VFX Position is set to 'Custom')."); } private static void RegisterWings4() { Wings4Enabled = IBelieveICanFlyPlugin.context.config("05.01 - Wings 4", "01 - Enabled", value: true, "Whether to enable or disable Wings 4. When enabled, this wings configuration will be active."); Wings4ItemName = IBelieveICanFlyPlugin.context.config("05.01 - Wings 4", "02 - Item Name", "Glider_Gjall_BackPack_Ygg", "Item prefab name that triggers Wings 4. Use vanilla item names like 'SwordSilver' or custom item names."); Wings4VisualPrefab = IBelieveICanFlyPlugin.context.config("05.01 - Wings 4", "03 - Visual Prefab Override", "DragonWings_Ygg3", "Optional: Override the visual prefab shown when gliding. If empty, uses the trigger item's model. Use this to show wings while having a ring/amulet as the trigger item."); Wings4CheckRightHand = IBelieveICanFlyPlugin.context.config("05.02 - Wings 4", "01 - Check Right Hand", value: false, "Whether to enable or disable checking the right hand slot for Wings 4 item."); Wings4CheckLeftHand = IBelieveICanFlyPlugin.context.config("05.02 - Wings 4", "02 - Check Left Hand", value: false, "Whether to enable or disable checking the left hand slot for Wings 4 item."); Wings4CheckUtility = IBelieveICanFlyPlugin.context.config("05.02 - Wings 4", "03 - Check Utility Slot", value: true, "Whether to enable or disable checking the utility/belt slot for Wings 4 item."); Wings4UseFallReset = IBelieveICanFlyPlugin.context.config("05.02 - Wings 4", "04 - Prevent Fall Damage", value: true, "Whether to enable or disable fall damage when landing after gliding with Wings 4."); Wings4Animation = IBelieveICanFlyPlugin.context.config("05.02 - Wings 4", "05 - Use Animation", value: true, "Whether to enable or disable using animation while gliding with Wings 4."); Wings4MinActivationFallSpeed = IBelieveICanFlyPlugin.context.config("05.03 - Wings 4", "01 - Min Activation Fall Speed", -0.5f, "Prevent glide trigger if you barely left ground for Wings 4."); Wings4ForwardSpeed = IBelieveICanFlyPlugin.context.config("05.03 - Wings 4", "02 - Max Forward Speed", 6f, "Maximum forward speed while gliding with Wings 4."); Wings4ForwardForce = IBelieveICanFlyPlugin.context.config("05.03 - Wings 4", "03 - Forward Force", 11f, "Forward acceleration while gliding with Wings 4."); Wings4DescentSpeed = IBelieveICanFlyPlugin.context.config("05.03 - Wings 4", "04 - Max Descent Speed", -1f, "How fast you can fall while gliding with Wings 4 (more negative = faster fall)."); Wings4AirTurnSpeed = IBelieveICanFlyPlugin.context.config("05.03 - Wings 4", "05 - Air Turn Speed", 130f, "Yaw control while gliding with Wings 4 (deg/sec)."); Wings4LateralDamp = IBelieveICanFlyPlugin.context.config("05.03 - Wings 4", "06 - Lateral Damping", 0.15f, "Slight damping to stabilize lateral drift for Wings 4."); Wings4GroundProbeDistance = IBelieveICanFlyPlugin.context.config("05.03 - Wings 4", "07 - Ground Probe Distance", 2.5f, "Start cushioning this far from ground for Wings 4."); Wings4CushionDescentSpeed = IBelieveICanFlyPlugin.context.config("05.03 - Wings 4", "08 - Cushion Descent Speed", -0.7f, "Final descent cap near ground for Wings 4."); Wings4CushionLerp = IBelieveICanFlyPlugin.context.config("05.03 - Wings 4", "09 - Cushion Lerp", 0.6f, "How quickly we clamp toward the cushion speed for Wings 4."); Wings4TiltMaxPitch = IBelieveICanFlyPlugin.context.config("05.04 - Wings 4", "01 - Max Pitch", 25f, "Maximum pitch angle (nose up/down) in degrees for Wings 4."); Wings4TiltMaxRoll = IBelieveICanFlyPlugin.context.config("05.04 - Wings 4", "02 - Max Roll", 35f, "Maximum roll angle (banking) in degrees for Wings 4."); Wings4TiltPitchSmoothTime = IBelieveICanFlyPlugin.context.config("05.04 - Wings 4", "03 - Pitch Smooth Time", 0.15f, "How quickly pitch changes (lower = faster response) for Wings 4."); Wings4TiltRollSmoothTime = IBelieveICanFlyPlugin.context.config("05.04 - Wings 4", "04 - Roll Smooth Time", 0.1f, "How quickly roll/banking changes (lower = faster response) for Wings 4."); Wings4UpDownOffset = IBelieveICanFlyPlugin.context.config("05.05 - Wings 4", "01 - Up/Down Offset", -2f, "Adjust Wings 4 vertical position on the player's back. Higher values move it up."); Wings4LeftRightOffset = IBelieveICanFlyPlugin.context.config("05.05 - Wings 4", "02 - Left/Right Offset", 0f, "Adjust Wings 4 horizontal position on the player's back. Positive values move it to the right."); Wings4ForwardBackOffset = IBelieveICanFlyPlugin.context.config("05.05 - Wings 4", "03 - Forward/Back Offset", -5f, "Adjust Wings 4 position front-to-back on the player. Negative values move it backward."); Wings4RotationX = IBelieveICanFlyPlugin.context.config("05.06 - Wings 4", "01 - X Rotation", 70f, "Adjust Wings 4 pitch rotation in degrees. Controls tilt forward/backward."); Wings4RotationY = IBelieveICanFlyPlugin.context.config("05.06 - Wings 4", "02 - Y Rotation", 0f, "Adjust Wings 4 yaw rotation in degrees. Controls left/right facing."); Wings4RotationZ = IBelieveICanFlyPlugin.context.config("05.06 - Wings 4", "03 - Z Rotation", 0f, "Adjust Wings 4 roll rotation in degrees. Controls tilt to sides."); Wings4Scale = IBelieveICanFlyPlugin.context.config("05.06 - Wings 4", "04 - Scale", 0.4f, "Adjust the overall size of Wings 4. 1.0 is normal size."); Wings4SFX = IBelieveICanFlyPlugin.context.config("05.07 - Wings 4", "01 - SFX", value: true, "Whether to enable or disable SFX when gliding with Wings 4."); Wings4AttachSFXToPlayer = IBelieveICanFlyPlugin.context.config("05.07 - Wings 4", "02 - Attach SFX To Player", value: false, "Whether to enable or disable SFX for Wings 4 will be attached to the player and follow their movement."); Wings4StartSFX = IBelieveICanFlyPlugin.context.config("05.07 - Wings 4", "03 - Start SFX", "sfx_flap_glider_Ygg", "Sound effect to play when starting to glide with Wings 4. Use vanilla sound effect names."); Wings4LoopSFX = IBelieveICanFlyPlugin.context.config("05.07 - Wings 4", "04 - Loop SFX", "", "Sound effect to play continuously while gliding with Wings 4. Use vanilla sound effect names."); Wings4StopSFX = IBelieveICanFlyPlugin.context.config("05.07 - Wings 4", "05 - Stop SFX", "sfx_flap_glider_Ygg", "Sound effect to play when stopping gliding with Wings 4. Use vanilla sound effect names."); Wings4VFX = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "01 - VFX", value: false, "Whether to enable or disable VFX when gliding with Wings 4."); Wings4AttachEffectsToPlayer = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "02 - Attach VFX To Player", value: false, "Whether to enable or disable VFX for Wings 4 will be attached to the player and follow their movement."); Wings4StartVFX = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "03 - Start VFX", "", "Visual effect to play when starting to glide with Wings 4. Use vanilla VFX names."); Wings4LoopVFX = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "04 - Loop VFX", "", "Visual effect to play continuously while gliding with Wings 4. Use vanilla VFX names."); Wings4StopVFX = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "05 - Stop VFX", "", "Visual effect to play when stopping gliding with Wings 4. Use vanilla VFX names."); Wings4VFXPosition = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "06 - VFX Position", "Root", "Position for VFX for Wings 4: 'Root' (at player's feet), 'Middle' (at player's center), or 'Custom' (use custom coordinates)."); Wings4VFXScale = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "07 - VFX Scale", 1f, "Scale factor for VFX for Wings 4. 1.0 is normal size."); Wings4VFXCustomX = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "08 - Custom X Offset", 0f, "X offset for custom VFX position for Wings 4 (only used when VFX Position is set to 'Custom')."); Wings4VFXCustomY = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "09 - Custom Y Offset", 1f, "Y offset for custom VFX position for Wings 4 (only used when VFX Position is set to 'Custom')."); Wings4VFXCustomZ = IBelieveICanFlyPlugin.context.config("05.08 - Wings 4", "10 - Custom Z Offset", 0f, "Z offset for custom VFX position for Wings 4 (only used when VFX Position is set to 'Custom')."); } private static void RegisterWings5() { Wings5Enabled = IBelieveICanFlyPlugin.context.config("06.01 - Wings 5", "01 - Enabled", value: true, "Whether to enable or disable Wings 5. When enabled, this wings configuration will be active."); Wings5ItemName = IBelieveICanFlyPlugin.context.config("06.01 - Wings 5", "02 - Item Name", "Glider_Gjall_Fader_BackPack_Ygg", "Item prefab name that triggers Wings 5. Use vanilla item names like 'SwordFlametal' or custom item names."); Wings5VisualPrefab = IBelieveICanFlyPlugin.context.config("06.01 - Wings 5", "03 - Visual Prefab Override", "DragonWings_Ygg4", "Optional: Override the visual prefab shown when gliding. If empty, uses the trigger item's model. Use this to show wings while having a ring/amulet as the trigger item."); Wings5CheckRightHand = IBelieveICanFlyPlugin.context.config("06.02 - Wings 5", "01 - Check Right Hand", value: false, "Whether to enable or disable checking the right hand slot for Wings 5 item."); Wings5CheckLeftHand = IBelieveICanFlyPlugin.context.config("06.02 - Wings 5", "02 - Check Left Hand", value: false, "Whether to enable or disable checking the left hand slot for Wings 5 item."); Wings5CheckUtility = IBelieveICanFlyPlugin.context.config("06.02 - Wings 5", "03 - Check Utility Slot", value: true, "Whether to enable or disable checking the utility/belt slot for Wings 5 item."); Wings5UseFallReset = IBelieveICanFlyPlugin.context.config("06.02 - Wings 5", "04 - Prevent Fall Damage", value: true, "Whether to enable or disable fall damage when landing after gliding with Wings 5."); Wings5Animation = IBelieveICanFlyPlugin.context.config("06.02 - Wings 5", "05 - Use Animation", value: true, "Whether to enable or disable using animation while gliding with Wings 5."); Wings5MinActivationFallSpeed = IBelieveICanFlyPlugin.context.config("06.03 - Wings 5", "01 - Min Activation Fall Speed", -0.5f, "Prevent glide trigger if you barely left ground for Wings 5."); Wings5ForwardSpeed = IBelieveICanFlyPlugin.context.config("06.03 - Wings 5", "02 - Max Forward Speed", 20f, "Maximum forward speed while gliding with Wings 5."); Wings5ForwardForce = IBelieveICanFlyPlugin.context.config("06.03 - Wings 5", "03 - Forward Force", 14f, "Forward acceleration while gliding with Wings 5."); Wings5DescentSpeed = IBelieveICanFlyPlugin.context.config("06.03 - Wings 5", "04 - Max Descent Speed", -1f, "How fast you can fall while gliding with Wings 5 (more negative = faster fall)."); Wings5AirTurnSpeed = IBelieveICanFlyPlugin.context.config("06.03 - Wings 5", "05 - Air Turn Speed", 150f, "Yaw control while gliding with Wings 5 (deg/sec)."); Wings5LateralDamp = IBelieveICanFlyPlugin.context.config("06.03 - Wings 5", "06 - Lateral Damping", 0.15f, "Slight damping to stabilize lateral drift for Wings 5."); Wings5GroundProbeDistance = IBelieveICanFlyPlugin.context.config("06.03 - Wings 5", "07 - Ground Probe Distance", 2.5f, "Start cushioning this far from ground for Wings 5."); Wings5CushionDescentSpeed = IBelieveICanFlyPlugin.context.config("06.03 - Wings 5", "08 - Cushion Descent Speed", -0.7f, "Final descent cap near ground for Wings 5."); Wings5CushionLerp = IBelieveICanFlyPlugin.context.config("06.03 - Wings 5", "09 - Cushion Lerp", 0.6f, "How quickly we clamp toward the cushion speed for Wings 5."); Wings5TiltMaxPitch = IBelieveICanFlyPlugin.context.config("06.04 - Wings 5", "01 - Max Pitch", 25f, "Maximum pitch angle (nose up/down) in degrees for Wings 5."); Wings5TiltMaxRoll = IBelieveICanFlyPlugin.context.config("06.04 - Wings 5", "02 - Max Roll", 35f, "Maximum roll angle (banking) in degrees for Wings 5."); Wings5TiltPitchSmoothTime = IBelieveICanFlyPlugin.context.config("06.04 - Wings 5", "03 - Pitch Smooth Time", 0.15f, "How quickly pitch changes (lower = faster response) for Wings 5."); Wings5TiltRollSmoothTime = IBelieveICanFlyPlugin.context.config("06.04 - Wings 5", "04 - Roll Smooth Time", 0.1f, "How quickly roll/banking changes (lower = faster response) for Wings 5."); Wings5UpDownOffset = IBelieveICanFlyPlugin.context.config("06.05 - Wings 5", "01 - Up/Down Offset", -1f, "Adjust Wings 5 vertical position on the player's back. Higher values move it up."); Wings5LeftRightOffset = IBelieveICanFlyPlugin.context.config("06.05 - Wings 5", "02 - Left/Right Offset", 0f, "Adjust Wings 5 horizontal position on the player's back. Positive values move it to the right."); Wings5ForwardBackOffset = IBelieveICanFlyPlugin.context.config("06.05 - Wings 5", "03 - Forward/Back Offset", -2.5f, "Adjust Wings 5 position front-to-back on the player. Negative values move it backward."); Wings5RotationX = IBelieveICanFlyPlugin.context.config("06.06 - Wings 5", "01 - X Rotation", 70f, "Adjust Wings 5 pitch rotation in degrees. Controls tilt forward/backward."); Wings5RotationY = IBelieveICanFlyPlugin.context.config("06.06 - Wings 5", "02 - Y Rotation", 0f, "Adjust Wings 5 yaw rotation in degrees. Controls left/right facing."); Wings5RotationZ = IBelieveICanFlyPlugin.context.config("06.06 - Wings 5", "03 - Z Rotation", 0f, "Adjust Wings 5 roll rotation in degrees. Controls tilt to sides."); Wings5Scale = IBelieveICanFlyPlugin.context.config("06.06 - Wings 5", "04 - Scale", 0.2f, "Adjust the overall size of Wings 5. 1.0 is normal size."); Wings5SFX = IBelieveICanFlyPlugin.context.config("06.07 - Wings 5", "01 - SFX", value: true, "Whether to enable or disable SFX when gliding with Wings 5."); Wings5AttachSFXToPlayer = IBelieveICanFlyPlugin.context.config("06.07 - Wings 5", "02 - Attach SFX To Player", value: false, "Whether to enable or disable SFX for Wings 5 will be attached to the player and follow their movement."); Wings5StartSFX = IBelieveICanFlyPlugin.context.config("06.07 - Wings 5", "03 - Start SFX", "sfx_FireAddFuel", "Sound effect to play when starting to glide with Wings 5. Use vanilla sound effect names."); Wings5LoopSFX = IBelieveICanFlyPlugin.context.config("06.07 - Wings 5", "04 - Loop SFX", "", "Sound effect to play continuously while gliding with Wings 5. Use vanilla sound effect names."); Wings5StopSFX = IBelieveICanFlyPlugin.context.config("06.07 - Wings 5", "05 - Stop SFX", "sfx_flap_glider_Ygg", "Sound effect to play when stopping gliding with Wings 5. Use vanilla sound effect names."); Wings5VFX = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "01 - VFX", value: false, "Whether to enable or disable VFX when gliding with Wings 5."); Wings5AttachEffectsToPlayer = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "02 - Attach VFX To Player", value: false, "Whether to enable or disable VFX for Wings 5 will be attached to the player and follow their movement."); Wings5StartVFX = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "03 - Start VFX", "vfx_GjallFuelBurst_Ygg", "Visual effect to play when starting to glide with Wings 5. Use vanilla VFX names."); Wings5LoopVFX = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "04 - Loop VFX", "vfx_GjallFuelBurst_Ygg2", "Visual effect to play continuously while gliding with Wings 5. Use vanilla VFX names."); Wings5StopVFX = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "05 - Stop VFX", "vfx_odin_despawn", "Visual effect to play when stopping gliding with Wings 5. Use vanilla VFX names."); Wings5VFXPosition = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "06 - VFX Position", "Root", "Position for VFX for Wings 5: 'Root' (at player's feet), 'Middle' (at player's center), or 'Custom' (use custom coordinates)."); Wings5VFXScale = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "07 - VFX Scale", 1f, "Scale factor for VFX for Wings 5. 1.0 is normal size."); Wings5VFXCustomX = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "08 - Custom X Offset", 0f, "X offset for custom VFX position for Wings 5 (only used when VFX Position is set to 'Custom')."); Wings5VFXCustomY = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "09 - Custom Y Offset", 1f, "Y offset for custom VFX position for Wings 5 (only used when VFX Position is set to 'Custom')."); Wings5VFXCustomZ = IBelieveICanFlyPlugin.context.config("06.08 - Wings 5", "10 - Custom Z Offset", 0f, "Z offset for custom VFX position for Wings 5 (only used when VFX Position is set to 'Custom')."); } private static void RegisterWings6() { Wings6Enabled = IBelieveICanFlyPlugin.context.config("07.01 - Wings 6", "01 - Enabled", value: true, "Whether to enable or disable Wings 6. When enabled, this wings configuration will be active."); Wings6ItemName = IBelieveICanFlyPlugin.context.config("07.01 - Wings 6", "02 - Item Name", "Glider_Pelt_Ygg", "Item prefab name that triggers Wings 6. Use vanilla item names or custom item names."); Wings6VisualPrefab = IBelieveICanFlyPlugin.context.config("07.01 - Wings 6", "03 - Visual Prefab Override", "DragonWings_Ygg5", "Optional: Override the visual prefab shown when gliding. If empty, uses the trigger item's model. Use this to show wings while having a ring/amulet as the trigger item."); Wings6CheckRightHand = IBelieveICanFlyPlugin.context.config("07.02 - Wings 6", "01 - Check Right Hand", value: false, "Whether to enable or disable checking the right hand slot for Wings 6 item."); Wings6CheckLeftHand = IBelieveICanFlyPlugin.context.config("07.02 - Wings 6", "02 - Check Left Hand", value: false, "Whether to enable or disable checking the left hand slot for Wings 6 item."); Wings6CheckUtility = IBelieveICanFlyPlugin.context.config("07.02 - Wings 6", "03 - Check Utility Slot", value: true, "Whether to enable or disable checking the utility/belt slot for Wings 6 item."); Wings6UseFallReset = IBelieveICanFlyPlugin.context.config("07.02 - Wings 6", "04 - Prevent Fall Damage", value: true, "Whether to enable or disable fall damage when landing after gliding with Wings 6."); Wings6Animation = IBelieveICanFlyPlugin.context.config("07.02 - Wings 6", "05 - Use Animation", value: true, "Whether to enable or disable using animation while gliding with Wings 6."); Wings6MinActivationFallSpeed = IBelieveICanFlyPlugin.context.config("07.03 - Wings 6", "01 - Min Activation Fall Speed", -0.5f, "Prevent glide trigger if you barely left ground for Wings 6."); Wings6ForwardSpeed = IBelieveICanFlyPlugin.context.config("07.03 - Wings 6", "02 - Max Forward Speed", 10f, "Maximum forward speed while gliding with Wings 6."); Wings6ForwardForce = IBelieveICanFlyPlugin.context.config("07.03 - Wings 6", "03 - Forward Force", 5f, "Forward acceleration while gliding with Wings 6."); Wings6DescentSpeed = IBelieveICanFlyPlugin.context.config("07.03 - Wings 6", "04 - Max Descent Speed", -4f, "How fast you can fall while gliding with Wings 6 (more negative = faster fall)."); Wings6AirTurnSpeed = IBelieveICanFlyPlugin.context.config("07.03 - Wings 6", "05 - Air Turn Speed", 120f, "Yaw control while gliding with Wings 6 (deg/sec)."); Wings6LateralDamp = IBelieveICanFlyPlugin.context.config("07.03 - Wings 6", "06 - Lateral Damping", 0.15f, "Slight damping to stabilize lateral drift for Wings 6."); Wings6GroundProbeDistance = IBelieveICanFlyPlugin.context.config("07.03 - Wings 6", "07 - Ground Probe Distance", 2.5f, "Start cushioning this far from ground for Wings 6."); Wings6CushionDescentSpeed = IBelieveICanFlyPlugin.context.config("07.03 - Wings 6", "08 - Cushion Descent Speed", -0.7f, "Final descent cap near ground for Wings 6."); Wings6CushionLerp = IBelieveICanFlyPlugin.context.config("07.03 - Wings 6", "09 - Cushion Lerp", 0.6f, "How quickly we clamp toward the cushion speed for Wings 6."); Wings6TiltMaxPitch = IBelieveICanFlyPlugin.context.config("07.04 - Wings 6", "01 - Max Pitch", 25f, "Maximum pitch angle (nose up/down) in degrees for Wings 6."); Wings6TiltMaxRoll = IBelieveICanFlyPlugin.context.config("07.04 - Wings 6", "02 - Max Roll", 35f, "Maximum roll angle (banking) in degrees for Wings 6."); Wings6TiltPitchSmoothTime = IBelieveICanFlyPlugin.context.config("07.04 - Wings 6", "03 - Pitch Smooth Time", 0.15f, "How quickly pitch changes (lower = faster response) for Wings 6."); Wings6TiltRollSmoothTime = IBelieveICanFlyPlugin.context.config("07.04 - Wings 6", "04 - Roll Smooth Time", 0.1f, "How quickly roll/banking changes (lower = faster response) for Wings 6."); Wings6UpDownOffset = IBelieveICanFlyPlugin.context.config("07.05 - Wings 6", "01 - Up/Down Offset", 0.3f, "Adjust Wings 6 vertical position on the player's back. Higher values move it up."); Wings6LeftRightOffset = IBelieveICanFlyPlugin.context.config("07.05 - Wings 6", "02 - Left/Right Offset", 0f, "Adjust Wings 6 horizontal position on the player's back. Positive values move it to the right."); Wings6ForwardBackOffset = IBelieveICanFlyPlugin.context.config("07.05 - Wings 6", "03 - Forward/Back Offset", 0.7f, "Adjust Wings 6 position front-to-back on the player. Negative values move it backward."); Wings6RotationX = IBelieveICanFlyPlugin.context.config("07.06 - Wings 6", "01 - X Rotation", 10f, "Adjust Wings 6 pitch rotation in degrees. Controls tilt forward/backward."); Wings6RotationY = IBelieveICanFlyPlugin.context.config("07.06 - Wings 6", "02 - Y Rotation", 160f, "Adjust Wings 6 yaw rotation in degrees. Controls left/right facing."); Wings6RotationZ = IBelieveICanFlyPlugin.context.config("07.06 - Wings 6", "03 - Z Rotation", 0f, "Adjust Wings 6 roll rotation in degrees. Controls tilt to sides."); Wings6Scale = IBelieveICanFlyPlugin.context.config("07.06 - Wings 6", "04 - Scale", 0.3f, "Adjust the overall size of Wings 6. 1.0 is normal size."); Wings6SFX = IBelieveICanFlyPlugin.context.config("07.07 - Wings 6", "01 - SFX", value: true, "Whether to enable or disable SFX when gliding with Wings 6."); Wings6AttachSFXToPlayer = IBelieveICanFlyPlugin.context.config("07.07 - Wings 6", "02 - Attach SFX To Player", value: false, "Whether to enable or disable SFX for Wings 6 will be attached to the player and follow their movement."); Wings6StartSFX = IBelieveICanFlyPlugin.context.config("07.07 - Wings 6", "03 - Start SFX", "sfx_flap_glider_Ygg", "Sound effect to play when starting to glide with Wings 6. Use vanilla sound effect names."); Wings6LoopSFX = IBelieveICanFlyPlugin.context.config("07.07 - Wings 6", "04 - Loop SFX", "", "Sound effect to play continuously while gliding with Wings 6. Use vanilla sound effect names."); Wings6StopSFX = IBelieveICanFlyPlugin.context.config("07.07 - Wings 6", "05 - Stop SFX", "sfx_flap_glider_Ygg", "Sound effect to play when stopping gliding with Wings 6. Use vanilla sound effect names."); Wings6VFX = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "01 - VFX", value: false, "Whether to enable or disable VFX when gliding with Wings 6."); Wings6AttachEffectsToPlayer = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "02 - Attach VFX To Player", value: false, "Whether to enable or disable VFX for Wings 6 will be attached to the player and follow their movement."); Wings6StartVFX = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "03 - Start VFX", "", "Visual effect to play when starting to glide with Wings 6. Use vanilla VFX names."); Wings6LoopVFX = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "04 - Loop VFX", "", "Visual effect to play continuously while gliding with Wings 6. Use vanilla VFX names."); Wings6StopVFX = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "05 - Stop VFX", "", "Visual effect to play when stopping gliding with Wings 6. Use vanilla VFX names."); Wings6VFXPosition = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "06 - VFX Position", "Root", "Position for VFX for Wings 6: 'Root' (at player's feet), 'Middle' (at player's center), or 'Custom' (use custom coordinates)."); Wings6VFXScale = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "07 - VFX Scale", 1f, "Scale factor for VFX for Wings 6. 1.0 is normal size."); Wings6VFXCustomX = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "08 - Custom X Offset", 0f, "X offset for custom VFX position for Wings 6 (only used when VFX Position is set to 'Custom')."); Wings6VFXCustomY = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "09 - Custom Y Offset", 1f, "Y offset for custom VFX position for Wings 6 (only used when VFX Position is set to 'Custom')."); Wings6VFXCustomZ = IBelieveICanFlyPlugin.context.config("07.08 - Wings 6", "10 - Custom Z Offset", 0f, "Z offset for custom VFX position for Wings 6 (only used when VFX Position is set to 'Custom')."); } public static (bool enabled, int wingsIndex) GetWingsConfigForItem(ItemData item) { if (item == null) { return (false, -1); } string text = (Object.op_Implicit((Object)(object)item.m_dropPrefab) ? ((Object)item.m_dropPrefab).name : ""); string name = item.m_shared.m_name; if (Wings1Enabled.Value && !string.IsNullOrEmpty(Wings1ItemName.Value) && (text.Equals(Wings1ItemName.Value) || name.Equals(Wings1ItemName.Value) || name.Contains(Wings1ItemName.Value))) { return (true, 1); } if (Wings2Enabled.Value && !string.IsNullOrEmpty(Wings2ItemName.Value) && (text.Equals(Wings2ItemName.Value) || name.Equals(Wings2ItemName.Value) || name.Contains(Wings2ItemName.Value))) { return (true, 2); } if (Wings3Enabled.Value && !string.IsNullOrEmpty(Wings3ItemName.Value) && (text.Equals(Wings3ItemName.Value) || name.Equals(Wings3ItemName.Value) || name.Contains(Wings3ItemName.Value))) { return (true, 3); } if (Wings4Enabled.Value && !string.IsNullOrEmpty(Wings4ItemName.Value) && (text.Equals(Wings4ItemName.Value) || name.Equals(Wings4ItemName.Value) || name.Contains(Wings4ItemName.Value))) { return (true, 4); } if (Wings5Enabled.Value && !string.IsNullOrEmpty(Wings5ItemName.Value) && (text.Equals(Wings5ItemName.Value) || name.Equals(Wings5ItemName.Value) || name.Contains(Wings5ItemName.Value))) { return (true, 5); } if (Wings6Enabled.Value && !string.IsNullOrEmpty(Wings6ItemName.Value) && (text.Equals(Wings6ItemName.Value) || name.Equals(Wings6ItemName.Value) || name.Contains(Wings6ItemName.Value))) { return (true, 6); } return (false, -1); } public static string GetWingsVisualPrefab(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => Wings1VisualPrefab.Value, 2 => Wings2VisualPrefab.Value, 3 => Wings3VisualPrefab.Value, 4 => Wings4VisualPrefab.Value, 5 => Wings5VisualPrefab.Value, 6 => Wings6VisualPrefab.Value, _ => "", }; if (1 == 0) { } return result; } public static bool GetWingsCheckRightHand(int wingsIndex) { if (1 == 0) { } bool result = wingsIndex switch { 1 => Wings1CheckRightHand.Value, 2 => Wings2CheckRightHand.Value, 3 => Wings3CheckRightHand.Value, 4 => Wings4CheckRightHand.Value, 5 => Wings5CheckRightHand.Value, 6 => Wings6CheckRightHand.Value, _ => true, }; if (1 == 0) { } return result; } public static bool GetWingsCheckLeftHand(int wingsIndex) { if (1 == 0) { } bool result = wingsIndex switch { 1 => Wings1CheckLeftHand.Value, 2 => Wings2CheckLeftHand.Value, 3 => Wings3CheckLeftHand.Value, 4 => Wings4CheckLeftHand.Value, 5 => Wings5CheckLeftHand.Value, 6 => Wings6CheckLeftHand.Value, _ => false, }; if (1 == 0) { } return result; } public static bool GetWingsCheckUtility(int wingsIndex) { if (1 == 0) { } bool result = wingsIndex switch { 1 => Wings1CheckUtility.Value, 2 => Wings2CheckUtility.Value, 3 => Wings3CheckUtility.Value, 4 => Wings4CheckUtility.Value, 5 => Wings5CheckUtility.Value, 6 => Wings6CheckUtility.Value, _ => false, }; if (1 == 0) { } return result; } public static bool GetWingsUseFallReset(int wingsIndex) { if (1 == 0) { } bool result = wingsIndex switch { 1 => Wings1UseFallReset.Value, 2 => Wings2UseFallReset.Value, 3 => Wings3UseFallReset.Value, 4 => Wings4UseFallReset.Value, 5 => Wings5UseFallReset.Value, 6 => Wings6UseFallReset.Value, _ => true, }; if (1 == 0) { } return result; } public static bool GetWingsAnimation(int wingsIndex) { if (1 == 0) { } bool result = wingsIndex switch { 1 => Wings1Animation.Value, 2 => Wings2Animation.Value, 3 => Wings3Animation.Value, 4 => Wings4Animation.Value, 5 => Wings5Animation.Value, 6 => Wings6Animation.Value, _ => true, }; if (1 == 0) { } return result; } public static float GetWingsMinActivationFallSpeed(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1MinActivationFallSpeed.Value, 2 => Wings2MinActivationFallSpeed.Value, 3 => Wings3MinActivationFallSpeed.Value, 4 => Wings4MinActivationFallSpeed.Value, 5 => Wings5MinActivationFallSpeed.Value, 6 => Wings6MinActivationFallSpeed.Value, _ => -0.5f, }; if (1 == 0) { } return result; } public static bool GetWingsSFX(int wingsIndex) { if (1 == 0) { } bool result = wingsIndex switch { 1 => Wings1SFX.Value, 2 => Wings2SFX.Value, 3 => Wings3SFX.Value, 4 => Wings4SFX.Value, 5 => Wings5SFX.Value, 6 => Wings6SFX.Value, _ => true, }; if (1 == 0) { } return result; } public static string GetWingsStartSFX(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => Wings1StartSFX.Value, 2 => Wings2StartSFX.Value, 3 => Wings3StartSFX.Value, 4 => Wings4StartSFX.Value, 5 => Wings5StartSFX.Value, 6 => Wings6StartSFX.Value, _ => "", }; if (1 == 0) { } return result; } public static string GetWingsLoopSFX(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => Wings1LoopSFX.Value, 2 => Wings2LoopSFX.Value, 3 => Wings3LoopSFX.Value, 4 => Wings4LoopSFX.Value, 5 => Wings5LoopSFX.Value, 6 => Wings6LoopSFX.Value, _ => "", }; if (1 == 0) { } return result; } public static string GetWingsStopSFX(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => Wings1StopSFX.Value, 2 => Wings2StopSFX.Value, 3 => Wings3StopSFX.Value, 4 => Wings4StopSFX.Value, 5 => Wings5StopSFX.Value, 6 => Wings6StopSFX.Value, _ => "", }; if (1 == 0) { } return result; } public static bool GetWingsVFX(int wingsIndex) { if (1 == 0) { } bool result = wingsIndex switch { 1 => Wings1VFX.Value, 2 => Wings2VFX.Value, 3 => Wings3VFX.Value, 4 => Wings4VFX.Value, 5 => Wings5VFX.Value, 6 => Wings6VFX.Value, _ => true, }; if (1 == 0) { } return result; } public static string GetWingsStartVFX(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => Wings1StartVFX.Value, 2 => Wings2StartVFX.Value, 3 => Wings3StartVFX.Value, 4 => Wings4StartVFX.Value, 5 => Wings5StartVFX.Value, 6 => Wings6StartVFX.Value, _ => "", }; if (1 == 0) { } return result; } public static string GetWingsLoopVFX(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => Wings1LoopVFX.Value, 2 => Wings2LoopVFX.Value, 3 => Wings3LoopVFX.Value, 4 => Wings4LoopVFX.Value, 5 => Wings5LoopVFX.Value, 6 => Wings6LoopVFX.Value, _ => "", }; if (1 == 0) { } return result; } public static string GetWingsStopVFX(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => Wings1StopVFX.Value, 2 => Wings2StopVFX.Value, 3 => Wings3StopVFX.Value, 4 => Wings4StopVFX.Value, 5 => Wings5StopVFX.Value, 6 => Wings6StopVFX.Value, _ => "", }; if (1 == 0) { } return result; } public static float GetWingsForwardSpeed(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1ForwardSpeed.Value, 2 => Wings2ForwardSpeed.Value, 3 => Wings3ForwardSpeed.Value, 4 => Wings4ForwardSpeed.Value, 5 => Wings5ForwardSpeed.Value, 6 => Wings6ForwardSpeed.Value, _ => 14f, }; if (1 == 0) { } return result; } public static float GetWingsForwardForce(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1ForwardForce.Value, 2 => Wings2ForwardForce.Value, 3 => Wings3ForwardForce.Value, 4 => Wings4ForwardForce.Value, 5 => Wings5ForwardForce.Value, 6 => Wings6ForwardForce.Value, _ => 10f, }; if (1 == 0) { } return result; } public static float GetWingsDescentSpeed(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1DescentSpeed.Value, 2 => Wings2DescentSpeed.Value, 3 => Wings3DescentSpeed.Value, 4 => Wings4DescentSpeed.Value, 5 => Wings5DescentSpeed.Value, 6 => Wings6DescentSpeed.Value, _ => -4f, }; if (1 == 0) { } return result; } public static float GetWingsAirTurnSpeed(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1AirTurnSpeed.Value, 2 => Wings2AirTurnSpeed.Value, 3 => Wings3AirTurnSpeed.Value, 4 => Wings4AirTurnSpeed.Value, 5 => Wings5AirTurnSpeed.Value, 6 => Wings6AirTurnSpeed.Value, _ => 120f, }; if (1 == 0) { } return result; } public static float GetWingsLateralDamp(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1LateralDamp.Value, 2 => Wings2LateralDamp.Value, 3 => Wings3LateralDamp.Value, 4 => Wings4LateralDamp.Value, 5 => Wings5LateralDamp.Value, 6 => Wings6LateralDamp.Value, _ => 0.15f, }; if (1 == 0) { } return result; } public static float GetWingsGroundProbeDistance(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1GroundProbeDistance.Value, 2 => Wings2GroundProbeDistance.Value, 3 => Wings3GroundProbeDistance.Value, 4 => Wings4GroundProbeDistance.Value, 5 => Wings5GroundProbeDistance.Value, 6 => Wings6GroundProbeDistance.Value, _ => 2.5f, }; if (1 == 0) { } return result; } public static float GetWingsCushionDescentSpeed(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1CushionDescentSpeed.Value, 2 => Wings2CushionDescentSpeed.Value, 3 => Wings3CushionDescentSpeed.Value, 4 => Wings4CushionDescentSpeed.Value, 5 => Wings5CushionDescentSpeed.Value, 6 => Wings6CushionDescentSpeed.Value, _ => -0.7f, }; if (1 == 0) { } return result; } public static float GetWingsCushionLerp(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1CushionLerp.Value, 2 => Wings2CushionLerp.Value, 3 => Wings3CushionLerp.Value, 4 => Wings4CushionLerp.Value, 5 => Wings5CushionLerp.Value, 6 => Wings6CushionLerp.Value, _ => 0.6f, }; if (1 == 0) { } return result; } public static float GetWingsTiltMaxPitch(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1TiltMaxPitch.Value, 2 => Wings2TiltMaxPitch.Value, 3 => Wings3TiltMaxPitch.Value, 4 => Wings4TiltMaxPitch.Value, 5 => Wings5TiltMaxPitch.Value, 6 => Wings6TiltMaxPitch.Value, _ => 25f, }; if (1 == 0) { } return result; } public static float GetWingsTiltMaxRoll(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1TiltMaxRoll.Value, 2 => Wings2TiltMaxRoll.Value, 3 => Wings3TiltMaxRoll.Value, 4 => Wings4TiltMaxRoll.Value, 5 => Wings5TiltMaxRoll.Value, 6 => Wings6TiltMaxRoll.Value, _ => 35f, }; if (1 == 0) { } return result; } public static float GetWingsTiltPitchSmoothTime(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1TiltPitchSmoothTime.Value, 2 => Wings2TiltPitchSmoothTime.Value, 3 => Wings3TiltPitchSmoothTime.Value, 4 => Wings4TiltPitchSmoothTime.Value, 5 => Wings5TiltPitchSmoothTime.Value, 6 => Wings6TiltPitchSmoothTime.Value, _ => 0.15f, }; if (1 == 0) { } return result; } public static float GetWingsTiltRollSmoothTime(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1TiltRollSmoothTime.Value, 2 => Wings2TiltRollSmoothTime.Value, 3 => Wings3TiltRollSmoothTime.Value, 4 => Wings4TiltRollSmoothTime.Value, 5 => Wings5TiltRollSmoothTime.Value, 6 => Wings6TiltRollSmoothTime.Value, _ => 0.1f, }; if (1 == 0) { } return result; } public static float GetWingsUpDownOffset(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1UpDownOffset.Value, 2 => Wings2UpDownOffset.Value, 3 => Wings3UpDownOffset.Value, 4 => Wings4UpDownOffset.Value, 5 => Wings5UpDownOffset.Value, 6 => Wings6UpDownOffset.Value, _ => 1.2f, }; if (1 == 0) { } return result; } public static float GetWingsLeftRightOffset(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1LeftRightOffset.Value, 2 => Wings2LeftRightOffset.Value, 3 => Wings3LeftRightOffset.Value, 4 => Wings4LeftRightOffset.Value, 5 => Wings5LeftRightOffset.Value, 6 => Wings6LeftRightOffset.Value, _ => 0f, }; if (1 == 0) { } return result; } public static float GetWingsForwardBackOffset(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1ForwardBackOffset.Value, 2 => Wings2ForwardBackOffset.Value, 3 => Wings3ForwardBackOffset.Value, 4 => Wings4ForwardBackOffset.Value, 5 => Wings5ForwardBackOffset.Value, 6 => Wings6ForwardBackOffset.Value, _ => -0.1f, }; if (1 == 0) { } return result; } public static float GetWingsRotationX(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1RotationX.Value, 2 => Wings2RotationX.Value, 3 => Wings3RotationX.Value, 4 => Wings4RotationX.Value, 5 => Wings5RotationX.Value, 6 => Wings6RotationX.Value, _ => 0f, }; if (1 == 0) { } return result; } public static float GetWingsRotationY(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1RotationY.Value, 2 => Wings2RotationY.Value, 3 => Wings3RotationY.Value, 4 => Wings4RotationY.Value, 5 => Wings5RotationY.Value, 6 => Wings6RotationY.Value, _ => 180f, }; if (1 == 0) { } return result; } public static float GetWingsRotationZ(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1RotationZ.Value, 2 => Wings2RotationZ.Value, 3 => Wings3RotationZ.Value, 4 => Wings4RotationZ.Value, 5 => Wings5RotationZ.Value, 6 => Wings6RotationZ.Value, _ => 0f, }; if (1 == 0) { } return result; } public static float GetWingsScale(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1Scale.Value, 2 => Wings2Scale.Value, 3 => Wings3Scale.Value, 4 => Wings4Scale.Value, 5 => Wings5Scale.Value, 6 => Wings6Scale.Value, _ => 1f, }; if (1 == 0) { } return result; } public static bool GetWingsAttachSFXToPlayer(int wingsIndex) { if (1 == 0) { } bool result = wingsIndex switch { 1 => Wings1AttachSFXToPlayer.Value, 2 => Wings2AttachSFXToPlayer.Value, 3 => Wings3AttachSFXToPlayer.Value, 4 => Wings4AttachSFXToPlayer.Value, 5 => Wings5AttachSFXToPlayer.Value, 6 => Wings6AttachSFXToPlayer.Value, _ => true, }; if (1 == 0) { } return result; } public static bool GetWingsAttachEffectsToPlayer(int wingsIndex) { if (1 == 0) { } bool result = wingsIndex switch { 1 => Wings1AttachEffectsToPlayer.Value, 2 => Wings2AttachEffectsToPlayer.Value, 3 => Wings3AttachEffectsToPlayer.Value, 4 => Wings4AttachEffectsToPlayer.Value, 5 => Wings5AttachEffectsToPlayer.Value, 6 => Wings6AttachEffectsToPlayer.Value, _ => true, }; if (1 == 0) { } return result; } public static string GetWingsVFXPosition(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => Wings1VFXPosition.Value, 2 => Wings2VFXPosition.Value, 3 => Wings3VFXPosition.Value, 4 => Wings4VFXPosition.Value, 5 => Wings5VFXPosition.Value, 6 => Wings6VFXPosition.Value, _ => "Root", }; if (1 == 0) { } return result; } public static float GetWingsVFXScale(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1VFXScale.Value, 2 => Wings2VFXScale.Value, 3 => Wings3VFXScale.Value, 4 => Wings4VFXScale.Value, 5 => Wings5VFXScale.Value, 6 => Wings6VFXScale.Value, _ => 1f, }; if (1 == 0) { } return result; } public static float GetWingsVFXCustomX(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1VFXCustomX.Value, 2 => Wings2VFXCustomX.Value, 3 => Wings3VFXCustomX.Value, 4 => Wings4VFXCustomX.Value, 5 => Wings5VFXCustomX.Value, 6 => Wings6VFXCustomX.Value, _ => 0f, }; if (1 == 0) { } return result; } public static float GetWingsVFXCustomY(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1VFXCustomY.Value, 2 => Wings2VFXCustomY.Value, 3 => Wings3VFXCustomY.Value, 4 => Wings4VFXCustomY.Value, 5 => Wings5VFXCustomY.Value, 6 => Wings6VFXCustomY.Value, _ => 1f, }; if (1 == 0) { } return result; } public static float GetWingsVFXCustomZ(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => Wings1VFXCustomZ.Value, 2 => Wings2VFXCustomZ.Value, 3 => Wings3VFXCustomZ.Value, 4 => Wings4VFXCustomZ.Value, 5 => Wings5VFXCustomZ.Value, 6 => Wings6VFXCustomZ.Value, _ => 0f, }; if (1 == 0) { } return result; } public static int GetCurrentWingsIndex() { return GliderSystem.GetCurrentWingsIndex(); } } public static class Item { public static ItemManager.Item? Glider_BackPack_Ygg { get; private set; } public static ItemManager.Item? Glider_Pelt_Ygg { get; private set; } public static ItemManager.Item? Glider_Gjall_BackPack_Ygg { get; private set; } public static ItemManager.Item? Glider_Gjall_Fader_BackPack_Ygg { get; private set; } public static ItemManager.Item? Glider_BackPack_DragonModer_Ygg { get; private set; } public static ItemManager.Item? Glider_BackPack_BlackDragon_Ygg { get; private set; } public static ItemManager.Item? Wing1 { get; private set; } public static ItemManager.Item? Wing2 { get; private set; } public static ItemManager.Item? Wing3 { get; private set; } public static ItemManager.Item? Wing4 { get; private set; } public static ItemManager.Item? Wing5 { get; private set; } public static ItemManager.Item? Wing6 { get; private set; } public static void RegisterAll(string bundleName) { RegisterItems(bundleName); RegisterGliders(bundleName); RegisterFX(bundleName); } private static void RegisterItems(string bundleName) { Glider_BackPack_Ygg = new ItemManager.Item(bundleName, "Glider_BackPack_Ygg"); Glider_BackPack_Ygg.Name.English("Glider Bag"); Glider_BackPack_Ygg.Description.English("Glider made from Glass Thread, Wolfpelt and Fine Wood."); Glider_BackPack_Ygg.Crafting.Add(ItemManager.CraftingTable.Workbench, 0); Glider_BackPack_Ygg.RequiredItems.Add("WolfPelt", 5); Glider_BackPack_Ygg.RequiredItems.Add("Resin", 10); Glider_BackPack_Ygg.RequiredItems.Add("Crystal", 10); Glider_BackPack_Ygg.RequiredItems.Add("FineWood", 15); Glider_BackPack_Ygg.CraftAmount = 1; Glider_Pelt_Ygg = new ItemManager.Item(bundleName, "Glider_Pelt_Ygg"); Glider_Pelt_Ygg.Name.English("Deer Hide Glider"); Glider_Pelt_Ygg.Description.English("A Glider made from Boar Leather, Deer Hide and Wood."); Glider_Pelt_Ygg.Crafting.Add(ItemManager.CraftingTable.Workbench, 0); Glider_Pelt_Ygg.RequiredItems.Add("DeerHide", 5); Glider_Pelt_Ygg.RequiredItems.Add("Resin", 10); Glider_Pelt_Ygg.RequiredItems.Add("LeatherScraps", 10); Glider_Pelt_Ygg.RequiredItems.Add("Wood", 15); Glider_Pelt_Ygg.CraftAmount = 1; Glider_Gjall_BackPack_Ygg = new ItemManager.Item(bundleName, "Glider_Gjall_BackPack_Ygg"); Glider_Gjall_BackPack_Ygg.Name.English("Gjall Air Balloon"); Glider_Gjall_BackPack_Ygg.Description.English("A Balloon Glider made from Gjall Trophy, Wisps and Yggdrassil Wood."); Glider_Gjall_BackPack_Ygg.Crafting.Add(ItemManager.CraftingTable.BlackForge, 0); Glider_Gjall_BackPack_Ygg.RequiredItems.Add("TrophyGjall", 1); Glider_Gjall_BackPack_Ygg.RequiredItems.Add("Wisp", 10); Glider_Gjall_BackPack_Ygg.RequiredItems.Add("YggdrasilWood", 15); Glider_Gjall_BackPack_Ygg.CraftAmount = 1; Glider_Gjall_Fader_BackPack_Ygg = new ItemManager.Item(bundleName, "Glider_Gjall_Fader_BackPack_Ygg"); Glider_Gjall_Fader_BackPack_Ygg.Name.English("Infused Gjall Glider"); Glider_Gjall_Fader_BackPack_Ygg.Description.English("Fader Infused Balloon Glider made from Gjall Trophy, Wisps and Yggdrassil Wood."); Glider_Gjall_Fader_BackPack_Ygg.Crafting.Add(ItemManager.CraftingTable.BlackForge, 0); Glider_Gjall_Fader_BackPack_Ygg.RequiredItems.Add("Glider_Gjall_BackPack_Ygg", 1); Glider_Gjall_Fader_BackPack_Ygg.RequiredItems.Add("TrophyFader", 1); Glider_Gjall_Fader_BackPack_Ygg.CraftAmount = 1; Glider_BackPack_DragonModer_Ygg = new ItemManager.Item(bundleName, "Glider_BackPack_DragonModer_Ygg"); Glider_BackPack_DragonModer_Ygg.Name.English("Dragon Glider Wings"); Glider_BackPack_DragonModer_Ygg.Description.English("A Dragon Glider back sack made from Moders wings."); Glider_BackPack_DragonModer_Ygg.DropsFrom.Add("Dragon", 0.05f, 1, 1); Glider_BackPack_BlackDragon_Ygg = new ItemManager.Item(bundleName, "Glider_BackPack_BlackDragon_Ygg"); Glider_BackPack_BlackDragon_Ygg.Name.English("Black Dragon Glider Wings"); Glider_BackPack_BlackDragon_Ygg.Description.English("A Dragon Glider back sack made from a special Black Dragon Wings."); Glider_BackPack_BlackDragon_Ygg.Crafting.Add(ItemManager.CraftingTable.BlackForge, 0); Glider_BackPack_BlackDragon_Ygg.RequiredItems.Add("Glider_BackPack_DragonModer_Ygg", 1); Glider_BackPack_BlackDragon_Ygg.RequiredItems.Add("FaderDrop", 10); Glider_BackPack_BlackDragon_Ygg.RequiredItems.Add("TrophyFader", 1); Glider_BackPack_BlackDragon_Ygg.CraftAmount = 1; } private static void RegisterGliders(string bundleName) { Wing1 = new ItemManager.Item(bundleName, "DragonWings_Ygg"); Wing1.Name.English("Glider Glass"); Wing1.Description.English("Wing 1"); Wing2 = new ItemManager.Item(bundleName, "DragonWings_Ygg1"); Wing2.Name.English("Dragon Glider Wings"); Wing2.Description.English("Wing 2"); Wing3 = new ItemManager.Item(bundleName, "DragonWings_Ygg2"); Wing3.Name.English("Black Dragon Glider Wings"); Wing3.Description.English("Wing 3"); Wing4 = new ItemManager.Item(bundleName, "DragonWings_Ygg3"); Wing4.Name.English("Gjall Air Balloon"); Wing4.Description.English("Wing 4"); Wing5 = new ItemManager.Item(bundleName, "DragonWings_Ygg4"); Wing5.Name.English("Infused Gjall Balloon"); Wing5.Description.English("Wing 5"); MaterialReplacer.RegisterGameObjectForShaderSwap(Wing5.Prefab, MaterialReplacer.ShaderType.UseUnityShader); Wing6 = new ItemManager.Item(bundleName, "DragonWings_Ygg5"); Wing6.Name.English("Celestial Wings"); Wing6.Description.English("Wing 6"); } private static void RegisterFX(string bundleName) { GameObject val = PrefabManager.RegisterPrefab("ibelieveicanfly", "sfx_flap_glider_Ygg"); GameObject val2 = PrefabManager.RegisterPrefab("ibelieveicanfly", "sfx_gliding_glider_Ygg"); GameObject val3 = PrefabManager.RegisterPrefab("ibelieveicanfly", "vfx_GjallFuelBurst_Ygg"); GameObject val4 = PrefabManager.RegisterPrefab("ibelieveicanfly", "vfx_GjallFuelBurst_Ygg2"); MaterialReplacer.RegisterGameObjectForShaderSwap(val3.gameObject, MaterialReplacer.ShaderType.UseUnityShader); MaterialReplacer.RegisterGameObjectForShaderSwap(val4.gameObject, MaterialReplacer.ShaderType.UseUnityShader); } } } namespace IBelieveICanFly.Patches { public static class GliderSystem { private const string WINGS1_CONTROLLER_NAME = "gliding_controller"; private const string WINGS1_START_TRIGGER = "start_gliding"; private const string WINGS1_STOP_TRIGGER = "stop_gliding"; private const float WINGS1_EXIT_DURATION = 0.1f; private const string WINGS2_CONTROLLER_NAME = "gliding_controller2"; private const string WINGS2_START_TRIGGER = "start_gliding"; private const string WINGS2_STOP_TRIGGER = "stop_gliding"; private const float WINGS2_EXIT_DURATION = 0.1f; private const string WINGS3_CONTROLLER_NAME = "gliding_controller3"; private const string WINGS3_START_TRIGGER = "start_gliding"; private const string WINGS3_STOP_TRIGGER = "stop_gliding"; private const float WINGS3_EXIT_DURATION = 0.1f; private const string WINGS4_CONTROLLER_NAME = "gliding_controller"; private const string WINGS4_START_TRIGGER = "start_gliding"; private const string WINGS4_STOP_TRIGGER = "stop_gliding"; private const float WINGS4_EXIT_DURATION = 0.1f; private const string WINGS5_CONTROLLER_NAME = "gliding_controller"; private const string WINGS5_START_TRIGGER = "start_gliding"; private const string WINGS5_STOP_TRIGGER = "stop_gliding"; private const float WINGS5_EXIT_DURATION = 0.1f; private const string WINGS6_CONTROLLER_NAME = "gliding_controller"; private const string WINGS6_START_TRIGGER = "start_gliding"; private const string WINGS6_STOP_TRIGGER = "stop_gliding"; private const float WINGS6_EXIT_DURATION = 0.1f; private static float lastItemCheckTime = 0f; private static float itemCheckInterval = 0.5f; private static bool cachedItemEquippedResult = false; private static bool isCurrentlyGliding = false; private static RuntimeAnimatorController? originalController; private static Dictionary gliderControllers = new Dictionary(); private static bool isExitingGlide = false; private static float exitAnimationStartTime = 0f; private static ItemData? equippedGliderItem = null; private static int currentWingsIndex = -1; private static FieldInfo? _fiMaxAirAltitude; private static bool toggleModeActive = false; private static bool lastSpaceKeyState = false; private static GameObject? activeLoopVFX = null; private static GameObject? activeLoopSFX = null; private const string ZDO_GLIDING_KEY = "IBelieveICanFly_Gliding"; private const string ZDO_WINGS_INDEX_KEY = "IBelieveICanFly_WingsIndex"; private static readonly Dictionary remotePlayerGliders = new Dictionary(); private static readonly Dictionary remotePlayerOriginalControllers = new Dictionary(); public static LayerMask groundMask = LayerMask.op_Implicit(-1); private static Vector3 _smoothedForward = Vector3.forward; private static Vector3 _smoothedVelocity = Vector3.zero; private static float _currentPitch = 0f; private static float _currentRoll = 0f; private static float _pitchVelocity = 0f; private static float _rollVelocity = 0f; private static Vector3 _lastPosition = Vector3.zero; private static float _lastUpdateTime = 0f; public static bool IsCurrentlyGliding() { return isCurrentlyGliding; } public static RuntimeAnimatorController? GetGliderController(int wingsIndex) { RuntimeAnimatorController value; return gliderControllers.TryGetValue(wingsIndex, out value) ? value : null; } public static RuntimeAnimatorController? GetOriginalController() { return originalController; } public static int GetCurrentWingsIndex() { return currentWingsIndex; } public static string GetWingsControllerName(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => "gliding_controller", 2 => "gliding_controller2", 3 => "gliding_controller3", 4 => "gliding_controller", 5 => "gliding_controller", 6 => "gliding_controller", _ => "gliding_controller", }; if (1 == 0) { } return result; } public static string GetWingsStartTrigger(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => "start_gliding", 2 => "start_gliding", 3 => "start_gliding", 4 => "start_gliding", 5 => "start_gliding", 6 => "start_gliding", _ => "start_gliding", }; if (1 == 0) { } return result; } public static string GetWingsStopTrigger(int wingsIndex) { if (1 == 0) { } string result = wingsIndex switch { 1 => "stop_gliding", 2 => "stop_gliding", 3 => "stop_gliding", 4 => "stop_gliding", 5 => "stop_gliding", 6 => "stop_gliding", _ => "stop_gliding", }; if (1 == 0) { } return result; } public static float GetWingsExitDuration(int wingsIndex) { if (1 == 0) { } float result = wingsIndex switch { 1 => 0.1f, 2 => 0.1f, 3 => 0.1f, 4 => 0.1f, 5 => 0.1f, 6 => 0.1f, _ => 0.1f, }; if (1 == 0) { } return result; } public static void Initialize() { lastItemCheckTime = 0f; cachedItemEquippedResult = false; AssetBundle assetBundle = IBelieveICanFlyPlugin.GetAssetBundle("ibelieveicanfly"); if ((Object)(object)assetBundle != (Object)null) { for (int i = 1; i <= 6; i++) { string wingsControllerName = GetWingsControllerName(i); RuntimeAnimatorController val = assetBundle.LoadAsset(wingsControllerName); if ((Object)(object)val != (Object)null) { gliderControllers[i] = val; } } if (gliderControllers.Count == 0) { RuntimeAnimatorController val2 = assetBundle.LoadAsset("gliding_controller"); if ((Object)(object)val2 != (Object)null) { for (int j = 1; j <= 6; j++) { gliderControllers[j] = val2; } } } } try { _fiMaxAirAltitude = typeof(Character).GetField("m_maxAirAltitude", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch (Exception) { _fiMaxAirAltitude = null; } } private static bool CanGlide(Player player) { //IL_0116: Unknown result type (might be due to invalid IL or missing references) var (flag, num) = GetEquippedWingsConfig(player); if (!flag) { return false; } currentWingsIndex = num; bool flag2 = ((Character)player).IsOnGround(); bool flag3 = ((Character)player).InWater(); bool flag4 = ((Character)player).IsAttached(); if (flag2 || flag3 || flag4) { return false; } bool flag5 = ZInput.GetButton("Jump") || ZInput.GetButton("JoyJump") || Input.GetKey((KeyCode)330); bool flag6 = ZInput.GetButtonDown("Jump") || ZInput.GetButtonDown("JoyJump") || Input.GetKeyDown((KeyCode)330); if (Config.ToggleMode.Value) { if (flag6) { toggleModeActive = !toggleModeActive; } if (!toggleModeActive) { return false; } } else if (!flag5) { toggleModeActive = false; return false; } Rigidbody component = ((Component)player).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } float y = component.linearVelocity.y; float wingsMinActivationFallSpeed = Config.GetWingsMinActivationFallSpeed(currentWingsIndex); if (y > wingsMinActivationFallSpeed) { return false; } return true; } public static bool IsGliderItem(ItemData item) { if ((Object)(object)item?.m_dropPrefab == (Object)null) { return false; } return Config.GetWingsConfigForItem(item).enabled; } public static (bool enabled, int wingsIndex) GetEquippedWingsConfig(Player player) { if (Time.time < lastItemCheckTime + itemCheckInterval && equippedGliderItem != null) { if (cachedItemEquippedResult) { return Config.GetWingsConfigForItem(equippedGliderItem); } return (false, -1); } lastItemCheckTime = Time.time; ItemData rightItem = ((Humanoid)player).GetRightItem(); if (rightItem != null) { (bool, int) wingsConfigForItem = Config.GetWingsConfigForItem(rightItem); if (wingsConfigForItem.Item1 && Config.GetWingsCheckRightHand(wingsConfigForItem.Item2)) { equippedGliderItem = rightItem; cachedItemEquippedResult = true; return wingsConfigForItem; } } ItemData leftItem = ((Humanoid)player).GetLeftItem(); if (leftItem != null) { (bool, int) wingsConfigForItem2 = Config.GetWingsConfigForItem(leftItem); if (wingsConfigForItem2.Item1 && Config.GetWingsCheckLeftHand(wingsConfigForItem2.Item2)) { equippedGliderItem = leftItem; cachedItemEquippedResult = true; return wingsConfigForItem2; } } if (((Humanoid)player).m_utilityItem != null) { (bool, int) wingsConfigForItem3 = Config.GetWingsConfigForItem(((Humanoid)player).m_utilityItem); if (wingsConfigForItem3.Item1 && Config.GetWingsCheckUtility(wingsConfigForItem3.Item2)) { equippedGliderItem = ((Humanoid)player).m_utilityItem; cachedItemEquippedResult = true; return wingsConfigForItem3; } } cachedItemEquippedResult = false; return (false, -1); } private static void StartGliding(Player player) { ResetFlightState(player); if ((Object)(object)originalController == (Object)null && (Object)(object)((Character)player).m_animator != (Object)null) { originalController = ((Character)player).m_animator.runtimeAnimatorController; } RuntimeAnimatorController gliderController = GetGliderController(currentWingsIndex); if (Config.GetWingsAnimation(currentWingsIndex) && (Object)(object)((Character)player).m_animator != (Object)null && (Object)(object)gliderController != (Object)null) { ((Character)player).m_animator.runtimeAnimatorController = gliderController; ((Character)player).m_animator.SetBool("wakeup", false); ((Character)player).m_animator.SetTrigger(GetWingsStartTrigger(currentWingsIndex)); ((Character)player).m_animator.Update(0f); } if (currentWingsIndex > 0 && Config.GetWingsSFX(currentWingsIndex)) { string wingsStartSFX = Config.GetWingsStartSFX(currentWingsIndex); if (!string.IsNullOrEmpty(wingsStartSFX)) { PlaySoundEffect(player, wingsStartSFX); } string wingsLoopSFX = Config.GetWingsLoopSFX(currentWingsIndex); if (!string.IsNullOrEmpty(wingsLoopSFX)) { PlaySoundEffect(player, wingsLoopSFX, isLoopSFX: true); } } if (currentWingsIndex > 0 && Config.GetWingsVFX(currentWingsIndex)) { string wingsStartVFX = Config.GetWingsStartVFX(currentWingsIndex); if (!string.IsNullOrEmpty(wingsStartVFX)) { SpawnVFX(player, wingsStartVFX); } } if (currentWingsIndex > 0 && Config.GetWingsVFX(currentWingsIndex)) { string wingsLoopVFX = Config.GetWingsLoopVFX(currentWingsIndex); if (!string.IsNullOrEmpty(wingsLoopVFX)) { SpawnVFX(player, wingsLoopVFX, isLoopVFX: true); } } isCurrentlyGliding = true; } private static void StopGliding(Player player) { if (!isCurrentlyGliding) { return; } isCurrentlyGliding = false; ResetFlightState(player); GliderVisual.HideGliderMesh(); CleanupEffects(); if ((Object)(object)ZNetScene.instance == (Object)null) { RestoreOriginalController(player); return; } if (currentWingsIndex > 0 && Config.GetWingsSFX(currentWingsIndex)) { string wingsStopSFX = Config.GetWingsStopSFX(currentWingsIndex); if (!string.IsNullOrEmpty(wingsStopSFX)) { PlaySoundEffect(player, wingsStopSFX); } } if (currentWingsIndex > 0 && Config.GetWingsVFX(currentWingsIndex)) { string wingsStopVFX = Config.GetWingsStopVFX(currentWingsIndex); if (!string.IsNullOrEmpty(wingsStopVFX)) { SpawnVFX(player, wingsStopVFX); } } RuntimeAnimatorController gliderController = GetGliderController(currentWingsIndex); if (Config.GetWingsAnimation(currentWingsIndex) && (Object)(object)((Character)player).m_animator != (Object)null && (Object)(object)((Character)player).m_animator.runtimeAnimatorController == (Object)(object)gliderController) { ((Character)player).m_animator.SetTrigger(GetWingsStopTrigger(currentWingsIndex)); RestoreOriginalController(player); } else { RestoreOriginalController(player); } } private static void RestoreOriginalController(Player player) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)originalController == (Object)null || (Object)(object)((Character)(player?)).m_animator == (Object)null) { CleanupEffects(); return; } Vector3 velocity = ((Character)player).GetVelocity(); isCurrentlyGliding = false; ((Character)player).m_animator.SetBool("wakeup", false); ((Character)player).m_animator.SetBool("sleeping", false); ((Character)player).m_animator.SetFloat("forward_speed", 0.1f); ((Character)player).m_animator.SetBool("onGround", true); ((Character)player).m_animator.Update(0f); RuntimeAnimatorController runtimeAnimatorController = originalController; originalController = null; ((Character)player).m_animator.runtimeAnimatorController = runtimeAnimatorController; ((Character)player).m_animator.SetBool("wakeup", false); ((Character)player).m_animator.SetBool("sleeping", false); ((Character)player).m_animator.SetFloat("forward_speed", 0.1f); ((Character)player).m_animator.SetBool("onGround", true); ((Character)player).m_animator.Update(0f); if ((Object)(object)((Character)player).m_body != (Object)null) { ((Character)player).m_body.linearVelocity = velocity; } CleanupEffects(); } public static void OnModUnload() { CleanupEffects(); isCurrentlyGliding = false; isExitingGlide = false; exitAnimationStartTime = 0f; originalController = null; cachedItemEquippedResult = false; lastItemCheckTime = 0f; toggleModeActive = false; lastSpaceKeyState = false; } public static void HandleGliding(Player player) { float wingsExitDuration = GetWingsExitDuration(currentWingsIndex); if (isExitingGlide && Time.time > exitAnimationStartTime + wingsExitDuration) { RestoreOriginalController(player); isExitingGlide = false; GliderVisual.HideGliderMesh(); return; } bool flag = CanGlide(player); if (((Character)player).IsOnGround() || ((Character)player).InWater() || ((Character)player).IsAttached()) { toggleModeActive = false; } if (isCurrentlyGliding && flag && Time.time % 1f < 0.1f && !GliderVisual.IsGliderMeshActive()) { GliderVisual.ShowGliderMesh(player); } if (flag && !isCurrentlyGliding && !isExitingGlide) { StartGliding(player); GliderVisual.ShowGliderMesh(player); } else if (isCurrentlyGliding && !flag && !isExitingGlide) { StopGliding(player); } else { if (!flag && !isExitingGlide) { return; } RuntimeAnimatorController gliderController = GetGliderController(currentWingsIndex); if ((isCurrentlyGliding || isExitingGlide) && Config.GetWingsAnimation(currentWingsIndex) && (Object)(object)((Character)player).m_animator != (Object)null && (Object)(object)gliderController != (Object)null) { if ((Object)(object)((Character)player).m_animator.runtimeAnimatorController != (Object)(object)gliderController) { ((Character)player).m_animator.runtimeAnimatorController = gliderController; } ((Character)player).m_animator.SetBool("wakeup", false); } if (isCurrentlyGliding) { ApplyGlidingPhysics(player); } } } public static void CleanupEffects() { CleanupVFX(); CleanupSFX(); } private static void SafeDestroy(ref GameObject? obj) { //IL_0049: 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) if ((Object)(object)obj == (Object)null) { return; } try { if ((Object)(object)obj.transform != (Object)null && (Object)(object)obj.transform.parent != (Object)null) { obj.transform.SetParent((Transform)null); } Scene scene = obj.scene; if (((Scene)(ref scene)).IsValid()) { Object.Destroy((Object)(object)obj); } } catch (Exception) { } obj = null; } private static void CleanupVFX() { SafeDestroy(ref activeLoopVFX); } private static void CleanupSFX() { SafeDestroy(ref activeLoopSFX); } public static void PlaySoundEffect(Player player, string sfxName, bool isLoopSFX = false) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || string.IsNullOrEmpty(sfxName) || !Object.op_Implicit((Object)(object)((Component)player).gameObject) || !((Component)player).gameObject.activeInHierarchy || (Object)(object)ZNetScene.instance == (Object)null) { return; } if (isLoopSFX) { CleanupSFX(); } GameObject prefab = ZNetScene.instance.GetPrefab(sfxName); if (!((Object)(object)prefab == (Object)null) && !((Object)(object)((Component)player).transform == (Object)null)) { GameObject val = Object.Instantiate(prefab, ((Component)player).transform.position, Quaternion.identity); if (!((Object)(object)val == (Object)null) && isLoopSFX) { activeLoopSFX = val; } } } public static void SpawnVFX(Player player, string vfxName, bool isLoopVFX = false) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || string.IsNullOrEmpty(vfxName) || !Object.op_Implicit((Object)(object)((Component)player).gameObject) || !((Component)player).gameObject.activeInHierarchy || (Object)(object)ZNetScene.instance == (Object)null) { return; } if (isLoopVFX) { CleanupVFX(); } Vector3 val; try { val = GetVFXPosition(player); } catch (Exception) { val = ((Component)player).transform.position; } GameObject prefab = ZNetScene.instance.GetPrefab(vfxName); if ((Object)(object)prefab == (Object)null) { return; } GameObject val2 = Object.Instantiate(prefab, val, Quaternion.identity); if ((Object)(object)val2 == (Object)null) { return; } try { int num = Config.GetCurrentWingsIndex(); float num2 = ((num > 0) ? Config.GetWingsVFXScale(num) : 1f); if ((Object)(object)val2.transform != (Object)null) { val2.transform.localScale = new Vector3(num2, num2, num2); } } catch (Exception) { } if (isLoopVFX) { activeLoopVFX = val2; } } public static Vector3 GetVFXPosition(Player player) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((player != null) ? ((Component)player).transform : null) == (Object)null) { return Vector3.zero; } Vector3 val = ((Component)player).transform.position; string text = "Root"; int num = Config.GetCurrentWingsIndex(); if (num > 0) { try { text = Config.GetWingsVFXPosition(num); } catch { } } if (text.Equals("Middle", StringComparison.OrdinalIgnoreCase)) { val += ((Component)player).transform.up * 1f; } else if (text.Equals("Custom", StringComparison.OrdinalIgnoreCase) && num > 0) { float wingsVFXCustomZ = Config.GetWingsVFXCustomZ(num); float wingsVFXCustomY = Config.GetWingsVFXCustomY(num); float wingsVFXCustomX = Config.GetWingsVFXCustomX(num); val += ((Component)player).transform.forward * wingsVFXCustomZ; val += ((Component)player).transform.up * wingsVFXCustomY; val += ((Component)player).transform.right * wingsVFXCustomX; } return val; } public static void UpdateGlidingZDO(Player player, bool isGliding) { if (player != null) { ZNetView nview = ((Character)player).m_nview; if (((nview != null) ? new bool?(nview.IsValid()) : null).GetValueOrDefault()) { ((Character)player).m_nview.m_zdo.Set("IBelieveICanFly_Gliding", isGliding); int num = GetCurrentWingsIndex(); ((Character)player).m_nview.m_zdo.Set("IBelieveICanFly_WingsIndex", num); } } } public static int GetRemotePlayerWingsIndex(Player player) { if (player != null) { ZNetView nview = ((Character)player).m_nview; if (((nview != null) ? new bool?(nview.IsValid()) : null).GetValueOrDefault()) { return ((Character)player).m_nview.m_zdo.GetInt("IBelieveICanFly_WingsIndex", 1); } } return 1; } public static bool IsPlayerGliding(Player player) { if (player != null) { ZNetView nview = ((Character)player).m_nview; if (((nview != null) ? new bool?(nview.IsValid()) : null).GetValueOrDefault()) { if ((Object)(object)player == (Object)(object)Player.m_localPlayer) { return isCurrentlyGliding; } return ((Character)player).m_nview.m_zdo.GetBool("IBelieveICanFly_Gliding", false); } } return false; } public static void UpdateRemotePlayerGlider(Player player) { //IL_0040: 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) if ((Object)(object)player == (Object)null || (Object)(object)player == (Object)(object)Player.m_localPlayer) { return; } ZNetView nview = ((Character)player).m_nview; if (nview != null && nview.IsValid()) { ZDOID uid = ((Character)player).m_nview.m_zdo.m_uid; bool @bool = ((Character)player).m_nview.m_zdo.GetBool("IBelieveICanFly_Gliding", false); if (@bool) { ShowRemotePlayerGlider(player); } else { HideRemotePlayerGlider(player); } UpdateRemotePlayerAnimator(player, @bool); } } private static void ShowRemotePlayerGlider(Player player) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)(object)Player.m_localPlayer || player == null) { return; } ZNetView nview = ((Character)player).m_nview; if (!((nview != null) ? new bool?(nview.IsValid()) : null).GetValueOrDefault()) { return; } ZDOID uid = ((Character)player).m_nview.m_zdo.m_uid; if (remotePlayerGliders.TryGetValue(uid, out GameObject value) && (Object)(object)value != (Object)null) { return; } int remotePlayerWingsIndex = GetRemotePlayerWingsIndex(player); string wingsVisualPrefab = Config.GetWingsVisualPrefab(remotePlayerWingsIndex); string text; if (!string.IsNullOrEmpty(wingsVisualPrefab)) { text = wingsVisualPrefab; } else { if (1 == 0) { } string text2 = remotePlayerWingsIndex switch { 1 => Config.Wings1ItemName.Value, 2 => Config.Wings2ItemName.Value, 3 => Config.Wings3ItemName.Value, 4 => Config.Wings4ItemName.Value, 5 => Config.Wings5ItemName.Value, _ => Config.Wings1ItemName.Value, }; if (1 == 0) { } text = text2; } if (string.IsNullOrEmpty(text)) { return; } GameObject prefab = ZNetScene.instance.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { return; } GameObject val = CreateVisualOnlyRemoteGliderMesh(prefab, $"RemoteGliderMesh_{uid}"); if (!((Object)(object)val == (Object)null)) { PositionRemoteGliderOnBack(player, val); if ((Object)(object)player != (Object)(object)Player.m_localPlayer) { remotePlayerGliders[uid] = val; } else { Object.Destroy((Object)(object)val); } } } private static void PositionRemoteGliderOnBack(Player player, GameObject gliderMesh) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) if (player != null) { GameObject gameObject = ((Component)player).gameObject; bool? obj; if (gameObject == null) { obj = null; } else { Scene scene = gameObject.scene; obj = ((Scene)(ref scene)).IsValid(); } bool? flag = obj; if (flag.GetValueOrDefault() && !((Object)(object)gliderMesh == (Object)null)) { GameObject val = new GameObject("RemoteGliderAttachPoint"); val.transform.SetParent(((Component)player).transform); int remotePlayerWingsIndex = GetRemotePlayerWingsIndex(player); float wingsUpDownOffset = Config.GetWingsUpDownOffset(remotePlayerWingsIndex); float wingsLeftRightOffset = Config.GetWingsLeftRightOffset(remotePlayerWingsIndex); float wingsForwardBackOffset = Config.GetWingsForwardBackOffset(remotePlayerWingsIndex); val.transform.localPosition = new Vector3(wingsLeftRightOffset, wingsUpDownOffset, wingsForwardBackOffset); val.transform.localRotation = Quaternion.identity; gliderMesh.transform.SetParent(val.transform); gliderMesh.transform.localPosition = Vector3.zero; float wingsRotationX = Config.GetWingsRotationX(remotePlayerWingsIndex); float wingsRotationY = Config.GetWingsRotationY(remotePlayerWingsIndex); float wingsRotationZ = Config.GetWingsRotationZ(remotePlayerWingsIndex); gliderMesh.transform.localRotation = Quaternion.Euler(wingsRotationX, wingsRotationY, wingsRotationZ); float wingsScale = Config.GetWingsScale(remotePlayerWingsIndex); gliderMesh.transform.localScale = Vector3.one * wingsScale; } } } private static void HideRemotePlayerGlider(Player player) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)(object)Player.m_localPlayer || player == null) { return; } ZNetView nview = ((Character)player).m_nview; if (!((nview != null) ? new bool?(nview.IsValid()) : null).GetValueOrDefault()) { return; } ZDOID uid = ((Character)player).m_nview.m_zdo.m_uid; if (!remotePlayerGliders.TryGetValue(uid, out GameObject value) || !((Object)(object)value != (Object)null)) { return; } value.SetActive(false); ZNetView[] componentsInChildren = value.GetComponentsInChildren(true); ZNetView[] array = componentsInChildren; foreach (ZNetView val in array) { if (!((Object)(object)val != (Object)null)) { continue; } try { if ((Object)(object)ZNetScene.instance != (Object)null && val.GetZDO() != null) { ZNetScene.instance.m_instances.Remove(val.GetZDO()); } } catch (Exception) { } Object.Destroy((Object)(object)val); } Animator[] componentsInChildren2 = value.GetComponentsInChildren(true); Animator[] array2 = componentsInChildren2; foreach (Animator val2 in array2) { if ((Object)(object)val2 != (Object)null) { ((Behaviour)val2).enabled = false; val2.runtimeAnimatorController = null; Object.Destroy((Object)(object)val2); } } SkinnedMeshRenderer[] componentsInChildren3 = value.GetComponentsInChildren(true); SkinnedMeshRenderer[] array3 = componentsInChildren3; foreach (SkinnedMeshRenderer val3 in array3) { if ((Object)(object)val3 != (Object)null) { ((Renderer)val3).enabled = false; val3.sharedMesh = null; val3.bones = (Transform[])(object)new Transform[0]; val3.rootBone = null; Object.Destroy((Object)(object)val3); } } if ((Object)(object)value.transform.parent != (Object)null && ((Object)value.transform.parent).name == "RemoteGliderAttachPoint") { Object.Destroy((Object)(object)((Component)value.transform.parent).gameObject); } else { Object.Destroy((Object)(object)value); } remotePlayerGliders.Remove(uid); } private static void UpdateRemotePlayerAnimator(Player player, bool isGliding) { //IL_004d: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: 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) int remotePlayerWingsIndex = GetRemotePlayerWingsIndex(player); bool wingsAnimation = Config.GetWingsAnimation(remotePlayerWingsIndex); RuntimeAnimatorController gliderController = GetGliderController(remotePlayerWingsIndex); if (!wingsAnimation || (Object)(object)((Character)(player?)).m_animator == (Object)null || (Object)(object)gliderController == (Object)null) { return; } ZDOID uid = ((Character)player).m_nview.m_zdo.m_uid; RuntimeAnimatorController value; if (isGliding) { if (!remotePlayerOriginalControllers.ContainsKey(uid) && (Object)(object)((Character)player).m_animator.runtimeAnimatorController != (Object)(object)gliderController) { remotePlayerOriginalControllers[uid] = ((Character)player).m_animator.runtimeAnimatorController; } if ((Object)(object)((Character)player).m_animator.runtimeAnimatorController != (Object)(object)gliderController) { ((Character)player).m_animator.runtimeAnimatorController = gliderController; ((Character)player).m_animator.SetBool("wakeup", false); ((Character)player).m_animator.SetTrigger(GetWingsStartTrigger(remotePlayerWingsIndex)); ((Character)player).m_animator.Update(0f); } } else if (remotePlayerOriginalControllers.TryGetValue(uid, out value) && (Object)(object)value != (Object)null) { ((Character)player).m_animator.SetBool("wakeup", false); ((Character)player).m_animator.SetBool("sleeping", false); ((Character)player).m_animator.SetFloat("forward_speed", 0.1f); ((Character)player).m_animator.SetBool("onGround", true); ((Character)player).m_animator.Update(0f); ((Character)player).m_animator.runtimeAnimatorController = value; ((Character)player).m_animator.SetBool("wakeup", false); ((Character)player).m_animator.SetBool("sleeping", false); ((Character)player).m_animator.SetFloat("forward_speed", 0.1f); ((Character)player).m_animator.SetBool("onGround", true); ((Character)player).m_animator.Update(0f); remotePlayerOriginalControllers.Remove(uid); } } private static GameObject? CreateVisualOnlyRemoteGliderMesh(GameObject itemPrefab, string meshName) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown if ((Object)(object)itemPrefab == (Object)null) { return null; } GameObject val2; if ((Object)(object)itemPrefab.GetComponentInChildren(true) != (Object)null) { Transform val = FindChildByName(itemPrefab.transform, "Visual"); if ((Object)(object)val != (Object)null) { val2 = Object.Instantiate(((Component)val).gameObject); ((Object)val2).name = meshName; CleanupNonVisualComponentsForRemote(val2); } else { val2 = new GameObject(meshName); CopyVisualComponentsForRemote(itemPrefab, val2); } } else { val2 = new GameObject(meshName); CopyVisualComponentsForRemote(itemPrefab, val2); } return val2; } private static void CleanupNonVisualComponentsForRemote(GameObject obj) { if ((Object)(object)obj == (Object)null) { return; } ZNetView[] componentsInChildren = obj.GetComponentsInChildren(true); ZNetView[] array = componentsInChildren; foreach (ZNetView val in array) { if (!((Object)(object)val != (Object)null)) { continue; } try { if ((Object)(object)ZNetScene.instance != (Object)null && val.GetZDO() != null) { ZNetScene.instance.m_instances.Remove(val.GetZDO()); } } catch (Exception) { } } Component[] components = obj.GetComponents(); Component[] array2 = components; foreach (Component val2 in array2) { if (!(val2 is Transform) && !(val2 is MeshFilter) && !(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer) && !(val2 is Animator) && !(val2 is ParticleSystem) && !(val2 is ParticleSystemRenderer) && !(val2 is Light) && !(val2 is AudioSource)) { Object.Destroy((Object)(object)val2); } } for (int k = 0; k < obj.transform.childCount; k++) { CleanupNonVisualComponentsForRemote(((Component)obj.transform.GetChild(k)).gameObject); } } private static void CopyVisualComponentsForRemote(GameObject source, GameObject target) { //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_01ab: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null || (Object)(object)target == (Object)null) { return; } MeshFilter component = source.GetComponent(); if ((Object)(object)((component != null) ? component.sharedMesh : null) != (Object)null) { MeshFilter val = target.GetComponent(); if ((Object)(object)val == (Object)null) { val = target.AddComponent(); } val.sharedMesh = component.sharedMesh; } MeshRenderer component2 = source.GetComponent(); if ((Object)(object)component2 != (Object)null) { MeshRenderer val2 = target.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = target.AddComponent(); } Material[] sharedMaterials = ((Renderer)component2).sharedMaterials; if (sharedMaterials != null && sharedMaterials.Length != 0) { ((Renderer)val2).sharedMaterials = ((Renderer)component2).sharedMaterials; } ((Renderer)val2).shadowCastingMode = ((Renderer)component2).shadowCastingMode; ((Renderer)val2).receiveShadows = ((Renderer)component2).receiveShadows; ((Renderer)val2).lightProbeUsage = ((Renderer)component2).lightProbeUsage; } SkinnedMeshRenderer component3 = source.GetComponent(); if ((Object)(object)component3 != (Object)null) { SkinnedMeshRenderer val3 = target.GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = target.AddComponent(); } val3.sharedMesh = component3.sharedMesh; Material[] sharedMaterials2 = ((Renderer)component3).sharedMaterials; if (sharedMaterials2 != null && sharedMaterials2.Length != 0) { ((Renderer)val3).sharedMaterials = ((Renderer)component3).sharedMaterials; } ((Renderer)val3).shadowCastingMode = ((Renderer)component3).shadowCastingMode; ((Renderer)val3).receiveShadows = ((Renderer)component3).receiveShadows; ((Renderer)val3).lightProbeUsage = ((Renderer)component3).lightProbeUsage; val3.rootBone = component3.rootBone; val3.bones = component3.bones; val3.quality = component3.quality; val3.updateWhenOffscreen = component3.updateWhenOffscreen; } Animator component4 = source.GetComponent(); if ((Object)(object)component4 != (Object)null) { Animator val4 = target.GetComponent(); if ((Object)(object)val4 == (Object)null) { val4 = target.AddComponent(); } val4.runtimeAnimatorController = component4.runtimeAnimatorController; val4.avatar = component4.avatar; val4.applyRootMotion = component4.applyRootMotion; val4.updateMode = component4.updateMode; val4.cullingMode = component4.cullingMode; } for (int i = 0; i < source.transform.childCount; i++) { Transform child = source.transform.GetChild(i); if (HasVisualComponentsForRemote(((Component)child).gameObject)) { GameObject val5 = new GameObject(((Object)child).name); val5.transform.SetParent(target.transform); val5.transform.localPosition = child.localPosition; val5.transform.localRotation = child.localRotation; val5.transform.localScale = child.localScale; CopyVisualComponentsForRemote(((Component)child).gameObject, val5); } } } private static Transform FindChildByName(Transform parent, string name) { if ((Object)(object)parent == (Object)null || string.IsNullOrEmpty(name)) { return null; } if (((Object)parent).name.Equals(name, StringComparison.OrdinalIgnoreCase)) { return parent; } for (int i = 0; i < parent.childCount; i++) { Transform child = parent.GetChild(i); Transform val = FindChildByName(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static bool HasVisualComponentsForRemote(GameObject obj) { if ((Object)(object)obj == (Object)null) { return false; } if ((Object)(object)obj.GetComponent() != (Object)null || (Object)(object)obj.GetComponent() != (Object)null || (Object)(object)obj.GetComponent() != (Object)null || (Object)(object)obj.GetComponent() != (Object)null) { return true; } for (int i = 0; i < obj.transform.childCount; i++) { if (HasVisualComponentsForRemote(((Component)obj.transform.GetChild(i)).gameObject)) { return true; } } return false; } public static void CleanupRemotePlayerGliders() { foreach (GameObject value in remotePlayerGliders.Values) { if (!((Object)(object)value != (Object)null)) { continue; } value.SetActive(false); Animator[] componentsInChildren = value.GetComponentsInChildren(true); Animator[] array = componentsInChildren; foreach (Animator val in array) { if ((Object)(object)val != (Object)null) { ((Behaviour)val).enabled = false; val.runtimeAnimatorController = null; Object.Destroy((Object)(object)val); } } SkinnedMeshRenderer[] componentsInChildren2 = value.GetComponentsInChildren(true); SkinnedMeshRenderer[] array2 = componentsInChildren2; foreach (SkinnedMeshRenderer val2 in array2) { if ((Object)(object)val2 != (Object)null) { ((Renderer)val2).enabled = false; val2.sharedMesh = null; val2.bones = (Transform[])(object)new Transform[0]; val2.rootBone = null; Object.Destroy((Object)(object)val2); } } if ((Object)(object)value.transform.parent != (Object)null && ((Object)value.transform.parent).name == "RemoteGliderAttachPoint") { Object.Destroy((Object)(object)((Component)value.transform.parent).gameObject); } else { Object.Destroy((Object)(object)value); } } remotePlayerGliders.Clear(); remotePlayerOriginalControllers.Clear(); } public static void UpdateAllRemotePlayers() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_019e: 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_0160: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ZNet.instance) || ZNet.instance.m_players.Count == 0) { return; } List allPlayers = Player.GetAllPlayers(); int num = 0; foreach (Player item in allPlayers) { if (!((Object)(object)item == (Object)(object)Player.m_localPlayer)) { num++; UpdateRemotePlayerGlider(item); } } List list = new List(); foreach (ZDOID key in remotePlayerGliders.Keys) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ZNetView nview = ((Character)localPlayer).m_nview; if (((nview != null) ? new bool?(nview.IsValid()) : null).GetValueOrDefault() && ((Character)Player.m_localPlayer).m_nview.m_zdo.m_uid == key) { list.Add(key); continue; } } bool flag = false; foreach (Player item2 in allPlayers) { if ((Object)(object)item2 != (Object)(object)Player.m_localPlayer) { ZNetView nview2 = ((Character)item2).m_nview; if (nview2 != null && nview2.IsValid() && ((Character)item2).m_nview.m_zdo.m_uid == key) { flag = true; break; } } } if (!flag) { list.Add(key); } } foreach (ZDOID item3 in list) { if (remotePlayerGliders.TryGetValue(item3, out GameObject value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } remotePlayerGliders.Remove(item3); remotePlayerOriginalControllers.Remove(item3); } } private static bool IsGlideForwardHeld() { return ZInput.GetButton("Forward") || ZInput.GetJoyLeftStickY(true) < -0.5f; } private static bool IsGlideBackwardHeld() { return ZInput.GetButton("Backward") || ZInput.GetJoyLeftStickY(true) > 0.5f; } public static void ResetFlightState(Player player) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) _currentPitch = 0f; _currentRoll = 0f; _pitchVelocity = 0f; _rollVelocity = 0f; if ((Object)(object)player != (Object)null) { _smoothedForward = ((Component)player).transform.forward; _lastPosition = ((Component)player).transform.position; Rigidbody component = ((Component)player).GetComponent(); if ((Object)(object)component != (Object)null) { _smoothedVelocity = component.linearVelocity; } Vector3 localEulerAngles = ((Component)player).transform.localEulerAngles; ((Component)player).transform.localRotation = Quaternion.Euler(0f, localEulerAngles.y, 0f); } _lastUpdateTime = Time.time; } public static void UpdateEyeRotation(Character character) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)character?.m_eye == (Object)null)) { character.m_eye.rotation = Quaternion.LookRotation(_smoothedForward); } } public static void ApplyGlidingPhysics(Player player) { //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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00b7: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) int num = Config.GetCurrentWingsIndex(); if (num <= 0) { return; } Rigidbody component = ((Component)player).GetComponent(); if (!((Object)(object)component == (Object)null)) { Vector3 smoothedForward = _smoothedForward; float num2 = Config.GetWingsForwardSpeed(num); float num3 = Config.GetWingsDescentSpeed(num); bool flag = IsGlideForwardHeld(); bool flag2 = IsGlideBackwardHeld(); if (flag) { num2 *= 1.25f; num3 *= 1.5f; } else if (flag2) { num2 *= 0.45f; num3 *= 0.5f; } Vector3 val = smoothedForward * num2; val.y = num3; float wingsGroundProbeDistance = Config.GetWingsGroundProbeDistance(num); float wingsCushionDescentSpeed = Config.GetWingsCushionDescentSpeed(num); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(((Component)player).transform.position + Vector3.up * 0.2f, Vector3.down, ref val2, wingsGroundProbeDistance, LayerMask.op_Implicit(groundMask), (QueryTriggerInteraction)1)) { val.y = wingsCushionDescentSpeed; } float num4 = 0.15f; _smoothedVelocity = Vector3.Lerp(_smoothedVelocity, val, num4); if (Config.GetWingsUseFallReset(num) && _fiMaxAirAltitude != null) { _fiMaxAirAltitude.SetValue(player, ((Component)player).transform.position.y); } ApplyVisualTilt(player, num, Time.deltaTime); component.linearVelocity = _smoothedVelocity; } } private static void ApplyVisualTilt(Player player, int wingsIndex, float deltaTime) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } Transform transform = ((Component)player).transform; Rigidbody component = ((Component)player).GetComponent(); float num = Time.time - _lastUpdateTime; if (num <= 0f) { num = deltaTime; } _lastUpdateTime = Time.time; GameCamera instance = GameCamera.instance; if ((Object)(object)instance != (Object)null) { Vector3 forward = ((Component)instance).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude > 0.01f) { ((Vector3)(ref forward)).Normalize(); float wingsAirTurnSpeed = Config.GetWingsAirTurnSpeed(wingsIndex); float num2 = wingsAirTurnSpeed * num * 0.02f; _smoothedForward = Vector3.Slerp(_smoothedForward, forward, num2); ((Vector3)(ref _smoothedForward)).Normalize(); } } float num3 = 0f; num3 = ((!((Object)(object)component != (Object)null)) ? ((transform.position.y - _lastPosition.y) / Mathf.Max(num, 0.001f)) : component.linearVelocity.y); _lastPosition = transform.position; float wingsTiltMaxPitch = Config.GetWingsTiltMaxPitch(wingsIndex); float wingsTiltMaxRoll = Config.GetWingsTiltMaxRoll(wingsIndex); float wingsTiltPitchSmoothTime = Config.GetWingsTiltPitchSmoothTime(wingsIndex); float wingsTiltRollSmoothTime = Config.GetWingsTiltRollSmoothTime(wingsIndex); float num4 = 2f; float num5 = Mathf.Clamp((0f - num3) * num4, 0f - wingsTiltMaxPitch, wingsTiltMaxPitch); bool flag = IsGlideForwardHeld(); bool flag2 = IsGlideBackwardHeld(); if (flag) { num5 += 35f; } else if (flag2) { num5 -= 22f; } num5 = Mathf.Clamp(num5, 0f - wingsTiltMaxPitch, wingsTiltMaxPitch); float num6 = 0f; if ((Object)(object)instance != (Object)null) { Vector3 forward2 = ((Component)instance).transform.forward; forward2.y = 0f; ((Vector3)(ref forward2)).Normalize(); Vector3 smoothedForward = _smoothedForward; smoothedForward.y = 0f; ((Vector3)(ref smoothedForward)).Normalize(); float y = Vector3.Cross(smoothedForward, forward2).y; float num7 = Mathf.Clamp(y * 3f, -1f, 1f); num6 = (0f - num7) * wingsTiltMaxRoll; } _currentPitch = Mathf.SmoothDamp(_currentPitch, num5, ref _pitchVelocity, wingsTiltPitchSmoothTime); _currentRoll = Mathf.SmoothDamp(_currentRoll, num6, ref _rollVelocity, wingsTiltRollSmoothTime); if (((Vector3)(ref _smoothedForward)).sqrMagnitude > 0.001f && (Object)(object)component != (Object)null) { Quaternion val = Quaternion.LookRotation(_smoothedForward, Vector3.up); float y2 = ((Quaternion)(ref val)).eulerAngles.y; Quaternion val2 = Quaternion.Euler(_currentPitch, y2, _currentRoll); component.MoveRotation(val2); } } } public class Misc { [HarmonyPatch] public static class AudioPatches { [HarmonyPatch(typeof(AudioMan), "Awake")] [HarmonyPostfix] [UsedImplicitly] private static void AudioMan_Awake_Postfix(AudioMan __instance) { try { AudioMixerGroup[] array = __instance.m_masterMixer.FindMatchingGroups("SFX"); if (array == null || array.Length == 0) { return; } AudioMixerGroup outputAudioMixerGroup = array[0]; GameObject[] array2 = PrefabManager.RegisterAssetBundle("ibicf_bundle").LoadAllAssets(); foreach (GameObject val in array2) { AudioSource[] componentsInChildren = val.GetComponentsInChildren(true); foreach (AudioSource val2 in componentsInChildren) { val2.outputAudioMixerGroup = outputAudioMixerGroup; } } } catch { } } } [HarmonyPatch(typeof(Debug))] internal static class DebugPatch { [HarmonyPatch("Log", new Type[] { typeof(object) })] internal static bool Prefix(object message) { if (message != null && message.ToString().Contains("PlatformUserID")) { return false; } return true; } } } [HarmonyPatch(typeof(ZNetScene), "RemoveObjects")] public class ZNetSceneRemoveObjectsPatch { [HarmonyPrefix] public static bool Prefix(ZNetScene __instance, List currentNearObjects, List currentDistantObjects) { try { if ((Object)(object)__instance == (Object)null || currentNearObjects == null || currentDistantObjects == null || __instance.m_instances == null) { return false; } for (int num = currentNearObjects.Count - 1; num >= 0; num--) { if (currentNearObjects[num] == null) { currentNearObjects.RemoveAt(num); } } for (int num2 = currentDistantObjects.Count - 1; num2 >= 0; num2--) { if (currentDistantObjects[num2] == null) { currentDistantObjects.RemoveAt(num2); } } List list = new List(); foreach (KeyValuePair instance in __instance.m_instances) { try { ZDO key = instance.Key; ZNetView value = instance.Value; if ((Object)(object)value == (Object)null) { list.Add(key); continue; } try { GameObject gameObject = ((Component)value).gameObject; } catch (NullReferenceException) { list.Add(key); } } catch (Exception) { } } foreach (ZDO item in list) { __instance.m_instances.Remove(item); } return true; } catch (Exception) { return false; } } } [HarmonyPatch(typeof(Player), "Update")] public static class Player_Update_Glider_Patch { private static bool wasGliding; private static float updateTimer; private static void Postfix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } bool flag = GliderSystem.IsCurrentlyGliding(); if (flag != wasGliding) { GliderSystem.UpdateGlidingZDO(__instance, flag); wasGliding = flag; GliderSystem.UpdateAllRemotePlayers(); updateTimer = 0f; return; } float num = 0.5f; num = Mathf.Max(0.1f, num); updateTimer += Time.deltaTime; if (!(updateTimer >= num)) { return; } if (flag) { if (updateTimer >= num * 2f) { GliderSystem.UpdateAllRemotePlayers(); updateTimer = 0f; } } else { GliderSystem.UpdateAllRemotePlayers(); updateTimer = 0f; } } } [HarmonyPatch(typeof(Player), "Update")] public static class Player_Update_Patch { private static void Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { GliderSystem.HandleGliding(__instance); } } } [HarmonyPatch(typeof(Player), "SetControls")] public static class Player_SetControls_Patch { private static void Prefix(Player __instance, ref Vector3 movedir, ref bool run, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool block, ref bool blockHold) { //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) if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && GliderSystem.IsCurrentlyGliding()) { movedir = Vector3.zero; run = false; attack = false; attackHold = false; secondaryAttack = false; block = false; blockHold = false; } } } [HarmonyPatch(typeof(Character), "UpdateFlying")] public static class Character_UpdateFlying_Patch { private static bool Prefix(Character __instance, float dt) { //IL_005b: 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) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !GliderSystem.IsCurrentlyGliding()) { return true; } Rigidbody body = __instance.m_body; if ((Object)(object)body != (Object)null) { body.useGravity = false; body.angularVelocity = Vector3.zero; } __instance.m_lastGroundTouch = 0f; __instance.m_maxAirAltitude = ((Component)__instance).transform.position.y; GliderSystem.UpdateEyeRotation(__instance); return false; } } [HarmonyPatch(typeof(Animator), "set_runtimeAnimatorController")] public static class Animator_runtimeAnimatorController_Patch { private static bool Prefix(Animator __instance, RuntimeAnimatorController value) { if (GliderSystem.IsCurrentlyGliding() && (Object)(object)__instance == (Object)(object)((Character)(Player.m_localPlayer?)).m_animator) { int currentWingsIndex = GliderSystem.GetCurrentWingsIndex(); if ((Object)(object)value == (Object)(object)GliderSystem.GetOriginalController() || (Object)(object)value == (Object)(object)GliderSystem.GetGliderController(currentWingsIndex)) { return true; } return false; } return true; } } public static class GliderVisual { private static GameObject? gliderMeshInstance; private static GameObject? gliderAttachPoint; private static string? currentGliderItemName; private static bool isCreatingGlider; public static void ShowGliderMesh(Player player) { if (isCreatingGlider || (Object)(object)player == (Object)null) { return; } isCreatingGlider = true; try { ItemData equippedGliderItem = GetEquippedGliderItem(player); if (equippedGliderItem == null) { return; } GameObject dropPrefab = equippedGliderItem.m_dropPrefab; string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); if (string.IsNullOrEmpty(text)) { return; } int currentWingsIndex = GliderSystem.GetCurrentWingsIndex(); string wingsVisualPrefab = Config.GetWingsVisualPrefab(currentWingsIndex); string text2 = ((!string.IsNullOrEmpty(wingsVisualPrefab)) ? wingsVisualPrefab : text); if (!(currentGliderItemName != text2) && !((Object)(object)gliderMeshInstance == (Object)null) && gliderMeshInstance.activeInHierarchy) { return; } HideGliderMesh(); ZNetScene instance = ZNetScene.instance; GameObject val = ((instance != null) ? instance.GetPrefab(text2) : null); if ((Object)(object)val == (Object)null) { return; } gliderMeshInstance = CreateVisualOnlyGliderMesh(val, text2); if (!((Object)(object)gliderMeshInstance == (Object)null)) { try { Object.DontDestroyOnLoad((Object)(object)gliderMeshInstance); } catch (Exception) { } currentGliderItemName = text2; PositionGliderOnBack(player, gliderMeshInstance); if (!((Object)(object)gliderMeshInstance == (Object)null)) { } } } catch (Exception) { HideGliderMesh(); } finally { isCreatingGlider = false; } } public static bool IsGliderMeshActive() { GameObject? obj = gliderMeshInstance; if (obj == null || !obj.activeInHierarchy) { return false; } MeshRenderer[] componentsInChildren = gliderMeshInstance.GetComponentsInChildren(); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val in array) { if (val != null && ((Renderer)val).enabled) { return true; } } return false; } public static void HideGliderMesh() { try { if ((Object)(object)gliderMeshInstance != (Object)null) { gliderMeshInstance.SetActive(false); ZNetView[] componentsInChildren = gliderMeshInstance.GetComponentsInChildren(true); ZNetView[] array = componentsInChildren; foreach (ZNetView val in array) { if (!((Object)(object)val != (Object)null)) { continue; } try { if ((Object)(object)ZNetScene.instance != (Object)null && val.GetZDO() != null) { ZNetScene.instance.m_instances.Remove(val.GetZDO()); } } catch { } Object.Destroy((Object)(object)val); } Animator[] componentsInChildren2 = gliderMeshInstance.GetComponentsInChildren(true); Animator[] array2 = componentsInChildren2; foreach (Animator val2 in array2) { if ((Object)(object)val2 != (Object)null) { ((Behaviour)val2).enabled = false; val2.runtimeAnimatorController = null; Object.Destroy((Object)(object)val2); } } SkinnedMeshRenderer[] componentsInChildren3 = gliderMeshInstance.GetComponentsInChildren(true); SkinnedMeshRenderer[] array3 = componentsInChildren3; foreach (SkinnedMeshRenderer val3 in array3) { if ((Object)(object)val3 != (Object)null) { ((Renderer)val3).enabled = false; val3.sharedMesh = null; val3.bones = (Transform[])(object)new Transform[0]; val3.rootBone = null; Object.Destroy((Object)(object)val3); } } Object.Destroy((Object)(object)gliderMeshInstance); } if ((Object)(object)gliderAttachPoint != (Object)null) { Object.Destroy((Object)(object)gliderAttachPoint); } } catch (Exception) { } finally { gliderMeshInstance = null; gliderAttachPoint = null; currentGliderItemName = null; } } private static void PositionGliderOnBack(Player player, GameObject gliderMesh) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) if (player == null) { return; } GameObject gameObject = ((Component)player).gameObject; bool? obj; if (gameObject == null) { obj = null; } else { Scene scene = gameObject.scene; obj = ((Scene)(ref scene)).IsValid(); } bool? flag = obj; if (!flag.GetValueOrDefault() || (Object)(object)gliderMesh == (Object)null) { return; } try { gliderAttachPoint = new GameObject("GliderAttachPoint"); gliderAttachPoint.transform.SetParent(((Component)player).transform); int currentWingsIndex = GliderSystem.GetCurrentWingsIndex(); float wingsUpDownOffset = Config.GetWingsUpDownOffset(currentWingsIndex); float wingsLeftRightOffset = Config.GetWingsLeftRightOffset(currentWingsIndex); float wingsForwardBackOffset = Config.GetWingsForwardBackOffset(currentWingsIndex); gliderAttachPoint.transform.localPosition = new Vector3(wingsLeftRightOffset, wingsUpDownOffset, wingsForwardBackOffset); gliderAttachPoint.transform.localRotation = Quaternion.identity; gliderMesh.transform.SetParent(gliderAttachPoint.transform); gliderMesh.transform.localPosition = Vector3.zero; float wingsRotationX = Config.GetWingsRotationX(currentWingsIndex); float wingsRotationY = Config.GetWingsRotationY(currentWingsIndex); float wingsRotationZ = Config.GetWingsRotationZ(currentWingsIndex); gliderMesh.transform.localRotation = Quaternion.Euler(wingsRotationX, wingsRotationY, wingsRotationZ); float wingsScale = Config.GetWingsScale(currentWingsIndex); gliderMesh.transform.localScale = Vector3.one * wingsScale; } catch (Exception) { if ((Object)(object)gliderAttachPoint != (Object)null) { Object.Destroy((Object)(object)gliderAttachPoint); gliderAttachPoint = null; } if ((Object)(object)gliderMesh != (Object)null) { Object.Destroy((Object)(object)gliderMesh); } } } private static GameObject? CreateVisualOnlyGliderMesh(GameObject itemPrefab, string prefabName) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown if ((Object)(object)itemPrefab == (Object)null) { return null; } GameObject val2; if ((Object)(object)itemPrefab.GetComponentInChildren(true) != (Object)null) { Transform val = FindChildByName(itemPrefab.transform, "Visual"); if ((Object)(object)val != (Object)null) { val2 = Object.Instantiate(((Component)val).gameObject); ((Object)val2).name = "VisualGlider_" + prefabName; CleanupNonVisualComponents(val2); } else { val2 = new GameObject("VisualGlider_" + prefabName); CopyVisualComponents(itemPrefab, val2); } } else { val2 = new GameObject("VisualGlider_" + prefabName); CopyVisualComponents(itemPrefab, val2); } return val2; } private static void CleanupNonVisualComponents(GameObject obj) { if ((Object)(object)obj == (Object)null) { return; } ZNetView[] componentsInChildren = obj.GetComponentsInChildren(true); ZNetView[] array = componentsInChildren; foreach (ZNetView val in array) { if (!((Object)(object)val != (Object)null)) { continue; } try { if ((Object)(object)ZNetScene.instance != (Object)null && val.GetZDO() != null) { ZNetScene.instance.m_instances.Remove(val.GetZDO()); } } catch { } } Component[] components = obj.GetComponents(); Component[] array2 = components; foreach (Component val2 in array2) { if (!(val2 is Transform) && !(val2 is MeshFilter) && !(val2 is MeshRenderer) && !(val2 is SkinnedMeshRenderer) && !(val2 is Animator) && !(val2 is ParticleSystem) && !(val2 is ParticleSystemRenderer) && !(val2 is Light) && !(val2 is AudioSource)) { Object.Destroy((Object)(object)val2); } } for (int k = 0; k < obj.transform.childCount; k++) { CleanupNonVisualComponents(((Component)obj.transform.GetChild(k)).gameObject); } } private static void CopyHierarchyAndVisuals(GameObject source, GameObject target) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0066: 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_008a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null || (Object)(object)target == (Object)null) { return; } CopyVisualComponents(source, target); foreach (Transform item in source.transform) { Transform val = item; GameObject val2 = new GameObject(((Object)val).name); val2.transform.SetParent(target.transform); val2.transform.localPosition = val.localPosition; val2.transform.localRotation = val.localRotation; val2.transform.localScale = val.localScale; CopyHierarchyAndVisuals(((Component)val).gameObject, val2); } } private static void CopyVisualComponents(GameObject source, GameObject target) { //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_01ab: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null || (Object)(object)target == (Object)null) { return; } MeshFilter component = source.GetComponent(); if ((Object)(object)((component != null) ? component.sharedMesh : null) != (Object)null) { MeshFilter val = target.GetComponent(); if ((Object)(object)val == (Object)null) { val = target.AddComponent(); } val.sharedMesh = component.sharedMesh; } MeshRenderer component2 = source.GetComponent(); if ((Object)(object)component2 != (Object)null) { MeshRenderer val2 = target.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = target.AddComponent(); } Material[] sharedMaterials = ((Renderer)component2).sharedMaterials; if (sharedMaterials != null && sharedMaterials.Length != 0) { ((Renderer)val2).sharedMaterials = ((Renderer)component2).sharedMaterials; } ((Renderer)val2).shadowCastingMode = ((Renderer)component2).shadowCastingMode; ((Renderer)val2).receiveShadows = ((Renderer)component2).receiveShadows; ((Renderer)val2).lightProbeUsage = ((Renderer)component2).lightProbeUsage; } SkinnedMeshRenderer component3 = source.GetComponent(); if ((Object)(object)component3 != (Object)null) { SkinnedMeshRenderer val3 = target.GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = target.AddComponent(); } val3.sharedMesh = component3.sharedMesh; Material[] sharedMaterials2 = ((Renderer)component3).sharedMaterials; if (sharedMaterials2 != null && sharedMaterials2.Length != 0) { ((Renderer)val3).sharedMaterials = ((Renderer)component3).sharedMaterials; } ((Renderer)val3).shadowCastingMode = ((Renderer)component3).shadowCastingMode; ((Renderer)val3).receiveShadows = ((Renderer)component3).receiveShadows; ((Renderer)val3).lightProbeUsage = ((Renderer)component3).lightProbeUsage; val3.rootBone = component3.rootBone; val3.bones = component3.bones; val3.quality = component3.quality; val3.updateWhenOffscreen = component3.updateWhenOffscreen; } Animator component4 = source.GetComponent(); if ((Object)(object)component4 != (Object)null) { Animator val4 = target.GetComponent(); if ((Object)(object)val4 == (Object)null) { val4 = target.AddComponent(); } val4.runtimeAnimatorController = component4.runtimeAnimatorController; val4.avatar = component4.avatar; val4.applyRootMotion = component4.applyRootMotion; val4.updateMode = component4.updateMode; val4.cullingMode = component4.cullingMode; } for (int i = 0; i < source.transform.childCount; i++) { Transform child = source.transform.GetChild(i); if (HasVisualComponents(((Component)child).gameObject)) { GameObject val5 = new GameObject(((Object)child).name); val5.transform.SetParent(target.transform); val5.transform.localPosition = child.localPosition; val5.transform.localRotation = child.localRotation; val5.transform.localScale = child.localScale; CopyVisualComponents(((Component)child).gameObject, val5); } } } public static Transform FindChildByName(Transform parent, string name) { if ((Object)(object)parent == (Object)null || string.IsNullOrEmpty(name)) { return null; } if (((Object)parent).name.Equals(name, StringComparison.OrdinalIgnoreCase)) { return parent; } for (int i = 0; i < parent.childCount; i++) { Transform child = parent.GetChild(i); Transform val = FindChildByName(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static bool HasVisualComponents(GameObject obj) { if ((Object)(object)obj == (Object)null) { return false; } if ((Object)(object)obj.GetComponent() != (Object)null || (Object)(object)obj.GetComponent() != (Object)null || (Object)(object)obj.GetComponent() != (Object)null || (Object)(object)obj.GetComponent() != (Object)null) { return true; } for (int i = 0; i < obj.transform.childCount; i++) { if (HasVisualComponents(((Component)obj.transform.GetChild(i)).gameObject)) { return true; } } return false; } private static ItemData? GetEquippedGliderItem(Player player) { if ((Object)(object)player == (Object)null) { return null; } var (flag, num) = GliderSystem.GetEquippedWingsConfig(player); if (!flag) { return null; } Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory == null) { return null; } foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem.IsEquipable() && allItem.m_equipped && GliderSystem.IsGliderItem(allItem)) { return allItem; } } return null; } } } namespace PieceManager { [PublicAPI] public static class MaterialReplacer { public enum ShaderType { PieceShader, VegetationShader, RockShader, RugShader, GrassShader, CustomCreature, UseUnityShader } private static readonly Dictionary ObjectToSwap; private static readonly Dictionary OriginalMaterials; private static readonly Dictionary ObjectsForShaderReplace; private static readonly HashSet CachedShaders; private static bool hasRun; static MaterialReplacer() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown CachedShaders = new HashSet(); hasRun = false; OriginalMaterials = new Dictionary(); ObjectToSwap = new Dictionary(); ObjectsForShaderReplace = new Dictionary(); Harmony val = new Harmony("org.bepinex.helpers.PieceManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZoneSystem), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MaterialReplacer), "ReplaceAllMaterialsWithOriginal", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void RegisterGameObjectForShaderSwap(GameObject go, ShaderType type) { if (!ObjectsForShaderReplace.ContainsKey(go)) { ObjectsForShaderReplace.Add(go, type); } } public static void RegisterGameObjectForMatSwap(GameObject go, bool isJotunnMock = false) { if (!((Object)(object)go == (Object)null) && !ObjectToSwap.ContainsKey(go)) { ObjectToSwap.Add(go, isJotunnMock); } } private static void GetAllMaterials() { Material[] array = Resources.FindObjectsOfTypeAll(); foreach (Material val in array) { OriginalMaterials[((Object)val).name] = val; } } [HarmonyPriority(700)] private static void ReplaceAllMaterialsWithOriginal() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType == 4 || hasRun) { return; } if (OriginalMaterials.Count == 0) { GetAllMaterials(); } foreach (KeyValuePair item in ObjectToSwap) { GameObject key = item.Key; bool value = item.Value; ProcessGameObjectMaterials(key, value); } AssetBundle[] array = Resources.FindObjectsOfTypeAll(); AssetBundle[] array2 = array; foreach (AssetBundle val in array2) { IEnumerable enumerable3; try { IEnumerable enumerable2; if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val)) { IEnumerable enumerable = val.LoadAllAssets(); enumerable2 = enumerable; } else { enumerable2 = from shader in ((IEnumerable)val.GetAllAssetNames()).Select((Func)val.LoadAsset) where (Object)(object)shader != (Object)null select shader; } enumerable3 = enumerable2; } catch (Exception) { continue; } if (enumerable3 == null) { continue; } foreach (Shader item2 in enumerable3) { CachedShaders.Add(item2); } } foreach (KeyValuePair item3 in ObjectsForShaderReplace) { GameObject key2 = item3.Key; ShaderType value2 = item3.Value; ProcessGameObjectShaders(key2, value2); } hasRun = true; } private static void ProcessGameObjectMaterials(GameObject go, bool isJotunnMock) { Renderer[] componentsInChildren = go.GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials.Select((Material material) => ((Object)(object)material == (Object)null) ? null : ReplaceMaterial(material, isJotunnMock)).ToArray(); val.sharedMaterials = sharedMaterials; } } private static Material ReplaceMaterial(Material originalMaterial, bool isJotunnMock) { if ((Object)(object)originalMaterial == (Object)null) { return null; } string text = (isJotunnMock ? "JVLmock_" : "_REPLACE_"); if (!((Object)originalMaterial).name.StartsWith(text, StringComparison.Ordinal)) { return originalMaterial; } string text2 = ((Object)originalMaterial).name.Replace(" (Instance)", "").Replace(text, ""); if (OriginalMaterials.TryGetValue(text2, out Material value)) { return value; } Debug.LogWarning((object)("No suitable material found to replace: " + text2)); return originalMaterial; } private static void ProcessGameObjectShaders(GameObject go, ShaderType shaderType) { Renderer[] componentsInChildren = go.GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null) { val2.shader = GetShaderForType(val2.shader, shaderType, ((Object)val2.shader).name); } } } } private static Shader GetShaderForType(Shader orig, ShaderType shaderType, string originalShaderName) { return (Shader)(shaderType switch { ShaderType.PieceShader => FindShaderWithName(orig, "Custom/Piece"), ShaderType.VegetationShader => FindShaderWithName(orig, "Custom/Vegetation"), ShaderType.RockShader => FindShaderWithName(orig, "Custom/StaticRock"), ShaderType.RugShader => FindShaderWithName(orig, "Custom/Rug"), ShaderType.GrassShader => FindShaderWithName(orig, "Custom/Grass"), ShaderType.CustomCreature => FindShaderWithName(orig, "Custom/Creature"), ShaderType.UseUnityShader => FindShaderWithName(orig, ((Object)(object)FindShaderWithName(orig, originalShaderName) != (Object)null) ? originalShaderName : "ToonDeferredShading2017"), _ => FindShaderWithName(orig, "Standard"), }); } public static Shader FindShaderWithName(Shader origShader, string name) { foreach (Shader cachedShader in CachedShaders) { if (((Object)cachedShader).name == name) { return cachedShader; } } return origShader; } } [PublicAPI] public enum CraftingTable { None, [InternalName("piece_workbench")] Workbench, [InternalName("piece_cauldron")] Cauldron, [InternalName("forge")] Forge, [InternalName("piece_artisanstation")] ArtisanTable, [InternalName("piece_stonecutter")] StoneCutter, [InternalName("piece_magetable")] MageTable, [InternalName("blackforge")] BlackForge, [InternalName("piece_preptable")] FoodPreparationTable, [InternalName("piece_MeadCauldron")] MeadKetill, Custom } public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [PublicAPI] public class ExtensionList { public readonly List ExtensionStations = new List(); public void Set(CraftingTable table, int maxStationDistance = 5) { ExtensionStations.Add(new ExtensionConfig { Table = table, maxStationDistance = maxStationDistance }); } public void Set(string customTable, int maxStationDistance = 5) { ExtensionStations.Add(new ExtensionConfig { Table = CraftingTable.Custom, custom = customTable, maxStationDistance = maxStationDistance }); } } public struct ExtensionConfig { public CraftingTable Table; public float maxStationDistance; public string? custom; } [PublicAPI] public class CraftingStationList { public readonly List Stations = new List(); public void Set(CraftingTable table) { Stations.Add(new CraftingStationConfig { Table = table }); } public void Set(string customTable) { Stations.Add(new CraftingStationConfig { Table = CraftingTable.Custom, custom = customTable }); } } public struct CraftingStationConfig { public CraftingTable Table; public int level; public string? custom; } [PublicAPI] public enum BuildPieceCategory { Misc = 0, Crafting = 1, BuildingWorkbench = 2, BuildingStonecutter = 3, Furniture = 4, All = 100, Custom = 99 } [PublicAPI] public class RequiredResourcesList { public readonly List Requirements = new List(); public void Add(string item, int amount, bool recover) { Requirements.Add(new Requirement { itemName = item, amount = amount, recover = recover }); } } public struct Requirement { public string itemName; public int amount; public bool recover; } public struct SpecialProperties { [Description("Admins should be the only ones that can build this piece.")] public bool AdminOnly; [Description("Turns off generating a config for this build piece.")] public bool NoConfig; } [PublicAPI] public class BuildingPieceCategory { public BuildPieceCategory Category; public string custom = ""; public void Set(BuildPieceCategory category) { Category = category; } public void Set(string customCategory) { Category = BuildPieceCategory.Custom; custom = customCategory; } } [PublicAPI] public class PieceTool { public readonly HashSet Tools = new HashSet(); public void Add(string tool) { Tools.Add(tool); } } [PublicAPI] public class BuildPiece { internal class PieceConfig { public ConfigEntry craft = null; public ConfigEntry category = null; public ConfigEntry customCategory = null; public ConfigEntry tools = null; public ConfigEntry extensionTable = null; public ConfigEntry customExtentionTable = null; public ConfigEntry maxStationDistance = null; public ConfigEntry table = null; public ConfigEntry customTable = null; } private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string? Category; [UsedImplicitly] public Action? CustomDrawer; } private class SerializedRequirements { public readonly List Reqs; public SerializedRequirements(List reqs) { Reqs = reqs; } public SerializedRequirements(string reqs) { Reqs = reqs.Split(new char[1] { ',' }).Select(delegate(string r) { string[] array = r.Split(new char[1] { ':' }); Requirement result = default(Requirement); result.itemName = array[0]; result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2); bool result3 = default(bool); result.recover = array.Length <= 2 || !bool.TryParse(array[2], out result3) || result3; return result; }).ToList(); } public override string ToString() { return string.Join(",", Reqs.Select((Requirement r) => $"{r.itemName}:{r.amount}:{r.recover}")); } public static ItemDrop? fetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)(((!string.IsNullOrWhiteSpace(((Object)plugin).name)) ? ("[" + ((Object)plugin).name + "]") : "") + " The required item '" + name + "' does not exist.")); } return val; } public static Requirement[] toPieceReqs(SerializedRequirements craft) { Dictionary dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func)((Requirement r) => r.itemName), (Func)delegate(Requirement r) { //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_001e: 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) ItemDrop val = ResItem(r); return (val == null) ? ((Requirement)null) : new Requirement { m_amount = r.amount, m_resItem = val, m_recover = r.recover }; }); return dictionary.Values.Where((Requirement v) => v != null).ToArray(); static ItemDrop? ResItem(Requirement r) { return fetchByName(ObjectDB.instance, r.itemName); } } } internal static readonly List registeredPieces = new List(); private static readonly Dictionary pieceMap = new Dictionary(); internal static Dictionary pieceConfigs = new Dictionary(); internal List Conversions = new List(); internal List conversions = new List(); [Description("Disables generation of the configs for your pieces. This is global, this turns it off for all pieces in your mod.")] public static bool ConfigurationEnabled = true; public readonly GameObject Prefab; [Description("Specifies the resources needed to craft the piece.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the building piece should need.")] public readonly RequiredResourcesList RequiredItems = new RequiredResourcesList(); [Description("Sets the category for the building piece.")] public readonly BuildingPieceCategory Category = new BuildingPieceCategory(); [Description("Specifies the tool needed to build your piece.\nUse .Add to add a tool.")] public readonly PieceTool Tool = new PieceTool(); [Description("Specifies the crafting station needed to build your piece.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.")] public CraftingStationList Crafting = new CraftingStationList(); [Description("Makes this piece a station extension")] public ExtensionList Extension = new ExtensionList(); [Description("Change the extended/special properties of your build piece.")] public SpecialProperties SpecialProperties; [Description("Specifies a config entry which toggles whether a recipe is active.")] public ConfigEntryBase? RecipeIsActive = null; private LocalizeKey? _name; private LocalizeKey? _description; internal string[] activeTools = null; private static object? configManager; private static Localization? _english; internal static BaseUnityPlugin? _plugin = null; private static bool hasConfigSync = true; private static object? _configSync; public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } Piece component = Prefab.GetComponent(); if (component.m_name.StartsWith("$")) { _name = new LocalizeKey(component.m_name); } else { string text = "$piece_" + ((Object)Prefab).name.Replace(" ", "_"); _name = new LocalizeKey(text).English(component.m_name); component.m_name = text; } return _name; } } public LocalizeKey Description { get { LocalizeKey description = _description; if (description != null) { return description; } Piece component = Prefab.GetComponent(); if (component.m_description.StartsWith("$")) { _description = new LocalizeKey(component.m_description); } else { string text = "$piece_" + ((Object)Prefab).name.Replace(" ", "_") + "_description"; _description = new LocalizeKey(text).English(component.m_description); component.m_description = text; } return _description; } } private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); internal static BaseUnityPlugin plugin { get { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown if (_plugin != null) { return _plugin; } IEnumerable source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); return _plugin; } } private static object? configSync { get { if (_configSync != null || !hasConfigSync) { return _configSync; } Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " PieceManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } return _configSync; } } public BuildPiece(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PiecePrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public BuildPiece(AssetBundle bundle, string prefabName) { Prefab = PiecePrefabManager.RegisterPrefab(bundle, prefabName); registeredPieces.Add(this); } internal static void Patch_FejdStartup(FejdStartup __instance) { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Expected O, but got Unknown //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Expected O, but got Unknown //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Expected O, but got Unknown //IL_08ea: Unknown result type (might be due to invalid IL or missing references) //IL_08f4: Expected O, but got Unknown //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Expected O, but got Unknown //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Expected O, but got Unknown //IL_095f: Unknown result type (might be due to invalid IL or missing references) //IL_0969: Expected O, but got Unknown //IL_0b7e: Unknown result type (might be due to invalid IL or missing references) //IL_0b88: Expected O, but got Unknown //IL_0c18: Unknown result type (might be due to invalid IL or missing references) //IL_0c22: Expected O, but got Unknown Type configManagerType = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); configManager = ((configManagerType == null) ? null : Chainloader.ManagerObject.GetComponent(configManagerType)); foreach (BuildPiece registeredPiece in registeredPieces) { registeredPiece.activeTools = registeredPiece.Tool.Tools.DefaultIfEmpty("Hammer").ToArray(); if (registeredPiece.Category.Category != BuildPieceCategory.Custom) { registeredPiece.Prefab.GetComponent().m_category = (PieceCategory)registeredPiece.Category.Category; } else { registeredPiece.Prefab.GetComponent().m_category = PiecePrefabManager.GetCategory(registeredPiece.Category.custom); } } if (!ConfigurationEnabled) { return; } bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (BuildPiece registeredPiece2 in registeredPieces) { BuildPiece piece = registeredPiece2; if (piece.SpecialProperties.NoConfig) { continue; } PieceConfig pieceConfig2 = (pieceConfigs[piece] = new PieceConfig()); PieceConfig cfg = pieceConfig2; Piece piecePrefab2 = piece.Prefab.GetComponent(); string pieceName = piecePrefab2.m_name; string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(pieceName), "").Trim(); string localizedName = Localization.instance.Localize(pieceName).Trim(); int order = 0; cfg.category = config(englishName, "Build Table Category", piece.Category.Category, new ConfigDescription("Build Category where " + localizedName + " is available.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Category = localizedName } })); ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = (cfg.category.Value == BuildPieceCategory.Custom), Category = localizedName }; cfg.customCategory = config(englishName, "Custom Build Category", piece.Category.custom, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.category.SettingChanged += BuildTableConfigChanged; cfg.customCategory.SettingChanged += BuildTableConfigChanged; if (cfg.category.Value == BuildPieceCategory.Custom) { piecePrefab2.m_category = PiecePrefabManager.GetCategory(cfg.customCategory.Value); } else { piecePrefab2.m_category = (PieceCategory)cfg.category.Value; } cfg.tools = config(englishName, "Tools", string.Join(", ", piece.activeTools), new ConfigDescription("Comma separated list of tools where " + localizedName + " is available.", (AcceptableValueBase)null, new object[1] { customTableAttributes })); piece.activeTools = (from s in cfg.tools.Value.Split(new char[1] { ',' }) select s.Trim()).ToArray(); cfg.tools.SettingChanged += delegate { Inventory[] source = (from c in Player.s_players.Select((Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType() select c.GetInventory()) where c != null select c).ToArray(); Dictionary> dictionary = (from kv in (from i in (from p in ObjectDB.instance.m_items select p.GetComponent() into c where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent()) select c).Concat(ItemDrop.s_instances) select new KeyValuePair(Utils.GetPrefabName(((Component)i).gameObject), i.m_itemData)).Concat(from i in source.SelectMany((Inventory i) => i.GetAllItems()) select new KeyValuePair(((Object)i.m_dropPrefab).name, i)) where Object.op_Implicit((Object)(object)kv.Value.m_shared.m_buildPieces) group kv by kv.Key).ToDictionary((IGrouping> g) => g.Key, (IGrouping> g) => g.Select((KeyValuePair kv) => kv.Value.m_shared.m_buildPieces).Distinct().ToList()); string[] array5 = piece.activeTools; foreach (string key in array5) { if (dictionary.TryGetValue(key, out var value3)) { foreach (PieceTable item3 in value3) { item3.m_pieces.Remove(piece.Prefab); } } } piece.activeTools = (from s in cfg.tools.Value.Split(new char[1] { ',' }) select s.Trim()).ToArray(); if (Object.op_Implicit((Object)(object)ObjectDB.instance)) { string[] array6 = piece.activeTools; foreach (string key2 in array6) { if (dictionary.TryGetValue(key2, out var value4)) { foreach (PieceTable item4 in value4) { if (!item4.m_pieces.Contains(piece.Prefab)) { item4.m_pieces.Add(piece.Prefab); } } } } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { PiecePrefabManager.CategoryRefreshNeeded = true; ((Humanoid)Player.m_localPlayer).SetPlaceMode(Player.m_localPlayer.m_buildPieces); } } }; StationExtension pieceExtensionComp; List hideWhenNoneAttributes2; if (piece.Extension.ExtensionStations.Count > 0) { pieceExtensionComp = piece.Prefab.GetOrAddComponent(); PieceConfig pieceConfig3 = cfg; string group = englishName; CraftingTable table = piece.Extension.ExtensionStations.First().Table; string text = "Crafting station that " + localizedName + " extends."; object[] array = new object[1]; ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes(); int num = order - 1; order = num; configurationManagerAttributes.Order = num; array[0] = configurationManagerAttributes; pieceConfig3.extensionTable = config(group, "Extends Station", table, new ConfigDescription(text, (AcceptableValueBase)null, array)); cfg.customExtentionTable = config(englishName, "Custom Extend Station", piece.Extension.ExtensionStations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); PieceConfig pieceConfig4 = cfg; string group2 = englishName; float maxStationDistance = piece.Extension.ExtensionStations.First().maxStationDistance; string text2 = "Distance from the station that " + localizedName + " can be placed."; object[] array2 = new object[1]; ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes(); num = order - 1; order = num; configurationManagerAttributes2.Order = num; array2[0] = configurationManagerAttributes2; pieceConfig4.maxStationDistance = config(group2, "Max Station Distance", maxStationDistance, new ConfigDescription(text2, (AcceptableValueBase)null, array2)); hideWhenNoneAttributes2 = new List(); cfg.extensionTable.SettingChanged += ExtensionTableConfigChanged; cfg.customExtentionTable.SettingChanged += ExtensionTableConfigChanged; cfg.maxStationDistance.SettingChanged += ExtensionTableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes(); num = order - 1; order = num; configurationManagerAttributes3.Order = num; configurationManagerAttributes3.Browsable = cfg.extensionTable.Value != CraftingTable.None; ConfigurationManagerAttributes item = configurationManagerAttributes3; hideWhenNoneAttributes2.Add(item); } List hideWhenNoneAttributes; if (piece.Crafting.Stations.Count > 0) { hideWhenNoneAttributes = new List(); PieceConfig pieceConfig5 = cfg; string group3 = englishName; CraftingTable table2 = piece.Crafting.Stations.First().Table; string text3 = "Crafting station where " + localizedName + " is available."; object[] array3 = new object[1]; ConfigurationManagerAttributes configurationManagerAttributes4 = new ConfigurationManagerAttributes(); int num = order - 1; order = num; configurationManagerAttributes4.Order = num; array3[0] = configurationManagerAttributes4; pieceConfig5.table = config(group3, "Crafting Station", table2, new ConfigDescription(text3, (AcceptableValueBase)null, array3)); cfg.customTable = config(englishName, "Custom Crafting Station", piece.Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.table.SettingChanged += TableConfigChanged; cfg.customTable.SettingChanged += TableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes5 = new ConfigurationManagerAttributes(); num = order - 1; order = num; configurationManagerAttributes5.Order = num; configurationManagerAttributes5.Browsable = cfg.table.Value != CraftingTable.None; ConfigurationManagerAttributes item2 = configurationManagerAttributes5; hideWhenNoneAttributes.Add(item2); } cfg.craft = itemConfig("Crafting Costs", new SerializedRequirements(piece.RequiredItems.Requirements).ToString(), "Item costs to craft " + localizedName); cfg.craft.SettingChanged += delegate { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && (Object)(object)ObjectDB.instance.GetItemPrefab("YmirRemains") != (Object)null) { Requirement[] resources = SerializedRequirements.toPieceReqs(new SerializedRequirements(cfg.craft.Value)); piecePrefab2.m_resources = resources; Piece[] array4 = Object.FindObjectsOfType(); foreach (Piece val in array4) { if (val.m_name == pieceName) { val.m_resources = resources; } } } }; for (int j = 0; j < piece.Conversions.Count; j++) { string text4 = ((piece.Conversions.Count > 1) ? $"{j + 1}. " : ""); Conversion conversion = piece.Conversions[j]; conversion.config = new Conversion.ConversionConfig(); int index = j; conversion.config.input = config(englishName, text4 + "Conversion Input Item", conversion.Input, new ConfigDescription("Conversion input item within " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName } })); conversion.config.input.SettingChanged += delegate { if (index < piece.conversions.Count) { ObjectDB instance2 = ObjectDB.instance; if (instance2 != null) { ItemDrop from = SerializedRequirements.fetchByName(instance2, conversion.config.input.Value); piece.conversions[index].m_from = from; } } }; conversion.config.output = config(englishName, text4 + "Conversion Output Item", conversion.Output, new ConfigDescription("Conversion output item within " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName } })); conversion.config.output.SettingChanged += delegate { if (index < piece.conversions.Count) { ObjectDB instance = ObjectDB.instance; if (instance != null) { ItemDrop to = SerializedRequirements.fetchByName(instance, conversion.config.output.Value); piece.conversions[index].m_to = to; } } }; } void BuildTableConfigChanged(object o, EventArgs e) { //IL_0066: 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_0047: Unknown result type (might be due to invalid IL or missing references) if (registeredPieces.Count > 0) { if (cfg.category.Value == BuildPieceCategory.Custom) { piecePrefab2.m_category = PiecePrefabManager.GetCategory(cfg.customCategory.Value); } else { piecePrefab2.m_category = (PieceCategory)cfg.category.Value; } if (Object.op_Implicit((Object)(object)Hud.instance)) { PiecePrefabManager.CategoryRefreshNeeded = true; PiecePrefabManager.CreateCategoryTabs(); } } customTableAttributes.Browsable = cfg.category.Value == BuildPieceCategory.Custom; ReloadConfigDisplay(); } void ExtensionTableConfigChanged(object o, EventArgs e) { if (piece.RequiredItems.Requirements.Count > 0) { CraftingTable value2 = cfg.extensionTable.Value; CraftingTable craftingTable = value2; if (craftingTable == CraftingTable.Custom) { StationExtension obj2 = pieceExtensionComp; GameObject prefab2 = ZNetScene.instance.GetPrefab(cfg.customExtentionTable.Value); obj2.m_craftingStation = ((prefab2 != null) ? prefab2.GetComponent() : null); } else { pieceExtensionComp.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.extensionTable.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); } pieceExtensionComp.m_maxStationDistance = cfg.maxStationDistance.Value; } customTableAttributes.Browsable = cfg.extensionTable.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item5 in hideWhenNoneAttributes2) { item5.Browsable = cfg.extensionTable.Value != CraftingTable.None; } ReloadConfigDisplay(); plugin.Config.Save(); } void TableConfigChanged(object o, EventArgs e) { if (piece.RequiredItems.Requirements.Count > 0) { switch (cfg.table.Value) { case CraftingTable.None: piecePrefab2.m_craftingStation = null; break; case CraftingTable.Custom: { Piece obj = piecePrefab2; GameObject prefab = ZNetScene.instance.GetPrefab(cfg.customTable.Value); obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent() : null); break; } default: piecePrefab2.m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(cfg.table.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); break; } } customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item6 in hideWhenNoneAttributes) { item6.Browsable = cfg.table.Value != CraftingTable.None; } ReloadConfigDisplay(); plugin.Config.Save(); } ConfigEntry itemConfig(string name, string value, string desc) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes6 = new ConfigurationManagerAttributes { CustomDrawer = DrawConfigTable, Order = (order -= 1), Category = localizedName }; return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes6 })); } } foreach (BuildPiece registeredPiece3 in registeredPieces) { ConfigEntryBase enabledCfg = registeredPiece3.RecipeIsActive; Piece piecePrefab; if (enabledCfg != null) { piecePrefab = registeredPiece3.Prefab.GetComponent(); ConfigChanged(null, null); ((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged)); } registeredPiece3.InitializeNewRegisteredPiece(registeredPiece3); void ConfigChanged(object? o, EventArgs? e) { piecePrefab.m_enabled = (int)enabledCfg.BoxedValue != 0; } } if (saveOnConfigSet) { plugin.Config.SaveOnConfigSet = true; plugin.Config.Save(); } void ReloadConfigDisplay() { object obj3 = configManagerType?.GetProperty("DisplayingWindow").GetValue(configManager); if (obj3 is bool && (bool)obj3) { configManagerType.GetMethod("BuildSettingList").Invoke(configManager, Array.Empty()); } } } private void InitializeNewRegisteredPiece(BuildPiece piece) { ConfigEntryBase recipeIsActive = piece.RecipeIsActive; PieceConfig cfg; Piece piecePrefab; string pieceName; if (recipeIsActive != null) { pieceConfigs.TryGetValue(piece, out cfg); piecePrefab = piece.Prefab.GetComponent(); pieceName = piecePrefab.m_name; ((object)recipeIsActive).GetType().GetEvent("SettingChanged").AddEventHandler(recipeIsActive, new EventHandler(ConfigChanged)); } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && (Object)(object)ObjectDB.instance.GetItemPrefab("YmirRemains") != (Object)null && cfg != null) { Requirement[] resources = SerializedRequirements.toPieceReqs(new SerializedRequirements(cfg.craft.Value)); piecePrefab.m_resources = resources; Piece[] array = Object.FindObjectsOfType(); foreach (Piece val in array) { if (val.m_name == pieceName) { val.m_resources = resources; } } } } } [HarmonyPriority(700)] internal static void Patch_ObjectDBInit(ObjectDB __instance) { //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Expected O, but got Unknown if ((Object)(object)__instance.GetItemPrefab("YmirRemains") == (Object)null) { return; } foreach (BuildPiece registeredPiece in registeredPieces) { pieceConfigs.TryGetValue(registeredPiece, out PieceConfig value); registeredPiece.Prefab.GetComponent().m_resources = SerializedRequirements.toPieceReqs((value == null) ? new SerializedRequirements(registeredPiece.RequiredItems.Requirements) : new SerializedRequirements(value.craft.Value)); foreach (ExtensionConfig extensionStation in registeredPiece.Extension.ExtensionStations) { switch ((value == null || registeredPiece.Extension.ExtensionStations.Count > 1) ? extensionStation.Table : value.extensionTable.Value) { case CraftingTable.None: registeredPiece.Prefab.GetComponent().m_craftingStation = null; break; case CraftingTable.Custom: { GameObject prefab = ZNetScene.instance.GetPrefab((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.custom : value.customExtentionTable.Value); if (prefab != null) { registeredPiece.Prefab.GetComponent().m_craftingStation = prefab.GetComponent(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((value == null || registeredPiece.Extension.ExtensionStations.Count > 0) ? extensionStation.custom : value.customExtentionTable.Value) + "' does not exist")); } break; } default: if (value != null && value.table.Value == CraftingTable.None) { registeredPiece.Prefab.GetComponent().m_craftingStation = null; } else { registeredPiece.Prefab.GetComponent().m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(((value == null || registeredPiece.Extension.ExtensionStations.Count > 1) ? extensionStation.Table : value.extensionTable.Value).ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); } break; } } foreach (CraftingStationConfig station in registeredPiece.Crafting.Stations) { switch ((value == null || registeredPiece.Crafting.Stations.Count > 1) ? station.Table : value.table.Value) { case CraftingTable.None: registeredPiece.Prefab.GetComponent().m_craftingStation = null; break; case CraftingTable.Custom: { GameObject prefab2 = ZNetScene.instance.GetPrefab((value == null || registeredPiece.Crafting.Stations.Count > 0) ? station.custom : value.customTable.Value); if (prefab2 != null) { registeredPiece.Prefab.GetComponent().m_craftingStation = prefab2.GetComponent(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((value == null || registeredPiece.Crafting.Stations.Count > 0) ? station.custom : value.customTable.Value) + "' does not exist")); } break; } default: if (value != null && value.table.Value == CraftingTable.None) { registeredPiece.Prefab.GetComponent().m_craftingStation = null; } else { registeredPiece.Prefab.GetComponent().m_craftingStation = ZNetScene.instance.GetPrefab(((InternalName)typeof(CraftingTable).GetMember(((value == null || registeredPiece.Crafting.Stations.Count > 1) ? station.Table : value.table.Value).ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName).GetComponent(); } break; } } registeredPiece.conversions = new List(); for (int i = 0; i < registeredPiece.Conversions.Count; i++) { Conversion conversion = registeredPiece.Conversions[i]; registeredPiece.conversions.Add(new ItemConversion { m_from = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.input.Value ?? conversion.Input), m_to = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.output.Value ?? conversion.Output) }); if (registeredPiece.conversions[i].m_from != null && registeredPiece.conversions[i].m_to != null) { registeredPiece.Prefab.GetComponent().m_conversion.Add(registeredPiece.conversions[i]); } } } } public void Snapshot(float lightIntensity = 1.3f, Quaternion? cameraRotation = null) { SnapshotPiece(Prefab, lightIntensity, cameraRotation); } internal void SnapshotPiece(GameObject prefab, float lightIntensity = 1.3f, Quaternion? cameraRotation = null) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0210: 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) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0250: 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_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Expected O, but got Unknown //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab == (Object)null) && (prefab.GetComponentsInChildren().Any() || prefab.GetComponentsInChildren().Any())) { Camera component = new GameObject("CameraIcon", new Type[1] { typeof(Camera) }).GetComponent(); component.backgroundColor = Color.clear; component.clearFlags = (CameraClearFlags)2; ((Component)component).transform.position = new Vector3(10000f, 10000f, 10000f); ((Component)component).transform.rotation = (Quaternion)(((??)cameraRotation) ?? Quaternion.Euler(0f, 180f, 0f)); component.fieldOfView = 0.5f; component.farClipPlane = 100000f; component.cullingMask = 8; Light component2 = new GameObject("LightIcon", new Type[1] { typeof(Light) }).GetComponent(); ((Component)component2).transform.position = new Vector3(10000f, 10000f, 10000f); ((Component)component2).transform.rotation = Quaternion.Euler(5f, 180f, 5f); component2.type = (LightType)1; component2.cullingMask = 8; component2.intensity = lightIntensity; GameObject val = Object.Instantiate(prefab); Transform[] componentsInChildren = val.GetComponentsInChildren(); foreach (Transform val2 in componentsInChildren) { ((Component)val2).gameObject.layer = 3; } val.transform.position = Vector3.zero; val.transform.rotation = Quaternion.Euler(23f, 51f, 25.8f); ((Object)val).name = ((Object)prefab).name; MeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren(); Vector3 val3 = componentsInChildren2.Aggregate(Vector3.positiveInfinity, delegate(Vector3 cur, MeshRenderer renderer) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) Bounds bounds2 = ((Renderer)renderer).bounds; return Vector3.Min(cur, ((Bounds)(ref bounds2)).min); }); Vector3 val4 = componentsInChildren2.Aggregate(Vector3.negativeInfinity, delegate(Vector3 cur, MeshRenderer renderer) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) Bounds bounds = ((Renderer)renderer).bounds; return Vector3.Max(cur, ((Bounds)(ref bounds)).max); }); val.transform.position = new Vector3(10000f, 10000f, 10000f) - (val3 + val4) / 2f; Vector3 val5 = val4 - val3; TimedDestruction val6 = val.AddComponent(); val6.Trigger(1f); Rect val7 = default(Rect); ((Rect)(ref val7))..ctor(0f, 0f, 128f, 128f); component.targetTexture = RenderTexture.GetTemporary((int)((Rect)(ref val7)).width, (int)((Rect)(ref val7)).height); component.fieldOfView = 20f; float num = Mathf.Max(val5.x, val5.y) + 0.1f; float num2 = num / Mathf.Tan(component.fieldOfView * ((float)Math.PI / 180f)) * 1.1f; ((Component)component).transform.position = new Vector3(10000f, 10000f, 10000f) + new Vector3(0f, 0f, num2); component.Render(); RenderTexture active = RenderTexture.active; RenderTexture.active = component.targetTexture; Texture2D val8 = new Texture2D((int)((Rect)(ref val7)).width, (int)((Rect)(ref val7)).height, (TextureFormat)4, false); val8.ReadPixels(new Rect(0f, 0f, (float)(int)((Rect)(ref val7)).width, (float)(int)((Rect)(ref val7)).height), 0, 0); val8.Apply(); RenderTexture.active = active; prefab.GetComponent().m_icon = Sprite.Create(val8, new Rect(0f, 0f, (float)(int)((Rect)(ref val7)).width, (float)(int)((Rect)(ref val7)).height), Vector2.one / 2f); ((Component)component2).gameObject.SetActive(false); component.targetTexture.Release(); ((Component)component).gameObject.SetActive(false); val.SetActive(false); Object.DestroyImmediate((Object)(object)val); Object.Destroy((Object)(object)component); Object.Destroy((Object)(object)component2); Object.Destroy((Object)(object)((Component)component).gameObject); Object.Destroy((Object)(object)((Component)component2).gameObject); } } private static void DrawConfigTable(ConfigEntryBase cfg) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select((object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault(); List list = new List(); bool flag = false; int num = (int)(configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true) .Invoke(configManager, Array.Empty()) ?? ((object)130)); GUILayout.BeginVertical(Array.Empty()); foreach (Requirement req in new SerializedRequirements((string)cfg.BoxedValue).Reqs) { GUILayout.BeginHorizontal(Array.Empty()); int num2 = req.amount; if (int.TryParse(GUILayout.TextField(num2.ToString(), new GUIStyle(GUI.skin.textField) { fixedWidth = 40f }, Array.Empty()), out var result) && result != num2 && !valueOrDefault) { num2 = result; flag = true; } string text = GUILayout.TextField(req.itemName, new GUIStyle(GUI.skin.textField) { fixedWidth = num - 40 - 67 - 21 - 21 - 12 }, Array.Empty()); string text2 = (valueOrDefault ? req.itemName : text); flag = flag || text2 != req.itemName; bool flag2 = req.recover; if (GUILayout.Toggle(req.recover, "Recover", new GUIStyle(GUI.skin.toggle) { fixedWidth = 67f }, Array.Empty()) != req.recover) { flag2 = !flag2; flag = true; } if (GUILayout.Button("x", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault) { flag = true; } else { list.Add(new Requirement { amount = num2, itemName = text2, recover = flag2 }); } if (GUILayout.Button("+", new GUIStyle(GUI.skin.button) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault) { flag = true; list.Add(new Requirement { amount = 1, itemName = "", recover = false }); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = new SerializedRequirements(list).ToString(); } } private static ConfigEntry config(string group, string name, T value, ConfigDescription description) { ConfigEntry val = plugin.Config.Bind(group, name, value, description); configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T)) .Invoke(configSync, new object[1] { val }); return val; } private static ConfigEntry config(string group, string name, T value, string description) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty())); } } public static class GoExtensions { public static T GetOrAddComponent(this GameObject gameObject) where T : Component { return gameObject.GetComponent() ?? gameObject.AddComponent(); } } [PublicAPI] public class LocalizeKey { private static readonly List keys = new List(); public readonly string Key; public readonly Dictionary Localizations = new Dictionary(); public LocalizeKey(string key) { Key = key.Replace("$", ""); keys.Add(this); } public void Alias(string alias) { Localizations.Clear(); if (!alias.Contains("$")) { alias = "$" + alias; } Localizations["alias"] = alias; if (Localization.m_instance != null) { Localization.instance.AddWord(Key, Localization.instance.Localize(alias)); } } public LocalizeKey English(string key) { return addForLang("English", key); } public LocalizeKey Swedish(string key) { return addForLang("Swedish", key); } public LocalizeKey French(string key) { return addForLang("French", key); } public LocalizeKey Italian(string key) { return addForLang("Italian", key); } public LocalizeKey German(string key) { return addForLang("German", key); } public LocalizeKey Spanish(string key) { return addForLang("Spanish", key); } public LocalizeKey Russian(string key) { return addForLang("Russian", key); } public LocalizeKey Romanian(string key) { return addForLang("Romanian", key); } public LocalizeKey Bulgarian(string key) { return addForLang("Bulgarian", key); } public LocalizeKey Macedonian(string key) { return addForLang("Macedonian", key); } public LocalizeKey Finnish(string key) { return addForLang("Finnish", key); } public LocalizeKey Danish(string key) { return addForLang("Danish", key); } public LocalizeKey Norwegian(string key) { return addForLang("Norwegian", key); } public LocalizeKey Icelandic(string key) { return addForLang("Icelandic", key); } public LocalizeKey Turkish(string key) { return addForLang("Turkish", key); } public LocalizeKey Lithuanian(string key) { return addForLang("Lithuanian", key); } public LocalizeKey Czech(string key) { return addForLang("Czech", key); } public LocalizeKey Hungarian(string key) { return addForLang("Hungarian", key); } public LocalizeKey Slovak(string key) { return addForLang("Slovak", key); } public LocalizeKey Polish(string key) { return addForLang("Polish", key); } public LocalizeKey Dutch(string key) { return addForLang("Dutch", key); } public LocalizeKey Portuguese_European(string key) { return addForLang("Portuguese_European", key); } public LocalizeKey Portuguese_Brazilian(string key) { return addForLang("Portuguese_Brazilian", key); } public LocalizeKey Chinese(string key) { return addForLang("Chinese", key); } public LocalizeKey Japanese(string key) { return addForLang("Japanese", key); } public LocalizeKey Korean(string key) { return addForLang("Korean", key); } public LocalizeKey Hindi(string key) { return addForLang("Hindi", key); } public LocalizeKey Thai(string key) { return addForLang("Thai", key); } public LocalizeKey Abenaki(string key) { return addForLang("Abenaki", key); } public LocalizeKey Croatian(string key) { return addForLang("Croatian", key); } public LocalizeKey Georgian(string key) { return addForLang("Georgian", key); } public LocalizeKey Greek(string key) { return addForLang("Greek", key); } public LocalizeKey Serbian(string key) { return addForLang("Serbian", key); } public LocalizeKey Ukrainian(string key) { return addForLang("Ukrainian", key); } private LocalizeKey addForLang(string lang, string value) { Localizations[lang] = value; if (Localization.m_instance != null) { if (Localization.instance.GetSelectedLanguage() == lang) { Localization.instance.AddWord(Key, value); } else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key)) { Localization.instance.AddWord(Key, value); } } return this; } [HarmonyPriority(300)] internal static void AddLocalizedKeys(Localization __instance, string language) { foreach (LocalizeKey key in keys) { string value2; if (key.Localizations.TryGetValue(language, out string value) || key.Localizations.TryGetValue("English", out value)) { __instance.AddWord(key.Key, value); } else if (key.Localizations.TryGetValue("alias", out value2)) { __instance.AddWord(key.Key, Localization.instance.Localize(value2)); } } } } public static class LocalizationCache { private static readonly Dictionary localizations = new Dictionary(); internal static void LocalizationPostfix(Localization __instance, string language) { Localization __instance2 = __instance; string key = localizations.FirstOrDefault>((KeyValuePair l) => l.Value == __instance2).Key; if (key != null) { localizations.Remove(key); } if (!localizations.ContainsKey(language)) { localizations.Add(language, __instance2); } } public static Localization ForLanguage(string? language = null) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (localizations.TryGetValue(language ?? PlayerPrefs.GetString("language", "English"), out Localization value)) { return value; } value = new Localization(); if (language != null) { value.SetupLanguage(language); } return value; } } public class AdminSyncing { [CompilerGenerated] private sealed class <g__WatchAdminListChanges|2_0>d : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private List 5__1; private List 5__2; private List 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <g__WatchAdminListChanges|2_0>d(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; if (!ZNet.instance.m_adminList.GetList().SequenceEqual(5__1)) { 5__1 = new List(ZNet.instance.m_adminList.GetList()); 5__2 = (from p in ZNet.instance.GetPeers() where ZNet.instance.ListContainsId(ZNet.instance.m_adminList, p.m_rpc.GetSocket().GetHostName()) select p).ToList(); 5__3 = ZNet.instance.GetPeers().Except(5__2).ToList(); g__SendAdmin|2_2(5__3, isAdmin: false); g__SendAdmin|2_2(5__2, isAdmin: true); 5__2 = null; 5__3 = null; } } else { <>1__state = -1; 5__1 = new List(ZNet.instance.m_adminList.GetList()); } <>2__current = (object)new WaitForSeconds(30f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <>c__DisplayClass3_0 { public ZPackage package; internal IEnumerator b__1(ZNetPeer p) { return TellPeerAdminStatus(p, package); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <>c__DisplayClass4_0 { public ZNetPeer peer; public ZRoutedRpc rpc; } [CompilerGenerated] private sealed class d__4 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private bool <>2__current; public ZNetPeer peer; public ZPackage package; private <>c__DisplayClass4_0 <>8__1; bool IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = default(<>c__DisplayClass4_0); <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; <>8__1.peer = peer; <>8__1.rpc = ZRoutedRpc.instance; if (<>8__1.rpc == null) { return false; } g__SendPackage|4_0(package, ref <>8__1); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public List peers; public ZPackage package; private <>c__DisplayClass3_0 <>8__1; private byte[] 5__2; private List> 5__3; private ZPackage 5__4; private MemoryStream 5__5; private DeflateStream 5__6; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; 5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass3_0(); <>8__1.package = package; if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return false; } 5__2 = <>8__1.package.GetArray(); if (5__2 != null && 5__2.LongLength > 10000) { 5__4 = new ZPackage(); 5__4.Write(4); 5__5 = new MemoryStream(); 5__6 = new DeflateStream(5__5, CompressionLevel.Optimal); try { 5__6.Write(5__2, 0, 5__2.Length); } finally { if (5__6 != null) { ((IDisposable)5__6).Dispose(); } } 5__6 = null; 5__4.Write(5__5.ToArray()); <>8__1.package = 5__4; 5__4 = null; 5__5 = null; } 5__3 = (from peer in peers where peer.IsReady() select peer into p select TellPeerAdminStatus(p, <>8__1.package)).ToList(); 5__3.RemoveAll((IEnumerator writer) => !writer.MoveNext()); break; case 1: <>1__state = -1; 5__3.RemoveAll((IEnumerator writer) => !writer.MoveNext()); break; } if (5__3.Count > 0) { <>2__current = null; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static bool isServer; internal static bool registeredOnClient; [HarmonyPriority(700)] internal static void AdminStatusSync(ZNet __instance) { isServer = __instance.IsServer(); if (BuildPiece._plugin != null) { if (isServer) { ZRoutedRpc.instance.Register(BuildPiece._plugin.Info.Metadata.Name + " PMAdminStatusSync", (Action)RPC_AdminPieceAddRemove); } else if (!registeredOnClient) { ZRoutedRpc.instance.Register(BuildPiece._plugin.Info.Metadata.Name + " PMAdminStatusSync", (Action)RPC_AdminPieceAddRemove); registeredOnClient = true; } } if (isServer) { ((MonoBehaviour)ZNet.instance).StartCoroutine(WatchAdminListChanges()); } [IteratorStateMachine(typeof(<g__WatchAdminListChanges|2_0>d))] static IEnumerator WatchAdminListChanges() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <g__WatchAdminListChanges|2_0>d(0); } } [IteratorStateMachine(typeof(d__3))] private static IEnumerator sendZPackage(List peers, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { peers = peers, package = package }; } [IteratorStateMachine(typeof(d__4))] private static IEnumerator TellPeerAdminStatus(ZNetPeer peer, ZPackage package) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { peer = peer, package = package }; } internal static void RPC_AdminPieceAddRemove(long sender, ZPackage package) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown ZNetPeer peer = ZNet.instance.GetPeer(sender); bool flag = false; try { flag = package.ReadBool(); } catch { } if (isServer) { ZRoutedRpc instance = ZRoutedRpc.instance; long everybody = ZRoutedRpc.Everybody; BaseUnityPlugin? plugin = BuildPiece._plugin; instance.InvokeRoutedRPC(everybody, ((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync", new object[1] { (object)new ZPackage() }); if (ZNet.instance.ListContainsId(ZNet.instance.m_adminList, peer.m_rpc.GetSocket().GetHostName())) { ZPackage val = new ZPackage(); val.Write(true); ZRpc rpc = peer.m_rpc; BaseUnityPlugin? plugin2 = BuildPiece._plugin; rpc.Invoke(((plugin2 != null) ? plugin2.Info.Metadata.Name : null) + " PMAdminStatusSync", new object[1] { val }); } return; } foreach (BuildPiece registeredPiece in BuildPiece.registeredPieces) { if (!registeredPiece.SpecialProperties.AdminOnly) { continue; } Piece component = registeredPiece.Prefab.GetComponent(); string name = component.m_name; string text = Localization.instance.Localize(name).Trim(); if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || (Object)(object)ObjectDB.instance.GetItemPrefab("YmirRemains") == (Object)null) { continue; } Piece[] array = Object.FindObjectsOfType(); foreach (Piece val2 in array) { if (flag) { if (val2.m_name == name) { val2.m_enabled = true; } } else if (val2.m_name == name) { val2.m_enabled = false; } } List pieces = ObjectDB.instance.GetItemPrefab("Hammer").GetComponent().m_itemData.m_shared.m_buildPieces.m_pieces; if (flag) { if (!pieces.Contains(ZNetScene.instance.GetPrefab(((Object)component).name))) { pieces.Add(ZNetScene.instance.GetPrefab(((Object)component).name)); } } else if (pieces.Contains(ZNetScene.instance.GetPrefab(((Object)component).name))) { pieces.Remove(ZNetScene.instance.GetPrefab(((Object)component).name)); } } } [CompilerGenerated] internal static void g__SendAdmin|2_2(List peers, bool isAdmin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(isAdmin); ((MonoBehaviour)ZNet.instance).StartCoroutine(sendZPackage(peers, val)); } [CompilerGenerated] internal static void g__SendPackage|4_0(ZPackage pkg, ref <>c__DisplayClass4_0 P_1) { BaseUnityPlugin? plugin = BuildPiece._plugin; string text = ((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync"; if (isServer) { P_1.peer.m_rpc.Invoke(text, new object[1] { pkg }); } else { P_1.rpc.InvokeRoutedRPC(P_1.peer.m_server ? 0 : P_1.peer.m_uid, text, new object[1] { pkg }); } } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] internal class RegisterClientRPCPatch { private static void Postfix(ZNet __instance, ZNetPeer peer) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown if (!__instance.IsServer()) { ZRpc rpc = peer.m_rpc; BaseUnityPlugin? plugin = BuildPiece._plugin; rpc.Register(((plugin != null) ? plugin.Info.Metadata.Name : null) + " PMAdminStatusSync", (Action)RPC_InitialAdminSync); return; } ZPackage val = new ZPackage(); val.Write(__instance.ListContainsId(__instance.m_adminList, peer.m_rpc.GetSocket().GetHostName())); ZRpc rpc2 = peer.m_rpc; BaseUnityPlugin? plugin2 = BuildPiece._plugin; rpc2.Invoke(((plugin2 != null) ? plugin2.Info.Metadata.Name : null) + " PMAdminStatusSync", new object[1] { val }); } private static void RPC_InitialAdminSync(ZRpc rpc, ZPackage package) { AdminSyncing.RPC_AdminPieceAddRemove(0L, package); } } public static class PiecePrefabManager { private struct BundleId { [UsedImplicitly] public string assetBundleFileName; [UsedImplicitly] public string folderName; } private static readonly Dictionary bundleCache; private static readonly List piecePrefabs; private static readonly Dictionary PieceCategories; private static readonly Dictionary OtherPieceCategories; private static readonly Dictionary VanillaLabels; internal static bool CategoryRefreshNeeded; static PiecePrefabManager() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_02eb: Expected O, but got Unknown //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Expected O, but got Unknown //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Expected O, but got Unknown //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Expected O, but got Unknown //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Expected O, but got Unknown bundleCache = new Dictionary(); piecePrefabs = new List(); PieceCategories = new Dictionary(); OtherPieceCategories = new Dictionary(); VanillaLabels = new Dictionary(); Harmony val = new Harmony("org.bepinex.helpers.PieceManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(BuildPiece), "Patch_FejdStartup", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizeKey), "AddLocalizedKeys", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizationCache), "LocalizationPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(BuildPiece), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "CopyOtherDB", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNet), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(AdminSyncing), "AdminStatusSync", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "RefFixPatch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PieceTable), "UpdateAvailable", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "UpdateAvailable_Transpiler", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(PieceTable), "UpdateAvailable", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "UpdateAvailable_Prefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "UpdateAvailable_Postfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Player), "SetPlaceMode", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Patch_SetPlaceMode", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "Hud_AwakeCreateTabs", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "UpdateBuild", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "RepositionCatsIfNeeded", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Hud), "LateUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "RepositionCatsIfNeeded", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Enum), "GetValues", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "EnumGetValuesPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Enum), "GetNames", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "EnumGetNamesPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static AssetBundle RegisterAssetBundle(string assetBundleFileName, string folderName = "assets") { string assetBundleFileName2 = assetBundleFileName; BundleId bundleId = default(BundleId); bundleId.assetBundleFileName = assetBundleFileName2; bundleId.folderName = folderName; BundleId key = bundleId; if (!bundleCache.TryGetValue(key, out AssetBundle value)) { Dictionary dictionary = bundleCache; AssetBundle? obj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((AssetBundle a) => ((Object)a).name == assetBundleFileName2)) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + folderName + "." + assetBundleFileName2)); AssetBundle result = obj; dictionary[key] = obj; return result; } return value; } public static IEnumerable FixRefs(AssetBundle assetBundle) { return assetBundle.LoadAllAssets(); } public static GameObject RegisterPrefab(string assetBundleFileName, string prefabName, string folderName = "assets") { return RegisterPrefab(RegisterAssetBundle(assetBundleFileName, folderName), prefabName); } public static GameObject RegisterPrefab(AssetBundle assets, string prefabName) { if ((Object)(object)assets == (Object)null) { Debug.LogError((object)"Failed to load asset bundle. Please make sure to mark all asset bundles as embedded resources."); return null; } GameObject val = assets.LoadAsset(prefabName); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("Failed to load prefab " + prefabName + " from asset bundle " + ((Object)assets).name)); return null; } piecePrefabs.Add(val); return val; } public static Sprite RegisterSprite(string assetBundleFileName, string prefabName, string folderName = "assets") { return RegisterSprite(RegisterAssetBundle(assetBundleFileName, folderName), prefabName); } public static Sprite RegisterSprite(AssetBundle assets, string prefabName) { return assets.LoadAsset(prefabName); } private static void EnumGetValuesPatch(Type enumType, ref Array __result) { if (!(enumType != typeof(PieceCategory)) && PieceCategories.Count != 0) { PieceCategory[] array = (PieceCategory[])(object)new PieceCategory[__result.Length + PieceCategories.Count]; __result.CopyTo(array, 0); PieceCategories.Values.CopyTo(array, __result.Length); __result = array; } } private static void EnumGetNamesPatch(Type enumType, ref string[] __result) { if (!(enumType != typeof(PieceCategory)) && PieceCategories.Count != 0) { __result = CollectionExtensions.AddRangeToArray(__result, PieceCategories.Keys.ToArray()); } } public static Dictionary GetPieceCategoriesMap() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) Array values = Enum.GetValues(typeof(PieceCategory)); string[] names = Enum.GetNames(typeof(PieceCategory)); Dictionary dictionary = new Dictionary(); for (int i = 0; i < values.Length; i++) { dictionary[(PieceCategory)values.GetValue(i)] = names[i]; } return dictionary; } public static PieceCategory GetCategory(string name) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_002c: 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) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0093: 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_00bb: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (Enum.TryParse(name, ignoreCase: true, out PieceCategory result)) { return result; } if (PieceCategories.TryGetValue(name, out result)) { return result; } if (OtherPieceCategories.TryGetValue(name, out result)) { return result; } Dictionary pieceCategoriesMap = GetPieceCategoriesMap(); foreach (KeyValuePair item in pieceCategoriesMap) { if (item.Value == name) { result = item.Key; OtherPieceCategories[name] = result; return result; } } result = (PieceCategory)(pieceCategoriesMap.Count - 1); PieceCategories[name] = result; string categoryToken = GetCategoryToken(name); Localization.instance.AddWord(categoryToken, name); return result; } internal static void CreateCategoryTabs() { if (Object.op_Implicit((Object)(object)Hud.instance)) { int num = ModifiedMaxCategory(); for (int i = Hud.instance.m_pieceCategoryTabs.Length; i < num; i++) { GameObject val = CreateCategoryTab(); Hud.instance.m_pieceCategoryTabs = CollectionExtensions.AddItem((IEnumerable)Hud.instance.m_pieceCategoryTabs, val).ToArray(); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { RepositionCategories(Player.m_localPlayer.m_buildPieces); Player.m_localPlayer.UpdateAvailablePiecesList(); } } } private static GameObject CreateCategoryTab() { //IL_0084: 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) GameObject val = Hud.instance.m_pieceCategoryTabs[0]; GameObject val2 = Object.Instantiate(Hud.instance.m_pieceCategoryTabs[0], val.transform.parent); val2.SetActive(false); UIInputHandler orAddComponent = val2.GetOrAddComponent(); orAddComponent.m_onLeftDown = (Action)Delegate.Combine(orAddComponent.m_onLeftDown, new Action(Hud.instance.OnLeftClickCategory)); TMP_Text[] componentsInChildren = val2.GetComponentsInChildren(); foreach (TMP_Text val3 in componentsInChildren) { val3.rectTransform.offsetMin = new Vector2(3f, 1f); val3.rectTransform.offsetMax = new Vector2(-3f, -1f); val3.enableAutoSizing = true; val3.fontSizeMin = 12f; val3.fontSizeMax = 20f; val3.lineSpacing = 0.8f; val3.textWrappingMode = (TextWrappingModes)1; val3.overflowMode = (TextOverflowModes)3; } return val2; } private static int ModifiedMaxCategory() { return Enum.GetValues(typeof(PieceCategory)).Length - 1; } private static int GetMaxCategoryOrDefault() { try { return (int)Enum.Parse(typeof(PieceCategory), "Max"); } catch (ArgumentException) { Debug.LogWarning((object)"Could not find Piece.PieceCategory.Max, using fallback value 4"); return 4; } } private static List TranspileMaxCategory(IEnumerable instructions, int maxOffset) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown int num = GetMaxCategoryOrDefault() + maxOffset; List list = new List(); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.LoadsConstant(instruction, (long)num)) { list.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(PiecePrefabManager), "ModifiedMaxCategory", (Type[])null, (Type[])null))); if (maxOffset != 0) { list.Add(new CodeInstruction(OpCodes.Ldc_I4, (object)maxOffset)); list.Add(new CodeInstruction(OpCodes.Add, (object)null)); } } else { list.Add(instruction); } } return list; } private static IEnumerable UpdateAvailable_Transpiler(IEnumerable instructions) { return TranspileMaxCategory(instructions, 0); } private static HashSet CategoriesInPieceTable(PieceTable pieceTable) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); Piece val = default(Piece); foreach (GameObject item in pieceTable.m_pieces.Where((GameObject pieceFab) => (Object)(object)pieceFab != (Object)null)) { if (item.TryGetComponent(ref val)) { hashSet.Add(val.m_category); } } return hashSet; } private static void RepositionCatsIfNeeded() { if (CategoryRefreshNeeded) { CategoryRefreshNeeded = false; CreateCategoryTabs(); RepositionCats(); } } private static void RepositionCats() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_buildPieces)) { RepositionCategories(Player.m_localPlayer.m_buildPieces); } } private static void RepositionCategories(PieceTable pieceTable) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_005f: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)Hud.instance.m_pieceCategoryTabs[0].transform; RectTransform val2 = (RectTransform)Hud.instance.m_pieceCategoryRoot.transform; RectTransform val3 = (RectTransform)Hud.instance.m_pieceSelectionWindow.transform; HorizontalLayoutGroup val4 = default(HorizontalLayoutGroup); if (((Component)((Transform)val).parent).TryGetComponent(ref val4)) { Object.DestroyImmediate((Object)(object)val4); } Rect rect = val.rect; Vector2 size = ((Rect)(ref rect)).size; GridLayoutGroup val5 = default(GridLayoutGroup); GridLayoutGroup val6 = (((Component)((Transform)val).parent).TryGetComponent(ref val5) ? val5 : ((Component)((Transform)val).parent).gameObject.AddComponent()); val6.cellSize = size; val6.spacing = new Vector2(0f, 1f); val6.constraint = (Constraint)1; val6.constraintCount = 5; ((LayoutGroup)val6).childAlignment = (TextAnchor)4; HashSet hashSet = CategoriesInPieceTable(pieceTable); UpdatePieceTableCategories(pieceTable, hashSet); rect = val2.rect; int num = Mathf.Max((int)(((Rect)(ref rect)).width / size.x), 1); int count = pieceTable.m_categories.Count; float num2 = (0f - size.x) * (float)num / 2f + size.x / 2f; float num3 = (size.y + 1f) * Mathf.Floor((float)(count - 1) / (float)num) + 5f; Vector2 val7 = default(Vector2); ((Vector2)(ref val7))..ctor(num2, num3); int num4 = Mathf.CeilToInt((float)count / (float)num); float num5 = (size.y + 1f) * (float)num4; RectTransform component = ((Component)((Transform)val).parent).GetComponent(); component.anchoredPosition = new Vector2(component.anchoredPosition.x, num5 / 2f); int num6 = 0; for (int i = 0; i < Hud.instance.m_pieceCategoryTabs.Length; i++) { GameObject val8 = Hud.instance.m_pieceCategoryTabs[i]; if ((Object)(object)val8 == (Object)null) { continue; } if (i >= pieceTable.m_categories.Count) { val8.SetActive(false); continue; } PieceCategory item = pieceTable.m_categories[i]; string text = pieceTable.m_categoryLabels[i]; if (hashSet.Contains(item)) { num6++; } val8.GetComponentInChildren().text = Localization.instance.Localize(text); } Transform obj = ((Transform)val3).Find("Bkg2"); RectTransform val9 = (RectTransform)((obj != null) ? ((Component)obj).transform : null); if (Object.op_Implicit((Object)(object)val9)) { float num7 = (size.y + 1f) * (float)Mathf.Max(0, Mathf.FloorToInt((float)(num6 - 1) / (float)num)); val9.offsetMax = new Vector2(val9.offsetMax.x, num7); } else { Debug.LogWarning((object)"RefreshCategories: Could not find background image"); } ((Component)Hud.instance).GetComponentInParent().RefreshLocalization(); } private static void UpdatePieceTableCategories(PieceTable pieceTable, HashSet visibleCategories) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_019f: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < GetMaxCategoryOrDefault(); i++) { PieceCategory val = (PieceCategory)i; if (visibleCategories.Contains(val) && !pieceTable.m_categories.Contains(val)) { pieceTable.m_categories.Add(val); pieceTable.m_categoryLabels.Add(GetVanillaLabel(val)); } if (!visibleCategories.Contains(val) && pieceTable.m_categories.Contains(val)) { int index = pieceTable.m_categories.IndexOf(val); pieceTable.m_categories.RemoveAt(index); pieceTable.m_categoryLabels.RemoveAt(index); } } foreach (KeyValuePair pieceCategory in PieceCategories) { string key = pieceCategory.Key; PieceCategory value = pieceCategory.Value; if (visibleCategories.Contains(value) && !pieceTable.m_categories.Contains(value)) { pieceTable.m_categories.Add(value); pieceTable.m_categoryLabels.Add("$" + GetCategoryToken(key)); } if (visibleCategories.Contains(value) && !pieceTable.m_categoryLabels.Contains("$" + GetCategoryToken(key))) { pieceTable.m_categoryLabels.Add("$" + GetCategoryToken(key)); } if (!visibleCategories.Contains(value) && pieceTable.m_categories.Contains(value)) { int index2 = pieceTable.m_categories.IndexOf(value); pieceTable.m_categories.RemoveAt(index2); pieceTable.m_categoryLabels.RemoveAt(index2); } } } private static string GetVanillaLabel(PieceCategory category) { //IL_0006: 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) if (!VanillaLabels.ContainsKey(category)) { SearchVanillaLabels(); } string value; return VanillaLabels.TryGetValue(category, out value) ? value : string.Empty; } private static void SearchVanillaLabels() { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) PieceTable[] array = Resources.FindObjectsOfTypeAll(); foreach (PieceTable val in array) { for (int j = 0; j < val.m_categories.Count; j++) { PieceCategory key = val.m_categories[j]; if (j < val.m_categoryLabels.Count && !VanillaLabels.ContainsKey(key) && !string.IsNullOrEmpty(val.m_categoryLabels[j])) { VanillaLabels[key] = val.m_categoryLabels[j]; } } } } private static string GetCategoryToken(string name) { char[] endChars = Localization.instance.m_endChars; string text = string.Concat(name.ToLower().Split(endChars)); return "piecemanager_cat_" + text; } private static void Patch_SetPlaceMode(Player __instance) { if (Object.op_Implicit((Object)(object)__instance.m_buildPieces)) { RepositionCategories(__instance.m_buildPieces); } } private static void UpdateAvailable_Prefix(PieceTable __instance) { if (__instance.m_availablePieces.Count > 0) { int num = ModifiedMaxCategory() - __instance.m_availablePieces.Count; for (int i = 0; i < num; i++) { __instance.m_availablePieces.Add(new List()); } } } private static void UpdateAvailable_Postfix(PieceTable __instance) { Array.Resize(ref __instance.m_selectedPiece, __instance.m_availablePieces.Count); Array.Resize(ref __instance.m_lastSelectedPiece, __instance.m_availablePieces.Count); } [HarmonyPriority(200)] private static void Hud_AwakeCreateTabs() { CreateCategoryTabs(); } [HarmonyPriority(700)] private static void Patch_ZNetSceneAwake(ZNetScene __instance) { foreach (GameObject piecePrefab in piecePrefabs) { if (!__instance.m_prefabs.Contains(piecePrefab)) { __instance.m_prefabs.Add(piecePrefab); } } } [HarmonyPriority(700)] private static void RefFixPatch_ZNetSceneAwake(ZNetScene __instance) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject piecePrefab in piecePrefabs) { if (__instance.m_prefabs.Contains(piecePrefab) && Object.op_Implicit((Object)(object)piecePrefab.GetComponent())) { piecePrefab.GetComponent().m_isUpgrade = true; piecePrefab.GetComponent().m_connectionPrefab = __instance.GetPrefab("piece_workbench_ext3").GetComponent().m_connectionPrefab; piecePrefab.GetComponent().m_connectionOffset = __instance.GetPrefab("piece_workbench_ext3").GetComponent().m_connectionOffset; } } } [HarmonyPriority(300)] private static void Patch_ObjectDBInit(ObjectDB __instance) { foreach (BuildPiece registeredPiece in BuildPiece.registeredPieces) { string[] activeTools = registeredPiece.activeTools; foreach (string text in activeTools) { GameObject itemPrefab = __instance.GetItemPrefab(text); PieceTable val = ((itemPrefab != null) ? itemPrefab.GetComponent().m_itemData.m_shared.m_buildPieces : null); if (val != null && !val.m_pieces.Contains(registeredPiece.Prefab)) { val.m_pieces.Add(registeredPiece.Prefab); } } } } } public static class PieceManagerVersion { public const string Version = "1.2.9"; } [PublicAPI] public class Conversion { internal class ConversionConfig { public ConfigEntry input = null; public ConfigEntry output = null; } public string Input = null; public string Output = null; internal ConversionConfig? config; public Conversion(BuildPiece conversionPiece) { conversionPiece.Conversions.Add(this); } } } namespace ItemManager { [PublicAPI] public enum CraftingTable { Disabled, Inventory, [InternalName("piece_workbench")] Workbench, [InternalName("piece_cauldron")] Cauldron, [InternalName("piece_MeadCauldron")] MeadCauldron, [InternalName("forge")] Forge, [InternalName("piece_artisanstation")] ArtisanTable, [InternalName("piece_stonecutter")] StoneCutter, [InternalName("piece_magetable")] MageTable, [InternalName("piece_preptable")] PrepTable, [InternalName("blackforge")] BlackForge, Custom } [PublicAPI] public enum ConversionPiece { Disabled, [InternalName("smelter")] Smelter, [InternalName("charcoal_kiln")] CharcoalKiln, [InternalName("blastfurnace")] BlastFurnace, [InternalName("windmill")] Windmill, [InternalName("piece_spinningwheel")] SpinningWheel, [InternalName("eitrrefinery")] EitrRefinery, Custom } public class InternalName : Attribute { public readonly string internalName; public InternalName(string internalName) { this.internalName = internalName; } } [PublicAPI] public class RequiredResourceList { public readonly List Requirements = new List(); public bool Free = false; public void Add(string itemName, int amount, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amount = amount, quality = quality }); } public void Add(string itemName, ConfigEntry amountConfig, int quality = 0) { Requirements.Add(new Requirement { itemName = itemName, amountConfig = amountConfig, quality = quality }); } } [PublicAPI] public class CraftingStationList { public readonly List Stations = new List(); public void Add(CraftingTable table, int level) { Stations.Add(new CraftingStationConfig { Table = table, level = level }); } public void Add(string customTable, int level) { Stations.Add(new CraftingStationConfig { Table = CraftingTable.Custom, level = level, custom = customTable }); } } [PublicAPI] public class ItemRecipe { public readonly RequiredResourceList RequiredItems = new RequiredResourceList(); public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList(); public readonly CraftingStationList Crafting = new CraftingStationList(); public int CraftAmount = 1; public bool RequireOnlyOneIngredient = false; public float QualityResultAmountMultiplier = 1f; public ConfigEntryBase? RecipeIsActive = null; } [PublicAPI] public class Trade { public Trader Trader = Trader.None; public uint Price = 0u; public uint Stack = 1u; public string? RequiredGlobalKey = null; } [PublicAPI] [Flags] public enum Trader { None = 0, Haldor = 1, Hildir = 2 } public struct Requirement { public string itemName; public int amount; public ConfigEntry? amountConfig; [Description("Set to a non-zero value to apply the requirement only for a specific quality")] public int quality; } public struct CraftingStationConfig { public CraftingTable Table; public int level; public string? custom; } [Flags] public enum Configurability { Disabled = 0, Recipe = 1, Stats = 2, Drop = 4, Trader = 8, Full = 0xF } [PublicAPI] public class DropTargets { public readonly List Drops = new List(); public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true) { Drops.Add(new DropTarget { creature = creatureName, chance = chance, min = min, max = max.GetValueOrDefault(min), levelMultiplier = levelMultiplier }); } } public struct DropTarget { public string creature; public int min; public int max; public float chance; public bool levelMultiplier; } public enum Toggle { On = 1, Off = 0 } [PublicAPI] public class Item { private class ItemConfig { public ConfigEntry? craft; public ConfigEntry? upgrade; public ConfigEntry table = null; public ConfigEntry tableLevel = null; public ConfigEntry customTable = null; public ConfigEntry? maximumTableLevel; public ConfigEntry requireOneIngredient = null; public ConfigEntry qualityResultAmountMultiplier = null; } private class TraderConfig { public ConfigEntry trader = null; public ConfigEntry price = null; public ConfigEntry stack = null; public ConfigEntry requiredGlobalKey = null; } private class RequirementQuality { public int quality; } private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string? Category; [UsedImplicitly] public Action? CustomDrawer; public Func? browsability; } [PublicAPI] public enum DamageModifier { Normal, Resistant, Weak, Immune, Ignore, VeryResistant, VeryWeak, None } private delegate void setDmgFunc(ref DamageTypes dmg, float value); private class SerializedRequirements { public readonly List Reqs; public SerializedRequirements(List reqs) { Reqs = reqs; } public SerializedRequirements(string reqs) : this(reqs.Split(new char[1] { ',' }).Select(delegate(string r) { string[] array = r.Split(new char[1] { ':' }); Requirement result = default(Requirement); result.itemName = array[0]; result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2); result.quality = ((array.Length > 2 && int.TryParse(array[2], out var result3)) ? result3 : 0); return result; }).ToList()) { } public override string ToString() { return string.Join(",", Reqs.Select((Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : ""))); } public static ItemDrop? fetchByName(ObjectDB objectDB, string name) { GameObject itemPrefab = objectDB.GetItemPrefab(name); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("The required item '" + name + "' does not exist.")); } return val; } public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade) { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01b7: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown ObjectDB objectDB2 = objectDB; Dictionary dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func)((Requirement r) => r.itemName), (Func)delegate(Requirement r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0037: Unknown result type (might be due to invalid IL or missing references) ItemDrop val6 = ResItem(r); return (val6 == null) ? ((Requirement)null) : new Requirement { m_amount = (r.amountConfig?.Value ?? r.amount), m_resItem = val6, m_amountPerLevel = 0 }; }); List list = dictionary.Values.Where((Requirement v) => v != null).ToList(); foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != "")) { if (item.quality > 0) { ItemDrop val = ResItem(item); if (val != null) { Requirement val2 = new Requirement { m_resItem = val, m_amountPerLevel = (item.amountConfig?.Value ?? item.amount), m_amount = 0 }; list.Add(val2); requirementQuality.Add(val2, new RequirementQuality { quality = item.quality }); } continue; } if (!dictionary.TryGetValue(item.itemName, out var value) || value == null) { ItemDrop val3 = ResItem(item); if (val3 != null) { string itemName = item.itemName; Requirement val4 = new Requirement { m_resItem = val3, m_amount = 0 }; Requirement val5 = val4; dictionary[itemName] = val4; value = val5; list.Add(value); } } if (value != null) { value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount; } } return list.ToArray(); ItemDrop? ResItem(Requirement r) { return fetchByName(objectDB2, r.itemName); } } } private class SerializedDrop { public readonly List Drops; public SerializedDrop(List drops) { Drops = drops; } public SerializedDrop(string drops) { Drops = ((drops == "") ? ((IEnumerable)Array.Empty()) : ((IEnumerable)drops.Split(new char[1] { ',' }))).Select(delegate(string r) { string[] array = r.Split(new char[1] { ':' }); if (array.Length <= 2 || !int.TryParse(array[2], out var result)) { result = 1; } if (array.Length <= 3 || !int.TryParse(array[3], out var result2)) { result2 = result; } bool levelMultiplier = array.Length <= 4 || array[4] != "0"; DropTarget result3 = default(DropTarget); result3.creature = array[0]; result3.chance = ((array.Length > 1 && float.TryParse(array[1], out var result4)) ? result4 : 1f); result3.min = result; result3.max = result2; result3.levelMultiplier = levelMultiplier; return result3; }).ToList(); } public override string ToString() { return string.Join(",", Drops.Select((DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0"))); } private static Character? fetchByName(ZNetScene netScene, string name) { GameObject prefab = netScene.GetPrefab(name); Character val = ((prefab != null) ? prefab.GetComponent() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("The drop target character '" + name + "' does not exist.")); } return val; } public Dictionary toCharacterDrops(ZNetScene netScene, GameObject item) { //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_0051: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown Dictionary dictionary = new Dictionary(); foreach (DropTarget drop in Drops) { Character val = fetchByName(netScene, drop.creature); if (val != null) { dictionary[val] = new Drop { m_prefab = item, m_amountMin = drop.min, m_amountMax = drop.max, m_chance = drop.chance, m_levelMultiplier = drop.levelMultiplier }; } } return dictionary; } } [CompilerGenerated] private sealed class <>c__DisplayClass83_0 { public Quaternion? cameraRotation; public float lightIntensity; public ItemDrop item; public Quaternion? itemRotation; } [CompilerGenerated] private sealed class d__85 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; private List 5__1; private FieldInfo 5__2; private int 5__3; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__85(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown int num; switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = instructions.ToList(); 5__2 = AccessTools.DeclaredField(typeof(Recipe), "m_amount"); 5__3 = 0; break; case 1: <>1__state = -1; if (5__3 > 1 && 5__1[5__3 - 2].opcode == OpCodes.Ldfld && CodeInstructionExtensions.OperandIs(5__1[5__3 - 2], (MemberInfo)5__2) && 5__1[5__3 - 1].opcode == OpCodes.Ldc_I4_1 && 5__1[5__3].operand is Label) { <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 2; return true; } goto IL_01ca; case 2: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(Item), "CheckItemIsUpgrade", (Type[])null, (Type[])null)); <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Brtrue, 5__1[5__3].operand); <>1__state = 4; return true; case 4: { <>1__state = -1; goto IL_01ca; } IL_01ca: num = 5__3 + 1; 5__3 = num; break; } if (5__3 < 5__1.Count) { <>2__current = 5__1[5__3]; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__85 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__85(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly List registeredItems = new List(); private static readonly Dictionary itemDropMap = new Dictionary(); private static Dictionary>> activeRecipes = new Dictionary>>(); private static Dictionary hiddenCraftRecipes = new Dictionary(); private static Dictionary hiddenUpgradeRecipes = new Dictionary(); private static Dictionary> itemCraftConfigs = new Dictionary>(); private static Dictionary> itemDropConfigs = new Dictionary>(); private Dictionary characterDrops = new Dictionary(); private readonly Dictionary statsConfigs = new Dictionary(); private static readonly ConditionalWeakTable requirementQuality = new ConditionalWeakTable(); public static Configurability DefaultConfigurability = Configurability.Full; public Configurability? Configurable = null; private Configurability configurationVisible = Configurability.Full; private TraderConfig? traderConfig; public readonly GameObject Prefab; [Description("Specifies the maximum required crafting station level to upgrade and repair the item.\nDefault is calculated from crafting station level and maximum quality.")] public int MaximumRequiredStationLevel = int.MaxValue; [Description("Assigns the item as a drop item to a creature.\nUses a creature name, a drop chance and a minimum and maximum amount.")] public readonly DropTargets DropsFrom = new DropTargets(); [Description("Configures whether the item can be bought at the trader.\nDon't forget to set cost to something above 0 or the item will be sold for free.")] public readonly Trade Trade = new Trade(); internal List Conversions = new List(); internal List conversions = new List(); public Dictionary Recipes = new Dictionary(); private LocalizeKey? _name; private LocalizeKey? _description; private static object? configManager; private static Localization? _english; private static BaseUnityPlugin? _plugin; private static bool hasConfigSync = true; private static object? _configSync; private Configurability configurability => Configurable ?? DefaultConfigurability; [Description("Specifies the resources needed to craft the item.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the item should need.")] public RequiredResourceList RequiredItems => this[""].RequiredItems; [Description("Specifies the resources needed to upgrade the item.\nUse .Add to add resources with their internal ID and an amount. This amount will be multipled by the item quality level.\nUse one .Add for each resource type the upgrade should need.")] public RequiredResourceList RequiredUpgradeItems => this[""].RequiredUpgradeItems; [Description("Specifies the crafting station needed to craft the item.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.\nUse one .Add for each crafting station.")] public CraftingStationList Crafting => this[""].Crafting; [Description("Specifies a config entry which toggles whether a recipe is active.")] public ConfigEntryBase? RecipeIsActive { get { return this[""].RecipeIsActive; } set { this[""].RecipeIsActive = value; } } [Description("Specifies the number of items that should be given to the player with a single craft of the item.\nDefaults to 1.")] public int CraftAmount { get { return this[""].CraftAmount; } set { this[""].CraftAmount = value; } } public bool RequireOnlyOneIngredient { get { return this[""].RequireOnlyOneIngredient; } set { this[""].RequireOnlyOneIngredient = value; } } public float QualityResultAmountMultiplier { get { return this[""].QualityResultAmountMultiplier; } set { this[""].QualityResultAmountMultiplier = value; } } public ItemRecipe this[string name] { get { if (Recipes.TryGetValue(name, out ItemRecipe value)) { return value; } return Recipes[name] = new ItemRecipe(); } } public LocalizeKey Name { get { LocalizeKey name = _name; if (name != null) { return name; } SharedData shared = Prefab.GetComponent().m_itemData.m_shared; if (shared.m_name.StartsWith("$")) { _name = new LocalizeKey(shared.m_name); } else { string text = "$item_" + ((Object)Prefab).name.Replace(" ", "_"); _name = new LocalizeKey(text).English(shared.m_name); shared.m_name = text; } return _name; } } public LocalizeKey Description { get { LocalizeKey description = _description; if (description != null) { return description; } SharedData shared = Prefab.GetComponent().m_itemData.m_shared; if (shared.m_description.StartsWith("$")) { _description = new LocalizeKey(shared.m_description); } else { string text = "$itemdesc_" + ((Object)Prefab).name.Replace(" ", "_"); _description = new LocalizeKey(text).English(shared.m_description); shared.m_description = text; } return _description; } } private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English")); private static BaseUnityPlugin plugin { get { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (_plugin == null) { IEnumerable source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static object? configSync { get { if (_configSync == null && hasConfigSync) { Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync"); if ((object)type != null) { _configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " ItemManager"); type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString()); type.GetProperty("IsLocked").SetValue(_configSync, true); } else { hasConfigSync = false; } } return _configSync; } } public Item(string assetBundleFileName, string prefabName, string folderName = "assets") : this(PrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName) { } public Item(AssetBundle bundle, string prefabName) : this(PrefabManager.RegisterPrefab(bundle, prefabName, addToObjectDb: true), skipRegistering: true) { } public Item(GameObject prefab, bool skipRegistering = false) { if (!skipRegistering) { PrefabManager.RegisterPrefab(prefab, addToObjectDb: true); } Prefab = prefab; registeredItems.Add(this); itemDropMap[Prefab.GetComponent()] = this; Prefab.GetComponent().m_itemData.m_dropPrefab = Prefab; } public void ToggleConfigurationVisibility(Configurability visible) { configurationVisible = visible; if (itemDropConfigs.TryGetValue(this, out ConfigEntry value)) { Toggle((ConfigEntryBase)(object)value, Configurability.Drop); } if (itemCraftConfigs.TryGetValue(this, out Dictionary value2)) { foreach (ItemConfig value4 in value2.Values) { ToggleObj(value4, Configurability.Recipe); } } foreach (Conversion conversion in Conversions) { if (conversion.config != null) { ToggleObj(conversion.config, Configurability.Recipe); } } foreach (KeyValuePair statsConfig in statsConfigs) { Toggle(statsConfig.Key, Configurability.Stats); if ((visible & Configurability.Stats) != 0) { statsConfig.Value(); } } reloadConfigDisplay(); void Toggle(ConfigEntryBase cfg, Configurability check) { object[] tags = cfg.Description.Tags; foreach (object obj2 in tags) { if (obj2 is ConfigurationManagerAttributes configurationManagerAttributes) { configurationManagerAttributes.Browsable = (visible & check) != 0 && (configurationManagerAttributes.browsability == null || configurationManagerAttributes.browsability()); } } } void ToggleObj(object obj, Configurability check) { FieldInfo[] fields = obj.GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { object? value3 = fieldInfo.GetValue(obj); ConfigEntryBase val = (ConfigEntryBase)((value3 is ConfigEntryBase) ? value3 : null); if (val != null) { Toggle(val, check); } } } } internal static void reloadConfigDisplay() { object obj = configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager); if (obj is bool && (bool)obj) { configManager.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty()); } } private void UpdateItemTableConfig(string recipeKey, CraftingTable table, string customTableValue) { if (activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(recipeKey, out List value)) { value.First().m_enabled = table != CraftingTable.Disabled; if ((uint)table <= 1u) { value.First().m_craftingStation = null; } else if (table == CraftingTable.Custom) { Recipe obj = value.First(); GameObject prefab = ZNetScene.instance.GetPrefab(customTableValue); obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent() : null); } else { value.First().m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName(table)).GetComponent(); } } } private void UpdateCraftConfig(string recipeKey, SerializedRequirements craftRequirements, SerializedRequirements upgradeRequirements) { if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || !activeRecipes.ContainsKey(this) || !activeRecipes[this].TryGetValue(recipeKey, out List value)) { return; } foreach (Recipe item in value) { item.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, craftRequirements, upgradeRequirements); } } internal static void Patch_FejdStartup() { //IL_1001: Unknown result type (might be due to invalid IL or missing references) //IL_1006: Unknown result type (might be due to invalid IL or missing references) //IL_2395: Unknown result type (might be due to invalid IL or missing references) //IL_239f: Expected O, but got Unknown //IL_10ce: Unknown result type (might be due to invalid IL or missing references) //IL_10d1: Unknown result type (might be due to invalid IL or missing references) //IL_1127: Expected I4, but got Unknown //IL_0ccc: Unknown result type (might be due to invalid IL or missing references) //IL_0cd6: Expected O, but got Unknown //IL_1267: Unknown result type (might be due to invalid IL or missing references) //IL_126a: Unknown result type (might be due to invalid IL or missing references) //IL_126c: Invalid comparison between Unknown and I4 //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown //IL_0dfa: Unknown result type (might be due to invalid IL or missing references) //IL_0e04: Expected O, but got Unknown //IL_0ea6: Unknown result type (might be due to invalid IL or missing references) //IL_0eb0: Expected O, but got Unknown //IL_1270: Unknown result type (might be due to invalid IL or missing references) //IL_1274: Invalid comparison between Unknown and I4 //IL_0f5b: Unknown result type (might be due to invalid IL or missing references) //IL_0f65: Expected O, but got Unknown //IL_1489: Unknown result type (might be due to invalid IL or missing references) //IL_148c: Unknown result type (might be due to invalid IL or missing references) //IL_148e: Invalid comparison between Unknown and I4 //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Expected O, but got Unknown //IL_1278: Unknown result type (might be due to invalid IL or missing references) //IL_127c: Invalid comparison between Unknown and I4 //IL_1492: Unknown result type (might be due to invalid IL or missing references) //IL_1496: Unknown result type (might be due to invalid IL or missing references) //IL_1498: Invalid comparison between Unknown and I4 //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Expected O, but got Unknown //IL_1581: Unknown result type (might be due to invalid IL or missing references) //IL_1586: Unknown result type (might be due to invalid IL or missing references) //IL_1588: Unknown result type (might be due to invalid IL or missing references) //IL_158b: Invalid comparison between Unknown and I4 //IL_149c: Unknown result type (might be due to invalid IL or missing references) //IL_14a0: Invalid comparison between Unknown and I4 //IL_158f: Unknown result type (might be due to invalid IL or missing references) //IL_1593: Invalid comparison between Unknown and I4 //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_07a0: Expected O, but got Unknown //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Expected O, but got Unknown //IL_160c: Unknown result type (might be due to invalid IL or missing references) //IL_160f: Unknown result type (might be due to invalid IL or missing references) //IL_1611: Invalid comparison between Unknown and I4 //IL_08b0: Unknown result type (might be due to invalid IL or missing references) //IL_08ba: Expected O, but got Unknown //IL_1615: Unknown result type (might be due to invalid IL or missing references) //IL_1619: Unknown result type (might be due to invalid IL or missing references) //IL_161b: Invalid comparison between Unknown and I4 //IL_176e: Unknown result type (might be due to invalid IL or missing references) //IL_1771: Invalid comparison between Unknown and I4 //IL_161f: Unknown result type (might be due to invalid IL or missing references) //IL_1623: Invalid comparison between Unknown and I4 //IL_1980: Unknown result type (might be due to invalid IL or missing references) //IL_1987: Invalid comparison between Unknown and I4 //IL_1a5c: Unknown result type (might be due to invalid IL or missing references) //IL_1a61: Unknown result type (might be due to invalid IL or missing references) //IL_1a63: Unknown result type (might be due to invalid IL or missing references) //IL_1a67: Unknown result type (might be due to invalid IL or missing references) //IL_1a69: Invalid comparison between Unknown and I4 //IL_16de: Unknown result type (might be due to invalid IL or missing references) //IL_16e3: Unknown result type (might be due to invalid IL or missing references) //IL_1ae2: Unknown result type (might be due to invalid IL or missing references) //IL_1ae5: Unknown result type (might be due to invalid IL or missing references) //IL_1ae7: Invalid comparison between Unknown and I4 //IL_1aeb: Unknown result type (might be due to invalid IL or missing references) //IL_1aef: Invalid comparison between Unknown and I4 //IL_1af3: Unknown result type (might be due to invalid IL or missing references) //IL_1af7: Invalid comparison between Unknown and I4 //IL_1f88: Unknown result type (might be due to invalid IL or missing references) //IL_1f8b: Invalid comparison between Unknown and I4 Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager"); if (DefaultConfigurability != 0) { bool saveOnConfigSet = plugin.Config.SaveOnConfigSet; plugin.Config.SaveOnConfigSet = false; foreach (Item item4 in registeredItems.Where((Item i) => i.configurability != Configurability.Disabled)) { Item item3 = item4; string name2 = item3.Prefab.GetComponent().m_itemData.m_shared.m_name; string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(name2), "").Trim(); string localizedName = Localization.instance.Localize(name2).Trim(); int order = 0; if ((item3.configurability & Configurability.Recipe) != 0) { itemCraftConfigs[item3] = new Dictionary(); foreach (string item5 in item3.Recipes.Keys.DefaultIfEmpty("")) { string configKey = item5; string text = ((configKey == "") ? "" : (" (" + configKey + ")")); if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0) { continue; } ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig()); ItemConfig cfg = itemConfig2; List hideWhenNoneAttributes = new List(); cfg.table = config(englishName, "Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName } })); ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = CustomTableBrowsability, Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.customTable = config(englishName, "Custom Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes })); cfg.table.SettingChanged += TableConfigChanged; cfg.customTable.SettingChanged += TableConfigChanged; ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = TableLevelBrowsability, Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes); cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item3.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); cfg.tableLevel.SettingChanged += delegate { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out List value6)) { value6.First().m_minStationLevel = cfg.tableLevel.Value; } }; if (item3.Prefab.GetComponent().m_itemData.m_shared.m_maxQuality > 1) { cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item3.MaximumRequiredStationLevel == int.MaxValue) ? (item3.Recipes[configKey].Crafting.Stations.First().level + item3.Prefab.GetComponent().m_itemData.m_shared.m_maxQuality - 1) : item3.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); } cfg.requireOneIngredient = config(englishName, "Require only one resource" + text, item3.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Category = localizedName } })); ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = QualityResultBrowsability, Browsable = (QualityResultBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; cfg.requireOneIngredient.SettingChanged += delegate { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out List value5)) { foreach (Recipe item6 in value5) { item6.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On; } } qualityResultAttributes.Browsable = QualityResultBrowsability(); reloadConfigDisplay(); }; cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text, item3.Recipes[configKey].QualityResultAmountMultiplier, new ConfigDescription("Multiplies the crafted amount based on the quality of the resources when crafting " + englishName + ". Only works, if Require Only One Resource is true.", (AcceptableValueBase)null, new object[1] { qualityResultAttributes })); cfg.qualityResultAmountMultiplier.SettingChanged += delegate { if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out List value4)) { foreach (Recipe item7 in value4) { item7.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value; } } }; if ((!item3.Recipes[configKey].RequiredItems.Free || item3.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.craft = itemConfig("Crafting Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false); } if (item3.Prefab.GetComponent().m_itemData.m_shared.m_maxQuality > 1 && (!item3.Recipes[configKey].RequiredUpgradeItems.Free || item3.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item3.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null)) { cfg.upgrade = itemConfig("Upgrading Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName, isUpgrade: true); } if (cfg.craft != null) { cfg.craft.SettingChanged += ConfigChanged; } if (cfg.upgrade != null) { cfg.upgrade.SettingChanged += ConfigChanged; } void ConfigChanged(object o, EventArgs e) { item3.UpdateCraftConfig(configKey, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? "")); } bool CustomTableBrowsability() { return cfg.table.Value == CraftingTable.Custom; } bool ItemBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } bool QualityResultBrowsability() { return cfg.requireOneIngredient.Value == Toggle.On; } void TableConfigChanged(object o, EventArgs e) { item3.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value); customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom; foreach (ConfigurationManagerAttributes item8 in hideWhenNoneAttributes) { item8.Browsable = cfg.table.Value != CraftingTable.Disabled; } reloadConfigDisplay(); } bool TableLevelBrowsability() { return cfg.table.Value != CraftingTable.Disabled; } ConfigEntry itemConfig(string name, string value, string desc, bool isUpgrade) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes { CustomDrawer = drawRequirementsConfigTable(item3, isUpgrade), Order = (order -= 1), browsability = ItemBrowsability, Browsable = (ItemBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0), Category = localizedName }; hideWhenNoneAttributes.Add(configurationManagerAttributes3); return config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 })); } } if ((item3.configurability & Configurability.Drop) != 0) { ConfigEntry val3 = (itemDropConfigs[item3] = config(englishName, "Drops from", new SerializedDrop(item3.DropsFrom.Drops).ToString(), new ConfigDescription(englishName + " drops from this creature.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = drawDropsConfigTable, Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Drop) != 0) } }))); ConfigEntry val4 = val3; val4.SettingChanged += delegate { item3.UpdateCharacterDrop(); }; } for (int j = 0; j < item3.Conversions.Count; j++) { string text2 = ((item3.Conversions.Count > 1) ? $"{j + 1}. " : ""); Conversion conversion = item3.Conversions[j]; conversion.config = new Conversion.ConversionConfig(); int index = j; conversion.config.input = config(englishName, text2 + "Conversion Input Item", conversion.Input, new ConfigDescription("Input item to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.input.SettingChanged += delegate { if (index < item3.conversions.Count) { ObjectDB instance = ObjectDB.instance; if (instance != null) { ItemDrop from = SerializedRequirements.fetchByName(instance, conversion.config.input.Value); item3.conversions[index].m_from = from; UpdatePiece(); } } }; conversion.config.piece = config(englishName, text2 + "Conversion Piece", conversion.Piece, new ConfigDescription("Conversion piece used to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.piece.SettingChanged += delegate { UpdatePiece(); }; conversion.config.customPiece = config(englishName, text2 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Custom conversion piece to create " + englishName, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0) } })); conversion.config.customPiece.SettingChanged += delegate { UpdatePiece(); }; void UpdatePiece() { if (index < item3.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance)) { string text3 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value))); string activePiece = conversion.config.activePiece; if (conversion.config.activePiece != null) { Smelter component = ZNetScene.instance.GetPrefab(conversion.config.activePiece).GetComponent(); int num = component.m_conversion.IndexOf(item3.conversions[index]); if (num >= 0) { Smelter[] array3 = Resources.FindObjectsOfTypeAll(); foreach (Smelter val6 in array3) { if (Utils.GetPrefabName(((Component)val6).gameObject) == activePiece) { val6.m_conversion.RemoveAt(num); } } } conversion.config.activePiece = null; } if (item3.conversions[index].m_from != null && conversion.config.piece.Value != 0) { GameObject prefab = ZNetScene.instance.GetPrefab(text3); if (((prefab != null) ? prefab.GetComponent() : null) != null) { conversion.config.activePiece = text3; Smelter[] array4 = Resources.FindObjectsOfTypeAll(); foreach (Smelter val7 in array4) { if (Utils.GetPrefabName(((Component)val7).gameObject) == text3) { val7.m_conversion.Add(item3.conversions[index]); } } } } } } } } if ((item3.configurability & Configurability.Stats) != 0) { item3.statsConfigs.Clear(); SharedData shared2 = item3.Prefab.GetComponent().m_itemData.m_shared; ItemType itemType = shared2.m_itemType; statcfg("Weight", "Weight of " + englishName + ".", (SharedData shared) => shared.m_weight, delegate(SharedData shared, float value) { shared.m_weight = value; }); statcfg("Trader Value", "Trader value of " + englishName + ".", (SharedData shared) => shared.m_value, delegate(SharedData shared, int value) { shared.m_value = value; }); bool flag; switch (itemType - 3) { case 0: case 1: case 2: case 3: case 4: case 8: case 9: case 11: case 14: case 16: case 19: flag = true; break; default: flag = false; break; } if (flag) { statcfg("Durability", "Durability of " + englishName + ".", (SharedData shared) => shared.m_maxDurability, delegate(SharedData shared, float value) { shared.m_maxDurability = value; }); statcfg("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData shared) => shared.m_durabilityPerLevel, delegate(SharedData shared, float value) { shared.m_durabilityPerLevel = value; }); statcfg("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData shared) => shared.m_movementModifier, delegate(SharedData shared, float value) { shared.m_movementModifier = value; }); } if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false) { statcfg("Block Armor", "Block armor of " + englishName + ".", (SharedData shared) => shared.m_blockPower, delegate(SharedData shared, float value) { shared.m_blockPower = value; }); statcfg("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData shared) => shared.m_blockPowerPerLevel, delegate(SharedData shared, float value) { shared.m_blockPowerPerLevel = value; }); statcfg("Block Force", "Block force of " + englishName + ".", (SharedData shared) => shared.m_deflectionForce, delegate(SharedData shared, float value) { shared.m_deflectionForce = value; }); statcfg("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData shared) => shared.m_deflectionForcePerLevel, delegate(SharedData shared, float value) { shared.m_deflectionForcePerLevel = value; }); statcfg("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData shared) => shared.m_timedBlockBonus, delegate(SharedData shared, float value) { shared.m_timedBlockBonus = value; }); } else if ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false) { statcfg("Armor", "Armor of " + englishName + ".", (SharedData shared) => shared.m_armor, delegate(SharedData shared, float value) { shared.m_armor = value; }); statcfg("Armor per Level", "Armor per level for " + englishName + ".", (SharedData shared) => shared.m_armorPerLevel, delegate(SharedData shared, float value) { shared.m_armorPerLevel = value; }); } SkillType skillType = shared2.m_skillType; if (((int)skillType == 7 || (int)skillType == 12) ? true : false) { statcfg("Tool tier", "Tool tier of " + englishName + ".", (SharedData shared) => shared.m_toolTier, delegate(SharedData shared, int value) { shared.m_toolTier = value; }); } if ((itemType - 5 <= 2 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false) { Dictionary modifiers = shared2.m_damageModifiers.ToDictionary((DamageModPair d) => d.m_type, (DamageModPair d) => (DamageModifier)d.m_modifier); DamageType[] first = (DamageType[])Enum.GetValues(typeof(DamageType)); DamageType[] array = new DamageType[5]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); foreach (DamageType item9 in first.Except((IEnumerable)(object)array)) { DamageType damageType = item9; statcfg(((object)(DamageType)(ref damageType)).ToString() + " Resistance", ((object)(DamageType)(ref damageType)).ToString() + " resistance of " + englishName + ".", (SharedData _) => modifiers.TryGetValue(damageType, out var value3) ? value3 : DamageModifier.None, delegate(SharedData shared, DamageModifier value) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) DamageModPair val8 = default(DamageModPair); val8.m_type = damageType; val8.m_modifier = (DamageModifier)value; DamageModPair val9 = val8; for (int num2 = 0; num2 < shared.m_damageModifiers.Count; num2++) { if (shared.m_damageModifiers[num2].m_type == damageType) { if (value == DamageModifier.None) { shared.m_damageModifiers.RemoveAt(num2); } else { shared.m_damageModifiers[num2] = val9; } return; } } if (value != DamageModifier.None) { shared.m_damageModifiers.Add(val9); } }); } } if ((int)itemType == 2 && shared2.m_food > 0f) { statcfg("Health", "Health value of " + englishName + ".", (SharedData shared) => shared.m_food, delegate(SharedData shared, float value) { shared.m_food = value; }); statcfg("Stamina", "Stamina value of " + englishName + ".", (SharedData shared) => shared.m_foodStamina, delegate(SharedData shared, float value) { shared.m_foodStamina = value; }); statcfg("Eitr", "Eitr value of " + englishName + ".", (SharedData shared) => shared.m_foodEitr, delegate(SharedData shared, float value) { shared.m_foodEitr = value; }); statcfg("Duration", "Duration of " + englishName + ".", (SharedData shared) => shared.m_foodBurnTime, delegate(SharedData shared, float value) { shared.m_foodBurnTime = value; }); statcfg("Health Regen", "Health regen value of " + englishName + ".", (SharedData shared) => shared.m_foodRegen, delegate(SharedData shared, float value) { shared.m_foodRegen = value; }); } if ((int)shared2.m_skillType == 10) { statcfg("Health Cost", "Health cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealth, delegate(SharedData shared, float value) { shared.m_attack.m_attackHealth = value; }); statcfg("Health Cost Percentage", "Health cost percentage of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackHealthPercentage, delegate(SharedData shared, float value) { shared.m_attack.m_attackHealthPercentage = value; }); } skillType = shared2.m_skillType; if (skillType - 9 <= 1) { statcfg("Eitr Cost", "Eitr cost of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackEitr, delegate(SharedData shared, float value) { shared.m_attack.m_attackEitr = value; }); } if ((itemType - 3 <= 1 || (int)itemType == 14 || (int)itemType == 22) ? true : false) { statcfg("Knockback", "Knockback of " + englishName + ".", (SharedData shared) => shared.m_attackForce, delegate(SharedData shared, float value) { shared.m_attackForce = value; }); statcfg("Backstab Bonus", "Backstab bonus of " + englishName + ".", (SharedData shared) => shared.m_backstabBonus, delegate(SharedData shared, float value) { shared.m_backstabBonus = value; }); statcfg("Attack Stamina", "Attack stamina of " + englishName + ".", (SharedData shared) => shared.m_attack.m_attackStamina, delegate(SharedData shared, float value) { shared.m_attack.m_attackStamina = value; }); SetDmg("True", (DamageTypes dmg) => dmg.m_damage, delegate(ref DamageTypes dmg, float val) { dmg.m_damage = val; }); SetDmg("Slash", (DamageTypes dmg) => dmg.m_slash, delegate(ref DamageTypes dmg, float val) { dmg.m_slash = val; }); SetDmg("Pierce", (DamageTypes dmg) => dmg.m_pierce, delegate(ref DamageTypes dmg, float val) { dmg.m_pierce = val; }); SetDmg("Blunt", (DamageTypes dmg) => dmg.m_blunt, delegate(ref DamageTypes dmg, float val) { dmg.m_blunt = val; }); SetDmg("Chop", (DamageTypes dmg) => dmg.m_chop, delegate(ref DamageTypes dmg, float val) { dmg.m_chop = val; }); SetDmg("Pickaxe", (DamageTypes dmg) => dmg.m_pickaxe, delegate(ref DamageTypes dmg, float val) { dmg.m_pickaxe = val; }); SetDmg("Fire", (DamageTypes dmg) => dmg.m_fire, delegate(ref DamageTypes dmg, float val) { dmg.m_fire = val; }); SetDmg("Poison", (DamageTypes dmg) => dmg.m_poison, delegate(ref DamageTypes dmg, float val) { dmg.m_poison = val; }); SetDmg("Frost", (DamageTypes dmg) => dmg.m_frost, delegate(ref DamageTypes dmg, float val) { dmg.m_frost = val; }); SetDmg("Lightning", (DamageTypes dmg) => dmg.m_lightning, delegate(ref DamageTypes dmg, float val) { dmg.m_lightning = val; }); SetDmg("Spirit", (DamageTypes dmg) => dmg.m_spirit, delegate(ref DamageTypes dmg, float val) { dmg.m_spirit = val; }); if ((int)itemType == 4) { statcfg("Projectiles", "Number of projectiles that " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_projectileBursts, delegate(SharedData shared, int value) { shared.m_attack.m_projectileBursts = value; }); statcfg("Burst Interval", "Time between the projectiles " + englishName + " shoots at once.", (SharedData shared) => shared.m_attack.m_burstInterval, delegate(SharedData shared, float value) { shared.m_attack.m_burstInterval = value; }); statcfg("Minimum Accuracy", "Minimum accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracyMin, delegate(SharedData shared, float value) { shared.m_attack.m_projectileAccuracyMin = value; }); statcfg("Accuracy", "Accuracy for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileAccuracy, delegate(SharedData shared, float value) { shared.m_attack.m_projectileAccuracy = value; }); statcfg("Minimum Velocity", "Minimum velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVelMin, delegate(SharedData shared, float value) { shared.m_attack.m_projectileVelMin = value; }); statcfg("Velocity", "Velocity for " + englishName + ".", (SharedData shared) => shared.m_attack.m_projectileVel, delegate(SharedData shared, float value) { shared.m_attack.m_projectileVel = value; }); statcfg("Maximum Draw Time", "Time until " + englishName + " is fully drawn at skill level 0.", (SharedData shared) => shared.m_attack.m_drawDurationMin, delegate(SharedData shared, float value) { shared.m_attack.m_drawDurationMin = value; }); statcfg("Stamina Drain", "Stamina drain per second while drawing " + englishName + ".", (SharedData shared) => shared.m_attack.m_drawStaminaDrain, delegate(SharedData shared, float value) { shared.m_attack.m_drawStaminaDrain = value; }); } } } List traderAttributes; if ((item3.configurability & Configurability.Trader) != 0) { traderAttributes = new List(); item3.traderConfig = new TraderConfig { trader = config(englishName, "Trader Selling", item3.Trade.Trader, new ConfigDescription("Which traders sell " + englishName + ".", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = (order -= 1), Browsable = ((item3.configurationVisible & Configurability.Trader) != 0), Category = localizedName } })) }; item3.traderConfig.trader.SettingChanged += delegate { item3.ReloadTraderConfiguration(); foreach (ConfigurationManagerAttributes item10 in traderAttributes) { item10.Browsable = TraderBrowsability(); } reloadConfigDisplay(); }; item3.traderConfig.price = traderConfig("Trader Price", item3.Trade.Price, "Price of " + englishName + " at the trader."); item3.traderConfig.stack = traderConfig("Trader Stack", item3.Trade.Stack, "Stack size of " + englishName + " in the trader. Also known as the number of items sold by a trader in one transaction."); item3.traderConfig.requiredGlobalKey = traderConfig("Trader Required Global Key", item3.Trade.RequiredGlobalKey ?? "", "Required global key to unlock " + englishName + " at the trader."); if (item3.traderConfig.trader.Value != 0) { PrefabManager.AddItemToTrader(item3.Prefab, item3.traderConfig.trader.Value, item3.traderConfig.price.Value, item3.traderConfig.stack.Value, item3.traderConfig.requiredGlobalKey.Value); } } else if (item3.Trade.Trader != 0) { PrefabManager.AddItemToTrader(item3.Prefab, item3.Trade.Trader, item3.Trade.Price, item3.Trade.Stack, item3.Trade.RequiredGlobalKey); } void SetDmg(string dmgType, Func readDmg, setDmgFunc setDmg) { Func readDmg2 = readDmg; setDmgFunc setDmg2 = setDmg; statcfg(dmgType + " Damage", dmgType + " damage dealt by " + englishName + ".", (SharedData shared) => readDmg2(shared.m_damages), delegate(SharedData shared, float val) { setDmg2(ref shared.m_damages, val); }); statcfg(dmgType + " Damage Per Level", dmgType + " damage dealt increase per level for " + englishName + ".", (SharedData shared) => readDmg2(shared.m_damagesPerLevel), delegate(SharedData shared, float val) { setDmg2(ref shared.m_damagesPerLevel, val); }); } bool TraderBrowsability() { return item3.traderConfig.trader.Value != Trader.None; } void statcfg(string configName, string description, Func readDefault, Action setValue) where T : notnull { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown Action setValue2 = setValue; SharedData shared3 = item3.Prefab.GetComponent().m_itemData.m_shared; ConfigEntry cfg2 = config(englishName, configName, readDefault(shared3), new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Category = localizedName, Browsable = ((item3.configurationVisible & Configurability.Stats) != 0) } })); if ((item3.configurationVisible & Configurability.Stats) != 0) { setValue2(shared3, cfg2.Value); } item3.statsConfigs.Add((ConfigEntryBase)(object)cfg2, ApplyConfig); cfg2.SettingChanged += delegate { if ((item3.configurationVisible & Configurability.Stats) != 0) { ApplyConfig(); } }; void ApplyConfig() { item3.ApplyToAllInstances(delegate(ItemData item) { setValue2(item.m_shared, cfg2.Value); }); } } ConfigEntry traderConfig(string name, T value, string desc) where T : notnull { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes { Order = (order -= 1), browsability = TraderBrowsability, Browsable = (TraderBrowsability() && (item3.configurationVisible & Configurability.Trader) != 0), Category = localizedName }; traderAttributes.Add(configurationManagerAttributes2); ConfigEntry val5 = config(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes2 })); val5.SettingChanged += delegate { item3.ReloadTraderConfiguration(); }; return val5; } } if (saveOnConfigSet) { plugin.Config.SaveOnConfigSet = true; plugin.Config.Save(); } } configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); foreach (Item registeredItem in registeredItems) { Item item2 = registeredItem; foreach (KeyValuePair recipe in item2.Recipes) { KeyValuePair kv = recipe; RequiredResourceList[] array2 = new RequiredResourceList[2] { kv.Value.RequiredItems, kv.Value.RequiredUpgradeItems }; foreach (RequiredResourceList requiredResourceList in array2) { for (int l = 0; l < requiredResourceList.Requirements.Count; l++) { ConfigEntry amountCfg; int resourceIndex; if ((item2.configurability & Configurability.Recipe) != 0) { amountCfg = requiredResourceList.Requirements[l].amountConfig; if (amountCfg != null) { resourceIndex = l; amountCfg.SettingChanged += ConfigChanged; } } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(item2) && activeRecipes[item2].TryGetValue(kv.Key, out List value2)) { foreach (Recipe item11 in value2) { item11.m_resources[resourceIndex].m_amount = amountCfg.Value; } } } } } } item2.InitializeNewRegisteredItem(); } } private void InitializeNewRegisteredItem() { foreach (KeyValuePair recipe in Recipes) { KeyValuePair kv = recipe; ConfigEntryBase enabledCfg = kv.Value.RecipeIsActive; if (enabledCfg != null) { ((object)enabledCfg).GetType().GetEvent("SettingChanged").AddEventHandler(enabledCfg, new EventHandler(ConfigChanged)); } void ConfigChanged(object o, EventArgs e) { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(kv.Key, out List value)) { foreach (Recipe item in value) { item.m_enabled = (int)enabledCfg.BoxedValue != 0; } } } } } public void ReloadCraftingConfiguration() { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name)) == null) { registerRecipesInObjectDB(ObjectDB.instance); ObjectDB.instance.m_items.Add(Prefab); ObjectDB.instance.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab); ZNetScene.instance.m_prefabs.Add(Prefab); ZNetScene.instance.m_namedPrefabs.Add(StringExtensionMethods.GetStableHashCode(((Object)Prefab).name), Prefab); } foreach (string item in Recipes.Keys.DefaultIfEmpty("")) { if (Recipes.TryGetValue(item, out ItemRecipe value) && value.Crafting.Stations.Count > 0) { UpdateItemTableConfig(item, value.Crafting.Stations.First().Table, value.Crafting.Stations.First().custom ?? ""); UpdateCraftConfig(item, new SerializedRequirements(value.RequiredItems.Requirements), new SerializedRequirements(value.RequiredUpgradeItems.Requirements)); } } } private void ReloadTraderConfiguration() { if (traderConfig.trader.Value == Trader.None) { PrefabManager.RemoveItemFromTrader(Prefab); } else { PrefabManager.AddItemToTrader(Prefab, traderConfig.trader.Value, traderConfig.price.Value, traderConfig.stack.Value, traderConfig.requiredGlobalKey.Value); } } public static void ApplyToAllInstances(GameObject prefab, Action callback) { callback(prefab.GetComponent().m_itemData); string name = prefab.GetComponent().m_itemData.m_shared.m_name; Inventory[] source = (from c in Player.s_players.Select((Player p) => ((Humanoid)p).GetInventory()).Concat(from c in Object.FindObjectsOfType() select c.GetInventory()) where c != null select c).ToArray(); foreach (ItemData item in (from i in (from p in ObjectDB.instance.m_items select p.GetComponent() into c where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((Component)c).GetComponent()) select c).Concat(ItemDrop.s_instances) select i.m_itemData).Concat(source.SelectMany((Inventory i) => i.GetAllItems()))) { if (item.m_shared.m_name == name) { callback(item); } } } public void ApplyToAllInstances(Action callback) { ApplyToAllInstances(Prefab, callback); } private static string getInternalName(T value) where T : struct { return ((InternalName)typeof(T).GetMember(value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).internalName; } private void registerRecipesInObjectDB(ObjectDB objectDB) { //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Expected O, but got Unknown activeRecipes[this] = new Dictionary>(); itemCraftConfigs.TryGetValue(this, out Dictionary value); foreach (KeyValuePair recipe in Recipes) { List list = new List(); foreach (CraftingStationConfig station in recipe.Value.Crafting.Stations) { ItemConfig itemConfig = value?[recipe.Key]; Recipe val = ScriptableObject.CreateInstance(); string name = ((Object)Prefab).name; CraftingTable table = station.Table; ((Object)val).name = name + "_Recipe_" + table; val.m_amount = recipe.Value.CraftAmount; bool enabled; if (itemConfig != null) { enabled = itemConfig.table.Value != CraftingTable.Disabled; } else { ConfigEntryBase? recipeIsActive = recipe.Value.RecipeIsActive; enabled = (int)(((recipeIsActive != null) ? recipeIsActive.BoxedValue : null) ?? ((object)1)) != 0; } val.m_enabled = enabled; val.m_item = Prefab.GetComponent(); val.m_resources = SerializedRequirements.toPieceReqs(objectDB, (itemConfig?.craft == null) ? new SerializedRequirements(recipe.Value.RequiredItems.Requirements) : new SerializedRequirements(itemConfig.craft.Value), (itemConfig?.upgrade == null) ? new SerializedRequirements(recipe.Value.RequiredUpgradeItems.Requirements) : new SerializedRequirements(itemConfig.upgrade.Value)); table = ((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value); if ((uint)table <= 1u) { val.m_craftingStation = null; } else if (((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value) == CraftingTable.Custom) { GameObject prefab = ZNetScene.instance.GetPrefab((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value); if (prefab != null) { val.m_craftingStation = prefab.GetComponent(); } else { Debug.LogWarning((object)("Custom crafting station '" + ((itemConfig == null || list.Count > 0) ? station.custom : itemConfig.customTable.Value) + "' does not exist")); } } else { val.m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName((itemConfig == null || list.Count > 0) ? station.Table : itemConfig.table.Value)).GetComponent(); } val.m_minStationLevel = ((itemConfig == null || list.Count > 0) ? station.level : itemConfig.tableLevel.Value); val.m_requireOnlyOneIngredient = ((itemConfig == null) ? recipe.Value.RequireOnlyOneIngredient : (itemConfig.requireOneIngredient.Value == Toggle.On)); val.m_qualityResultAmountMultiplier = itemConfig?.qualityResultAmountMultiplier.Value ?? recipe.Value.QualityResultAmountMultiplier; list.Add(val); RequiredResourceList requiredItems = recipe.Value.RequiredItems; if (requiredItems != null && !requiredItems.Free) { List requirements = requiredItems.Requirements; if (requirements != null && requirements.Count == 0) { hiddenCraftRecipes.Add(val, recipe.Value.RecipeIsActive); } } requiredItems = recipe.Value.RequiredUpgradeItems; if (requiredItems != null && !requiredItems.Free) { List requirements = requiredItems.Requirements; if (requirements != null && requirements.Count == 0) { hiddenUpgradeRecipes.Add(val, recipe.Value.RecipeIsActive); } } } activeRecipes[this].Add(recipe.Key, list); objectDB.m_recipes.AddRange(list); } conversions = new List(); for (int i = 0; i < Conversions.Count; i++) { Conversion conversion = Conversions[i]; conversions.Add(new ItemConversion { m_from = SerializedRequirements.fetchByName(ObjectDB.instance, conversion.config?.input.Value ?? conversion.Input), m_to = Prefab.GetComponent() }); ConversionPiece conversionPiece = conversion.config?.piece.Value ?? conversion.Piece; string text = null; if (conversionPiece != 0 && conversions[i].m_from != null) { text = ((conversionPiece != ConversionPiece.Custom) ? getInternalName(conversionPiece) : (conversion.config?.customPiece.Value ?? conversion.customPiece)); GameObject prefab2 = ZNetScene.instance.GetPrefab(text); Smelter val2 = ((prefab2 != null) ? prefab2.GetComponent() : null); if (val2 != null) { val2.m_conversion.Add(conversions[i]); } else { text = null; } } if (conversion.config != null) { conversion.config.activePiece = text; } } } [HarmonyPriority(0)] internal static void Patch_ObjectDBInit(ObjectDB __instance) { if ((Object)(object)__instance.GetItemPrefab("YagluthDrop") == (Object)null) { return; } hiddenCraftRecipes.Clear(); hiddenUpgradeRecipes.Clear(); foreach (Item registeredItem in registeredItems) { registeredItem.registerRecipesInObjectDB(__instance); } } internal static void Patch_TraderGetAvailableItems(Trader __instance, ref List __result) { string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); if (1 == 0) { } Trader trader2 = ((prefabName == "Haldor") ? Trader.Haldor : ((prefabName == "Hildir") ? Trader.Hildir : Trader.None)); if (1 == 0) { } Trader trader = trader2; __result.AddRange(from tuple in PrefabManager.CustomTradeItems.Values where (tuple.Item1 & trader) != 0 select tuple.Item2 into tradeItem where string.IsNullOrEmpty(tradeItem.m_requiredGlobalKey) || ZoneSystem.instance.GetGlobalKey(tradeItem.m_requiredGlobalKey) select tradeItem); } internal static void Patch_OnAddSmelterInput(ItemData item, bool __result) { if (__result) { ((Humanoid)Player.m_localPlayer).UnequipItem(item, true); } } internal static void Patch_MaximumRequiredStationLevel(Recipe __instance, ref int __result, int quality) { if (!itemDropMap.TryGetValue(__instance.m_item, out Item value)) { return; } IEnumerable source; if (!itemCraftConfigs.TryGetValue(value, out Dictionary value2)) { source = Enumerable.Empty(); } else { CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation(); if (currentCraftingStation != null) { string stationName = Utils.GetPrefabName(((Component)currentCraftingStation).gameObject); source = from c in value2.Where(delegate(KeyValuePair c) { CraftingTable value3 = c.Value.table.Value; if (1 == 0) { } bool result; switch (value3) { case CraftingTable.Disabled: case CraftingTable.Inventory: result = false; break; case CraftingTable.Custom: result = c.Value.customTable.Value == stationName; break; default: result = getInternalName(c.Value.table.Value) == stationName; break; } if (1 == 0) { } return result; }) select c.Value; } else { source = value2.Values; } } __result = Mathf.Min(Mathf.Max(1, __instance.m_minStationLevel) + (quality - 1), (from cfg in source where cfg.maximumTableLevel != null select cfg.maximumTableLevel.Value).DefaultIfEmpty(value.MaximumRequiredStationLevel).Max()); } internal static void Patch_GetAvailableRecipesPrefix(ref Dictionary>? __state) { if (__state == null) { __state = new Dictionary>(); } Dictionary dictionary; if (InventoryGui.instance.InCraftTab()) { dictionary = hiddenCraftRecipes; } else { if (!InventoryGui.instance.InUpradeTab()) { return; } dictionary = hiddenUpgradeRecipes; } foreach (Recipe key in dictionary.Keys) { key.m_enabled = false; } __state[Assembly.GetExecutingAssembly()] = dictionary; } internal static void Patch_GetAvailableRecipesFinalizer(Dictionary> __state) { if (!__state.TryGetValue(Assembly.GetExecutingAssembly(), out Dictionary value)) { return; } foreach (KeyValuePair item in value) { Recipe key = item.Key; ConfigEntryBase value2 = item.Value; key.m_enabled = (int)(((value2 != null) ? value2.BoxedValue : null) ?? ((object)1)) != 0; } } internal static IEnumerable Transpile_SetupRequirementList(IEnumerable instructionsEnumerable, ILGenerator ilg) { //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Expected O, but got Unknown //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown List list = instructionsEnumerable.ToList(); MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(InventoryGui), "SetupRequirement", (Type[])null, (Type[])null); CodeInstruction val = null; CodeInstruction val2 = null; LocalBuilder localBuilder = ilg.DeclareLocal(typeof(int)); Dictionary dictionary = new Dictionary(); bool flag = false; int num = 0; int value = 0; Label? label = default(Label?); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { val = list[i + 2]; val2 = list[i + 5]; flag = true; } if (flag) { if (CodeInstructionExtensions.Branches(list[i], ref label) && dictionary.TryGetValue(label.Value, out value)) { num = i; break; } continue; } foreach (Label label4 in list[i].labels) { dictionary[label4] = i; } } if (list[value - 3].opcode == OpCodes.Dup) { return list; } Label label2 = ilg.DefineLabel(); Label label3 = ilg.DefineLabel(); list[num + 1].labels.Add(label2); list.InsertRange(num + 1, (IEnumerable)(object)new CodeInstruction[11] { new CodeInstruction(OpCodes.Ldloc, (object)localBuilder), new CodeInstruction(OpCodes.Brfalse, (object)label2), val.Clone(), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.DeclaredField(typeof(InventoryGui), "m_recipeRequirementList")), new CodeInstruction(OpCodes.Ldlen, (object)null), new CodeInstruction(OpCodes.Bgt, (object)label2), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), val2.Clone(), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Br, (object)label3) }); list.InsertRange(value - 2, (IEnumerable)(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Dup, (object)null) { labels = new List