using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ShipEquipment")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ShipEquipment")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1dfd2955-15aa-482e-ba47-30ef42456b96")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] public class SimpleFloat : MonoBehaviour { private Vector3 _startPos; private void Start() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) _startPos = ((Component)this).transform.localPosition; } private void Update() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Sin(Time.time * 2f) * 0.05f; ((Component)this).transform.localPosition = _startPos + new Vector3(0f, num, 0f); } } namespace HardheimShipEquipment; [BepInPlugin("h4nz0.hardheimshipequipment", "HardheimShipEquipment", "1.0.0")] [BepInDependency("com.jotunn.jotunn", "2.29.0")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class HardheimShipEquipmentPlugin : BaseUnityPlugin { private sealed class UnityAudioSpamFilterLogHandler : ILogHandler { private readonly ILogHandler _inner; public UnityAudioSpamFilterLogHandler(ILogHandler inner) { _inner = inner; } public void LogFormat(LogType logType, Object context, string format, params object[] args) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) try { string text = ((args != null && args.Length != 0) ? string.Format(format, args) : format); if (text != null && text.Contains("Attempting to set `time` on an audio source")) { return; } } catch { } ILogHandler inner = _inner; if (inner != null) { inner.LogFormat(logType, context, format, args); } } public void LogException(Exception exception, Object context) { ILogHandler inner = _inner; if (inner != null) { inner.LogException(exception, context); } } } public const string ModGuid = "h4nz0.hardheimshipequipment"; public const string ModName = "HardheimShipEquipment"; public const string ModVersion = "1.0.0"; public const string ShipTorchPrefabName = "HH_ShipTorch"; public const string ShipTorchIronPrefabName = "HH_ShipTorchIron"; public const string ShipTorchMistPrefabName = "HH_ShipTorchMist"; public const string DrumHoopsItemName = "HH_DrumHoops"; public const string ShipDrumPrefabName = "HH_ShipDrum"; private const string RpcRegisterGender = "HH_RegisterGender"; private const string RpcSyncGender = "HH_SyncGender"; public const string ZdoSongIndex = "hh_song_index"; public const string ZdoSongDrumActive = "hh_song_drum_active"; public const string ZdoSongDrumStart = "hh_song_drum_start"; public const string ZdoSongDrummerId = "hh_song_drummer_id"; public const string ZdoSongDrummerHeartbeat = "hh_song_drummer_heartbeat"; public const string ZdoSongVocalStart = "hh_song_vocal_start"; public const string ZdoSongMaleVocalCount = "hh_song_male_vocal_count"; public const string ZdoSongFemaleVocalCount = "hh_song_female_vocal_count"; public const string ZdoSongMaleVocalPlayerId = "hh_song_male_vocal_player_id"; public const string ZdoSongFemaleVocalPlayerId = "hh_song_female_vocal_player_id"; public const string ZdoSongFinishedToken = "hh_song_finished_token"; public const string ZdoSongFinishedIndex = "hh_song_finished_index"; public const string SongBuffInternalName = "HardheimSongBuff"; public static readonly int SongBuffHash = StringExtensionMethods.GetStableHashCode("HardheimSongBuff"); public const string UnderworldBuffInternalName = "HardheimUnderworldBuff"; public const float UnderworldArmorMultiplier = 1.1f; public const float UnderworldMaxStaminaMultiplier = 1.1f; internal static HardheimShipEquipmentPlugin Instance; internal static ManualLogSource Log; private Harmony _harmony; private bool _pieceRegistered; private string _modRootPath; private string _pluginsPath; private string _soundsPath; private string _genderYamlPath; private readonly Dictionary _genderById = new Dictionary(StringComparer.OrdinalIgnoreCase); private bool _localPlayerRegistered; private bool _genderRpcRegistered; private static ILogHandler _originalUnityLogHandler; private static bool _unityAudioSpamFilterInstalled; internal static ConfigEntry CfgEnableMod; internal static ConfigEntry CfgDebug; internal static ConfigEntry CfgAttachSearchRadius; internal static ConfigEntry CfgReattachInterval; internal static ConfigEntry CfgPieceTable; internal static ConfigEntry CfgCategory; internal static ConfigEntry CfgWoodCost; internal static ConfigEntry CfgResinCost; internal static ConfigEntry CfgDestroyIfNotOnShip; internal static ConfigEntry CfgNoRoofWear; internal static ConfigEntry CfgGhostSnapSearchRadius; internal static ConfigEntry CfgMarkerOffsetY; internal static ConfigEntry CfgMarkerOffsetStep; internal static ConfigEntry CfgFinalPlacementOffsetY; internal static ConfigEntry CfgMarkerOffsetUpKey; internal static ConfigEntry CfgMarkerOffsetDownKey; internal static ConfigEntry CfgMarkerOffsetLogKey; internal static ConfigEntry CfgDumpHHStateKey; internal static ConfigEntry CfgEnableMigrationFileLog; internal static ConfigEntry CfgKeepMigrationLogs; internal static ConfigEntry CfgMigrationPlayerProximityRadius; private static AssetBundle _iconBundle; private static Sprite _drumRingIcon; private static Sprite _drumIcon; private static AssetBundle _drumBundle; private static GameObject _drumPrefab; internal string SoundsPath => _soundsPath; private void EnsureModFolders() { try { _modRootPath = Path.Combine(Paths.ConfigPath, "HardheimShipEquipment"); _pluginsPath = Path.Combine(_modRootPath, "plugins"); _soundsPath = Path.Combine(_modRootPath, "sounds"); Directory.CreateDirectory(_modRootPath); Directory.CreateDirectory(_pluginsPath); Directory.CreateDirectory(_soundsPath); _genderYamlPath = Path.Combine(_modRootPath, "player_genders.yml"); EnsureGenderYamlExists(); LoadGenderYaml(); Log.LogInfo((object)"[HardheimShipEquipment] Mappák létrehozva:"); Log.LogInfo((object)("Root: " + _modRootPath)); Log.LogInfo((object)("Plugins: " + _pluginsPath)); Log.LogInfo((object)("Sounds: " + _soundsPath)); Log.LogInfo((object)("GenderYaml: " + _genderYamlPath)); } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Hiba mappák létrehozásakor: {1}", "HardheimShipEquipment", arg)); } } private void EnsureGenderYamlExists() { try { if (!string.IsNullOrWhiteSpace(_genderYamlPath) && !File.Exists(_genderYamlPath)) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("# Hardheim Ship Equipment - player gender map"); stringBuilder.AppendLine("# Kulcs: SteamID / fallback player profile ID"); stringBuilder.AppendLine("# Érték: male vagy female"); stringBuilder.AppendLine("players:"); stringBuilder.AppendLine(" \"76561198000000000\": male"); stringBuilder.AppendLine(" \"76561198000000001\": female"); File.WriteAllText(_genderYamlPath, stringBuilder.ToString(), Encoding.UTF8); Log.LogInfo((object)("[HardheimShipEquipment] Létrehozva: " + _genderYamlPath)); } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Gender YAML create error: {1}", "HardheimShipEquipment", arg)); } } private void LoadGenderYaml() { _genderById.Clear(); try { if (string.IsNullOrWhiteSpace(_genderYamlPath) || !File.Exists(_genderYamlPath)) { return; } string[] array = File.ReadAllLines(_genderYamlPath, Encoding.UTF8); string[] array2 = array; foreach (string text in array2) { if (string.IsNullOrWhiteSpace(text)) { continue; } string text2 = text.Trim(); if (text2.StartsWith("#") || text2.Equals("players:", StringComparison.OrdinalIgnoreCase)) { continue; } int num = text2.IndexOf(':'); if (num > 0) { string text3 = text2.Substring(0, num).Trim().Trim(new char[1] { '"' }); string text4 = text2.Substring(num + 1).Trim().Trim(new char[1] { '"' }) .ToLowerInvariant(); if (!string.IsNullOrWhiteSpace(text3) && (!(text4 != "male") || !(text4 != "female"))) { _genderById[text3] = text4; } } } Log.LogInfo((object)string.Format("[{0}] Gender YAML entries betöltve: {1}", "HardheimShipEquipment", _genderById.Count)); } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Gender YAML load error: {1}", "HardheimShipEquipment", arg)); } } private void SaveGenderYaml() { try { if (string.IsNullOrWhiteSpace(_genderYamlPath)) { return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("# Hardheim Ship Equipment - player gender map"); stringBuilder.AppendLine("# Kulcs: SteamID / fallback player profile ID"); stringBuilder.AppendLine("# Érték: male vagy female"); stringBuilder.AppendLine("players:"); foreach (KeyValuePair item in _genderById.OrderBy, string>((KeyValuePair k) => k.Key, StringComparer.OrdinalIgnoreCase)) { stringBuilder.AppendLine(" \"" + item.Key + "\": " + item.Value); } File.WriteAllText(_genderYamlPath, stringBuilder.ToString(), Encoding.UTF8); } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Gender YAML save error: {1}", "HardheimShipEquipment", arg)); } } internal string ResolveLocalPlayerIdentityKey(Player player) { try { if ((Object)(object)ZNet.instance != (Object)null) { MethodInfo method = typeof(ZNet).GetMethod("GetUID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method != null) { object obj = method.Invoke(ZNet.instance, null); if (obj != null) { string text = obj.ToString(); if (!string.IsNullOrWhiteSpace(text) && text != "0") { return text; } } } } } catch (Exception arg) { Log.LogDebug((object)string.Format("[{0}] ResolveLocalPlayerIdentityKey ZNet.GetUID error: {1}", "HardheimShipEquipment", arg)); } try { if ((Object)(object)Game.instance != (Object)null) { PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); if (playerProfile != null) { long playerID = playerProfile.GetPlayerID(); if (playerID != 0) { return playerID.ToString(); } } } } catch (Exception arg2) { Log.LogDebug((object)string.Format("[{0}] ResolveLocalPlayerIdentityKey profile error: {1}", "HardheimShipEquipment", arg2)); } try { if ((Object)(object)player != (Object)null) { string playerName = player.GetPlayerName(); if (!string.IsNullOrWhiteSpace(playerName)) { return playerName; } } } catch { } return "unknown"; } internal bool ResolveFemaleFromYaml(Player player) { string text = ResolveLocalPlayerIdentityKey(player); if (string.IsNullOrWhiteSpace(text)) { text = "unknown"; } if (_genderById.Count == 0) { LoadGenderYaml(); } if (_genderById.TryGetValue(text, out var value)) { bool result = string.Equals(value, "female", StringComparison.OrdinalIgnoreCase); Log.LogDebug((object)("[HardheimShipEquipment] Gender YAML hit: key=" + text + " gender=" + value)); return result; } Log.LogWarning((object)("[HardheimShipEquipment] Gender YAML miss: key=" + text + ". Default=male")); return false; } internal void ReloadGenderYamlNow() { LoadGenderYaml(); } internal void RegisterLocalPlayerGender(Player player) { //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown if (_localPlayerRegistered) { return; } if ((Object)(object)player == (Object)null) { Log.LogInfo((object)"[HardheimShipEquipment] RegisterLocalPlayerGender: player == null"); return; } if (_genderById.Count == 0) { LoadGenderYaml(); } string text = ResolveLocalPlayerIdentityKey(player); Log.LogInfo((object)("[HardheimShipEquipment] RegisterLocalPlayerGender: resolved key = " + text)); if (string.IsNullOrWhiteSpace(text)) { Log.LogWarning((object)"[HardheimShipEquipment] RegisterLocalPlayerGender: empty key"); return; } if (!TryDetectGender(player, out var gender)) { Log.LogInfo((object)"[HardheimShipEquipment] RegisterLocalPlayerGender: gender not ready yet, retry later"); return; } string value; bool flag = !_genderById.TryGetValue(text, out value) || !string.Equals(value, gender, StringComparison.OrdinalIgnoreCase); _genderById[text] = gender; if (flag) { SaveGenderYaml(); Log.LogInfo((object)("[HardheimShipEquipment] LOCAL gender saved/updated: key=" + text + " gender=" + gender)); } else { Log.LogInfo((object)("[HardheimShipEquipment] LOCAL gender unchanged: key=" + text + " gender=" + gender)); } if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { Log.LogInfo((object)"[HardheimShipEquipment] RegisterLocalPlayerGender running on server, no RPC needed"); } else if (ZRoutedRpc.instance != null) { ZPackage val = new ZPackage(); val.Write(text); val.Write(gender); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "HH_RegisterGender", new object[1] { val }); Log.LogInfo((object)("[HardheimShipEquipment] CLIENT gender sent to server: key=" + text + " gender=" + gender)); } else { Log.LogWarning((object)"[HardheimShipEquipment] CLIENT could not send gender to server, ZRoutedRpc.instance == null"); } _localPlayerRegistered = true; } private void RPC_RegisterGender(long sender, ZPackage pkg) { try { if (pkg == null) { return; } string text = pkg.ReadString(); string text2 = pkg.ReadString(); if (!string.IsNullOrWhiteSpace(text) && (!(text2 != "male") || !(text2 != "female"))) { if (_genderById.Count == 0) { LoadGenderYaml(); } string value; bool flag = !_genderById.TryGetValue(text, out value) || !string.Equals(value, text2, StringComparison.OrdinalIgnoreCase); _genderById[text] = text2; if (flag) { SaveGenderYaml(); Log.LogInfo((object)string.Format("[{0}] SERVER gender saved/updated: key={1} gender={2} sender={3}", "HardheimShipEquipment", text, text2, sender)); } else { Log.LogInfo((object)("[HardheimShipEquipment] SERVER gender unchanged: key=" + text + " gender=" + text2)); } } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] RPC_RegisterGender error: {1}", "HardheimShipEquipment", arg)); } } private void RPC_SyncGender(long sender, ZPackage pkg) { try { if (pkg == null) { return; } string text = pkg.ReadString(); string text2 = pkg.ReadString(); if (!string.IsNullOrWhiteSpace(text) && (!(text2 != "male") || !(text2 != "female"))) { if (_genderById.Count == 0) { LoadGenderYaml(); } _genderById[text] = text2; SaveGenderYaml(); Log.LogInfo((object)string.Format("[{0}] CLIENT gender synced: key={1} gender={2} sender={3}", "HardheimShipEquipment", text, text2, sender)); } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] RPC_SyncGender error: {1}", "HardheimShipEquipment", arg)); } } private bool TryDetectGender(Player player, out string gender) { gender = null; if ((Object)(object)player == (Object)null) { return false; } try { if (TryReadModelIndex(player, out var modelIndex)) { Log.LogInfo((object)string.Format("[{0}] TryDetectGender: modelIndex={1}", "HardheimShipEquipment", modelIndex)); switch (modelIndex) { case 0: gender = "male"; return true; case 1: gender = "female"; return true; } } Animator val = ((Component)player).GetComponentInChildren(true) ?? ((Component)player).GetComponent(); if ((Object)(object)val != (Object)null && (Object)(object)val.avatar != (Object)null) { string text = ((Object)val.avatar).name ?? ""; string text2 = text.ToLowerInvariant(); Log.LogInfo((object)("[HardheimShipEquipment] TryDetectGender: avatar=" + text)); if (text2.Contains("female")) { gender = "female"; return true; } if (text2.Contains("male")) { gender = "male"; return true; } } } catch (Exception arg) { Log.LogWarning((object)string.Format("[{0}] TryDetectGender error: {1}", "HardheimShipEquipment", arg)); } return false; } private bool TryReadModelIndex(Player player, out int modelIndex) { modelIndex = -1; BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; try { if (TryReadIntMember(player, ((object)player).GetType(), bindingFlags, out modelIndex, "m_modelIndex", "modelIndex", "m_playerModel", "playerModel")) { return true; } VisEquipment val = ((Component)player).GetComponentInChildren(true) ?? ((Component)player).GetComponent(); if ((Object)(object)val != (Object)null && TryReadIntMember(val, ((object)val).GetType(), bindingFlags, out modelIndex, "m_modelIndex", "modelIndex", "m_currentModel", "m_model", "m_modelType")) { return true; } if ((Object)(object)player == (Object)(object)Player.m_localPlayer && (Object)(object)Game.instance != (Object)null) { PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); if (playerProfile != null) { MethodInfo method = ((object)playerProfile).GetType().GetMethod("GetPlayerModel", bindingFlags, null, Type.EmptyTypes, null); if (method != null && method.Invoke(playerProfile, null) is int num) { modelIndex = num; return true; } if (TryReadIntMember(playerProfile, ((object)playerProfile).GetType(), bindingFlags, out modelIndex, "m_playerModel", "m_modelIndex", "modelIndex")) { return true; } } } } catch (Exception arg) { Log.LogWarning((object)string.Format("[{0}] TryReadModelIndex error: {1}", "HardheimShipEquipment", arg)); } return false; } private bool TryReadIntMember(object instance, Type type, BindingFlags flags, out int value, params string[] memberNames) { value = -1; foreach (string text in memberNames) { FieldInfo field = type.GetField(text, flags); if (field != null && field.FieldType == typeof(int) && field.GetValue(instance) is int num) { value = num; Log.LogInfo((object)string.Format("[{0}] TryReadIntMember field {1}.{2} = {3}", "HardheimShipEquipment", type.Name, text, value)); return true; } PropertyInfo property = type.GetProperty(text, flags); if (property != null && property.PropertyType == typeof(int) && property.CanRead && property.GetIndexParameters().Length == 0 && property.GetValue(instance, null) is int num2) { value = num2; Log.LogInfo((object)string.Format("[{0}] TryReadIntMember property {1}.{2} = {3}", "HardheimShipEquipment", type.Name, text, value)); return true; } } return false; } private void LoadIconBundle() { try { string text = Path.Combine(Paths.ConfigPath, "HardheimShipEquipment", "plugins", "hardheim_icons"); if (!File.Exists(text)) { Log.LogWarning((object)("[HardheimShipEquipment] Ikon bundle nem található: " + text)); return; } _iconBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_iconBundle == (Object)null) { Log.LogError((object)"[HardheimShipEquipment] Nem sikerült betölteni az ikon bundle-t."); return; } _drumRingIcon = _iconBundle.LoadAsset("drum_ring"); if ((Object)(object)_drumRingIcon == (Object)null) { Log.LogError((object)"[HardheimShipEquipment] Nem található sprite: drum_ring"); return; } _drumIcon = _iconBundle.LoadAsset("drum_icon"); if ((Object)(object)_drumIcon == (Object)null) { Log.LogWarning((object)"[HardheimShipEquipment] Nem található sprite: drum_icon"); } Log.LogInfo((object)"[HardheimShipEquipment] Drum icon betöltve!"); } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Bundle load error: {1}", "HardheimShipEquipment", arg)); } } private void LoadDrumBundle() { try { string text = Path.Combine(Paths.ConfigPath, "HardheimShipEquipment", "plugins", "hardheimship"); if (!File.Exists(text)) { Log.LogWarning((object)("[HardheimShipEquipment] Drum bundle nem található: " + text)); return; } _drumBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_drumBundle == (Object)null) { Log.LogError((object)"[HardheimShipEquipment] Nem sikerült betölteni a drum bundle-t."); return; } _drumPrefab = _drumBundle.LoadAsset("HH_ShipDrumVisual"); if ((Object)(object)_drumPrefab == (Object)null) { Log.LogError((object)"[HardheimShipEquipment] HH_ShipDrumVisual prefab nincs a bundle-ben."); } else { Log.LogInfo((object)"[HardheimShipEquipment] Drum prefab betöltve!"); } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Drum bundle load error: {1}", "HardheimShipEquipment", arg)); } } private static void InstallUnityAudioSpamFilter() { if (!_unityAudioSpamFilterInstalled) { _originalUnityLogHandler = Debug.unityLogger.logHandler; Debug.unityLogger.logHandler = (ILogHandler)(object)new UnityAudioSpamFilterLogHandler(_originalUnityLogHandler); _unityAudioSpamFilterInstalled = true; } } private void Awake() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown InstallUnityAudioSpamFilter(); Instance = this; Log = ((BaseUnityPlugin)this).Logger; EnsureModFolders(); LoadIconBundle(); LoadDrumBundle(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; BindConfigs(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); SynchronizationManager.OnConfigurationSynchronized += OnConfigurationSynchronized; SynchronizationManager.OnAdminStatusChanged += OnAdminStatusChanged; if (!CfgEnableMod.Value) { Log.LogInfo((object)"[HardheimShipEquipment] Mod letiltva konfiguráció alapján."); return; } _harmony = new Harmony("h4nz0.hardheimshipequipment"); _harmony.PatchAll(); ((Component)this).gameObject.AddComponent(); if (ZRoutedRpc.instance != null) { EnsureGenderRpcRegistered(); } else { Log.LogWarning((object)"[HardheimShipEquipment] ZRoutedRpc.instance == null az Awake-ben"); } PrefabManager.OnVanillaPrefabsAvailable += RegisterPiece; Log.LogInfo((object)"[HardheimShipEquipment] Mod betöltve."); LogDebugConfigSnapshot("Awake"); } private void EnsureGenderRpcRegistered() { if (!_genderRpcRegistered && ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register("HH_RegisterGender", (Action)RPC_RegisterGender); ZRoutedRpc.instance.Register("HH_SyncGender", (Action)RPC_SyncGender); _genderRpcRegistered = true; Log.LogInfo((object)"[HardheimShipEquipment] Gender RPC registered: HH_RegisterGender, HH_SyncGender"); } } private void Update() { try { if (CfgEnableMod.Value) { EnsureGenderRpcRegistered(); if (!_localPlayerRegistered && !((Object)(object)Player.m_localPlayer == (Object)null)) { RegisterLocalPlayerGender(Player.m_localPlayer); } } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Update RegisterLocalPlayerGender error: {1}", "HardheimShipEquipment", arg)); } } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterPiece; SynchronizationManager.OnConfigurationSynchronized -= OnConfigurationSynchronized; SynchronizationManager.OnAdminStatusChanged -= OnAdminStatusChanged; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } PendingShipPlacement.Clear(); LastShipRaycastHit.Clear(); if (_unityAudioSpamFilterInstalled && _originalUnityLogHandler != null) { Debug.unityLogger.logHandler = _originalUnityLogHandler; _originalUnityLogHandler = null; _unityAudioSpamFilterInstalled = false; } } private void BindConfigs() { //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) CfgEnableMod = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "1 - General", "Enabled", true, "Mod engedélyezése.", true, true, true, (AcceptableValueBase)null, (Action)null, (ConfigurationManagerAttributes)null); CfgDebug = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "9 - Debug", "EnableDebug", false, "Debug logok engedélyezése.", true, true, true, (AcceptableValueBase)null, (Action)null, (ConfigurationManagerAttributes)null); CfgAttachSearchRadius = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "1 - General", "AttachSearchRadius", 12f, "Mekkora sugarú körben keressen hajót a lerakott HH_ építmény.", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(1f, 30f), (Action)null, (ConfigurationManagerAttributes)null); CfgReattachInterval = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "1 - General", "ReattachInterval", 0.5f, "Milyen gyakran próbálja újrakeresni a hajó referenciát a lerakott HH_ építmény.", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 30f), (Action)null, (ConfigurationManagerAttributes)null); CfgDestroyIfNotOnShip = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "1 - General", "DestroyIfNotOnShip", true, "Ha lerakás után nem talál hajót, törölje magát.", true, true, true, (AcceptableValueBase)null, (Action)null, (ConfigurationManagerAttributes)null); CfgNoRoofWear = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "1 - General", "NoRoofWear", true, "Ne sérüljön tető hiánya miatt.", true, true, true, (AcceptableValueBase)null, (Action)null, (ConfigurationManagerAttributes)null); CfgPieceTable = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "2 - Build", "PieceTable", "_HammerPieceTable", "Melyik build menübe kerüljön a hajófáklya.", true, true, true, (AcceptableValueBase)null, (Action)null, (ConfigurationManagerAttributes)null); CfgCategory = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "2 - Build", "Category", "Hajófelszerelés", "Kategória neve a kalapácsban. Példa: Hajófelszerelés", false, true, true, (AcceptableValueBase)null, (Action)null, (ConfigurationManagerAttributes)null); CfgWoodCost = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "2 - Build", "WoodCost", 2, "Fa költség.", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), (Action)null, (ConfigurationManagerAttributes)null); CfgResinCost = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "2 - Build", "ResinCost", 2, "Gyanta költség.", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), (Action)null, (ConfigurationManagerAttributes)null); CfgGhostSnapSearchRadius = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "3 - Placement", "GhostSnapSearchRadius", 4f, "Mekkora sugarú körben számítson hajónak a HH_ lerakási pont környezete.", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 12f), (Action)null, (ConfigurationManagerAttributes)null); CfgMarkerOffsetY = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "3 - Placement", "MarkerOffsetY", 0.54f, "A sárga placement markerhez képesti függőleges offset a HH_ preview ghost számára.", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(-2f, 2f), (Action)null, (ConfigurationManagerAttributes)null); CfgMarkerOffsetStep = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "3 - Placement", "MarkerOffsetStep", 0.01f, "Mennyit változzon a MarkerOffsetY a hotkeyek használatakor.", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(0.001f, 0.5f), (Action)null, (ConfigurationManagerAttributes)null); CfgMarkerOffsetUpKey = ((BaseUnityPlugin)this).Config.Bind("8 - Hotkeys", "MarkerOffsetUpKey", new KeyboardShortcut((KeyCode)280, Array.Empty()), "MarkerOffsetY növelése."); CfgMarkerOffsetDownKey = ((BaseUnityPlugin)this).Config.Bind("8 - Hotkeys", "MarkerOffsetDownKey", new KeyboardShortcut((KeyCode)281, Array.Empty()), "MarkerOffsetY csökkentése."); CfgMarkerOffsetLogKey = ((BaseUnityPlugin)this).Config.Bind("8 - Hotkeys", "MarkerOffsetLogKey", new KeyboardShortcut((KeyCode)279, Array.Empty()), "Aktuális marker/ghost offset kilogolása és mentése."); CfgEnableMigrationFileLog = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "9 - Debug", "EnableMigrationFileLog", true, "Mentse a migration / restore / bind eseményeket napi txt fájlba.", false, true, true, (AcceptableValueBase)null, (Action)null, (ConfigurationManagerAttributes)null); CfgKeepMigrationLogs = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "9 - Debug", "KeepMigrationLogs", 5, "Hány napi migration txt log maradjon meg a mappában.", false, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(1, 30), (Action)null, (ConfigurationManagerAttributes)null); CfgMigrationPlayerProximityRadius = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "9 - Debug", "MigrationPlayerProximityRadius", 64f, "Csak akkor próbáljon migrálni egy HH_ itemet, ha játékos van a közelében.", false, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(5f, 200f), (Action)null, (ConfigurationManagerAttributes)null); CfgFinalPlacementOffsetY = ConfigFileExtensions.BindConfigInOrder(((BaseUnityPlugin)this).Config, "3 - Placement", "FinalPlacementOffsetY", 0f, "A lerakott HH_ építmény végleges függőleges offsetje a marker/hit ponthoz képest.", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange(-1f, 1f), (Action)null, (ConfigurationManagerAttributes)null); CfgDumpHHStateKey = ((BaseUnityPlugin)this).Config.Bind("9 - Debug", "DumpHHStateKey", new KeyboardShortcut((KeyCode)278, Array.Empty()), "Kilistázza az összes HH_ item állapotát (migration debug)."); } private void OnConfigurationSynchronized(object sender, ConfigurationSynchronizationEventArgs args) { string arg = (args.InitialSynchronization ? "Initial" : "Runtime"); Log.LogInfo((object)string.Format("[{0}] Konfig szinkron esemény: {1}. PlayerIsAdmin={2}", "HardheimShipEquipment", arg, SynchronizationManager.Instance.PlayerIsAdmin)); LogDebugConfigSnapshot("OnConfigurationSynchronized"); } private void OnAdminStatusChanged() { Log.LogInfo((object)string.Format("[{0}] Admin státusz szinkron frissült. PlayerIsAdmin={1}", "HardheimShipEquipment", SynchronizationManager.Instance.PlayerIsAdmin)); } private void RegisterPiece() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Expected O, but got Unknown //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Expected O, but got Unknown //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Expected O, but got Unknown //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Expected O, but got Unknown //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Expected O, but got Unknown //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Expected O, but got Unknown //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Expected O, but got Unknown //IL_061d: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Expected O, but got Unknown //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Expected O, but got Unknown //IL_0822: Unknown result type (might be due to invalid IL or missing references) if (_pieceRegistered) { return; } try { PieceConfig val = new PieceConfig(); val.Name = "Hajófáklya"; val.Description = "Csak hajóra építhető fáklya."; val.PieceTable = CfgPieceTable.Value; val.Category = "Hajófelszerelés"; val.AllowedInDungeons = true; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("RoundLog", CfgWoodCost.Value, 0, true), new RequirementConfig("Resin", CfgResinCost.Value, 0, true) }; PieceConfig val2 = val; CustomPiece val3 = new CustomPiece("HH_ShipTorch", "piece_groundtorch_wood", val2); Piece piece = val3.Piece; if ((Object)(object)piece == (Object)null) { Log.LogError((object)"[HardheimShipEquipment] Nem sikerült létrehozni a custom piece-t: HH_ShipTorch"); return; } DebugHoverSources(((Component)piece).gameObject, "HH_ShipTorch"); piece.m_name = "Hajófáklya"; piece.m_description = "Csak hajóra építhető fáklya."; piece.m_canBeRemoved = true; piece.m_groundPiece = false; piece.m_groundOnly = false; piece.m_cultivatedGroundOnly = false; piece.m_waterPiece = true; piece.m_noInWater = false; piece.m_notOnWood = false; piece.m_notOnTiltingSurface = false; piece.m_inCeilingOnly = false; piece.m_notOnFloor = false; piece.m_mustConnectTo = null; piece.m_mustBeAboveConnected = false; piece.m_clipGround = false; piece.m_clipEverything = false; piece.m_craftingStation = null; piece.m_onlyInTeleportArea = false; piece.m_allowedInDungeons = true; WearNTear component = ((Component)piece).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Rigidbody component2 = ((Component)piece).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.isKinematic = true; component2.useGravity = false; } Collider[] componentsInChildren = ((Component)piece).GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val4 in array) { if ((Object)(object)val4 != (Object)null) { val4.isTrigger = true; } } ((Component)piece).gameObject.layer = LayerMask.NameToLayer("piece_nonsolid"); if ((Object)(object)((Component)piece).GetComponent() == (Object)null) { ((Component)piece).gameObject.AddComponent(); } StripVanillaTorchHoverSources(((Component)piece).gameObject); ShipTorchHover shipTorchHover = ((Component)piece).gameObject.GetComponent(); if ((Object)(object)shipTorchHover == (Object)null) { shipTorchHover = ((Component)piece).gameObject.AddComponent(); } shipTorchHover.HoverName = "Hajófáklya"; shipTorchHover.HoverText = "Hajófáklya"; PieceManager.Instance.AddPiece(val3); LogDebug("[HardheimShipEquipment] Hajófáklya piece regisztrálva: HH_ShipTorch"); val = new PieceConfig(); val.Name = "Vas hajófáklya"; val.Description = "Erősebb fényt adó hajófáklya. Tartósabb és nagyobb fényt biztosít."; val.PieceTable = CfgPieceTable.Value; val.Category = "Hajófelszerelés"; val.AllowedInDungeons = true; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("RoundLog", 1, 0, true), new RequirementConfig("Resin", 2, 0, true) }; PieceConfig val5 = val; CustomPiece val6 = new CustomPiece("HH_ShipTorchIron", "piece_groundtorch", val5); Piece piece2 = val6.Piece; piece2.m_name = "Vas hajófáklya"; piece2.m_description = "Erősebb fényt adó hajófáklya. Tartósabb és nagyobb fényt biztosít."; if ((Object)(object)piece2 == (Object)null) { Log.LogError((object)"[HardheimShipEquipment] Nem sikerült létrehozni a custom piece-t: HH_ShipTorchIron"); return; } DebugHoverSources(((Component)piece2).gameObject, "HH_ShipTorchIron"); piece2.m_canBeRemoved = true; piece2.m_groundPiece = false; piece2.m_groundOnly = false; piece2.m_cultivatedGroundOnly = false; piece2.m_waterPiece = true; piece2.m_noInWater = false; piece2.m_notOnWood = false; piece2.m_notOnTiltingSurface = false; piece2.m_inCeilingOnly = false; piece2.m_notOnFloor = false; piece2.m_mustConnectTo = null; piece2.m_mustBeAboveConnected = false; piece2.m_clipGround = false; piece2.m_clipEverything = false; piece2.m_craftingStation = null; piece2.m_onlyInTeleportArea = false; piece2.m_allowedInDungeons = true; WearNTear component3 = ((Component)piece2).GetComponent(); if ((Object)(object)component3 != (Object)null) { Object.Destroy((Object)(object)component3); } Rigidbody component4 = ((Component)piece2).GetComponent(); if ((Object)(object)component4 != (Object)null) { component4.isKinematic = true; component4.useGravity = false; } Collider[] componentsInChildren2 = ((Component)piece2).GetComponentsInChildren(true); Collider[] array2 = componentsInChildren2; foreach (Collider val7 in array2) { if ((Object)(object)val7 != (Object)null) { val7.isTrigger = true; } } ((Component)piece2).gameObject.layer = LayerMask.NameToLayer("piece_nonsolid"); Light componentInChildren = ((Component)piece2).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.range *= 1.8f; componentInChildren.intensity *= 1.5f; } if ((Object)(object)((Component)piece2).gameObject.GetComponent() == (Object)null) { ((Component)piece2).gameObject.AddComponent(); } StripVanillaTorchHoverSources(((Component)piece2).gameObject); ShipTorchHover shipTorchHover2 = ((Component)piece2).gameObject.GetComponent(); if ((Object)(object)shipTorchHover2 == (Object)null) { shipTorchHover2 = ((Component)piece2).gameObject.AddComponent(); } shipTorchHover2.HoverName = "Vas hajófáklya"; shipTorchHover2.HoverText = "Vas hajófáklya"; PieceManager.Instance.AddPiece(val6); LogDebug("[HardheimShipEquipment] Vas hajófáklya piece regisztrálva: HH_ShipTorchIron"); val = new PieceConfig(); val.Name = "Ködtörő hajófáklya"; val.Description = "Ködtörő hajófáklya. Tündér energiával működik, és áttöri a ködvidék sűrű ködét."; val.PieceTable = CfgPieceTable.Value; val.Category = "Hajófelszerelés"; val.AllowedInDungeons = true; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[4] { new RequirementConfig("BlackMetal", 4, 0, true), new RequirementConfig("Silver", 2, 0, true), new RequirementConfig("FineWood", 5, 0, true), new RequirementConfig("Wisp", 1, 0, true) }; PieceConfig val8 = val; CustomPiece val9 = new CustomPiece("HH_ShipTorchMist", "piece_groundtorch_blue", val8); DebugPrefabComponents("piece_groundtorch_blue"); Piece piece3 = val9.Piece; piece3.m_name = "Ködtörő hajófáklya"; piece3.m_description = "Ködtörő hajófáklya. Tündér energiával működik, és áttöri a ködvidék sűrű ködét."; if ((Object)(object)piece3 == (Object)null) { Log.LogError((object)"[HardheimShipEquipment] Nem sikerült létrehozni a custom piece-t: HH_ShipTorchMist"); return; } DebugHoverSources(((Component)piece3).gameObject, "HH_ShipTorchMist"); piece3.m_canBeRemoved = true; piece3.m_groundPiece = false; piece3.m_groundOnly = false; piece3.m_cultivatedGroundOnly = false; piece3.m_waterPiece = true; piece3.m_noInWater = false; piece3.m_notOnWood = false; piece3.m_notOnTiltingSurface = false; piece3.m_inCeilingOnly = false; piece3.m_notOnFloor = false; piece3.m_mustConnectTo = null; piece3.m_mustBeAboveConnected = false; piece3.m_clipGround = false; piece3.m_clipEverything = false; piece3.m_craftingStation = null; piece3.m_onlyInTeleportArea = false; piece3.m_allowedInDungeons = true; WearNTear component5 = ((Component)piece3).GetComponent(); if ((Object)(object)component5 != (Object)null) { Object.Destroy((Object)(object)component5); } Rigidbody component6 = ((Component)piece3).GetComponent(); if ((Object)(object)component6 != (Object)null) { component6.isKinematic = true; component6.useGravity = false; } Collider[] componentsInChildren3 = ((Component)piece3).GetComponentsInChildren(true); Collider[] array3 = componentsInChildren3; foreach (Collider val10 in array3) { if ((Object)(object)val10 != (Object)null) { val10.isTrigger = true; } } ((Component)piece3).gameObject.layer = LayerMask.NameToLayer("piece_nonsolid"); Light componentInChildren2 = ((Component)piece3).GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.range *= 1.8f; componentInChildren2.intensity *= 1.5f; componentInChildren2.color = new Color(0.7f, 0.85f, 1f); } if ((Object)(object)((Component)piece3).gameObject.GetComponent() == (Object)null) { ((Component)piece3).gameObject.AddComponent(); } StripVanillaTorchHoverSources(((Component)piece3).gameObject); ShipTorchHover shipTorchHover3 = ((Component)piece3).gameObject.GetComponent(); if ((Object)(object)shipTorchHover3 == (Object)null) { shipTorchHover3 = ((Component)piece3).gameObject.AddComponent(); } shipTorchHover3.HoverName = "Ködtörő hajófáklya"; shipTorchHover3.HoverText = "Ködtörő hajófáklya"; PieceManager.Instance.AddPiece(val9); LogDebug("[HardheimShipEquipment] Ködtörő hajófáklya piece regisztrálva: HH_ShipTorchMist"); RegisterDrumItem(); RegisterDrumPiece(); if (CfgDebug != null && CfgDebug.Value) { DebugObjectDBItemPrefabs("Demister"); DebugObjectDBItemPrefabs("Wisp"); } _pieceRegistered = true; LogDebugConfigSnapshot("RegisterPiece"); } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Hiba a piece regisztráció közben: {1}", "HardheimShipEquipment", arg)); } } private void RegisterDrumItem() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown try { ItemConfig val = new ItemConfig(); val.Name = "Dobgyűrű"; val.Description = "Átalakított hordógyűrűk hajódob készítéséhez."; CustomItem val2 = new CustomItem("HH_DrumHoops", "BarrelRings", val); ItemDrop itemDrop = val2.ItemDrop; if ((Object)(object)itemDrop == (Object)null || itemDrop.m_itemData == null || itemDrop.m_itemData.m_shared == null) { Log.LogError((object)"[HardheimShipEquipment] Nem sikerült létrehozni a custom itemet: HH_DrumHoops"); return; } itemDrop.m_itemData.m_shared.m_name = "Dobgyűrű"; itemDrop.m_itemData.m_shared.m_description = "Átalakított hordógyűrűk hajódob készítéséhez."; itemDrop.m_itemData.m_shared.m_maxStackSize = 50; itemDrop.m_itemData.m_shared.m_weight = 1f; itemDrop.m_itemData.m_shared.m_value = 0; if ((Object)(object)_drumRingIcon != (Object)null) { itemDrop.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { _drumRingIcon }; } ItemManager.Instance.AddItem(val2); RecipeConfig val3 = new RecipeConfig(); val3.Name = "Recipe_HH_DrumHoops"; val3.Item = "HH_DrumHoops"; val3.Amount = 1; val3.CraftingStation = "forge"; val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("BarrelRings", 1, 0, true), new RequirementConfig("Bronze", 2, 0, true) }; ItemManager.Instance.AddRecipe(new CustomRecipe(val3)); LogDebug("[HardheimShipEquipment] Dobgyűrű item + recipe regisztrálva: HH_DrumHoops"); } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Hiba a dobgyűrű item regisztráció közben: {1}", "HardheimShipEquipment", arg)); } } private void RegisterDrumPiece() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Expected O, but got Unknown //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: 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_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) try { PieceConfig val = new PieceConfig(); val.Name = "Hajódob"; val.Description = "Hajóra építhető dob. A dobgyűrű birtokában készíthető el."; val.PieceTable = CfgPieceTable.Value; val.Category = "Hajófelszerelés"; val.AllowedInDungeons = true; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("HH_DrumHoops", 1, 0, true), new RequirementConfig("DeerHide", 2, 0, true), new RequirementConfig("Wood", 4, 0, true) }; PieceConfig val2 = val; CustomPiece val3 = new CustomPiece("HH_ShipDrum", "piece_chest_barrel", val2); Piece piece = val3.Piece; if ((Object)(object)piece == (Object)null) { Log.LogError((object)"[HardheimShipEquipment] Nem sikerült létrehozni a custom piece-t: HH_ShipDrum"); return; } piece.m_name = "Dob"; piece.m_description = "Hajóra építhető dob. A dobgyűrű birtokában készíthető el."; if ((Object)(object)_drumIcon != (Object)null) { piece.m_icon = _drumIcon; } piece.m_canBeRemoved = true; piece.m_groundPiece = false; piece.m_groundOnly = false; piece.m_cultivatedGroundOnly = false; piece.m_waterPiece = true; piece.m_noInWater = false; piece.m_notOnWood = false; piece.m_notOnTiltingSurface = false; piece.m_inCeilingOnly = false; piece.m_notOnFloor = false; piece.m_mustConnectTo = null; piece.m_mustBeAboveConnected = false; piece.m_clipGround = false; piece.m_clipEverything = false; piece.m_craftingStation = null; piece.m_onlyInTeleportArea = false; piece.m_allowedInDungeons = true; GameObject gameObject = ((Component)piece).gameObject; Container component = gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } WearNTear component2 = gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } Rigidbody component3 = gameObject.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.isKinematic = true; component3.useGravity = false; } Collider[] componentsInChildren = gameObject.GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val4 in array) { if ((Object)(object)val4 != (Object)null) { val4.isTrigger = true; } } gameObject.layer = LayerMask.NameToLayer("piece_nonsolid"); if ((Object)(object)_drumIcon != (Object)null) { piece.m_icon = _drumIcon; } if ((Object)(object)_drumPrefab != (Object)null) { Renderer[] componentsInChildren2 = gameObject.GetComponentsInChildren(true); foreach (Renderer val5 in componentsInChildren2) { if ((Object)(object)val5 != (Object)null) { val5.enabled = false; } } List list = new List(); foreach (Transform item in gameObject.transform) { Transform val6 = item; list.Add(((Component)val6).gameObject); } foreach (GameObject item2 in list) { Object.Destroy((Object)(object)item2); } GameObject val7 = new GameObject("HH_DrumVisualRoot"); val7.transform.SetParent(gameObject.transform, false); val7.transform.localPosition = new Vector3(0f, -0.8f, 0f); val7.transform.localRotation = Quaternion.identity; val7.transform.localScale = new Vector3(1.2f, 1.2f, 1.2f); GameObject val8 = Object.Instantiate(_drumPrefab, val7.transform, false); ((Object)val8).name = "HH_DrumVisual"; val8.transform.localPosition = Vector3.zero; val8.transform.localRotation = Quaternion.identity; val8.transform.localScale = Vector3.one; Piece[] componentsInChildren3 = val8.GetComponentsInChildren(true); foreach (Piece val9 in componentsInChildren3) { Object.Destroy((Object)(object)val9); } WearNTear[] componentsInChildren4 = val8.GetComponentsInChildren(true); foreach (WearNTear val10 in componentsInChildren4) { Object.Destroy((Object)(object)val10); } ZNetView[] componentsInChildren5 = val8.GetComponentsInChildren(true); foreach (ZNetView val11 in componentsInChildren5) { Object.Destroy((Object)(object)val11); } Renderer[] componentsInChildren6 = val8.GetComponentsInChildren(true); foreach (Renderer val12 in componentsInChildren6) { if ((Object)(object)val12 != (Object)null) { val12.enabled = true; val12.forceRenderingOff = false; } } Collider[] componentsInChildren7 = val8.GetComponentsInChildren(true); foreach (Collider val13 in componentsInChildren7) { Object.Destroy((Object)(object)val13); } BoxCollider val14 = gameObject.GetComponent(); if ((Object)(object)val14 == (Object)null) { val14 = gameObject.AddComponent(); } val14.center = new Vector3(0f, 0.1f, 0f); val14.size = new Vector3(0.85f, 0.42f, 0.85f); ((Collider)val14).isTrigger = true; Transform[] componentsInChildren8 = val7.GetComponentsInChildren(true); foreach (Transform val15 in componentsInChildren8) { ((Component)val15).gameObject.layer = LayerMask.NameToLayer("piece"); } int num3 = val7.GetComponentsInChildren(true).Length; Log.LogInfo((object)string.Format("[{0}] Drum visual berakva. renderers={1}, localPos={2}, localScale={3}", "HardheimShipEquipment", num3, val7.transform.localPosition, val7.transform.localScale)); } else { Log.LogWarning((object)"[HardheimShipEquipment] Drum prefab nincs betöltve, marad a vanilla barrel vizuál."); } if ((Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); } if ((Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); } PieceManager.Instance.AddPiece(val3); LogDebug("[HardheimShipEquipment] Hajódob piece regisztrálva: HH_ShipDrum"); } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Hiba a hajódob piece regisztráció közben: {1}", "HardheimShipEquipment", arg)); } } internal static void LogDebug(string msg) { if (CfgDebug != null && CfgDebug.Value) { Log.LogInfo((object)msg); } } internal static void LogDebugConfigSnapshot(string source) { if (CfgDebug != null && CfgDebug.Value) { Log.LogInfo((object)("[HardheimShipEquipment] [" + source + "] Config snapshot => " + $"Enabled={CfgEnableMod?.Value}, " + $"AttachSearchRadius={CfgAttachSearchRadius?.Value}, " + $"ReattachInterval={CfgReattachInterval?.Value}, " + $"DestroyIfNotOnShip={CfgDestroyIfNotOnShip?.Value}, " + $"NoRoofWear={CfgNoRoofWear?.Value}, " + "PieceTable=" + CfgPieceTable?.Value + ", Category=" + CfgCategory?.Value + ", " + $"WoodCost={CfgWoodCost?.Value}, " + $"ResinCost={CfgResinCost?.Value}, " + $"GhostSnapSearchRadius={CfgGhostSnapSearchRadius?.Value}, " + $"MarkerOffsetY={CfgMarkerOffsetY?.Value}, " + $"MarkerOffsetStep={CfgMarkerOffsetStep?.Value}")); } } private static void DebugHoverSources(GameObject root, string tag) { if ((Object)(object)root == (Object)null) { return; } Log.LogInfo((object)("[HardheimShipEquipment] [HOVER DEBUG] ===== " + tag + " =====")); MonoBehaviour[] componentsInChildren = root.GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { bool flag = val is Hoverable; bool flag2 = val is Interactable; if (flag || flag2) { Log.LogInfo((object)("[HardheimShipEquipment] [HOVER DEBUG] obj=" + ((Object)((Component)val).gameObject).name + " comp=" + ((object)val).GetType().FullName + " " + $"hoverable={flag} interactable={flag2}")); } } } } private static void DebugFindWispPrefabs() { if ((Object)(object)ZNetScene.instance == (Object)null) { Log.LogWarning((object)"[HardheimShipEquipment] [WISP DEBUG] ZNetScene.instance == null"); return; } foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { string text = ((Object)prefab).name ?? ""; if (text.IndexOf("wisp", StringComparison.OrdinalIgnoreCase) >= 0) { Log.LogWarning((object)("[HardheimShipEquipment] [WISP DEBUG] prefab = " + text)); } } } } private static void DebugPrefabComponents(string prefabName) { try { if ((Object)(object)ZNetScene.instance == (Object)null) { Log.LogWarning((object)"[HardheimShipEquipment] [PREFAB DEBUG] ZNetScene.instance == null"); return; } GameObject prefab = ZNetScene.instance.GetPrefab(prefabName); if ((Object)(object)prefab == (Object)null) { Log.LogWarning((object)("[HardheimShipEquipment] [PREFAB DEBUG] Prefab nem található: " + prefabName)); return; } Log.LogWarning((object)("[HardheimShipEquipment] [PREFAB DEBUG] ===== " + prefabName + " =====")); Component[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { string transformPath = GetTransformPath(val.transform, prefab.transform); Log.LogWarning((object)("[HardheimShipEquipment] [PREFAB DEBUG] path=" + transformPath + " type=" + ((object)val).GetType().FullName)); } } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] [PREFAB DEBUG] Hiba: {1}", "HardheimShipEquipment", arg)); } } internal static void DebugLiveObjectComponents(GameObject obj, string tag) { if (CfgDebug == null || !CfgDebug.Value) { return; } try { if ((Object)(object)obj == (Object)null) { LogDebug("[HardheimShipEquipment] [LIVE DEBUG] " + tag + ": obj == null"); return; } LogDebug("[HardheimShipEquipment] [LIVE DEBUG] ===== " + tag + " / " + ((Object)obj).name + " ====="); Component[] componentsInChildren = obj.GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { string transformPath = GetTransformPath(val.transform, obj.transform); LogDebug("[HardheimShipEquipment] [LIVE DEBUG] path=" + transformPath + " type=" + ((object)val).GetType().FullName); } } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] [LIVE DEBUG] Hiba: {1}", "HardheimShipEquipment", arg)); } } internal static void DebugObjectDBItemPrefabs(string containsFilter) { try { if ((Object)(object)ObjectDB.instance == (Object)null) { Log.LogWarning((object)"[HardheimShipEquipment] [ITEM DEBUG] ObjectDB.instance == null"); return; } Log.LogWarning((object)("[HardheimShipEquipment] [ITEM DEBUG] ===== filter=" + containsFilter + " =====")); foreach (GameObject item in ObjectDB.instance.m_items) { if ((Object)(object)item == (Object)null) { continue; } string text = ((Object)item).name ?? string.Empty; if (text.IndexOf(containsFilter, StringComparison.OrdinalIgnoreCase) < 0) { continue; } Log.LogWarning((object)("[HardheimShipEquipment] [ITEM DEBUG] ITEM PREFAB = " + text)); Component[] componentsInChildren = item.GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { string transformPath = GetTransformPath(val.transform, item.transform); Log.LogWarning((object)("[HardheimShipEquipment] [ITEM DEBUG] path=" + transformPath + " type=" + ((object)val).GetType().FullName)); } } } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] [ITEM DEBUG] Hiba: {1}", "HardheimShipEquipment", arg)); } } internal static void DebugZNetScenePrefabComponents(string prefabName) { try { if ((Object)(object)ZNetScene.instance == (Object)null) { Log.LogWarning((object)"[HardheimShipEquipment] [ZNET PREFAB DEBUG] ZNetScene.instance == null"); return; } GameObject prefab = ZNetScene.instance.GetPrefab(prefabName); if ((Object)(object)prefab == (Object)null) { Log.LogWarning((object)("[HardheimShipEquipment] [ZNET PREFAB DEBUG] Prefab nem található: " + prefabName)); return; } Log.LogWarning((object)("[HardheimShipEquipment] [ZNET PREFAB DEBUG] ===== " + prefabName + " =====")); Component[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { string transformPath = GetTransformPath(val.transform, prefab.transform); Log.LogWarning((object)("[HardheimShipEquipment] [ZNET PREFAB DEBUG] path=" + transformPath + " type=" + ((object)val).GetType().FullName)); } } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] [ZNET PREFAB DEBUG] Hiba: {1}", "HardheimShipEquipment", arg)); } } private static string GetTransformPath(Transform current, Transform root) { if ((Object)(object)current == (Object)null) { return ""; } if ((Object)(object)current == (Object)(object)root) { return ((Object)current).name; } List list = new List(); Transform val = current; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) { list.Add(((Object)val).name); val = val.parent; } if ((Object)(object)root != (Object)null) { list.Add(((Object)root).name); } list.Reverse(); return string.Join("/", list); } private static void StripVanillaTorchHoverSources(GameObject root) { if ((Object)(object)root == (Object)null) { return; } MonoBehaviour[] componentsInChildren = root.GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !(val is ShipTorchHover) && !(val is ShipTorchAttachment) && !(val is Fireplace) && (val is Hoverable || val is Interactable)) { Object.Destroy((Object)(object)val); } } } private static void AttachSafeMistVisual(GameObject root) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { return; } Transform val = root.transform.Find("HH_SafeMistVisual"); if (!((Object)(object)val != (Object)null)) { GameObject val2 = new GameObject("HH_SafeMistVisual"); val2.transform.SetParent(root.transform, false); val2.transform.localPosition = new Vector3(0f, 1f, 0f); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; val2.AddComponent(); GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val3).name = "HH_SafeMistOrb"; val3.transform.SetParent(val2.transform, false); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); Collider component = val3.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = val3.GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; Material val4 = new Material(Shader.Find("Sprites/Default")); val4.color = new Color(0.45f, 0.8f, 1f, 0.75f); ((Renderer)component2).sharedMaterial = val4; } Light val5 = val2.AddComponent(); val5.type = (LightType)2; val5.color = new Color(0.45f, 0.8f, 1f); val5.range = 8f; val5.intensity = 4.5f; val5.shadows = (LightShadows)0; LogDebug("[MIST VISUAL] Safe mist visual attached."); } } internal static void AttachDemisterEffect(GameObject root) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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) //IL_014d: 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_0171: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)root == (Object)null) { return; } Transform val = root.transform.Find("HH_DemisterBall"); if ((Object)(object)val != (Object)null) { return; } if ((Object)(object)ZNetScene.instance == (Object)null) { Log.LogWarning((object)"[HardheimShipEquipment] [DEMISTER ATTACH] ZNetScene.instance == null"); return; } GameObject prefab = ZNetScene.instance.GetPrefab("demister_ball"); if ((Object)(object)prefab == (Object)null) { Log.LogWarning((object)"[HardheimShipEquipment] [DEMISTER ATTACH] demister_ball prefab nem található"); return; } Transform val2 = prefab.transform.Find("effects/Particle System Force Field"); if ((Object)(object)val2 == (Object)null) { Log.LogWarning((object)"[HardheimShipEquipment] [DEMISTER ATTACH] Nem található: demister_ball/effects/Particle System Force Field"); return; } GameObject val3 = new GameObject("HH_DemisterBall"); val3.transform.SetParent(root.transform, false); val3.transform.localPosition = new Vector3(0f, 1f, 0f); val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = Vector3.one; GameObject val4 = Object.Instantiate(((Component)val2).gameObject, val3.transform, false); ((Object)val4).name = "Particle System Force Field"; val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = Vector3.one; ZNetView[] componentsInChildren = val4.GetComponentsInChildren(true); foreach (ZNetView val5 in componentsInChildren) { if ((Object)(object)val5 != (Object)null) { Object.Destroy((Object)(object)val5); } } ZSyncTransform[] componentsInChildren2 = val4.GetComponentsInChildren(true); foreach (ZSyncTransform val6 in componentsInChildren2) { if ((Object)(object)val6 != (Object)null) { Object.Destroy((Object)(object)val6); } } Renderer[] componentsInChildren3 = val4.GetComponentsInChildren(true); foreach (Renderer val7 in componentsInChildren3) { if ((Object)(object)val7 != (Object)null) { val7.enabled = false; } } ParticleSystem[] componentsInChildren4 = val4.GetComponentsInChildren(true); foreach (ParticleSystem val8 in componentsInChildren4) { if ((Object)(object)val8 != (Object)null) { val8.Stop(true, (ParticleSystemStopBehavior)0); } } AudioSource[] componentsInChildren5 = val4.GetComponentsInChildren(true); foreach (AudioSource val9 in componentsInChildren5) { if ((Object)(object)val9 != (Object)null) { ((Behaviour)val9).enabled = false; } } LogDebug("[HardheimShipEquipment] [DEMISTER ATTACH] ForceField demister attach OK"); } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] [DEMISTER ATTACH] Hiba: {1}", "HardheimShipEquipment", arg)); } } } [HarmonyPatch(typeof(ZNet), "Start")] public static class ZNet_Start_SessionLog_Patch { private static void Postfix() { try { if (!((Object)(object)ZNet.instance == (Object)null)) { string text = ZNet.instance.GetWorldName(); if (string.IsNullOrWhiteSpace(text)) { text = "unknown_world"; } MigrationFileLogger.WriteLine("SESSION", "world_loaded world=" + text + " modVersion=1.0.0"); } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SESSION LOG ERROR] " + ex); } } } [HarmonyPatch(typeof(Fireplace), "GetHoverText")] public static class Fireplace_GetHoverText_Hardheim_Patch { private static void Postfix(Fireplace __instance, ref string __result) { if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).gameObject == (Object)null) { return; } string text = ((Object)((Component)__instance).gameObject).name ?? string.Empty; float num = 0f; float maxFuel = __instance.m_maxFuel; try { ZNetView component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO() != null) { num = component.GetZDO().GetFloat("fuel", 0f); } } catch { } int num2 = Mathf.RoundToInt(num); int num3 = Mathf.RoundToInt(maxFuel); if (text.StartsWith("HH_ShipTorchMist", StringComparison.OrdinalIgnoreCase)) { __result = "Ködtörő hajófáklya\n" + $"(Üzemanyag {num2}/{num3})\n" + "[E] Használ: Tündér\n[1-8] Tárgyat használ"; } else if (text.StartsWith("HH_ShipTorchIron", StringComparison.OrdinalIgnoreCase)) { __result = "Vas hajófáklya\n" + $"(Üzemanyag {num2}/{num3})\n" + "[E] Használ: Gyanta\n[1-8] Tárgyat használ"; } else if (text.StartsWith("HH_ShipTorch", StringComparison.OrdinalIgnoreCase)) { __result = "Hajófáklya\n" + $"(Üzemanyag {num2}/{num3})\n" + "[E] Használ: Gyanta\n[1-8] Tárgyat használ"; } } } internal static class ReflectionCache { internal static readonly FieldInfo PlacementGhostField = AccessTools.Field(typeof(Player), "m_placementGhost"); internal static readonly FieldInfo PlacementStatusField = AccessTools.Field(typeof(Player), "m_placementStatus"); internal static readonly FieldInfo PlacementMarkerField = AccessTools.Field(typeof(Player), "m_placementMarkerInstance"); internal static readonly MethodInfo SetPlacementGhostValidMethod = AccessTools.Method(typeof(Player), "SetPlacementGhostValid", (Type[])null, (Type[])null); internal static readonly FieldInfo ZanimField = AccessTools.Field(typeof(Character), "m_zanim"); internal static Animator GetZanim(Character c) { object? obj = ZanimField?.GetValue(c); return (Animator)((obj is Animator) ? obj : null); } internal static GameObject GetPlacementGhost(Player player) { object? obj = PlacementGhostField?.GetValue(player); return (GameObject)((obj is GameObject) ? obj : null); } internal static GameObject GetPlacementMarker(Player player) { object? obj = PlacementMarkerField?.GetValue(player); return (GameObject)((obj is GameObject) ? obj : null); } internal static void CallSetPlacementGhostValid(Player player, bool valid) { try { if (!((Object)(object)player == (Object)null) && !(SetPlacementGhostValidMethod == null)) { SetPlacementGhostValidMethod.Invoke(player, new object[1] { valid }); } } catch { } } internal static void SetPlacementStatusValid(Player player) { if (!((Object)(object)player == (Object)null) && !(PlacementStatusField == null)) { object value = Enum.ToObject(PlacementStatusField.FieldType, 0); PlacementStatusField.SetValue(player, value); } } } internal static class PendingShipPlacement { internal struct Snapshot { public bool IsValid; public Vector3 WorldPosition; public Quaternion WorldRotation; public ZDOID ShipId; public float TimeStamp; } private static Snapshot _last; internal static void Set(Vector3 worldPosition, Quaternion worldRotation, Ship ship) { //IL_0050: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ship == (Object)null)) { ZNetView component = ((Component)ship).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.GetZDO() != null) { Snapshot last = default(Snapshot); last.IsValid = true; last.WorldPosition = worldPosition; last.WorldRotation = worldRotation; last.ShipId = component.GetZDO().m_uid; last.TimeStamp = Time.time; _last = last; HardheimShipEquipmentPlugin.LogDebug($"[HH_BIND_TRACE] PENDING SET worldPos={worldPosition} worldRot={((Quaternion)(ref worldRotation)).eulerAngles} ship={((Object)ship).name} shipId={_last.ShipId}"); } } } internal static bool TryConsume(out Snapshot snapshot) { snapshot = _last; if (!_last.IsValid) { return false; } if (Time.time - _last.TimeStamp > 10f) { Clear(); return false; } Clear(); return true; } internal static void Clear() { _last = default(Snapshot); } } internal static class MigrationFileLogger { private static readonly object FileLock = new object(); private static string GetLogDirectory() { string text = Path.Combine(Paths.ConfigPath, "HardheimShipEquipment"); Directory.CreateDirectory(text); return text; } private static string GetCurrentLogPath() { string path = $"migration_{DateTime.Now:yyyy-MM-dd}.txt"; return Path.Combine(GetLogDirectory(), path); } private static void CleanupOldLogs() { try { int num = ((HardheimShipEquipmentPlugin.CfgKeepMigrationLogs != null) ? HardheimShipEquipmentPlugin.CfgKeepMigrationLogs.Value : 5); string logDirectory = GetLogDirectory(); List list = (from f in new DirectoryInfo(logDirectory).GetFiles("migration_*.txt", SearchOption.TopDirectoryOnly) orderby f.Name descending select f).ToList(); for (int i = num; i < list.Count; i++) { try { list[i].Delete(); } catch { } } } catch { } } private static string SafeVec(Vector3 v) { //IL_0006: 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_001c: Unknown result type (might be due to invalid IL or missing references) return $"({v.x:0.000},{v.y:0.000},{v.z:0.000})"; } private static string SafeQuat(Quaternion q) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0024: Unknown result type (might be due to invalid IL or missing references) Vector3 eulerAngles = ((Quaternion)(ref q)).eulerAngles; return $"({eulerAngles.x:0.000},{eulerAngles.y:0.000},{eulerAngles.z:0.000})"; } private static string SafeShipId(ZDOID id) { return $"{((ZDOID)(ref id)).UserID}:{((ZDOID)(ref id)).ID}"; } private static string GetWorldNameSafe() { try { return ((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetWorldName() : "unknown_world"; } catch { return "unknown_world"; } } internal static void WriteLine(string eventType, string message) { try { if (HardheimShipEquipmentPlugin.CfgEnableMigrationFileLog != null && !HardheimShipEquipmentPlugin.CfgEnableMigrationFileLog.Value) { return; } lock (FileLock) { CleanupOldLogs(); string currentLogPath = GetCurrentLogPath(); bool flag = !File.Exists(currentLogPath); using StreamWriter streamWriter = new StreamWriter(currentLogPath, append: true, Encoding.UTF8); if (flag) { streamWriter.WriteLine("============================================================"); streamWriter.WriteLine("HardheimShipEquipment migration log"); streamWriter.WriteLine($"Date: {DateTime.Now:yyyy-MM-dd}"); streamWriter.WriteLine("ModVersion: 1.0.0"); streamWriter.WriteLine("World: " + GetWorldNameSafe()); streamWriter.WriteLine("============================================================"); streamWriter.WriteLine(); } streamWriter.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{eventType}] {message}"); } } catch { } } internal static void WriteItemState(string eventType, GameObject item, ZDO zdo, Ship resolvedShip, bool bound, int schema, bool hasShipId, bool hasLocalAnchor, bool hasShipRef, string result, string reason = null, Vector3? localPos = null, Quaternion? localRot = null) { //IL_002f: 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_0034: 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_003e: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) try { string text = (((Object)(object)item != (Object)null) ? ((Object)item).name : ""); Vector3 v = (((Object)(object)item != (Object)null) ? item.transform.position : Vector3.zero); Quaternion q = (((Object)(object)item != (Object)null) ? item.transform.rotation : Quaternion.identity); string text2 = (((Object)(object)resolvedShip != (Object)null) ? ((Object)resolvedShip).name : "NULL"); string text3 = "NULL"; if (zdo != null) { uint num = (uint)zdo.GetLong("hh_ship_uid_user", 0L); uint num2 = (uint)zdo.GetLong("hh_ship_uid_id", 0L); if (num != 0 || num2 != 0) { text3 = $"{num}:{num2}"; } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("result=" + result); stringBuilder.AppendLine("itemName=" + text); stringBuilder.AppendLine("worldPos=" + SafeVec(v)); stringBuilder.AppendLine("worldRot=" + SafeQuat(q)); stringBuilder.AppendLine($"bound={bound}"); stringBuilder.AppendLine($"schema={schema}"); stringBuilder.AppendLine($"hasShipId={hasShipId}"); stringBuilder.AppendLine("resolvedShip=" + text2); stringBuilder.AppendLine("shipId=" + text3); stringBuilder.AppendLine($"hasLocalAnchor={hasLocalAnchor}"); stringBuilder.AppendLine($"hasShipRef={hasShipRef}"); if (localPos.HasValue) { stringBuilder.AppendLine("localPos=" + SafeVec(localPos.Value)); } if (localRot.HasValue) { stringBuilder.AppendLine("localRot=" + SafeQuat(localRot.Value)); } if (!string.IsNullOrEmpty(reason)) { stringBuilder.AppendLine("reason=" + reason); } WriteLine(eventType, Environment.NewLine + stringBuilder.ToString().TrimEnd(Array.Empty())); } catch { } } } internal static class LastShipRaycastHit { internal struct Snapshot { public bool IsValid; public Vector3 Point; public Vector3 Normal; public ZDOID ShipId; public float TimeStamp; } private static Snapshot _last; internal static void Set(Vector3 point, Vector3 normal, Ship ship) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0084: 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) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ship == (Object)null)) { ZNetView component = ((Component)ship).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.GetZDO() != null) { Snapshot last = default(Snapshot); last.IsValid = true; last.Point = point; last.Normal = normal; last.ShipId = component.GetZDO().m_uid; last.TimeStamp = Time.time; _last = last; HardheimShipEquipmentPlugin.LogDebug($"[LAST RAY HIT] point={point} normal={normal} shipId={_last.ShipId}"); } } } internal static bool TryGet(out Snapshot snapshot) { snapshot = _last; if (!_last.IsValid) { return false; } if (Time.time - _last.TimeStamp > 1f) { Clear(); return false; } return true; } internal static void Clear() { _last = default(Snapshot); } } public static class ShipTorchPlacementHelper { internal static class HardheimShipCleanupHelper { internal static void DestroyAllBoundHHItemsForShip(Ship ship) { //IL_0046: 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_00a0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ship == (Object)null) { return; } ZNetView component = ((Component)ship).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid() || component.GetZDO() == null) { return; } ZDOID uid = component.GetZDO().m_uid; ShipTorchAttachment[] array = Object.FindObjectsByType((FindObjectsSortMode)0); if (array == null || array.Length == 0) { return; } ShipTorchAttachment[] array2 = array; foreach (ShipTorchAttachment shipTorchAttachment in array2) { if (!((Object)(object)shipTorchAttachment == (Object)null) && IsHardheimPieceName(((Object)shipTorchAttachment).name) && shipTorchAttachment.IsBoundToShip(uid)) { shipTorchAttachment.DestroyBecauseShipWasDestroyed(); } } } } public static bool IsHardheimPieceName(string value) { if (string.IsNullOrEmpty(value)) { return false; } return value.StartsWith("hh_", StringComparison.OrdinalIgnoreCase); } public static bool IsShipChest(GameObject obj) { return false; } public static bool IsHardheimGhost(GameObject ghost) { if ((Object)(object)ghost == (Object)null) { return false; } string value = ((Object)ghost).name ?? string.Empty; if (IsHardheimPieceName(value)) { return true; } Piece component = ghost.GetComponent(); if ((Object)(object)component != (Object)null && IsHardheimPieceName(((Object)component).name)) { return true; } return false; } public static bool IsPreviewGhostObject(GameObject obj) { if ((Object)(object)obj == (Object)null) { return false; } if (!IsHardheimPieceName(((Object)obj).name)) { return false; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return false; } GameObject placementGhost = ReflectionCache.GetPlacementGhost(localPlayer); if ((Object)(object)placementGhost == (Object)null) { return false; } return (Object)(object)placementGhost == (Object)(object)obj; } public static void EnsureGhostVisible(GameObject ghost) { if ((Object)(object)ghost == (Object)null) { return; } if (!ghost.activeSelf) { ghost.SetActive(true); } Transform[] componentsInChildren = ghost.GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val != (Object)null && !((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } } Renderer[] componentsInChildren2 = ghost.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null)) { val2.enabled = true; val2.forceRenderingOff = false; } } } public static void HandleMarkerOffsetHotkeys(GameObject ghost, GameObject marker) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ghost == (Object)null || (Object)(object)marker == (Object)null || HardheimShipEquipmentPlugin.CfgMarkerOffsetY == null) { return; } bool flag = false; float num = ((HardheimShipEquipmentPlugin.CfgMarkerOffsetStep != null) ? HardheimShipEquipmentPlugin.CfgMarkerOffsetStep.Value : 0.01f); KeyboardShortcut value; if (HardheimShipEquipmentPlugin.CfgMarkerOffsetUpKey != null) { value = HardheimShipEquipmentPlugin.CfgMarkerOffsetUpKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ConfigEntry cfgMarkerOffsetY = HardheimShipEquipmentPlugin.CfgMarkerOffsetY; cfgMarkerOffsetY.Value += num; flag = true; } } if (HardheimShipEquipmentPlugin.CfgMarkerOffsetDownKey != null) { value = HardheimShipEquipmentPlugin.CfgMarkerOffsetDownKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ConfigEntry cfgMarkerOffsetY2 = HardheimShipEquipmentPlugin.CfgMarkerOffsetY; cfgMarkerOffsetY2.Value -= num; flag = true; } } if (flag) { HardheimShipEquipmentPlugin instance = HardheimShipEquipmentPlugin.Instance; if (instance != null) { ConfigFile config = ((BaseUnityPlugin)instance).Config; if (config != null) { config.Save(); } } HardheimShipEquipmentPlugin.LogDebug($"[MARKER OFFSET] savedOffsetY={HardheimShipEquipmentPlugin.CfgMarkerOffsetY.Value:0.000}"); } if (HardheimShipEquipmentPlugin.CfgMarkerOffsetLogKey == null) { return; } value = HardheimShipEquipmentPlugin.CfgMarkerOffsetLogKey.Value; if (!((KeyboardShortcut)(ref value)).IsDown()) { return; } Vector3 position = marker.transform.position; Vector3 position2 = ghost.transform.position; Vector3 val = position2 - position; HardheimShipEquipmentPlugin.CfgMarkerOffsetY.Value = val.y; HardheimShipEquipmentPlugin instance2 = HardheimShipEquipmentPlugin.Instance; if (instance2 != null) { ConfigFile config2 = ((BaseUnityPlugin)instance2).Config; if (config2 != null) { config2.Save(); } } HardheimShipEquipmentPlugin.LogDebug($"[MARKER OFFSET LOG] markerPos={position} ghostPos={position2} savedOffset=(0.00, {val.y:0.00}, 0.00)"); } public static void ForceGhostToMarkerOffset(GameObject ghost, GameObject marker) { //IL_0035: 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_0041: 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_004f: 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) if (!((Object)(object)ghost == (Object)null) && !((Object)(object)marker == (Object)null) && HardheimShipEquipmentPlugin.CfgMarkerOffsetY != null) { float value = HardheimShipEquipmentPlugin.CfgMarkerOffsetY.Value; Vector3 position = marker.transform.position; ghost.transform.position = new Vector3(position.x, position.y + value, position.z); } } public static Ship FindShipByZdoId(ZDOID id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) if (id == ZDOID.None) { return null; } Ship[] array = Object.FindObjectsByType((FindObjectsSortMode)0); HardheimShipEquipmentPlugin.LogDebug($"[FIND SHIP] wanted={((ZDOID)(ref id)).UserID}:{((ZDOID)(ref id)).ID} activeShips={array.Length}"); Ship[] array2 = array; foreach (Ship val in array2) { if ((Object)(object)val == (Object)null) { continue; } ZNetView component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); HardheimShipEquipmentPlugin.LogDebug("[FIND SHIP CANDIDATE] ship=" + ((Object)val).name + " uid=" + ((zDO != null) ? $"{((ZDOID)(ref zDO.m_uid)).UserID}:{((ZDOID)(ref zDO.m_uid)).ID}" : "null")); if (zDO != null && zDO.m_uid == id) { return val; } } } return null; } public static Ship FindNearestShip(Vector3 position, float radius) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00c1: Unknown result type (might be due to invalid IL or missing references) Ship[] array = Object.FindObjectsByType((FindObjectsSortMode)0); Ship result = null; float num = float.MaxValue; Ship[] array2 = array; foreach (Ship val in array2) { if ((Object)(object)val == (Object)null) { continue; } ZNetView component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { continue; } Collider[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { continue; } Collider[] array3 = componentsInChildren; foreach (Collider val2 in array3) { if (!((Object)(object)val2 == (Object)null) && val2.enabled && !val2.isTrigger) { Vector3 val3 = val2.ClosestPoint(position); float num2 = Vector3.Distance(position, val3); if (num2 <= radius && num2 < num) { result = val; num = num2; } } } } return result; } } public sealed class ShipTorchHover : MonoBehaviour, Hoverable, Interactable { public string HoverName = ""; public string HoverText = ""; public string GetHoverName() { return string.IsNullOrWhiteSpace(HoverName) ? "Hajófáklya" : HoverName; } public string GetHoverText() { return HoverName + "\n[E] Használ\n[1-8] Tárgyat használ"; } public bool Interact(Humanoid user, bool hold, bool alt) { Fireplace componentInChildren = ((Component)this).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { return componentInChildren.Interact(user, hold, alt); } return false; } public bool UseItem(Humanoid user, ItemData item) { Fireplace componentInChildren = ((Component)this).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { return componentInChildren.UseItem(user, item); } return false; } } public sealed class ShipDrumInteraction : MonoBehaviour, Interactable, Hoverable { [CompilerGenerated] private sealed class d__74 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public bool female; public ShipDrumInteraction <>4__this; private int 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__74(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 0; break; case 1: <>1__state = -1; if (female && !<>4__this._localJoinedFemaleVocal) { return false; } if (!female && !<>4__this._localJoinedMaleVocal) { return false; } <>4__this.ForceVocalJoinState(female); <>4__this.SyncSongPlayback(allowDuringInitialBlock: true); 5__1++; break; } if (5__1 < 10) { <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 1; return true; } if (female) { <>4__this._pendingFemaleJoinUntil = 0f; } else { <>4__this._pendingMaleJoinUntil = 0f; } 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 AudioSource _drumSource; private float _nextDrumInteractTime; private AudioSource _maleVocalSource; private AudioSource _femaleVocalSource; private bool _localJoinedMaleVocal; private bool _localJoinedFemaleVocal; private float _nextDrummerHeartbeatTime; private ZNetView _nview; private bool _songWasPlaying = false; private bool _drumWasPlayingLocally; private bool _localDrumStartedByThisClient; private bool _suppressSongEndReward; private bool _initialSongStateSanitized; private float _blockAutoSongPlaybackUntil; private bool _localSongActionThisSession; private float _suppressMaleVocalUntil; private float _suppressFemaleVocalUntil; private float _pendingMaleJoinUntil; private float _pendingFemaleJoinUntil; private static Sprite _songBuffIcon; private long _localDrummerPlayerId; private float _nextDrummerDistanceCheck; private float _nextLocalVocalShipCheckTime; private const float MaxDrumDistance = 2.2f; private static readonly string[] SongIds = new string[2] { "song1", "song2" }; private static readonly string[] SongDisplayNames = new string[2] { "Valhalla", "Túlpart" }; private readonly Dictionary _savedVanillaMusicVolumes = new Dictionary(); private readonly Dictionary _clipCache = new Dictionary(); private float _nextSongSyncTime; private int _lastProcessedSongFinishedToken; public string GetHoverName() { return "Dob"; } public string GetHoverText() { if ((Object)(object)_nview == (Object)null) { _nview = ((Component)this).GetComponent(); } if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return "Harci szellem"; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return "Harci szellem"; } bool @bool = zDO.GetBool("hh_song_drum_active", false); int num = Mathf.Clamp(zDO.GetInt("hh_song_index", 0), 0, SongIds.Length - 1); if (!@bool) { return "Harci szellem\n[E] Rituálé indítása\n[Shift+E] Dal váltása\nAktuális dal: " + SongDisplayNames[num]; } return "Harci szellem\n[E] Rituálé megszakítása\nAktív dal: " + SongDisplayNames[num]; } private void Start() { _blockAutoSongPlaybackUntil = Time.time + 8f; EnsureAudioSources(); StopAndClearSource(_drumSource); StopAndClearSource(_maleVocalSource); StopAndClearSource(_femaleVocalSource); SetVanillaMusicMuted(muted: false); HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] Initial auto playback blocked for 8 sec."); } public bool IsDrumSongActive() { EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return false; } return zDO.GetBool("hh_song_drum_active", false); } public bool CanPlayerJoinVocal(Player player) { if ((Object)(object)player == (Object)null) { return false; } EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return false; } if (!zDO.GetBool("hh_song_drum_active", false)) { return false; } if (IsFemale(player)) { return zDO.GetInt("hh_song_female_vocal_count", 0) <= 0; } return zDO.GetInt("hh_song_male_vocal_count", 0) <= 0; } public bool UseItem(Humanoid user, ItemData item) { return false; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } if (Time.time < _nextDrumInteractTime) { return true; } _nextDrumInteractTime = Time.time + 0.35f; Player val = (Player)(object)((user is Player) ? user : null); if ((Object)(object)val == (Object)null) { return false; } EnsureNView(); EnsureAudioSources(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo == null) { return false; } bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); bool @bool = ownedZdo.GetBool("hh_song_drum_active", false); if (flag && !@bool) { int @int = ownedZdo.GetInt("hh_song_index", 0); @int = (@int + 1) % SongIds.Length; ownedZdo.Set("hh_song_index", @int); ((Character)val).Message((MessageType)2, "Aktuális dal: " + SongDisplayNames[@int], 0, (Sprite)null); return true; } if (@bool) { ResetSongState(val); return true; } Transform orCreateSitPoint = GetOrCreateSitPoint(); float num = (((Object)(object)ZNet.instance != (Object)null) ? ((float)ZNet.instance.GetTimeSeconds()) : Time.time); bool flag2 = IsFemale(val); ownedZdo.Set("hh_song_drum_active", true); ownedZdo.Set("hh_song_drum_start", num); ownedZdo.Set("hh_song_vocal_start", num); _localDrumStartedByThisClient = true; _localSongActionThisSession = true; ownedZdo.Set("hh_song_male_vocal_count", (!flag2) ? 1 : 0); ownedZdo.Set("hh_song_female_vocal_count", flag2 ? 1 : 0); ownedZdo.Set("hh_song_male_vocal_player_id", flag2 ? "" : val.GetPlayerID().ToString()); ownedZdo.Set("hh_song_female_vocal_player_id", flag2 ? val.GetPlayerID().ToString() : ""); _localJoinedMaleVocal = !flag2; _localJoinedFemaleVocal = flag2; _pendingMaleJoinUntil = 0f; _pendingFemaleJoinUntil = 0f; _suppressMaleVocalUntil = 0f; _suppressFemaleVocalUntil = 0f; _localDrummerPlayerId = val.GetPlayerID(); _nextDrummerDistanceCheck = Time.time + 0.5f; ownedZdo.Set("hh_song_drummer_id", val.GetPlayerID().ToString()); ownedZdo.Set("hh_song_drummer_heartbeat", num); _nextDrummerHeartbeatTime = Time.time + 0.5f; ForceVocalJoinState(flag2); SyncSongPlayback(allowDuringInitialBlock: true); if ((Object)(object)HardheimShipEquipmentPlugin.Instance != (Object)null) { ((MonoBehaviour)HardheimShipEquipmentPlugin.Instance).StartCoroutine(DelayedVocalJoinSync(flag2)); } ((Character)val).Message((MessageType)2, flag2 ? "Harci szellem: női ének" : "Harci szellem: férfi ének", 0, (Sprite)null); return true; } private void EnsureNView() { if ((Object)(object)_nview == (Object)null) { _nview = ((Component)this).GetComponent(); } } private ZDO GetOwnedZdo() { EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return null; } if (!_nview.IsOwner()) { _nview.ClaimOwnership(); } return _nview.GetZDO(); } private void EnsureAudioSources() { //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_drumSource == (Object)null) { Transform val = ((Component)this).transform.Find("HH_DrumAudio"); GameObject val2; if ((Object)(object)val != (Object)null) { val2 = ((Component)val).gameObject; } else { val2 = new GameObject("HH_DrumAudio"); val2.transform.SetParent(((Component)this).transform, false); val2.transform.localPosition = new Vector3(0f, 0.8f, 0f); val2.transform.localRotation = Quaternion.identity; } _drumSource = val2.GetComponent(); if ((Object)(object)_drumSource == (Object)null) { _drumSource = val2.AddComponent(); } _drumSource.playOnAwake = false; _drumSource.loop = false; _drumSource.spatialBlend = 1f; _drumSource.rolloffMode = (AudioRolloffMode)1; _drumSource.maxDistance = 40f; _drumSource.minDistance = 2f; _drumSource.dopplerLevel = 0f; _drumSource.spread = 0f; _drumSource.reverbZoneMix = 0f; _drumSource.priority = 32; _drumSource.volume = 1f; _drumSource.bypassEffects = true; _drumSource.bypassListenerEffects = true; _drumSource.bypassReverbZones = true; AudioLowPassFilter component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } AudioReverbFilter component2 = val2.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } } if ((Object)(object)_maleVocalSource == (Object)null) { GameObject val3 = new GameObject("HH_MaleVocalSource"); val3.transform.SetParent(((Component)this).transform, false); val3.transform.localPosition = Vector3.zero; _maleVocalSource = val3.AddComponent(); _maleVocalSource.playOnAwake = false; _maleVocalSource.loop = false; _maleVocalSource.spatialBlend = 0.65f; _maleVocalSource.minDistance = 2f; _maleVocalSource.maxDistance = 30f; _maleVocalSource.rolloffMode = (AudioRolloffMode)1; } if ((Object)(object)_femaleVocalSource == (Object)null) { GameObject val4 = new GameObject("HH_FemaleVocalSource"); val4.transform.SetParent(((Component)this).transform, false); val4.transform.localPosition = Vector3.zero; _femaleVocalSource = val4.AddComponent(); _femaleVocalSource.playOnAwake = false; _femaleVocalSource.loop = false; _femaleVocalSource.spatialBlend = 0.65f; _femaleVocalSource.minDistance = 2f; _femaleVocalSource.maxDistance = 30f; _femaleVocalSource.rolloffMode = (AudioRolloffMode)1; } } private GameObject GetOrCreateMastAudioAnchor() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00ef: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) Ship componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { Transform val = ((Component)this).transform.Find("HH_MastAudioAnchor"); if ((Object)(object)val != (Object)null) { return ((Component)val).gameObject; } GameObject val2 = new GameObject("HH_MastAudioAnchor"); val2.transform.SetParent(((Component)this).transform, false); val2.transform.localPosition = new Vector3(0f, 2.5f, 0f); val2.transform.localRotation = Quaternion.identity; return val2; } Transform val3 = ((Component)componentInParent).transform.Find("HH_MastAudioAnchor"); if ((Object)(object)val3 != (Object)null) { return ((Component)val3).gameObject; } GameObject val4 = new GameObject("HH_MastAudioAnchor"); val4.transform.SetParent(((Component)componentInParent).transform, true); val4.transform.position = FindApproxMastWorldPosition(componentInParent); val4.transform.rotation = Quaternion.identity; HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] Mast anchor worldPos={val4.transform.position}"); return val4; } private Vector3 FindApproxMastWorldPosition(Ship ship) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0114: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_01da: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ship == (Object)null) { return ((Component)this).transform.position + Vector3.up * 2.5f; } Transform[] componentsInChildren = ((Component)ship).GetComponentsInChildren(true); Transform val = null; Transform[] array = componentsInChildren; foreach (Transform val2 in array) { if (!((Object)(object)val2 == (Object)null)) { string text = (((Object)val2).name ?? string.Empty).ToLowerInvariant(); if ((text.Contains("mast") || text.Contains("sail") || text.Contains("yard")) && ((Object)(object)val == (Object)null || val2.position.y > val.position.y)) { val = val2; } } } if ((Object)(object)val != (Object)null) { Vector3 val3 = val.position + Vector3.up * 1f; HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] Mast candidate: {((Object)val).name} -> {val3}"); return val3; } Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(((Component)ship).transform.position, Vector3.zero); bool flag = false; Renderer[] componentsInChildren2 = ((Component)ship).GetComponentsInChildren(true); foreach (Renderer val4 in componentsInChildren2) { if (!((Object)(object)val4 == (Object)null)) { if (!flag) { bounds = val4.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val4.bounds); } } } Vector3 val5 = (flag ? (((Bounds)(ref bounds)).center + Vector3.up * (((Bounds)(ref bounds)).extents.y + 1.2f)) : (((Component)ship).transform.position + Vector3.up * 3f)); HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] Mast fallback: {val5}"); return val5; } private AudioClip LoadClip(string filename) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Invalid comparison between Unknown and I4 try { if (_clipCache.TryGetValue(filename, out var value) && (Object)(object)value != (Object)null) { return value; } string text = Path.Combine(HardheimShipEquipmentPlugin.Instance.SoundsPath, filename); if (!File.Exists(text)) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] Missing clip: " + text); return null; } string text2 = "file://" + text.Replace("\\", "/"); UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(text2, (AudioType)14); try { UnityWebRequestAsyncOperation val = audioClip.SendWebRequest(); while (!((AsyncOperation)val).isDone) { } if ((int)audioClip.result == 2 || (int)audioClip.result == 3) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] Load failed: " + text + " err=" + audioClip.error); return null; } AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip); if ((Object)(object)content != (Object)null) { ((Object)content).name = filename; _clipCache[filename] = content; } return content; } finally { ((IDisposable)audioClip)?.Dispose(); } } catch (Exception arg) { HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] LoadClip exception: {arg}"); return null; } } private void SetVanillaMusicMuted(bool muted) { try { MusicMan val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { return; } AudioSource[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } if (muted) { AudioSource[] array = componentsInChildren; foreach (AudioSource val2 in array) { if (!((Object)(object)val2 == (Object)null)) { if (!_savedVanillaMusicVolumes.ContainsKey(val2)) { _savedVanillaMusicVolumes[val2] = val2.volume; } val2.volume = 0f; val2.mute = true; } } return; } foreach (KeyValuePair savedVanillaMusicVolume in _savedVanillaMusicVolumes) { if (!((Object)(object)savedVanillaMusicVolume.Key == (Object)null)) { savedVanillaMusicVolume.Key.mute = false; savedVanillaMusicVolume.Key.volume = savedVanillaMusicVolume.Value; } } _savedVanillaMusicVolumes.Clear(); } catch (Exception arg) { HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] SetVanillaMusicMuted exception: {arg}"); } } private bool IsAnyLocalShipTrackPlaying() { return ((Object)(object)_drumSource != (Object)null && _drumSource.isPlaying) || ((Object)(object)_maleVocalSource != (Object)null && _maleVocalSource.isPlaying) || ((Object)(object)_femaleVocalSource != (Object)null && _femaleVocalSource.isPlaying); } private void Update() { ProcessFinishedSongBuffSignal(); if (Time.time >= _nextSongSyncTime) { _nextSongSyncTime = Time.time + 0.25f; SyncSongPlayback(); } } private bool IsSongNaturallyFinished() { EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo == null) { return false; } int num = Mathf.Clamp(ownedZdo.GetInt("hh_song_index", 0), 0, SongIds.Length - 1); bool @bool = ownedZdo.GetBool("hh_song_drum_active", false); int @int = ownedZdo.GetInt("hh_song_male_vocal_count", 0); int int2 = ownedZdo.GetInt("hh_song_female_vocal_count", 0); bool flag = @int > 0 || int2 > 0; if (!(@bool || flag)) { return false; } float num2 = (((Object)(object)ZNet.instance != (Object)null) ? ((float)ZNet.instance.GetTimeSeconds()) : Time.time); float num3 = 0f; bool flag2 = false; if (@bool) { float @float = ownedZdo.GetFloat("hh_song_drum_start", 0f); AudioClip val = LoadClip(SongIds[num] + "_drum.ogg"); if ((Object)(object)val != (Object)null && val.length > 0.05f) { num3 = Mathf.Max(num3, @float + val.length); flag2 = true; } } if (@int > 0) { float float2 = ownedZdo.GetFloat("hh_song_vocal_start", 0f); AudioClip val2 = LoadClip(SongIds[num] + "man_vocal.ogg"); if ((Object)(object)val2 != (Object)null && val2.length > 0.05f) { num3 = Mathf.Max(num3, float2 + val2.length); flag2 = true; } } if (int2 > 0) { float float3 = ownedZdo.GetFloat("hh_song_vocal_start", 0f); AudioClip val3 = LoadClip(SongIds[num] + "woman_vocal.ogg"); if ((Object)(object)val3 != (Object)null && val3.length > 0.05f) { num3 = Mathf.Max(num3, float3 + val3.length); flag2 = true; } } if (!flag2) { return false; } return num2 >= num3; } private void StopSongIfLocalDrummerLeft() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (_localDrummerPlayerId == 0 || Time.time < _nextDrummerDistanceCheck) { return; } _nextDrummerDistanceCheck = Time.time + 0.5f; Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && localPlayer.GetPlayerID() == _localDrummerPlayerId) { float num = Vector3.Distance(((Component)localPlayer).transform.position, ((Component)this).transform.position); if (num > 2.5f) { HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] Dobos eltávolodott, dal stop. dist={num:0.00}"); ResetSongState(localPlayer); _localDrummerPlayerId = 0L; } } } private void UpdateDrummerHeartbeat() { if (_localDrummerPlayerId == 0 || Time.time < _nextDrummerHeartbeatTime) { return; } _nextDrummerHeartbeatTime = Time.time + 0.5f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.GetPlayerID() != _localDrummerPlayerId) { return; } EnsureNView(); if (!((Object)(object)_nview == (Object)null) && _nview.IsValid()) { ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo != null && ownedZdo.GetBool("hh_song_drum_active", false)) { float num = (((Object)(object)ZNet.instance != (Object)null) ? ((float)ZNet.instance.GetTimeSeconds()) : Time.time); ownedZdo.Set("hh_song_drummer_id", _localDrummerPlayerId.ToString()); ownedZdo.Set("hh_song_drummer_heartbeat", num); } } } private void StopSongIfDrummerHeartbeatExpired() { EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO zDO = _nview.GetZDO(); if (zDO == null || !zDO.GetBool("hh_song_drum_active", false)) { return; } string @string = zDO.GetString("hh_song_drummer_id", ""); if (string.IsNullOrEmpty(@string)) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && @string == localPlayer.GetPlayerID().ToString()) { return; } float @float = zDO.GetFloat("hh_song_drummer_heartbeat", 0f); if (!(@float <= 0f)) { float num = (((Object)(object)ZNet.instance != (Object)null) ? ((float)ZNet.instance.GetTimeSeconds()) : Time.time); if (num - @float > 12f) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] Dobos heartbeat lejárt, dal leállítva."); ResetSongState(); } } } private void LateUpdate() { StopLocalVocalIfLeftShip(); UpdateDrummerHeartbeat(); StopSongIfLocalDrummerLeft(); StopSongIfDrummerHeartbeatExpired(); if (IsAnyLocalShipTrackPlaying()) { SetVanillaMusicMuted(muted: true); } else if (!HasAnySongActive()) { SetVanillaMusicMuted(muted: false); } } private void PlayDrumLocal(Player localPlayer) { EnsureNView(); EnsureAudioSources(); AudioSource[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (AudioSource val in componentsInChildren) { if ((Object)(object)val != (Object)(object)_drumSource && (Object)(object)val != (Object)(object)_maleVocalSource && (Object)(object)val != (Object)(object)_femaleVocalSource) { ((Behaviour)val).enabled = false; } } AudioLowPassFilter[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(true); foreach (AudioLowPassFilter val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null)) { bool flag = (Object)(object)_drumSource != (Object)null && (Object)(object)((Component)val2).gameObject == (Object)(object)((Component)_drumSource).gameObject; bool flag2 = (Object)(object)_maleVocalSource != (Object)null && (Object)(object)((Component)val2).gameObject == (Object)(object)((Component)_maleVocalSource).gameObject; bool flag3 = (Object)(object)_femaleVocalSource != (Object)null && (Object)(object)((Component)val2).gameObject == (Object)(object)((Component)_femaleVocalSource).gameObject; if (!flag && !flag2 && !flag3) { ((Behaviour)val2).enabled = false; } } } AudioReverbFilter[] componentsInChildren3 = ((Component)this).GetComponentsInChildren(true); foreach (AudioReverbFilter val3 in componentsInChildren3) { if (!((Object)(object)val3 == (Object)null)) { bool flag4 = (Object)(object)_drumSource != (Object)null && (Object)(object)((Component)val3).gameObject == (Object)(object)((Component)_drumSource).gameObject; bool flag5 = (Object)(object)_maleVocalSource != (Object)null && (Object)(object)((Component)val3).gameObject == (Object)(object)((Component)_maleVocalSource).gameObject; bool flag6 = (Object)(object)_femaleVocalSource != (Object)null && (Object)(object)((Component)val3).gameObject == (Object)(object)((Component)_femaleVocalSource).gameObject; if (!flag4 && !flag5 && !flag6) { ((Behaviour)val3).enabled = false; } } } AudioChorusFilter[] componentsInChildren4 = ((Component)this).GetComponentsInChildren(true); foreach (AudioChorusFilter val4 in componentsInChildren4) { if (!((Object)(object)val4 == (Object)null)) { bool flag7 = (Object)(object)_drumSource != (Object)null && (Object)(object)((Component)val4).gameObject == (Object)(object)((Component)_drumSource).gameObject; bool flag8 = (Object)(object)_maleVocalSource != (Object)null && (Object)(object)((Component)val4).gameObject == (Object)(object)((Component)_maleVocalSource).gameObject; bool flag9 = (Object)(object)_femaleVocalSource != (Object)null && (Object)(object)((Component)val4).gameObject == (Object)(object)((Component)_femaleVocalSource).gameObject; if (!flag7 && !flag8 && !flag9) { ((Behaviour)val4).enabled = false; } } } AudioDistortionFilter[] componentsInChildren5 = ((Component)this).GetComponentsInChildren(true); foreach (AudioDistortionFilter val5 in componentsInChildren5) { if (!((Object)(object)val5 == (Object)null)) { bool flag10 = (Object)(object)_drumSource != (Object)null && (Object)(object)((Component)val5).gameObject == (Object)(object)((Component)_drumSource).gameObject; bool flag11 = (Object)(object)_maleVocalSource != (Object)null && (Object)(object)((Component)val5).gameObject == (Object)(object)((Component)_maleVocalSource).gameObject; bool flag12 = (Object)(object)_femaleVocalSource != (Object)null && (Object)(object)((Component)val5).gameObject == (Object)(object)((Component)_femaleVocalSource).gameObject; if (!flag10 && !flag11 && !flag12) { ((Behaviour)val5).enabled = false; } } } AudioEchoFilter[] componentsInChildren6 = ((Component)this).GetComponentsInChildren(true); foreach (AudioEchoFilter val6 in componentsInChildren6) { if (!((Object)(object)val6 == (Object)null)) { bool flag13 = (Object)(object)_drumSource != (Object)null && (Object)(object)((Component)val6).gameObject == (Object)(object)((Component)_drumSource).gameObject; bool flag14 = (Object)(object)_maleVocalSource != (Object)null && (Object)(object)((Component)val6).gameObject == (Object)(object)((Component)_maleVocalSource).gameObject; bool flag15 = (Object)(object)_femaleVocalSource != (Object)null && (Object)(object)((Component)val6).gameObject == (Object)(object)((Component)_femaleVocalSource).gameObject; if (!flag13 && !flag14 && !flag15) { ((Behaviour)val6).enabled = false; } } } if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO zDO = _nview.GetZDO(); if (zDO == null || !zDO.GetBool("hh_song_drum_active", false)) { return; } int num = Mathf.Clamp(zDO.GetInt("hh_song_index", 0), 0, SongIds.Length - 1); float @float = zDO.GetFloat("hh_song_drum_start", 0f); float num2 = (((Object)(object)ZNet.instance != (Object)null) ? ((float)ZNet.instance.GetTimeSeconds()) : Time.time); float offset = Mathf.Max(0f, num2 - @float); string text = SongIds[num] + "_drum.ogg"; AudioClip val7 = LoadClip(text); if ((Object)(object)val7 == (Object)null) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] Drum clip null: " + text); return; } _drumSource.clip = val7; SyncSourceToOffset(_drumSource, val7, offset, "DRUM_LOCAL"); if (!_drumSource.isPlaying) { _drumSource.Play(); } SetVanillaMusicMuted(muted: true); } public void PlayVocalLocal(string file, float offset) { } private bool IsFemale(Player player) { if ((Object)(object)HardheimShipEquipmentPlugin.Instance == (Object)null) { return false; } bool flag = HardheimShipEquipmentPlugin.Instance.ResolveFemaleFromYaml(player); HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] IsFemale via YAML = {flag}"); return flag; } public bool IsSameShip(Player player) { if ((Object)(object)player == (Object)null) { return false; } Ship componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return false; } Ship val = FindShipUnderPlayer(player); return (Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)componentInParent; } private static Ship FindShipUnderPlayer(Player player) { //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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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) if ((Object)(object)player == (Object)null) { return null; } Vector3 position = ((Component)player).transform.position; Ship[] array = Object.FindObjectsByType((FindObjectsSortMode)0); if (array == null || array.Length == 0) { return null; } Ship val = null; float num = float.MaxValue; Ship[] array2 = array; foreach (Ship val2 in array2) { if ((Object)(object)val2 == (Object)null) { continue; } Collider[] componentsInChildren = ((Component)val2).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { continue; } bool flag = false; float num2 = float.MaxValue; Collider[] array3 = componentsInChildren; foreach (Collider val3 in array3) { if (!((Object)(object)val3 == (Object)null) && val3.enabled) { Vector3 val4 = val3.ClosestPoint(position); Vector3 val5 = val4 - position; float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude; if (sqrMagnitude < 0.04f) { flag = true; num2 = 0f; break; } if (sqrMagnitude < num2) { num2 = sqrMagnitude; } } } if (flag) { return val2; } if (num2 < num) { num = num2; val = val2; } } return (num <= 9f) ? val : null; } private void StopAndClearSource(AudioSource source) { if ((Object)(object)source == (Object)null) { return; } try { if (source.isPlaying) { source.Stop(); } } catch { } source.clip = null; } private void ResetSongState(Player player = null) { EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo != null) { _localDrummerPlayerId = 0L; _nextDrummerDistanceCheck = 0f; ownedZdo.Set("hh_song_drum_active", false); ownedZdo.Set("hh_song_drum_start", 0f); ownedZdo.Set("hh_song_vocal_start", 0f); ownedZdo.Set("hh_song_male_vocal_count", 0); ownedZdo.Set("hh_song_female_vocal_count", 0); ownedZdo.Set("hh_song_male_vocal_player_id", ""); ownedZdo.Set("hh_song_female_vocal_player_id", ""); ownedZdo.Set("hh_song_drummer_id", ""); ownedZdo.Set("hh_song_drummer_heartbeat", 0f); _nextDrummerHeartbeatTime = 0f; StopAndClearSource(_drumSource); StopAndClearSource(_maleVocalSource); StopAndClearSource(_femaleVocalSource); _localJoinedMaleVocal = false; _localJoinedFemaleVocal = false; _localDrumStartedByThisClient = false; SetVanillaMusicMuted(muted: false); if (player != null) { ((Character)player).Message((MessageType)2, "Dal leállítva", 0, (Sprite)null); } } } private void ResetDrumState(Player player = null) { EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo != null) { _suppressSongEndReward = true; _drumWasPlayingLocally = false; _localDrumStartedByThisClient = false; ownedZdo.Set("hh_song_drum_active", false); ownedZdo.Set("hh_song_drum_start", 0f); ownedZdo.Set("hh_song_drummer_id", ""); ownedZdo.Set("hh_song_drummer_heartbeat", 0f); _nextDrummerHeartbeatTime = 0f; StopAndClearSource(_drumSource); if (player != null) { ((Character)player).Message((MessageType)2, "Dob leállítva", 0, (Sprite)null); } int @int = ownedZdo.GetInt("hh_song_male_vocal_count", 0); int int2 = ownedZdo.GetInt("hh_song_female_vocal_count", 0); if (@int <= 0 && int2 <= 0) { SetVanillaMusicMuted(muted: false); } } } private void CleanupStaleLocalVocalFlags() { if (_localJoinedMaleVocal && (!((Object)(object)_maleVocalSource != (Object)null) || !((Object)(object)_maleVocalSource.clip != (Object)null) || !_maleVocalSource.isPlaying)) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] Stale local male vocal flag törölve"); _localJoinedMaleVocal = false; } if (_localJoinedFemaleVocal && (!((Object)(object)_femaleVocalSource != (Object)null) || !((Object)(object)_femaleVocalSource.clip != (Object)null) || !_femaleVocalSource.isPlaying)) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] Stale local female vocal flag törölve"); _localJoinedFemaleVocal = false; } } private void StopLocalVocalIfLeftShip() { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (Time.time < _nextLocalVocalShipCheckTime) { return; } _nextLocalVocalShipCheckTime = Time.time + 0.5f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo == null || !ownedZdo.GetBool("hh_song_drum_active", false)) { return; } string text = localPlayer.GetPlayerID().ToString(); string @string = ownedZdo.GetString("hh_song_male_vocal_player_id", ""); string string2 = ownedZdo.GetString("hh_song_female_vocal_player_id", ""); bool flag = !string.IsNullOrEmpty(@string) && @string == text; bool flag2 = !string.IsNullOrEmpty(string2) && string2 == text; if (!flag && !flag2) { return; } bool flag3 = IsSameShip(localPlayer); float num = Vector3.Distance(((Component)localPlayer).transform.position, ((Component)this).transform.position); if (!flag3 && !(num <= 10f)) { if (flag) { ownedZdo.Set("hh_song_male_vocal_count", 0); ownedZdo.Set("hh_song_male_vocal_player_id", ""); _localJoinedMaleVocal = false; StopAndClearSource(_maleVocalSource); HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] Male vocal törölve: vocalos elhagyta a hajót. dist={num:0.00}"); } if (flag2) { ownedZdo.Set("hh_song_female_vocal_count", 0); ownedZdo.Set("hh_song_female_vocal_player_id", ""); _localJoinedFemaleVocal = false; StopAndClearSource(_femaleVocalSource); HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] Female vocal törölve: vocalos elhagyta a hajót. dist={num:0.00}"); } SetVanillaMusicMuted(IsAnyLocalShipTrackPlaying()); } } private void ResetVocalState(Player player = null) { EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo == null) { return; } if ((Object)(object)player != (Object)null && IsFemale(player)) { ownedZdo.Set("hh_song_female_vocal_count", 0); _localJoinedFemaleVocal = false; if ((Object)(object)_femaleVocalSource != (Object)null) { if (_femaleVocalSource.isPlaying) { _femaleVocalSource.Stop(); } _femaleVocalSource.clip = null; } if (player != null) { ((Character)player).Message((MessageType)2, "Női ének leállítva", 0, (Sprite)null); } } else { ownedZdo.Set("hh_song_male_vocal_count", 0); _localJoinedMaleVocal = false; if ((Object)(object)_maleVocalSource != (Object)null) { if (_maleVocalSource.isPlaying) { _maleVocalSource.Stop(); } _maleVocalSource.clip = null; } if (player != null) { ((Character)player).Message((MessageType)2, "Férfi ének leállítva", 0, (Sprite)null); } } int @int = ownedZdo.GetInt("hh_song_male_vocal_count", 0); int int2 = ownedZdo.GetInt("hh_song_female_vocal_count", 0); if (@int <= 0 && int2 <= 0 && !ownedZdo.GetBool("hh_song_drum_active", false)) { ownedZdo.Set("hh_song_vocal_start", 0f); SetVanillaMusicMuted(muted: false); } } public bool HasAnySongActive() { EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return false; } int @int = zDO.GetInt("hh_song_male_vocal_count", 0); int int2 = zDO.GetInt("hh_song_female_vocal_count", 0); return zDO.GetBool("hh_song_drum_active", false) || @int > 0 || int2 > 0; } private static Sprite LoadSongBuffIcon() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_0101: 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) if ((Object)(object)_songBuffIcon != (Object)null) { return _songBuffIcon; } try { string text = Path.Combine(Paths.ConfigPath, "HardheimShipEquipment", "plugins", "songbuff.png"); HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] buff icon path: " + text); if (!File.Exists(text)) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] buff icon nincs meg: " + text); return null; } byte[] array = File.ReadAllBytes(text); if (array == null || array.Length == 0) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!LoadImageReflective(val, array)) { Object.Destroy((Object)(object)val); HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] buff icon LoadImage reflection sikertelen"); return null; } ((Object)val).name = "HardheimSongBuffIcon"; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; _songBuffIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)_songBuffIcon).name = "HardheimSongBuffIconSprite"; HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] buff icon betöltve"); return _songBuffIcon; } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] buff icon load error: " + ex); return null; } } private static bool LoadImageReflective(Texture2D tex, byte[] bytes) { try { Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { type = assembly.GetType("UnityEngine.ImageConversion"); if (type != null) { break; } } if (type == null) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] UnityEngine.ImageConversion type nem található"); return false; } MethodInfo method = type.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(Texture2D), typeof(byte[]) }, null); if (method == null) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] ImageConversion.LoadImage(Texture2D, byte[]) nem található"); return false; } object obj = method.Invoke(null, new object[2] { tex, bytes }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] LoadImageReflective error: " + ex); return false; } } private void ApplySongBuff(Player player) { if ((Object)(object)player == (Object)null) { return; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan != null) { Player_Update_ShipSongPatch.ShipSongBuffUtility.RemoveUnderworldBuff(player); if (Player_Update_ShipSongPatch.ShipSongBuffUtility.RefreshExistingSongBuff(player, 3000f)) { ((Character)player).Message((MessageType)2, "A dal ereje újra átjár!", 0, (Sprite)null); HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] buff refreshed, no stacking"); return; } SE_Stats val = ScriptableObject.CreateInstance(); ((Object)val).name = "HardheimSongBuff"; ((StatusEffect)val).m_name = "Valhalla áldása"; ((StatusEffect)val).m_tooltip = "A dal ereje átjár.\n+10% életerő-regeneráció\n-50% állóképesség-regeneráció\n+5% mozgási sebesség"; ((StatusEffect)val).m_ttl = 3000f; val.m_healthRegenMultiplier = 1.1f; val.m_staminaRegenMultiplier = 0.5f; ((StatusEffect)val).m_icon = LoadSongBuffIcon(); sEMan.AddStatusEffect((StatusEffect)(object)val, false, 0, 0f); HardheimShipEquipmentPlugin.Log.LogInfo((object)("[VALHALLA APPLY] regen=" + val.m_healthRegenMultiplier + " stamina=" + val.m_staminaRegenMultiplier)); ((Character)player).Message((MessageType)2, "Valhalla ereje átjár!", 0, (Sprite)null); } } private void ApplyUnderworldSongBuff(Player player) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan != null) { Player_Update_ShipSongPatch.ShipSongBuffUtility.RemoveSongBuff(player); if (Player_Update_ShipSongPatch.ShipSongBuffUtility.RefreshExistingUnderworldBuff(player, 3000f)) { ClampHealthToCurrentMax(player); ((Character)player).Message((MessageType)2, "A Túlpart ereje újra átjár!", 0, (Sprite)null); HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] underworld buff refreshed, no stacking"); return; } SE_Stats val = ScriptableObject.CreateInstance(); ((Object)val).name = "HardheimUnderworldBuff"; ((StatusEffect)val).m_name = "Túlpart áldása"; ((StatusEffect)val).m_tooltip = "A dal ereje átjár.\n\n-8% mozgási sebesség\n+10% páncél\n+10% állóképesség-regeneráció"; ((StatusEffect)val).m_startMessageType = (MessageType)2; ((StatusEffect)val).m_startMessage = "A Túlpart ereje átjár!"; ((StatusEffect)val).m_stopMessageType = (MessageType)2; ((StatusEffect)val).m_stopMessage = "A Túlpart ereje elhagyott."; ((StatusEffect)val).m_ttl = 3000f; val.m_staminaRegenMultiplier = 1.1f; ((StatusEffect)val).m_icon = LoadSongBuffIcon(); sEMan.AddStatusEffect((StatusEffect)(object)val, false, 0, 0f); ClampHealthToCurrentMax(player); ((Character)player).Message((MessageType)2, "A Túlpart ereje átjár!", 0, (Sprite)null); } } private void ClampHealthToCurrentMax(Player player) { if ((Object)(object)player == (Object)null) { return; } try { float health = ((Character)player).GetHealth(); float maxHealth = ((Character)player).GetMaxHealth(); if (health > maxHealth) { ((Character)player).SetHealth(maxHealth); } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP UNDERWORLD HP CLAMP ERROR] " + ex); } } private void GiveBuffToShipPlayers() { EnsureNView(); int songIndex = 0; if ((Object)(object)_nview != (Object)null && _nview.IsValid()) { ZDO zDO = _nview.GetZDO(); if (zDO != null) { songIndex = Mathf.Clamp(zDO.GetInt("hh_song_index", 0), 0, SongIds.Length - 1); } } GiveBuffToLocalPlayerIfEligible(songIndex); } private void GiveBuffToLocalPlayerIfEligible(int songIndex) { //IL_0025: 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) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } bool flag = IsSameShip(localPlayer); float num = Vector3.Distance(((Component)localPlayer).transform.position, ((Component)this).transform.position); if (!flag && num > 30f) { HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] Buff kihagyva local playeren. onSameShip={flag} dist={num:0.00}"); } else if (songIndex == 1) { if (!Player_Update_ShipSongPatch.ShipSongBuffUtility.HasUnderworldBuff(localPlayer)) { ApplyUnderworldSongBuff(localPlayer); } } else if (!Player_Update_ShipSongPatch.ShipSongBuffUtility.HasSongBuff(localPlayer)) { ApplySongBuff(localPlayer); } } private void SignalSongFinishedForAllClients(int songIndex) { EnsureNView(); if (!((Object)(object)_nview == (Object)null) && _nview.IsValid()) { ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo != null) { int num = ownedZdo.GetInt("hh_song_finished_token", 0) + 1; ownedZdo.Set("hh_song_finished_token", num); ownedZdo.Set("hh_song_finished_index", songIndex); HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] Dal vége jel kiküldve. token={num} songIndex={songIndex}"); } } } private void ProcessFinishedSongBuffSignal() { EnsureNView(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO zDO = _nview.GetZDO(); if (zDO != null) { int @int = zDO.GetInt("hh_song_finished_token", 0); if (@int > 0 && @int != _lastProcessedSongFinishedToken) { _lastProcessedSongFinishedToken = @int; int num = Mathf.Clamp(zDO.GetInt("hh_song_finished_index", 0), 0, SongIds.Length - 1); HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] Dal vége jel feldolgozva local kliensen. token={@int} songIndex={num}"); GiveBuffToLocalPlayerIfEligible(num); } } } public bool StartOrJoinVocal(Player player, bool allowSongSwitchIfIdle) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG] StartOrJoinVocal meghívva"); if ((Object)(object)player == (Object)null) { return false; } EnsureNView(); EnsureAudioSources(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo == null) { return false; } if (!ownedZdo.GetBool("hh_song_drum_active", false)) { ((Character)player).Message((MessageType)2, "Előbb induljon a dob", 0, (Sprite)null); return true; } bool flag = IsFemale(player); HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] StartOrJoinVocal female={flag}"); float num = (((Object)(object)ZNet.instance != (Object)null) ? ((float)ZNet.instance.GetTimeSeconds()) : Time.time); float num2 = ownedZdo.GetFloat("hh_song_drum_start", 0f); if (num2 <= 0f) { num2 = num; ownedZdo.Set("hh_song_drum_start", num2); } float @float = ownedZdo.GetFloat("hh_song_vocal_start", 0f); if (@float <= 0f) { ownedZdo.Set("hh_song_vocal_start", num2); } if (flag) { _localJoinedFemaleVocal = true; _pendingFemaleJoinUntil = Time.time + 3f; _suppressFemaleVocalUntil = 0f; if (ownedZdo.GetInt("hh_song_female_vocal_count", 0) <= 0) { ownedZdo.Set("hh_song_female_vocal_count", 1); } ownedZdo.Set("hh_song_female_vocal_player_id", player.GetPlayerID().ToString()); _localSongActionThisSession = true; ForceVocalJoinState(female: true); SyncSongPlayback(allowDuringInitialBlock: true); if ((Object)(object)HardheimShipEquipmentPlugin.Instance != (Object)null) { ((MonoBehaviour)HardheimShipEquipmentPlugin.Instance).StartCoroutine(DelayedVocalJoinSync(female: true)); } ((Character)player).Message((MessageType)2, "Csatlakozol női énekkel", 0, (Sprite)null); return true; } _localJoinedMaleVocal = true; _pendingMaleJoinUntil = Time.time + 3f; _suppressMaleVocalUntil = 0f; if (ownedZdo.GetInt("hh_song_male_vocal_count", 0) <= 0) { ownedZdo.Set("hh_song_male_vocal_count", 1); } ownedZdo.Set("hh_song_male_vocal_player_id", player.GetPlayerID().ToString()); _localSongActionThisSession = true; ForceVocalJoinState(female: false); SyncSongPlayback(allowDuringInitialBlock: true); if ((Object)(object)HardheimShipEquipmentPlugin.Instance != (Object)null) { ((MonoBehaviour)HardheimShipEquipmentPlugin.Instance).StartCoroutine(DelayedVocalJoinSync(female: false)); } ((Character)player).Message((MessageType)2, "Csatlakozol férfi énekkel", 0, (Sprite)null); return true; } private void ForceVocalJoinState(bool female) { ZDO ownedZdo = GetOwnedZdo(); if (ownedZdo == null) { return; } Player localPlayer = Player.m_localPlayer; float num = ownedZdo.GetFloat("hh_song_drum_start", 0f); if (num <= 0f) { num = (((Object)(object)ZNet.instance != (Object)null) ? ((float)ZNet.instance.GetTimeSeconds()) : Time.time); } if (ownedZdo.GetFloat("hh_song_vocal_start", 0f) <= 0f) { ownedZdo.Set("hh_song_vocal_start", num); } if (female) { ownedZdo.Set("hh_song_female_vocal_count", Mathf.Max(1, ownedZdo.GetInt("hh_song_female_vocal_count", 0))); if ((Object)(object)localPlayer != (Object)null) { ownedZdo.Set("hh_song_female_vocal_player_id", localPlayer.GetPlayerID().ToString()); } } else { ownedZdo.Set("hh_song_male_vocal_count", Mathf.Max(1, ownedZdo.GetInt("hh_song_male_vocal_count", 0))); if ((Object)(object)localPlayer != (Object)null) { ownedZdo.Set("hh_song_male_vocal_player_id", localPlayer.GetPlayerID().ToString()); } } } [IteratorStateMachine(typeof(d__74))] private IEnumerator DelayedVocalJoinSync(bool female) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__74(0) { <>4__this = this, female = female }; } private Transform GetOrCreateSitPoint() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)this).transform.Find("HH_DrumSitPoint"); if ((Object)(object)val != (Object)null) { return val; } GameObject val2 = new GameObject("HH_DrumSitPoint"); val2.transform.SetParent(((Component)this).transform, false); val2.transform.localPosition = new Vector3(0f, 0.15f, -0.75f); val2.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); return val2.transform; } private void OnDisable() { SetVanillaMusicMuted(muted: false); } private void OnDestroy() { SetVanillaMusicMuted(muted: false); } private string GetVocalFileForPlayer(Player player, int songIndex) { bool flag = IsFemale(player); string text = (flag ? (SongIds[songIndex] + "woman_vocal.ogg") : (SongIds[songIndex] + "man_vocal.ogg")); HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] GetVocalFileForPlayer songIndex={songIndex} female={flag} file={text}"); return text; } private void SyncSourceToOffset(AudioSource source, AudioClip clip, float offset, string tag, float toleranceSeconds = 0.08f, bool allowEarlyResync = false) { if ((Object)(object)source == (Object)null || (Object)(object)clip == (Object)null) { return; } float num = ((clip.length > 0.05f) ? (offset % clip.length) : 0f); int num2 = Mathf.Clamp(Mathf.RoundToInt(num * (float)clip.frequency), 0, Mathf.Max(0, clip.samples - 1)); if (!source.isPlaying || (Object)(object)source.clip != (Object)(object)clip) { if (source.isPlaying) { source.Stop(); } source.clip = clip; source.timeSamples = num2; source.Play(); HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] {tag} start targetTime={num:0.000} samples={num2}"); } else { int num3 = Mathf.Abs(source.timeSamples - num2); int num4 = ((clip.samples > 0) ? Mathf.Min(num3, clip.samples - num3) : num3); int num5 = Mathf.RoundToInt(toleranceSeconds * (float)clip.frequency); if (num4 > num5 && (allowEarlyResync || !(source.time < 1f))) { source.timeSamples = num2; HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] {tag} resync diffSamples={num4} targetSamples={num2}"); } } } private void SyncSongPlayback(bool allowDuringInitialBlock = false) { EnsureNView(); EnsureAudioSources(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return; } if (!allowDuringInitialBlock && !_localSongActionThisSession && Time.time < _blockAutoSongPlaybackUntil) { StopAndClearSource(_drumSource); StopAndClearSource(_maleVocalSource); StopAndClearSource(_femaleVocalSource); SetVanillaMusicMuted(muted: false); return; } bool @bool = zDO.GetBool("hh_song_drum_active", false); int num = zDO.GetInt("hh_song_male_vocal_count", 0); int num2 = zDO.GetInt("hh_song_female_vocal_count", 0); int num3 = Mathf.Clamp(zDO.GetInt("hh_song_index", 0), 0, SongIds.Length - 1); float num4 = (((Object)(object)ZNet.instance != (Object)null) ? ((float)ZNet.instance.GetTimeSeconds()) : Time.time); if (@bool && _localJoinedMaleVocal && num <= 0 && Time.time < _pendingMaleJoinUntil) { num = 1; zDO.Set("hh_song_male_vocal_count", 1); } if (@bool && _localJoinedFemaleVocal && num2 <= 0 && Time.time < _pendingFemaleJoinUntil) { num2 = 1; zDO.Set("hh_song_female_vocal_count", 1); } HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG] SyncSongPlayback state drumActive={@bool} maleCount={num} femaleCount={num2} songIndex={num3}"); if (!@bool) { if ((Object)(object)_drumSource != (Object)null) { _drumSource.Stop(); _drumSource.clip = null; } StopAndClearSource(_maleVocalSource); StopAndClearSource(_femaleVocalSource); _localJoinedMaleVocal = false; _localJoinedFemaleVocal = false; _pendingMaleJoinUntil = 0f; _pendingFemaleJoinUntil = 0f; SetVanillaMusicMuted(muted: false); return; } float @float = zDO.GetFloat("hh_song_drum_start", 0f); if (@float <= 0f) { return; } float num5 = Mathf.Max(0f, num4 - @float); string filename = SongIds[num3] + "_drum.ogg"; AudioClip val = LoadClip(filename); AudioClip val2 = ((num > 0) ? LoadClip(SongIds[num3] + "man_vocal.ogg") : null); AudioClip val3 = ((num2 > 0) ? LoadClip(SongIds[num3] + "woman_vocal.ogg") : null); float num6 = 0f; if ((Object)(object)val != (Object)null && val.length > 0.05f) { num6 = Mathf.Max(num6, val.length); } if ((Object)(object)val2 != (Object)null && val2.length > 0.05f) { num6 = Mathf.Max(num6, val2.length); } if ((Object)(object)val3 != (Object)null && val3.length > 0.05f) { num6 = Mathf.Max(num6, val3.length); } if (num6 > 0.05f && num5 >= num6) { SignalSongFinishedForAllClients(num3); GiveBuffToLocalPlayerIfEligible(num3); ResetSongState(); return; } if ((Object)(object)val != (Object)null && (Object)(object)_drumSource != (Object)null) { SyncSourceToOffset(_drumSource, val, num5, "DRUM", 0.1f); } float offset = Mathf.Max(0f, num5 - 0.06f); if (num > 0) { if ((Object)(object)val2 != (Object)null && (Object)(object)_maleVocalSource != (Object)null) { SyncSourceToOffset(_maleVocalSource, val2, offset, "MALE", 0.025f, allowEarlyResync: true); } } else { if ((Object)(object)_maleVocalSource != (Object)null) { _maleVocalSource.Stop(); _maleVocalSource.clip = null; } _localJoinedMaleVocal = false; } if (num2 > 0) { if ((Object)(object)val3 != (Object)null && (Object)(object)_femaleVocalSource != (Object)null) { SyncSourceToOffset(_femaleVocalSource, val3, offset, "FEMALE", 0.025f, allowEarlyResync: true); } } else { if ((Object)(object)_femaleVocalSource != (Object)null) { _femaleVocalSource.Stop(); _femaleVocalSource.clip = null; } _localJoinedFemaleVocal = false; } SetVanillaMusicMuted(muted: true); } } [HarmonyPatch(typeof(Player), "Update")] public static class Player_Update_ShipSongPatch { public static class ShipSongBuffUtility { public static bool HasSongBuff(Player player) { return (Object)(object)FindSongBuff(player) != (Object)null; } public static bool HasUnderworldBuff(Player player) { return (Object)(object)FindUnderworldBuff(player) != (Object)null; } public static void RemoveSongBuff(Player player) { RemoveBuff(player, "HardheimSongBuff"); } public static void RemoveUnderworldBuff(Player player) { RemoveBuff(player, "HardheimUnderworldBuff"); } private static void RemoveBuff(Player player, string internalName) { try { if (!((Object)(object)player == (Object)null) && !string.IsNullOrEmpty(internalName)) { SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan != null) { sEMan.RemoveStatusEffect(StringExtensionMethods.GetStableHashCode(internalName), false); } } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG BUFF REMOVE ERROR] " + ex); } } public static float GetSongBuffRemainingTime(Player player) { StatusEffect val = FindSongBuff(player); if ((Object)(object)val == (Object)null) { return 0f; } try { FieldInfo field = typeof(StatusEffect).GetField("m_time", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); float num = 0f; if (field != null) { num = (float)field.GetValue(val); } return Mathf.Max(0f, val.m_ttl - num); } catch { return Mathf.Max(0f, val.m_ttl); } } public static Sprite GetSongBuffIcon(Player player) { StatusEffect val = FindSongBuff(player); if ((Object)(object)val == (Object)null) { return null; } return val.m_icon; } public static Sprite GetUnderworldBuffIcon(Player player) { StatusEffect val = FindUnderworldBuff(player); if ((Object)(object)val == (Object)null) { return null; } return val.m_icon; } public static float GetUnderworldBuffRemainingTime(Player player) { StatusEffect val = FindUnderworldBuff(player); if ((Object)(object)val == (Object)null) { return 0f; } try { FieldInfo field = typeof(StatusEffect).GetField("m_time", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); float num = 0f; if (field != null) { num = (float)field.GetValue(val); } return Mathf.Max(0f, val.m_ttl - num); } catch { return Mathf.Max(0f, val.m_ttl); } } public static bool RefreshExistingSongBuff(Player player, float duration) { StatusEffect val = FindSongBuff(player); if ((Object)(object)val == (Object)null) { return false; } try { val.m_ttl = duration; SE_Stats val2 = (SE_Stats)(object)((val is SE_Stats) ? val : null); if ((Object)(object)val2 != (Object)null) { val2.m_healthRegenMultiplier = 1.1f; val2.m_staminaRegenMultiplier = 0.5f; ((StatusEffect)val2).m_tooltip = "A dal ereje átjár.\n+10% életerő-regeneráció\n-50% állóképesség-regeneráció\n+5% mozgási sebesség"; } FieldInfo field = typeof(StatusEffect).GetField("m_time", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, 0f); } return true; } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG BUFF REFRESH ERROR] " + ex); return true; } } public static bool RefreshExistingUnderworldBuff(Player player, float duration) { StatusEffect val = FindUnderworldBuff(player); if ((Object)(object)val == (Object)null) { return false; } try { val.m_ttl = duration; FieldInfo field = typeof(StatusEffect).GetField("m_time", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, 0f); } return true; } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP UNDERWORLD BUFF REFRESH ERROR] " + ex); return true; } } private static StatusEffect FindSongBuff(Player player) { try { if ((Object)(object)player == (Object)null) { return null; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return null; } FieldInfo field = typeof(SEMan).GetField("m_statusEffects", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return null; } object value = field.GetValue(sEMan); if (!(value is IEnumerable enumerable)) { return null; } foreach (object item in enumerable) { StatusEffect val = (StatusEffect)((item is StatusEffect) ? item : null); if ((Object)(object)val == (Object)null || !string.Equals(((Object)val).name, "HardheimSongBuff", StringComparison.OrdinalIgnoreCase)) { continue; } return val; } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG BUFF FIND ERROR] " + ex); } return null; } private static StatusEffect FindUnderworldBuff(Player player) { try { if ((Object)(object)player == (Object)null) { return null; } SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan == null) { return null; } FieldInfo field = typeof(SEMan).GetField("m_statusEffects", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return null; } object value = field.GetValue(sEMan); if (!(value is IEnumerable enumerable)) { return null; } foreach (object item in enumerable) { StatusEffect val = (StatusEffect)((item is StatusEffect) ? item : null); if ((Object)(object)val == (Object)null || !string.Equals(((Object)val).name, "HardheimUnderworldBuff", StringComparison.OrdinalIgnoreCase)) { continue; } return val; } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP UNDERWORLD BUFF FIND ERROR] " + ex); } return null; } } private static float _lastVocalPress; private static float _blockShipSongInputUntil; private static float _nextJoinHintTime; private static void Postfix(Player __instance) { try { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } if (IsUiBlockingShipSongInput()) { _lastVocalPress = Time.time; _blockShipSongInputUntil = Time.time + 0.75f; } else { if (Time.time < _blockShipSongInputUntil) { return; } HardheimShipEquipmentPlugin.LogDebug("=== PATCH LIVE 777 ==="); HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG PATCH] Postfix belépett"); ShipDrumInteraction shipDrumInteraction = FindNearestShipDrumForPlayer(__instance); if ((Object)(object)shipDrumInteraction == (Object)null) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG PATCH] drum == null"); return; } if (shipDrumInteraction.CanPlayerJoinVocal(__instance) && Time.time >= _nextJoinHintTime) { _nextJoinHintTime = Time.time + 3f; ((Character)__instance).Message((MessageType)2, "[H] Csatlakozás a harci énekhez", 0, (Sprite)null); } bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (Input.GetKeyDown((KeyCode)104)) { if (IsUiBlockingShipSongInput() || IsPlayerBusyWithContainerOrGui(__instance)) { _lastVocalPress = Time.time; } else if (!(Time.time - _lastVocalPress < 0.5f)) { _lastVocalPress = Time.time; HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG PATCH] H lenyomva, vocal csatlakozás próbálva."); shipDrumInteraction.StartOrJoinVocal(__instance, allowSongSwitchIfIdle: true); } } } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG PATCH ERROR] " + ex); } } private static bool IsUiBlockingShipSongInput() { try { if (InventoryGui.IsVisible()) { return true; } if (TextInput.IsVisible()) { return true; } if (Menu.IsVisible()) { return true; } if (Console.IsVisible()) { return true; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return true; } if (Minimap.IsOpen()) { return true; } } catch { } return false; } private static bool IsPlayerBusyWithContainerOrGui(Player player) { try { if ((Object)(object)player == (Object)null) { return false; } if (InventoryGui.IsVisible()) { return true; } if (Minimap.IsOpen()) { return true; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return true; } } catch { } return false; } private static ShipDrumInteraction FindNearestShipDrumForPlayer(Player player) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return null; } ShipDrumInteraction[] array = Object.FindObjectsByType((FindObjectsSortMode)0); if (array == null || array.Length == 0) { return null; } ShipDrumInteraction shipDrumInteraction = null; float num = float.MaxValue; ShipDrumInteraction[] array2 = array; foreach (ShipDrumInteraction shipDrumInteraction2 in array2) { if (!((Object)(object)shipDrumInteraction2 == (Object)null)) { float num2 = Vector3.Distance(((Component)player).transform.position, ((Component)shipDrumInteraction2).transform.position); if (!(num2 > 10f) && num2 < num) { shipDrumInteraction = shipDrumInteraction2; num = num2; } } } if ((Object)(object)shipDrumInteraction == (Object)null) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG PATCH] FindNearestShipDrumForPlayer: nincs 10m-en belül dob"); } else { HardheimShipEquipmentPlugin.LogDebug($"[SHIP SONG PATCH] FindNearestShipDrumForPlayer: talált dob, dist={num:0.00}"); } return shipDrumInteraction; } } [HarmonyPatch] public static class SEMan_ApplyStatusEffectSpeedMods_ShipSongBuffPatch { private static float _nextLogTime; private static MethodBase TargetMethod() { return AccessTools.DeclaredMethod(typeof(SEMan), "ApplyStatusEffectSpeedMods", (Type[])null, (Type[])null); } private static void Postfix(SEMan __instance, ref float speed, Vector3 dir, Character ___m_character) { try { Player val = (Player)(object)((___m_character is Player) ? ___m_character : null); if (!((Object)(object)val == (Object)null)) { float num = speed; bool flag = Player_Update_ShipSongPatch.ShipSongBuffUtility.HasUnderworldBuff(val); bool flag2 = Player_Update_ShipSongPatch.ShipSongBuffUtility.HasSongBuff(val); if (flag) { speed *= 0.92f; } if (flag2) { speed *= 1.05f; } if (Time.time >= _nextLogTime && (flag || flag2)) { _nextLogTime = Time.time + 1f; HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG SPEED PATCH] player=" + val.GetPlayerName() + " " + $"underworld={flag} valhalla={flag2} " + $"speedBefore={num:0.000} speedAfter={speed:0.000}"); } } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP SONG SPEED MOD PATCH ERROR] " + ex); } } } [HarmonyPatch] public static class ItemData_GetArmor_UnderworldBuffPatch { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private List.Enumerator <>s__1; private MethodInfo 5__2; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>s__1 = default(List.Enumerator); 5__2 = null; <>1__state = -2; } private bool MoveNext() { try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; goto IL_00a8; } <>1__state = -1; <>s__1 = AccessTools.GetDeclaredMethods(typeof(ItemData)).GetEnumerator(); <>1__state = -3; goto IL_00b0; IL_00a8: 5__2 = null; goto IL_00b0; IL_00b0: if (<>s__1.MoveNext()) { 5__2 = <>s__1.Current; if (5__2 != null && 5__2.Name == "GetArmor") { <>2__current = 5__2; <>1__state = 1; return true; } goto IL_00a8; } <>m__Finally1(); <>s__1 = default(List.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__0(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] private static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2); } private static void Postfix(ItemData __instance, ref float __result) { try { if (__instance != null && !(__result <= 0f) && IsEquippedByAnyUnderworldBuffedPlayer(__instance)) { __result *= 1.1f; } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP UNDERWORLD ITEM ARMOR PATCH ERROR] " + ex); } } private static bool IsEquippedByAnyUnderworldBuffedPlayer(ItemData item) { if (item == null) { return false; } List allPlayers = Player.GetAllPlayers(); if (allPlayers == null) { return false; } foreach (Player item2 in allPlayers) { if ((Object)(object)item2 == (Object)null || !Player_Update_ShipSongPatch.ShipSongBuffUtility.HasUnderworldBuff(item2) || !IsEquippedByPlayer(item2, item)) { continue; } return true; } return false; } private static bool IsEquippedByPlayer(Player player, ItemData item) { return SameEquippedItem(player, item, "m_helmetItem") || SameEquippedItem(player, item, "m_chestItem") || SameEquippedItem(player, item, "m_legItem") || SameEquippedItem(player, item, "m_shoulderItem"); } private static bool SameEquippedItem(Player player, ItemData item, string fieldName) { try { FieldInfo fieldInfo = typeof(Humanoid).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeof(Player).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo == null) { return false; } object value = fieldInfo.GetValue(player); return value == item; } catch { return false; } } } [HarmonyPatch] public static class InventoryGui_UpdateCharacterStats_UnderworldArmorColorPatch { [CompilerGenerated] private sealed class d__1 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private MethodInfo 5__1; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = AccessTools.Method(typeof(InventoryGui), "UpdateCharacterStats", (Type[])null, (Type[])null); if (5__1 != null) { <>2__current = 5__1; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } 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() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__1(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly FieldInfo ArmorField = AccessTools.Field(typeof(InventoryGui), "m_armor"); [IteratorStateMachine(typeof(d__1))] private static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(-2); } private static void Postfix(InventoryGui __instance) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return; } object obj = ArmorField?.GetValue(__instance); if (obj != null) { bool flag = Player_Update_ShipSongPatch.ShipSongBuffUtility.HasUnderworldBuff(Player.m_localPlayer); Type type = obj.GetType(); Color val = (flag ? Color.green : Color.white); PropertyInfo property = type.GetProperty("color"); if (property != null && property.CanWrite) { property.SetValue(obj, val, null); } FieldInfo field = type.GetField("color"); if (field != null) { field.SetValue(obj, val); } } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP UNDERWORLD ARMOR UI PATCH ERROR] " + ex); } } } public sealed class ShipTorchAttachment : MonoBehaviour { [CompilerGenerated] private sealed class d__27 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ShipTorchAttachment <>4__this; private float 5__1; private float 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__27(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = 5f; 5__2 = 0f; break; case 1: <>1__state = -1; break; } if (5__2 < 5__1) { 5__2 += Time.deltaTime; if ((Object)(object)<>4__this == (Object)null || (Object)(object)((Component)<>4__this).gameObject == (Object)null) { return false; } if ((Object)(object)ZNetScene.instance != (Object)null) { HardheimShipEquipmentPlugin.AttachDemisterEffect(((Component)<>4__this).gameObject); return false; } <>2__current = null; <>1__state = 1; return true; } HardheimShipEquipmentPlugin.LogDebug("[DEMISTER ATTACH] Timeout: ZNetScene.instance továbbra is null"); 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 const string ZdoShipUidA = "hh_ship_uid_user"; private const string ZdoShipUidB = "hh_ship_uid_id"; private const string ZdoBound = "hh_ship_bound"; private const string ZdoLocalPos = "hh_local_pos"; private const string ZdoLocalRot = "hh_local_rot"; private const string ZdoSchemaVersion = "hh_schema_version"; private const int CurrentSchemaVersion = 2; private ZNetView _nview; private Ship _ship; private bool _initialized; private bool _isPreviewGhost; private bool _hasLocalAnchor; private Vector3 _localPos; private Quaternion _localRot; private Vector3 _lastSyncedWorldPos; private Quaternion _lastSyncedWorldRot; private bool _hasLastSyncedWorldState; private float _nextWorldSyncTime; private float _nextRestoreTryTime; private float _nextMigrationTryTime; private bool _wasPlayerNearbyForPresenceLog; private float _noRebindBeforeTime; private float _nextResolveTryTime; private float _nextNearbyRestoreTryTime; private bool _pendingDestroyBecauseShipDied; private void FixMistTorchFuel() { if (!((Object)this).name.StartsWith("HH_ShipTorchMist", StringComparison.OrdinalIgnoreCase)) { return; } Fireplace componentInChildren = ((Component)this).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { HardheimShipEquipmentPlugin.Log.LogWarning((object)"[HardheimShipEquipment] [MIST FUEL] A ködtörő fáklyán nincs Fireplace."); return; } if ((Object)(object)ObjectDB.instance == (Object)null) { HardheimShipEquipmentPlugin.Log.LogWarning((object)"[HardheimShipEquipment] [MIST FUEL] ObjectDB.instance == null"); return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Wisp"); if ((Object)(object)itemPrefab == (Object)null) { HardheimShipEquipmentPlugin.Log.LogWarning((object)"[HardheimShipEquipment] [MIST FUEL] Wisp item prefab nem található."); return; } ItemDrop component = itemPrefab.GetComponent(); if ((Object)(object)component == (Object)null) { HardheimShipEquipmentPlugin.Log.LogWarning((object)"[HardheimShipEquipment] [MIST FUEL] A Wisp prefabon nincs ItemDrop."); return; } componentInChildren.m_fuelItem = component; componentInChildren.m_maxFuel = 4f; HardheimShipEquipmentPlugin.LogDebug("[MIST FUEL] Ködtörő fáklya fuel item átállítva Wisp-re."); } private void Awake() { _nview = ((Component)this).GetComponent(); _initialized = true; _isPreviewGhost = ShipTorchPlacementHelper.IsPreviewGhostObject(((Component)this).gameObject); HardheimShipEquipmentPlugin.LogDebug($"[ATTACHMENT AWAKE] id={((Object)((Component)this).gameObject).GetInstanceID()} name={((Object)this).name} isPreviewGhost={_isPreviewGhost}"); if (((Object)this).name.StartsWith("HH_ShipTorchMist", StringComparison.OrdinalIgnoreCase)) { HardheimShipEquipmentPlugin.DebugLiveObjectComponents(((Component)this).gameObject, "HH_ShipTorchMist Awake"); } if (_isPreviewGhost) { ((Behaviour)this).enabled = false; return; } _noRebindBeforeTime = Time.time + 12f; TryInitialBind(); _nextRestoreTryTime = Time.time + 0.1f; _nextMigrationTryTime = Time.time + 0.5f; _nextResolveTryTime = Time.time + 0.1f; _nextNearbyRestoreTryTime = Time.time + 0.25f; _wasPlayerNearbyForPresenceLog = false; FixMistTorchFuel(); if (((Object)this).name.StartsWith("HH_ShipTorchMist", StringComparison.OrdinalIgnoreCase)) { ((MonoBehaviour)this).StartCoroutine(AttachDemisterWhenReady()); } } [IteratorStateMachine(typeof(d__27))] private IEnumerator AttachDemisterWhenReady() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__27(0) { <>4__this = this }; } private void Update() { //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_0099: Unknown result type (might be due to invalid IL or missing references) if (HardheimShipEquipmentPlugin.CfgDumpHHStateKey != null) { KeyboardShortcut value = HardheimShipEquipmentPlugin.CfgDumpHHStateKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { DumpAllHHState(); } } if (_isPreviewGhost || !_initialized || (Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } if (_pendingDestroyBecauseShipDied) { if (_nview.IsOwner()) { HardheimShipEquipmentPlugin.LogDebug($"[SHIP CLEANUP DESTROY UPDATE] item={((Object)this).name} pos={((Component)this).transform.position}"); LogMigrationState("SHIP_DESTROY", "DESTROYED_WITH_PARENT_SHIP", "parent ship destroyed (delayed after ownership)"); ZNetScene instance = ZNetScene.instance; if (instance != null) { instance.Destroy(((Component)this).gameObject); } } else { _nview.ClaimOwnership(); } return; } TryLogPresenceState(); if (Time.time >= _nextMigrationTryTime) { _nextMigrationTryTime = Time.time + 1f; if (IsAnyPlayerNearbyForMigration()) { TryMigrateLegacyIfNeeded(); } } if (Time.time >= _nextResolveTryTime) { float num = ((HardheimShipEquipmentPlugin.CfgReattachInterval != null) ? HardheimShipEquipmentPlugin.CfgReattachInterval.Value : 2f); _nextResolveTryTime = Time.time + num; ResolveShipReference(); } if (((Object)(object)_ship == (Object)null || !_hasLocalAnchor) && Time.time >= _nextRestoreTryTime) { _nextRestoreTryTime = Time.time + 1f; TryRestoreFromZDO(); } } private void LateUpdate() { if (!_isPreviewGhost && _initialized && !((Object)(object)_nview == (Object)null) && _nview.IsValid() && !((Object)(object)_ship == (Object)null) && _hasLocalAnchor) { ApplyLocalFollow(); SyncWorldStateToServer(); } } private void OnDestroy() { } private void DumpAllHHState() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) try { ShipTorchAttachment[] array = Object.FindObjectsByType((FindObjectsSortMode)0); HardheimShipEquipmentPlugin.LogDebug("========== HH STATE DUMP =========="); ShipTorchAttachment[] array2 = array; foreach (ShipTorchAttachment shipTorchAttachment in array2) { if ((Object)(object)shipTorchAttachment == (Object)null) { continue; } ZNetView component = ((Component)shipTorchAttachment).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { continue; } ZDO zDO = component.GetZDO(); if (zDO != null) { string name = ((Object)shipTorchAttachment).name; Vector3 position = ((Component)shipTorchAttachment).transform.position; bool @bool = zDO.GetBool("hh_ship_bound", false); int @int = zDO.GetInt("hh_schema_version", 0); uint num = (uint)zDO.GetLong("hh_ship_uid_user", 0L); uint num2 = (uint)zDO.GetLong("hh_ship_uid_id", 0L); bool flag = num != 0 || num2 != 0; bool hasLocalAnchor = shipTorchAttachment._hasLocalAnchor; bool flag2 = (Object)(object)shipTorchAttachment._ship != (Object)null; Ship val = null; if (flag) { val = ShipTorchPlacementHelper.FindShipByZdoId(new ZDOID((long)num, num2)); } HardheimShipEquipmentPlugin.LogDebug($"[HH ITEM] name={name} pos={position} " + $"bound={@bool} schema={@int} " + string.Format("hasShipId={0} resolvedShip={1} ", flag, Object.op_Implicit((Object)(object)val) ? ((Object)val).name : "NULL") + $"hasLocal={hasLocalAnchor} hasShipRef={flag2}"); } } HardheimShipEquipmentPlugin.LogDebug("========== END HH STATE DUMP =========="); } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[HH DUMP ERROR] " + ex); } } private void TryInitialBind() { //IL_0194: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0109: 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_01bf: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return; } if (zDO.GetBool("hh_ship_bound", false)) { LoadLocalAnchor(zDO); } else { if (!_nview.IsOwner()) { return; } if (PendingShipPlacement.TryConsume(out var snapshot)) { object[] obj = new object[7] { ((Object)this).name, ShipTorchPlacementHelper.IsShipChest(((Component)this).gameObject), snapshot.WorldPosition, ((Quaternion)(ref snapshot.WorldRotation)).eulerAngles, snapshot.ShipId, ((Component)this).transform.position, null }; Quaternion rotation = ((Component)this).transform.rotation; obj[6] = ((Quaternion)(ref rotation)).eulerAngles; HardheimShipEquipmentPlugin.LogDebug(string.Format("[HH_BIND_TRACE] PENDING CONSUME item={0} isChest={1} pendingWorld={2} pendingRot={3} pendingShipId={4} actualObjPos={5} actualObjRot={6}", obj)); Ship val = ShipTorchPlacementHelper.FindShipByZdoId(snapshot.ShipId); if ((Object)(object)val != (Object)null) { HardheimShipEquipmentPlugin.LogDebug("[HH_BIND_TRACE] PENDING SHIP FOUND item=" + ((Object)this).name + " ship=" + ((Object)val).name); BindToShipUsingLocalAnchor(val, snapshot.WorldPosition, snapshot.WorldRotation); return; } HardheimShipEquipmentPlugin.LogDebug("[HH_BIND_TRACE] PENDING SHIP NOT FOUND item=" + ((Object)this).name); } Ship val2 = ShipTorchPlacementHelper.FindNearestShip(((Component)this).transform.position, HardheimShipEquipmentPlugin.CfgAttachSearchRadius.Value); if ((Object)(object)val2 != (Object)null) { BindToShipUsingLocalAnchor(val2, ((Component)this).transform.position, ((Component)this).transform.rotation); } else if (HardheimShipEquipmentPlugin.CfgDestroyIfNotOnShip.Value) { LogMigrationState("INIT", "DESTROYED", "no ship found during initial bind and DestroyIfNotOnShip=true"); ZNetScene instance = ZNetScene.instance; if (instance != null) { instance.Destroy(((Component)this).gameObject); } } else { LogMigrationState("INIT", "SKIPPED", "no ship found during initial bind"); } } } private int GetSchemaVersion(ZDO zdo) { if (zdo == null) { return 0; } return zdo.GetInt("hh_schema_version", 0); } private void SetSchemaVersion(ZDO zdo, int version = 2) { if (zdo != null) { zdo.Set("hh_schema_version", version); } } private bool HasLocalAnchorData(ZDO zdo) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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 (zdo == null) { return false; } Vector3 vec = zdo.GetVec3("hh_local_pos", Vector3.zero); Vector3 vec2 = zdo.GetVec3("hh_local_rot", Vector3.zero); return vec != Vector3.zero || vec2 != Vector3.zero; } private void LogMigrationState(string eventType, string result, string reason = null, Ship resolvedShip = null) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) ZDO val = (((Object)(object)_nview != (Object)null && _nview.IsValid()) ? _nview.GetZDO() : null); bool bound = val != null && val.GetBool("hh_ship_bound", false); int schema = ((val != null) ? val.GetInt("hh_schema_version", 0) : 0); bool hasShipId = false; if (val != null) { uint num = (uint)val.GetLong("hh_ship_uid_user", 0L); uint num2 = (uint)val.GetLong("hh_ship_uid_id", 0L); hasShipId = num != 0 || num2 != 0; } MigrationFileLogger.WriteItemState(eventType, ((Component)this).gameObject, val, resolvedShip, bound, schema, hasShipId, _hasLocalAnchor || HasLocalAnchorData(val), (Object)(object)_ship != (Object)null, result, reason, _hasLocalAnchor ? new Vector3?(_localPos) : null, _hasLocalAnchor ? new Quaternion?(_localRot) : null); } private void LogPresenceState(string result, string reason = null, Ship resolvedShip = null) { //IL_00d1: 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) ZDO val = (((Object)(object)_nview != (Object)null && _nview.IsValid()) ? _nview.GetZDO() : null); bool bound = val != null && val.GetBool("hh_ship_bound", false); int schema = ((val != null) ? val.GetInt("hh_schema_version", 0) : 0); bool hasShipId = false; if (val != null) { uint num = (uint)val.GetLong("hh_ship_uid_user", 0L); uint num2 = (uint)val.GetLong("hh_ship_uid_id", 0L); hasShipId = num != 0 || num2 != 0; } MigrationFileLogger.WriteItemState("PRESENCE", ((Component)this).gameObject, val, resolvedShip, bound, schema, hasShipId, _hasLocalAnchor || HasLocalAnchorData(val), (Object)(object)_ship != (Object)null, result, reason, _hasLocalAnchor ? new Vector3?(_localPos) : null, _hasLocalAnchor ? new Quaternion?(_localRot) : null); } private void TryLogPresenceState() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } if (!IsAnyPlayerNearbyForMigration()) { _wasPlayerNearbyForPresenceLog = false; } else { if (_wasPlayerNearbyForPresenceLog) { return; } _wasPlayerNearbyForPresenceLog = true; ZDO zDO = _nview.GetZDO(); if (zDO != null) { int schemaVersion = GetSchemaVersion(zDO); bool @bool = zDO.GetBool("hh_ship_bound", false); ZDOID shipId; bool flag = HasShipId(zDO, out shipId); Ship resolvedShip = null; if (flag) { resolvedShip = ShipTorchPlacementHelper.FindShipByZdoId(shipId); } string result; string reason; if (schemaVersion >= 2) { result = "VISIBLE_ALREADY_CURRENT"; reason = "player entered proximity, item already on current schema"; } else if (@bool && flag) { result = "VISIBLE_LEGACY_BOUND"; reason = "player entered proximity, legacy schema with stored ship binding"; } else { result = "VISIBLE_LEGACY_UNBOUND"; reason = "player entered proximity, legacy schema without complete binding"; } LogPresenceState(result, reason, resolvedShip); } } } private bool HasShipId(ZDO zdo, out ZDOID shipId) { //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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) shipId = ZDOID.None; if (zdo == null) { return false; } uint num = (uint)zdo.GetLong("hh_ship_uid_user", 0L); uint num2 = (uint)zdo.GetLong("hh_ship_uid_id", 0L); if (num == 0 && num2 == 0) { return false; } shipId = new ZDOID((long)num, num2); return true; } internal bool IsBoundToShip(ZDOID shipId) { if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return false; } if (!zDO.GetBool("hh_ship_bound", false)) { return false; } uint num = (uint)zDO.GetLong("hh_ship_uid_user", 0L); uint num2 = (uint)zDO.GetLong("hh_ship_uid_id", 0L); return num == ((ZDOID)(ref shipId)).UserID && num2 == ((ZDOID)(ref shipId)).ID; } internal bool TryGetOwnZdoId(out ZDOID id) { //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_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) id = ZDOID.None; if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return false; } id = zDO.m_uid; return true; } internal void DestroyBecauseShipWasDestroyed() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } _pendingDestroyBecauseShipDied = true; if (!_nview.IsOwner()) { HardheimShipEquipmentPlugin.LogDebug($"[SHIP CLEANUP CLAIM] item={((Object)this).name} pos={((Component)this).transform.position}"); _nview.ClaimOwnership(); return; } HardheimShipEquipmentPlugin.LogDebug($"[SHIP CLEANUP DESTROY] item={((Object)this).name} pos={((Component)this).transform.position}"); LogMigrationState("SHIP_DESTROY", "DESTROYED_WITH_PARENT_SHIP", "parent ship destroyed"); ZNetScene instance = ZNetScene.instance; if (instance != null) { instance.Destroy(((Component)this).gameObject); } } private bool IsAnyPlayerNearbyForMigration() { //IL_0037: 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) if ((Object)(object)Player.m_localPlayer == (Object)null) { return false; } float num = ((HardheimShipEquipmentPlugin.CfgMigrationPlayerProximityRadius != null) ? HardheimShipEquipmentPlugin.CfgMigrationPlayerProximityRadius.Value : 64f); float num2 = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position); return num2 <= num; } private void TryMigrateLegacyIfNeeded() { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } if (!_nview.IsOwner()) { if (IsAnyPlayerNearbyForMigration()) { _nview.ClaimOwnership(); } } else { if (!IsAnyPlayerNearbyForMigration()) { return; } ZDO zDO = _nview.GetZDO(); if (zDO == null || GetSchemaVersion(zDO) >= 2 || !ShipTorchPlacementHelper.IsHardheimPieceName(((Object)((Component)this).gameObject).name)) { return; } bool @bool = zDO.GetBool("hh_ship_bound", false); ZDOID shipId; bool flag = HasShipId(zDO, out shipId); if (@bool && flag) { Ship val = ShipTorchPlacementHelper.FindShipByZdoId(shipId); if ((Object)(object)val != (Object)null) { LoadLocalAnchor(zDO); _ship = val; _hasLocalAnchor = true; ApplyLocalFollow(); IgnoreCollisionWithShip(ignore: true); SetSchemaVersion(zDO); HardheimShipEquipmentPlugin.LogDebug("[MIGRATE] Existing binding upgraded for " + ((Object)this).name + ", ship=" + ((Object)val).name); LogMigrationState("MIGRATE", "UPGRADED_EXISTING_BIND", "existing bind found and schema upgraded", val); } } else { float radius = Mathf.Max(HardheimShipEquipmentPlugin.CfgAttachSearchRadius.Value, HardheimShipEquipmentPlugin.CfgGhostSnapSearchRadius.Value); Ship val2 = ShipTorchPlacementHelper.FindNearestShip(((Component)this).transform.position, radius); if ((Object)(object)val2 != (Object)null) { BindToShipUsingLocalAnchor(val2, ((Component)this).transform.position, ((Component)this).transform.rotation); zDO = _nview.GetZDO(); SetSchemaVersion(zDO); HardheimShipEquipmentPlugin.LogDebug($"[MIGRATE] Legacy HH_ item rebound to nearest ship. item={((Object)this).name}, ship={((Object)val2).name}, worldPos={((Component)this).transform.position}"); LogMigrationState("MIGRATE", "REBOUND_TO_NEAREST_SHIP", "legacy item rebound to nearest ship", val2); } } } } private void TryRestoreFromZDO() { //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) Ship[] array = Object.FindObjectsByType((FindObjectsSortMode)0); if (array == null || array.Length == 0) { return; } HardheimShipEquipmentPlugin.LogDebug("[RESTORE TRY] name=" + ((Object)this).name + " " + $"nviewValid={(Object)(object)_nview != (Object)null && _nview.IsValid()} " + $"hasShipRef={(Object)(object)_ship != (Object)null} " + $"hasLocalAnchor={_hasLocalAnchor}"); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { HardheimShipEquipmentPlugin.LogDebug("[RESTORE SKIP] " + ((Object)this).name + " invalid nview"); return; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { HardheimShipEquipmentPlugin.LogDebug("[RESTORE SKIP] " + ((Object)this).name + " zdo null"); return; } if (!zDO.GetBool("hh_ship_bound", false)) { HardheimShipEquipmentPlugin.LogDebug("[RESTORE SKIP] " + ((Object)this).name + " not bound"); return; } if (_hasLocalAnchor) { uint num = (uint)zDO.GetLong("hh_ship_uid_user", 0L); uint num2 = (uint)zDO.GetLong("hh_ship_uid_id", 0L); if ((Object)(object)_ship != (Object)null) { ZNetView component = ((Component)_ship).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { ZDO zDO2 = component.GetZDO(); if (zDO2 != null && ((ZDOID)(ref zDO2.m_uid)).UserID == num && ((ZDOID)(ref zDO2.m_uid)).ID == num2) { return; } } } } LoadLocalAnchor(zDO); uint num3 = (uint)zDO.GetLong("hh_ship_uid_user", 0L); uint num4 = (uint)zDO.GetLong("hh_ship_uid_id", 0L); ZDOID id = default(ZDOID); ((ZDOID)(ref id))..ctor((long)num3, num4); Ship val = ShipTorchPlacementHelper.FindShipByZdoId(id); if ((Object)(object)val == (Object)null && _hasLocalAnchor) { Ship val2 = null; float num5 = float.MaxValue; Ship[] array2 = array; foreach (Ship val3 in array2) { if ((Object)(object)val3 == (Object)null) { continue; } ZNetView component2 = ((Component)val3).GetComponent(); if (!((Object)(object)component2 == (Object)null) && component2.IsValid()) { Vector3 val4 = ((Component)val3).transform.TransformPoint(_localPos); float num6 = Vector3.Distance(val4, ((Component)this).transform.position); HardheimShipEquipmentPlugin.LogDebug($"[SMART FALLBACK CHECK] item={((Object)this).name} ship={((Object)val3).name} expected={val4} current={((Component)this).transform.position} dist={num6:0.000}"); if (num6 < num5) { val2 = val3; num5 = num6; } } } float num7 = (ShipTorchPlacementHelper.IsShipChest(((Component)this).gameObject) ? 18f : 6f); if ((Object)(object)val2 != (Object)null && num5 <= num7) { val = val2; HardheimShipEquipmentPlugin.LogDebug($"[SMART FALLBACK OK] item={((Object)this).name} ship={((Object)val2).name} bestDist={num5:0.000} limit={num7:0.000}"); } else { HardheimShipEquipmentPlugin.LogDebug("[SMART FALLBACK FAIL] item=" + ((Object)this).name + " best=" + (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "null") + " bestDist=" + (((Object)(object)val2 != (Object)null) ? num5.ToString("0.000") : "n/a")); } } if ((Object)(object)val == (Object)null) { HardheimShipEquipmentPlugin.LogDebug($"[RESTORE WAIT] {((Object)this).name} ship not found for uid={num3}:{num4}"); return; } _ship = val; _hasLocalAnchor = true; ZNetView component3 = ((Component)val).GetComponent(); ZDO val5 = (((Object)(object)component3 != (Object)null) ? component3.GetZDO() : null); if (val5 != null) { zDO.Set("hh_ship_uid_user", ((ZDOID)(ref val5.m_uid)).UserID); zDO.Set("hh_ship_uid_id", (long)((ZDOID)(ref val5.m_uid)).ID); zDO.Set("hh_ship_bound", true); HardheimShipEquipmentPlugin.LogDebug($"[RESTORE REWRITE SHIP UID] item={((Object)this).name} newUid={((ZDOID)(ref val5.m_uid)).UserID}:{((ZDOID)(ref val5.m_uid)).ID}"); } ApplyLocalFollow(); IgnoreCollisionWithShip(ignore: true); SetSchemaVersion(zDO); HardheimShipEquipmentPlugin.LogDebug($"[RESTORE] ship={((Object)val).name} localPos={_localPos} localRot={((Quaternion)(ref _localRot)).eulerAngles}"); LogMigrationState("RESTORE", "RESTORE_OK", "restored from zdo", val); } private void ResolveShipReference() { //IL_00db: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } if ((Object)(object)_ship != (Object)null) { ZNetView component = ((Component)_ship).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { return; } _ship = null; } ZDO zDO = _nview.GetZDO(); if (zDO == null) { return; } bool @bool = zDO.GetBool("hh_ship_bound", false); uint num = (uint)zDO.GetLong("hh_ship_uid_user", 0L); uint num2 = (uint)zDO.GetLong("hh_ship_uid_id", 0L); if (num == 0 && num2 == 0) { return; } ZDOID id = default(ZDOID); ((ZDOID)(ref id))..ctor((long)num, num2); Ship val = ShipTorchPlacementHelper.FindShipByZdoId(id); if ((Object)(object)val != (Object)null) { _ship = val; if (_hasLocalAnchor) { ApplyLocalFollow(); IgnoreCollisionWithShip(ignore: true); } } else if (@bool) { if ((Object)(object)val != (Object)null) { _ship = val; if (_hasLocalAnchor) { ApplyLocalFollow(); } } } else if (!_nview.IsOwner() && IsAnyPlayerNearbyForMigration()) { _nview.ClaimOwnership(); } else if (!(Time.time < _noRebindBeforeTime)) { } } private void BindToShipUsingLocalAnchor(Ship ship, Vector3 worldPos, Quaternion worldRot) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00d4: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_01e1: 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) if ((Object)(object)ship == (Object)null || (Object)(object)_nview == (Object)null || !_nview.IsValid() || !_nview.IsOwner()) { return; } ZNetView component = ((Component)ship).GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { _ship = ship; Transform transform = ((Component)ship).transform; HardheimShipEquipmentPlugin.LogDebug($"[HH_BIND_TRACE] BIND START item={((Object)this).name} isChest={ShipTorchPlacementHelper.IsShipChest(((Component)this).gameObject)} worldPosArg={worldPos} objPos={((Component)this).transform.position} shipPos={transform.position}"); _localPos = transform.InverseTransformPoint(worldPos); _localRot = Quaternion.Inverse(transform.rotation) * worldRot; HardheimShipEquipmentPlugin.LogDebug($"[HH_BIND_TRACE] BIND CALC item={((Object)this).name} localPos={_localPos} localRot={((Quaternion)(ref _localRot)).eulerAngles}"); _hasLocalAnchor = true; ZDO zDO = _nview.GetZDO(); ZDO zDO2 = component.GetZDO(); if (zDO != null && zDO2 != null) { zDO.Set("hh_ship_uid_user", ((ZDOID)(ref zDO2.m_uid)).UserID); zDO.Set("hh_ship_uid_id", (long)((ZDOID)(ref zDO2.m_uid)).ID); zDO.Set("hh_local_pos", _localPos); zDO.Set("hh_local_rot", ((Quaternion)(ref _localRot)).eulerAngles); zDO.Set("hh_ship_bound", true); SetSchemaVersion(zDO); ApplyLocalFollow(); IgnoreCollisionWithShip(ignore: true); SyncWorldStateToServer(force: true); HardheimShipEquipmentPlugin.LogDebug($"[BIND] localPos={_localPos} localRot={((Quaternion)(ref _localRot)).eulerAngles}"); LogMigrationState("BIND", "BIND_OK", "bound to ship using local anchor", ship); } } } private void LoadLocalAnchor(ZDO zdo) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) _localPos = zdo.GetVec3("hh_local_pos", Vector3.zero); _localRot = Quaternion.Euler(zdo.GetVec3("hh_local_rot", Vector3.zero)); _hasLocalAnchor = true; } public void ForceApplyLocalFollowForContainerUpdate() { if (!_isPreviewGhost && _initialized && !((Object)(object)_nview == (Object)null) && _nview.IsValid() && !((Object)(object)_ship == (Object)null) && _hasLocalAnchor) { ApplyLocalFollow(); } } private void ApplyLocalFollow() { //IL_006d: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00cc: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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) if (!((Object)(object)_ship == (Object)null)) { HardheimShipEquipmentPlugin.LogDebug(string.Format("[HH_BIND_TRACE] FOLLOW item={0} isChest={1} hasParent={2} localPos={3} worldBefore={4}", ((Object)this).name, ShipTorchPlacementHelper.IsShipChest(((Component)this).gameObject), ((Object)(object)((Component)this).transform.parent != (Object)null) ? ((Object)((Component)this).transform.parent).name : "null", _localPos, ((Component)this).transform.position)); Transform transform = ((Component)_ship).transform; ((Component)this).transform.position = transform.TransformPoint(_localPos); ((Component)this).transform.rotation = transform.rotation * _localRot; object[] obj = new object[4] { ((Object)this).name, ShipTorchPlacementHelper.IsShipChest(((Component)this).gameObject), ((Component)this).transform.position, null }; Quaternion rotation = ((Component)this).transform.rotation; obj[3] = ((Quaternion)(ref rotation)).eulerAngles; HardheimShipEquipmentPlugin.LogDebug(string.Format("[HH_BIND_TRACE] FOLLOW DONE item={0} isChest={1} worldAfter={2} rotAfter={3}", obj)); } } private void IgnoreCollisionWithShip(bool ignore) { if ((Object)(object)_ship == (Object)null) { return; } Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); Collider[] componentsInChildren2 = ((Component)_ship).GetComponentsInChildren(true); Collider[] array = componentsInChildren; foreach (Collider val in array) { if ((Object)(object)val == (Object)null) { continue; } Collider[] array2 = componentsInChildren2; foreach (Collider val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { Physics.IgnoreCollision(val, val2, ignore); } } } } private void SyncWorldStateToServer(bool force = false) { //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_0065: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_nview == (Object)null || !_nview.IsValid() || !_nview.IsOwner()) { return; } ZDO zDO = _nview.GetZDO(); if (zDO != null) { Vector3 position = ((Component)this).transform.position; Quaternion rotation = ((Component)this).transform.rotation; bool flag = !_hasLastSyncedWorldState || Vector3.Distance(_lastSyncedWorldPos, position) > 0.02f || Quaternion.Angle(_lastSyncedWorldRot, rotation) > 0.5f; if (force || (flag && !(Time.time < _nextWorldSyncTime))) { zDO.SetPosition(position); zDO.SetRotation(rotation); _lastSyncedWorldPos = position; _lastSyncedWorldRot = rotation; _hasLastSyncedWorldState = true; _nextWorldSyncTime = Time.time + 0.05f; } } } } [HarmonyPatch(typeof(Player), "PlacePiece")] public static class Player_PlacePiece_Patch { private static bool Prefix(Player __instance) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_011d: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || (Object)(object)Player.m_localPlayer != (Object)(object)__instance) { return true; } GameObject placementGhost = ReflectionCache.GetPlacementGhost(__instance); if (!ShipTorchPlacementHelper.IsHardheimGhost(placementGhost)) { return true; } GameObject placementMarker = ReflectionCache.GetPlacementMarker(__instance); if ((Object)(object)placementMarker != (Object)null) { ShipTorchPlacementHelper.ForceGhostToMarkerOffset(placementGhost, placementMarker); } if (!LastShipRaycastHit.TryGet(out var snapshot)) { PendingShipPlacement.Clear(); MessageHud instance = MessageHud.instance; if (instance != null) { instance.ShowMessage((MessageType)2, "Hiányzó követelmény: Hajó", 0, (Sprite)null, false); } HardheimShipEquipmentPlugin.LogDebug("[PLACE BLOCKED] No ship ray hit"); return false; } Ship val = ShipTorchPlacementHelper.FindShipByZdoId(snapshot.ShipId); if ((Object)(object)val == (Object)null) { PendingShipPlacement.Clear(); MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)2, "Hiányzó követelmény: Hajó", 0, (Sprite)null, false); } HardheimShipEquipmentPlugin.LogDebug("[PLACE BLOCKED] Ship not found from ray hit"); return false; } Vector3 position = placementGhost.transform.position; PendingShipPlacement.Set(position, placementGhost.transform.rotation, val); HardheimShipEquipmentPlugin.LogDebug($"[PLACE OK] ship={((Object)val).name} anchor={position}"); return true; } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[PLACE PATCH ERROR] " + ex); return true; } } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] public static class Player_UpdatePlacementGhost_HardheimPostfix { private static void Postfix(Player __instance) { //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_015c: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || (Object)(object)Player.m_localPlayer != (Object)(object)__instance) { return; } GameObject placementGhost = ReflectionCache.GetPlacementGhost(__instance); if ((Object)(object)placementGhost == (Object)null || !ShipTorchPlacementHelper.IsHardheimGhost(placementGhost)) { return; } GameObject placementMarker = ReflectionCache.GetPlacementMarker(__instance); ShipTorchPlacementHelper.EnsureGhostVisible(placementGhost); Camera val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).gameObject.GetComponent() : null); if ((Object)(object)val != (Object)null) { int mask = LayerMask.GetMask(new string[7] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "vehicle" }); RaycastHit val2 = default(RaycastHit); Vector3 position = ((!Physics.Raycast(((Component)val).transform.position, ((Component)val).transform.forward, ref val2, Mathf.Max(__instance.m_maxPlaceDistance, 50f), mask, (QueryTriggerInteraction)1)) ? (((Component)val).transform.position + ((Component)val).transform.forward * 4f) : ((RaycastHit)(ref val2)).point); position.y += HardheimShipEquipmentPlugin.CfgMarkerOffsetY.Value; placementGhost.transform.position = position; } Ship val3 = ShipTorchPlacementHelper.FindNearestShip(placementGhost.transform.position, Mathf.Max(HardheimShipEquipmentPlugin.CfgGhostSnapSearchRadius.Value, 0.5f)); if (!((Object)(object)val3 != (Object)null) || !LastShipRaycastHit.TryGet(out var _)) { ReflectionCache.CallSetPlacementGhostValid(__instance, valid: false); if ((Object)(object)placementMarker != (Object)null && placementMarker.activeSelf) { placementMarker.SetActive(false); } return; } ReflectionCache.SetPlacementStatusValid(__instance); ReflectionCache.CallSetPlacementGhostValid(__instance, valid: true); if ((Object)(object)placementMarker != (Object)null && !placementMarker.activeSelf) { placementMarker.SetActive(true); } if ((Object)(object)placementMarker != (Object)null) { ShipTorchPlacementHelper.HandleMarkerOffsetHotkeys(placementGhost, placementMarker); ShipTorchPlacementHelper.ForceGhostToMarkerOffset(placementGhost, placementMarker); } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[UPDATE PLACEMENT GHOST POSTFIX ERROR] " + ex); } } } [HarmonyPatch(typeof(Player), "PieceRayTest")] public static class Player_PieceRayTest_Patch { private static bool Prefix(Player __instance, ref bool __result, ref Vector3 point, ref Vector3 normal, ref Piece piece, ref Heightmap heightmap, ref Collider waterSurface, ref bool water) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance == (Object)null || (Object)(object)Player.m_localPlayer != (Object)(object)__instance) { return true; } GameObject placementGhost = ReflectionCache.GetPlacementGhost(__instance); if (!ShipTorchPlacementHelper.IsHardheimGhost(placementGhost)) { return true; } Camera val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).gameObject.GetComponent() : null); if ((Object)(object)val == (Object)null) { return true; } int mask = LayerMask.GetMask(new string[7] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "vehicle" }); RaycastHit[] array = Physics.RaycastAll(((Component)val).transform.position, ((Component)val).transform.forward, 50f, mask, (QueryTriggerInteraction)1); if (array == null || array.Length == 0) { return true; } RaycastHit val2 = default(RaycastHit); bool flag = false; float num = float.MinValue; HardheimShipEquipmentPlugin.LogDebug($"[PIECERAYTEST BEGIN] ghost={((Object)placementGhost).name} ghostPos={placementGhost.transform.position} camPos={((Component)val).transform.position} camForward={((Component)val).transform.forward}"); RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val3 = array2[i]; if ((Object)(object)((RaycastHit)(ref val3)).collider == (Object)null) { continue; } Ship componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { continue; } float num2 = Vector3.Distance(((Character)__instance).m_eye.position, ((RaycastHit)(ref val3)).point); bool flag2 = num2 <= __instance.m_maxPlaceDistance; string[] obj = new string[8] { "[PIECERAYTEST HIT] collider=", ((Object)((RaycastHit)(ref val3)).collider).name, " colliderTransform=", ((Object)((Component)((RaycastHit)(ref val3)).collider).transform).name, " ", $"colliderWorldPos={((Component)((RaycastHit)(ref val3)).collider).transform.position} point={((RaycastHit)(ref val3)).point} normal={((RaycastHit)(ref val3)).normal} ", $"distance={((RaycastHit)(ref val3)).distance:0.000} eyeDist={num2:0.000} withinPlaceDistance={flag2} ", null }; string name = ((Object)componentInParent).name; object arg = ((Component)componentInParent).transform.position; Quaternion rotation = ((Component)componentInParent).transform.rotation; obj[7] = $"ship={name} shipPos={arg} shipRot={((Quaternion)(ref rotation)).eulerAngles}"; HardheimShipEquipmentPlugin.LogDebug(string.Concat(obj)); if (flag2) { string text = (((Object)((RaycastHit)(ref val3)).collider).name ?? string.Empty).ToLowerInvariant(); bool flag3 = text.Contains("hull"); bool flag4 = ((RaycastHit)(ref val3)).normal.y >= 0.7f; bool flag5 = ((RaycastHit)(ref val3)).normal.y < 0.35f; float num3 = 0f; if (flag3) { num3 += 100000f; } if (flag4) { num3 += 10000f; } if (flag5) { num3 -= 5000f; } num3 -= ((RaycastHit)(ref val3)).distance * 10f; num3 += ((RaycastHit)(ref val3)).normal.y * 100f; if (!flag || num3 > num) { val2 = val3; num = num3; flag = true; HardheimShipEquipmentPlugin.LogDebug($"[PIECERAYTEST BEST_CANDIDATE] collider={((Object)((RaycastHit)(ref val3)).collider).name} point={((RaycastHit)(ref val3)).point} normal={((RaycastHit)(ref val3)).normal} distance={((RaycastHit)(ref val3)).distance:0.000} score={num3:0.00} isHull={flag3} upwardSurface={flag4}"); } } } if (!flag) { piece = null; heightmap = null; waterSurface = null; water = false; __result = false; HardheimShipEquipmentPlugin.LogDebug("[PIECERAYTEST BLOCK] No ship hit"); return false; } point = ((RaycastHit)(ref val2)).point; normal = ((RaycastHit)(ref val2)).normal; piece = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent(); heightmap = ((Component)((RaycastHit)(ref val2)).collider).GetComponent(); waterSurface = null; water = false; Ship val4 = (((Object)(object)((RaycastHit)(ref val2)).collider != (Object)null) ? ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() : null); if ((Object)(object)val4 != (Object)null) { LastShipRaycastHit.Set(point, normal, val4); } HardheimShipEquipmentPlugin.LogDebug("[PIECERAYTEST RESULT] bestCollider=" + (Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).collider) ? ((Object)((RaycastHit)(ref val2)).collider).name : "") + " bestTransform=" + (Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).collider) ? ((Object)((Component)((RaycastHit)(ref val2)).collider).transform).name : "") + " " + string.Format("point={0} normal={1} piece={2} ", point, normal, Object.op_Implicit((Object)(object)piece) ? ((Object)piece).name : "") + string.Format("heightmap={0} water={1} ", Object.op_Implicit((Object)(object)heightmap) ? ((Object)heightmap).name : "", water) + string.Format("bestShip={0} ghostPos={1}", Object.op_Implicit((Object)(object)val4) ? ((Object)val4).name : "", placementGhost.transform.position)); __result = true; return false; } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[PieceRayTest PATCH ERROR] " + ex); return true; } } } [HarmonyPatch(typeof(WearNTear), "Destroy")] public static class WearNTear_Destroy_HHShipCleanup_Patch { private static void Prefix(WearNTear __instance) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)__instance == (Object)null)) { Ship component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { HardheimShipEquipmentPlugin.LogDebug($"[SHIP DESTROY DETECTED] ship={((Object)component).name} pos={((Component)component).transform.position}"); ShipTorchPlacementHelper.HardheimShipCleanupHelper.DestroyAllBoundHHItemsForShip(component); } } } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[SHIP DESTROY CLEANUP ERROR] " + ex); } } } [HarmonyPatch(typeof(WearNTear), "Highlight")] public static class WearNTear_Highlight_Block_HH { private static bool Prefix(WearNTear __instance) { try { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } GameObject placementGhost = ReflectionCache.GetPlacementGhost(localPlayer); if (!ShipTorchPlacementHelper.IsHardheimGhost(placementGhost)) { return true; } Ship componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return false; } return true; } catch (Exception ex) { HardheimShipEquipmentPlugin.LogDebug("[HIGHLIGHT BLOCK ERROR] " + ex); return true; } } } public class ShipSongBuffOverlay : MonoBehaviour { private GameObject _panel; private Text _text; private Text _timerText; private Image _iconImage; private void Update() { try { bool flag = (Object)(object)Player.m_localPlayer != (Object)null && Player_Update_ShipSongPatch.ShipSongBuffUtility.HasSongBuff(Player.m_localPlayer); bool flag2 = (Object)(object)Player.m_localPlayer != (Object)null && Player_Update_ShipSongPatch.ShipSongBuffUtility.HasUnderworldBuff(Player.m_localPlayer); bool flag3 = InventoryGui.IsVisible() && (Object)(object)Player.m_localPlayer != (Object)null && (flag || flag2); EnsurePanel(); if ((Object)(object)_panel != (Object)null) { _panel.SetActive(flag3); } if (flag3 && (Object)(object)_timerText != (Object)null) { float num = (flag2 ? Player_Update_ShipSongPatch.ShipSongBuffUtility.GetUnderworldBuffRemainingTime(Player.m_localPlayer) : Player_Update_ShipSongPatch.ShipSongBuffUtility.GetSongBuffRemainingTime(Player.m_localPlayer)); int num2 = Mathf.FloorToInt(num / 60f); int num3 = Mathf.FloorToInt(num % 60f); _timerText.text = $"{num2:00}:{num3:00}"; if ((Object)(object)_iconImage != (Object)null) { _iconImage.sprite = (flag2 ? Player_Update_ShipSongPatch.ShipSongBuffUtility.GetUnderworldBuffIcon(Player.m_localPlayer) : Player_Update_ShipSongPatch.ShipSongBuffUtility.GetSongBuffIcon(Player.m_localPlayer)); } if ((Object)(object)_text != (Object)null) { _text.text = (flag2 ? "Túlpart áldása\n-8% mozgási sebesség\n+10% páncél\n+10% állóképesség-regeneráció" : "Valhalla áldása\n+10% életerő-regeneráció\n-50% állóképesség-regeneráció\n+5% mozgási sebesség"); } } } catch { } } private void EnsurePanel() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0073: 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_009f: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Expected O, but got Unknown //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: 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_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Expected O, but got Unknown //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_panel != (Object)null) && !((Object)(object)InventoryGui.instance == (Object)null)) { Transform transform = ((Component)InventoryGui.instance).transform; _panel = new GameObject("HH_ShipSongBuffPanel"); _panel.transform.SetParent(transform, false); RectTransform val = _panel.AddComponent(); val.anchorMin = new Vector2(1f, 1f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(1f, 1f); val.anchoredPosition = new Vector2(-650f, -52f); val.sizeDelta = new Vector2(420f, 110f); Image val2 = _panel.AddComponent(); ((Graphic)val2).color = new Color(0.15f, 0.1f, 0.06f, 0.8f); ((Graphic)val2).raycastTarget = false; GameObject val3 = new GameObject("Text"); val3.transform.SetParent(_panel.transform, false); RectTransform val4 = val3.AddComponent(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = new Vector2(18f, 10f); val4.offsetMax = new Vector2(-18f, -10f); val3.AddComponent(); _text = val3.AddComponent(); Text componentInChildren = ((Component)InventoryGui.instance).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.font != (Object)null) { _text.font = componentInChildren.font; } else { _text.font = Resources.GetBuiltinResource("Arial.ttf"); } _text.fontSize = 17; _text.alignment = (TextAnchor)3; ((Graphic)_text).color = new Color(1f, 0.73f, 0.28f, 1f); ((Graphic)_text).raycastTarget = false; _text.supportRichText = true; _text.text = "Harci dal aktív\n+10% életerő-regeneráció\n-50% állóképesség-regeneráció\n+5% mozgási sebesség"; val3.transform.SetAsLastSibling(); GameObject val5 = new GameObject("BuffIcon"); val5.transform.SetParent(_panel.transform, false); RectTransform val6 = val5.AddComponent(); val6.anchorMin = new Vector2(1f, 0.5f); val6.anchorMax = new Vector2(1f, 0.5f); val6.pivot = new Vector2(1f, 0.5f); val6.anchoredPosition = new Vector2(-28f, 10f); val6.sizeDelta = new Vector2(56f, 56f); _iconImage = val5.AddComponent(); ((Graphic)_iconImage).raycastTarget = false; _iconImage.preserveAspect = true; _iconImage.sprite = Player_Update_ShipSongPatch.ShipSongBuffUtility.GetSongBuffIcon(Player.m_localPlayer); GameObject val7 = new GameObject("TimerText"); val7.transform.SetParent(_panel.transform, false); RectTransform val8 = val7.AddComponent(); val8.anchorMin = new Vector2(1f, 0.5f); val8.anchorMax = new Vector2(1f, 0.5f); val8.pivot = new Vector2(1f, 0.5f); val8.anchoredPosition = new Vector2(-5f, -36f); val8.sizeDelta = new Vector2(90f, 26f); val7.AddComponent(); _timerText = val7.AddComponent(); _timerText.font = _text.font; _timerText.fontSize = 16; _timerText.alignment = (TextAnchor)4; ((Graphic)_timerText).color = new Color(1f, 0.73f, 0.28f, 1f); ((Graphic)_timerText).raycastTarget = false; _timerText.text = "50:00"; val5.transform.SetAsLastSibling(); val7.transform.SetAsLastSibling(); _panel.SetActive(false); } } }