Decompiled source of Marriage v0.8.1
Pix.Marriage.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace Pix.Marriage; [BepInPlugin("Pix.Marriage", "Marriage", "0.8.1")] public sealed class MarriagePlugin : BaseUnityPlugin { private struct Proposal { public long FromRouteUid; public string FromPersistentId; public string FromName; public string FromHouseholdId; public float LastNotifyTime; public long ToRouteUid; public string ToPersistentId; } private sealed class Household { public string id; public Dictionary<string, Member> members = new Dictionary<string, Member>(); } private sealed class Member { public string pid; public string name; public double bondSeconds; public int deaths; } private sealed class SE_PX_FamilyTier : SE_Stats { public int Tier; public override string GetIconText() { if (Tier <= 0) { return ""; } return "Tier " + Tier; } } [HarmonyPatch(typeof(Terminal), "Awake")] private static class Patch_Terminal_Awake { private static void Postfix(Terminal __instance) { try { int num = (((Object)(object)__instance != (Object)null) ? ((object)__instance).GetHashCode() : 0); if (num != 0 && num != _terminalInstanceHash) { _terminalInstanceHash = num; _consoleRegistered = false; } TryRegisterConsoleCommands(); } catch { } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] private static class Patch_ObjectDB_Awake { private static void Postfix(ObjectDB __instance) { TryRegisterStatusEffects(__instance); } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] private static class Patch_ObjectDB_CopyOtherDB { private static void Postfix(ObjectDB __instance, ObjectDB other) { TryRegisterStatusEffects(__instance); } } [HarmonyPatch(typeof(Character), "OnDeath")] private static class Patch_Character_OnDeath { private static void Postfix(Character __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if ((Object)__instance == (Object)null || (Object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if ((Object)val == (Object)null) { return; } try { EnsureLoadedOnServer(); ServerTick_RebuildPeerIdMaps(); if (!TryResolvePersistentIdFromPlayer(val, out var pid) || string.IsNullOrEmpty(pid) || !PidToHousehold.TryGetValue(pid, out var value) || string.IsNullOrEmpty(value) || !Households.TryGetValue(value, out var value2) || value2 == null) { return; } if (value2.members.TryGetValue(pid, out var value3) && value3 != null) { value3.deaths = Mathf.Max(0, value3.deaths) + 1; _householdsDirty = true; } int tier = 1; if (value2.members.TryGetValue(pid, out var value4) && value4 != null) { tier = Mathf.Max(1, GetTierFromBondSeconds(value4.bondSeconds)); } float durationSeconds = Mathf.Max(1f, _mourningDurationSeconds.Value); if (_enableMourning.Value) { foreach (KeyValuePair<string, Member> member in value2.members) { string key = member.Key; if (!(key == pid) && TryGetRouteUidForPersistentId(key, out var routeUid)) { if (IsHostUid(routeUid)) { Client_ApplyMourning_Local(tier, durationSeconds); } else if (ZNet.instance.GetPeer(routeUid) != null) { Server_ToClientMourning(routeUid, tier, durationSeconds); } } } } int num = Mathf.Clamp(_dissolveRule.Value, 0, 1); if (num == 1) { Server_DissolveHousehold(value, "Household dissolved (hardcore death rule)."); } else if (Server_ShouldDissolve_AllMembersDiedOnce(value2)) { Server_DissolveHousehold(value, "Household dissolved (everyone has died once)."); } } catch { } } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__132_0; public static ConsoleEvent <>9__132_1; public static ConsoleEvent <>9__132_2; public static ConsoleEvent <>9__132_3; public static ConsoleEvent <>9__132_4; public static ConsoleEvent <>9__132_5; public static ConsoleEvent <>9__132_6; public static ConsoleEvent <>9__132_7; internal void <TryRegisterConsoleCommands>b__132_0(ConsoleEventArgs args) { try { if (args?.Args == null || args.Args.Length < 2) { MessageCenter("Usage: /marry <playerName>"); return; } string s = string.Join(" ", args.Args, 1, args.Args.Length - 1); s = NormalizePlayerNameInput(s).Trim(new char[1] { '"' }); if (string.IsNullOrEmpty(s)) { MessageCenter("Usage: /marry <playerName>"); } else { Client_RequestMarriage(s); } } catch { } } internal void <TryRegisterConsoleCommands>b__132_1(ConsoleEventArgs args) { try { Client_RespondMarriage(accept: true); } catch { } } internal void <TryRegisterConsoleCommands>b__132_2(ConsoleEventArgs args) { try { Client_RespondMarriage(accept: false); } catch { } } internal void <TryRegisterConsoleCommands>b__132_3(ConsoleEventArgs args) { try { Client_RequestDivorce(); } catch { } } internal void <TryRegisterConsoleCommands>b__132_4(ConsoleEventArgs args) { try { Client_RequestHouseholdInfo(); } catch { } } internal void <TryRegisterConsoleCommands>b__132_5(ConsoleEventArgs args) { try { int result = 1; if (args?.Args != null && args.Args.Length >= 2) { int.TryParse(args.Args[1], out result); } result = Mathf.Clamp(result, 1, MaxTierClamped()); if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Debug_MarrySelf", new object[1] { result }); } } catch { } } internal void <TryRegisterConsoleCommands>b__132_6(ConsoleEventArgs args) { try { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Debug_ClearMarriage", Array.Empty<object>()); } } catch { } } internal void <TryRegisterConsoleCommands>b__132_7(ConsoleEventArgs args) { try { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Debug_State", Array.Empty<object>()); } } catch { } } } public const string PluginGuid = "Pix.Marriage"; public const string PluginName = "Marriage"; public const string PluginVersion = "0.8.1"; private const string RpcRequestMarriage = "PX_Marry_Request"; private const string RpcRespondMarriage = "PX_Marry_Response"; private const string RpcNotifyProposal = "PX_Marry_NotifyProposal"; private const string RpcNotifyToast = "PX_Marry_NotifyToast"; private const string RpcDebugMarrySelf = "PX_Debug_MarrySelf"; private const string RpcDebugClear = "PX_Debug_ClearMarriage"; private const string RpcDebugState = "PX_Debug_State"; private const string RpcClientSetFamilyTier = "PX_Family_SetTier"; private const string RpcClientSetFamilyProgress = "PX_Family_SetProgress"; private const string RpcClientMourning = "PX_Mourning_Apply"; private const string RpcClientPlayVfx = "PX_Marry_PlayVfx"; private const string RpcDivorce = "PX_Marry_Divorce"; private const string RpcRequestHouseholdInfo = "PX_Household_Info"; private const string FamilySeBase = "SE_PX_Marriage_Family_"; private const string MourningSeBase = "SE_PX_Marriage_Mourning_"; private const float InGameDaySeconds = 1800f; private const string HostPid = "HOST"; private static MarriagePlugin _self; private Harmony _harmony; private static ConfigEntry<float> _rangeMeters; private static ConfigEntry<float> _proximityTickSeconds; private static ConfigEntry<float> _saveIntervalSeconds; private static ConfigEntry<int> _maxTier; private static ConfigEntry<bool> _startAtTier1; private static ConfigEntry<int> _tier1Days; private static ConfigEntry<int> _tier2Days; private static ConfigEntry<int> _tier3Days; private static ConfigEntry<int> _tier4Days; private static ConfigEntry<int> _tier5Days; private static ConfigEntry<int> _tier6Days; private static ConfigEntry<int> _tier7Days; private static ConfigEntry<int> _tier8Days; private static ConfigEntry<int> _tier9Days; private static ConfigEntry<int> _tier10Days; private static ConfigEntry<int> _tier11Days; private static ConfigEntry<int> _tier12Days; private static ConfigEntry<int> _tier13Days; private static ConfigEntry<int> _tier14Days; private static ConfigEntry<int> _tier15Days; private static ConfigEntry<float> _tierBaseBonus; private static ConfigEntry<bool> _tierDoubleEachTier; private static ConfigEntry<float> _tierMaxBonus; private static ConfigEntry<bool> _buffMove; private static ConfigEntry<bool> _buffDamage; private static ConfigEntry<bool> _buffStaminaRegen; private static ConfigEntry<bool> _buffHealthRegen; private static ConfigEntry<bool> _buffEitrRegen; private static ConfigEntry<bool> _enableMourning; private static ConfigEntry<float> _mourningDurationSeconds; private static ConfigEntry<float> _mourningBasePenalty; private static ConfigEntry<float> _mourningMaxPenalty; private static ConfigEntry<bool> _mourningDoublesWithTier; private static ConfigEntry<float> _mourningCarryWeightPenalty; private static ConfigEntry<bool> _announce; private static ConfigEntry<bool> _familyProgressInTooltip; private static ConfigEntry<bool> _familyProgressToasts; private static ConfigEntry<bool> _familyTierUpToasts; private static ConfigEntry<bool> _showErrorMessages; private static ConfigEntry<float> _progressSendIntervalSeconds; private static ConfigEntry<int> _dissolveRule; private static ConfigEntry<bool> _debugEnabledServer; private static ConfigEntry<bool> _diagnosticsVerbose; private static string[] FamilySeNames; private static int[] _familySeHashes; private static string[] MourningSeNames; private static int[] _mourningSeHashes; private static Sprite _familyIcon; private static Sprite _mourningIcon; private static bool _iconsTried; private static bool _pngLoaderReady; private static MethodInfo _miImageConversionLoadImage; private static MethodInfo _miTexture2DLoadImageBytes; private static MethodInfo _miTexture2DLoadImageBytesBool; private static float _clientEnsureSeNextTry; private static bool _clientSeEnsured; private static readonly string[] RejectionLines = new string[6] { "They said your feet smell funky. It's a no.", "They stared into your eyes, then stared into the distance. Declined.", "The raven whispered \"absolutely not\".", "They said \"it's not you... it's your stamina management\".", "They chose violence instead of commitment.", "They said yes in their heart, but no in chat." }; private static readonly Dictionary<long, Proposal> PendingByRoute = new Dictionary<long, Proposal>(); private static readonly Dictionary<string, Proposal> PendingByPid = new Dictionary<string, Proposal>(); private static readonly Dictionary<string, Household> Households = new Dictionary<string, Household>(); private static readonly Dictionary<string, string> PidToHousehold = new Dictionary<string, string>(); private static readonly Dictionary<long, int> _lastSentTier = new Dictionary<long, int>(); private static readonly Dictionary<long, float> _lastSentProgressRealtime = new Dictionary<long, float>(); private static readonly Dictionary<long, float> _lastSentTierRealtime = new Dictionary<long, float>(); private static readonly HashSet<string> _debugSoloFamily = new HashSet<string>(); private static readonly Dictionary<long, string> _routeToPersistent = new Dictionary<long, string>(); private static readonly Dictionary<string, long> _persistentToRoute = new Dictionary<string, long>(); private static readonly Dictionary<long, float> _diagNextLogAt = new Dictionary<long, float>(); private static string _householdsPath; private static bool _householdsLoaded; private static bool _householdsDirty; private static float _lastSaveRealtime; private static double _serverBondAccrualRemainder; private static float _lastBondAccrueRealtime; private static bool _rpcsRegistered; private static int _rpcsInstanceHash; private static bool _consoleRegistered; private static int _terminalInstanceHash; private float _serverTickTimer; private float _serverProximityTimer; private static float _clientMourningEndTime; private static int _clientMourningTier; private static int _clientFamilyTier; private static float _clientFamilyBondDays; private static int _clientFamilyMilestoneBucket; private static int _clientHighestEverTierSeen; private static bool _clientSuppressNextProgressToast; private static float _clientFamilyTooltipNextRefresh; private static bool LooksLikeSteamId(long id) { return id >= 10000000000000000L; } private static void DiagLog(long routeUid, string msg) { try { if (!((Object)(object)_self == (Object)null) && _diagnosticsVerbose != null && _diagnosticsVerbose.Value) { float realtimeSinceStartup = Time.realtimeSinceStartup; if (!_diagNextLogAt.TryGetValue(routeUid, out var value) || !(realtimeSinceStartup < value)) { _diagNextLogAt[routeUid] = realtimeSinceStartup + 2f; ((BaseUnityPlugin)_self).Logger.LogWarning((object)("[MarriageDiag] uid=" + routeUid + " " + msg)); } } } catch { } } private static bool IsDedicatedServer() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown try { return (Object)ZNet.instance != (Object)null && ZNet.instance.IsDedicated(); } catch { return false; } } private static bool IsHostUid(long routeUid) { if (routeUid == 0L) { return !IsDedicatedServer(); } return false; } private static ZNetPeer TryResolveSenderPeer(long senderRouteUid) { try { if ((Object)(object)ZNet.instance == (Object)null) { return null; } if (senderRouteUid == 0L && !IsDedicatedServer()) { return null; } ZNetPeer peer = ZNet.instance.GetPeer(senderRouteUid); if (peer != null) { return peer; } List<ZNetPeer> peers = ZNet.instance.GetPeers(); if (peers != null) { for (int i = 0; i < peers.Count; i++) { ZNetPeer val = peers[i]; if (val != null && val.m_uid == senderRouteUid) { return val; } } } } catch { } return null; } private static bool TryResolvePersistentIdFromPeer_GuildsStyle(ZNetPeer peer, out string pid) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) pid = null; try { if (peer == null || (Object)(object)ZNet.instance == (Object)null) { return false; } string value = null; try { if (peer.m_socket != null) { value = peer.m_socket.GetHostName(); } } catch { value = null; } if (string.IsNullOrEmpty(value)) { return false; } List<PlayerInfo> playerInfosSafe = GetPlayerInfosSafe(); if (playerInfosSafe == null || playerInfosSafe.Count == 0) { return false; } for (int i = 0; i < playerInfosSafe.Count; i++) { PlayerInfo val = playerInfosSafe[i]; string text = null; try { text = ((object)(PlatformUserID)(ref val.m_userInfo.m_id)).ToString(); } catch { text = null; } if (!string.IsNullOrEmpty(text) && text.EndsWith(value, StringComparison.Ordinal)) { pid = text; return true; } } string text2 = null; int num = 0; for (int j = 0; j < playerInfosSafe.Count; j++) { PlayerInfo val2 = playerInfosSafe[j]; string text3 = null; try { text3 = ((object)(PlatformUserID)(ref val2.m_userInfo.m_id)).ToString(); } catch { text3 = null; } if (!string.IsNullOrEmpty(text3) && text3.IndexOf(value, StringComparison.Ordinal) >= 0) { text2 = text3; num++; if (num > 1) { break; } } } if (num == 1 && !string.IsNullOrEmpty(text2)) { pid = text2; return true; } } catch { } return false; } private static string GetPersistentIdForRouteUid(long routeUid) { if (IsHostUid(routeUid)) { return "HOST"; } if (LooksLikeSteamId(routeUid)) { string text = routeUid.ToString(CultureInfo.InvariantCulture); _routeToPersistent[routeUid] = text; _persistentToRoute[text] = routeUid; return text; } if (_routeToPersistent.TryGetValue(routeUid, out var value) && !string.IsNullOrEmpty(value)) { return value; } ZNetPeer val = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeer(routeUid) : null); if (val == null) { return null; } if (TryResolvePersistentIdFromPeer_GuildsStyle(val, out var pid) && !string.IsNullOrEmpty(pid)) { _routeToPersistent[routeUid] = pid; _persistentToRoute[pid] = routeUid; return pid; } if (LooksLikeSteamId(val.m_uid)) { string text2 = val.m_uid.ToString(CultureInfo.InvariantCulture); _routeToPersistent[routeUid] = text2; _persistentToRoute[text2] = routeUid; return text2; } return null; } private static List<PlayerInfo> GetPlayerInfosSafe() { try { if ((Object)(object)ZNet.instance == (Object)null) { return null; } MethodInfo methodInfo = AccessTools.Method(typeof(ZNet), "GetPlayerList", (Type[])null, (Type[])null); if (methodInfo != null) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 0) { object obj = methodInfo.Invoke(ZNet.instance, null); if (obj is List<PlayerInfo> result) { return result; } } if (parameters.Length >= 1 && parameters[0].ParameterType == typeof(List<PlayerInfo>)) { List<PlayerInfo> list = new List<PlayerInfo>(); object[] array = new object[parameters.Length]; array[0] = list; for (int i = 1; i < parameters.Length; i++) { Type parameterType = parameters[i].ParameterType; if (parameterType == typeof(bool)) { array[i] = false; } else if (parameterType == typeof(int)) { array[i] = 0; } else if (parameterType.IsValueType) { array[i] = Activator.CreateInstance(parameterType); } else { array[i] = null; } } methodInfo.Invoke(ZNet.instance, array); return list; } } FieldInfo fieldInfo = AccessTools.Field(typeof(ZNet), "m_players") ?? AccessTools.Field(typeof(ZNet), "m_playerList") ?? AccessTools.Field(typeof(ZNet), "m_playerInfos") ?? AccessTools.Field(typeof(ZNet), "m_playersList"); if (fieldInfo != null) { object value = fieldInfo.GetValue(ZNet.instance); if (value is List<PlayerInfo> result2) { return result2; } } } catch { } return null; } private static bool TryGetRouteUidForPersistentId(string persistentId, out long routeUid) { routeUid = 0L; if (string.IsNullOrEmpty(persistentId)) { return false; } if (persistentId == "HOST" && !IsDedicatedServer()) { routeUid = 0L; return true; } if (_persistentToRoute.TryGetValue(persistentId, out routeUid) && routeUid != 0L) { return true; } if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return false; } List<ZNetPeer> peers = ZNet.instance.GetPeers(); if (peers == null) { return false; } for (int i = 0; i < peers.Count; i++) { ZNetPeer val = peers[i]; if (val == null || val.m_uid == 0L) { continue; } string persistentIdForRouteUid = GetPersistentIdForRouteUid(val.m_uid); if (!string.IsNullOrEmpty(persistentIdForRouteUid)) { _routeToPersistent[val.m_uid] = persistentIdForRouteUid; _persistentToRoute[persistentIdForRouteUid] = val.m_uid; if (persistentIdForRouteUid == persistentId) { routeUid = val.m_uid; return true; } } } return false; } private static void ServerTick_RebuildPeerIdMaps() { //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } _routeToPersistent.Clear(); _persistentToRoute.Clear(); List<ZNetPeer> peers = ZNet.instance.GetPeers(); if (peers != null) { for (int i = 0; i < peers.Count; i++) { ZNetPeer val = peers[i]; if (val != null && val.m_uid != 0L) { long uid = val.m_uid; if (!TryResolvePersistentIdFromPeer_GuildsStyle(val, out var pid) || string.IsNullOrEmpty(pid)) { pid = (LooksLikeSteamId(uid) ? uid.ToString(CultureInfo.InvariantCulture) : ((!LooksLikeSteamId(val.m_uid)) ? null : val.m_uid.ToString(CultureInfo.InvariantCulture))); } if (string.IsNullOrEmpty(pid)) { DiagLog(uid, "RebuildPeerIdMaps: pid unresolved."); continue; } _routeToPersistent[uid] = pid; _persistentToRoute[pid] = uid; } } } if (!IsDedicatedServer() && (Object)Player.m_localPlayer != (Object)null) { _routeToPersistent[0L] = "HOST"; _persistentToRoute["HOST"] = 0L; } if (PendingByPid.Count <= 0) { return; } List<string> list = new List<string>(PendingByPid.Keys); for (int j = 0; j < list.Count; j++) { string key = list[j]; if (!PendingByPid.TryGetValue(key, out var value) || !_persistentToRoute.TryGetValue(key, out var value2) || value2 == 0L) { continue; } if (value.ToRouteUid != value2) { if (value.ToRouteUid != 0L) { PendingByRoute.Remove(value.ToRouteUid); } value.ToRouteUid = value2; PendingByPid[key] = value; PendingByRoute[value2] = value; } else { PendingByRoute[value2] = value; } } } private void Awake() { //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Expected O, but got Unknown _self = this; _rangeMeters = ((BaseUnityPlugin)this).Config.Bind<float>("Server", "ProximityRangeMeters", 25f, "Distance required to activate Family buff."); _proximityTickSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Server", "ProximityTickSeconds", 0.25f, "Server proximity tick interval (seconds)."); _saveIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Persistence", "SaveIntervalSeconds", 60f, "Minimum seconds between household file writes when dirty."); _startAtTier1 = ((BaseUnityPlugin)this).Config.Bind<bool>("Tiers", "StartAtTier1", true, "If true, new household members start at Tier 1 so Family can activate immediately."); _tier1Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier1Days", 6, "In-game days alive in household to reach tier 1."); _tier2Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier2Days", 12, "In-game days alive in household to reach tier 2."); _tier3Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier3Days", 24, "In-game days alive in household to reach tier 3."); _tier4Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier4Days", 48, "In-game days alive in household to reach tier 4."); _tier5Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier5Days", 60, "In-game days alive in household to reach tier 5."); _tier6Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier6Days", 90, "In-game days alive in household to reach tier 6."); _tier7Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier7Days", 120, "In-game days alive in household to reach tier 7."); _tier8Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier8Days", 180, "In-game days alive in household to reach tier 8."); _tier9Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier9Days", 240, "In-game days alive in household to reach tier 9."); _tier10Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier10Days", 300, "In-game days alive in household to reach tier 10."); _tier11Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier11Days", 360, "In-game days alive in household to reach tier 11."); _tier12Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier12Days", 420, "In-game days alive in household to reach tier 12."); _tier13Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier13Days", 480, "In-game days alive in household to reach tier 13."); _tier14Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier14Days", 540, "In-game days alive in household to reach tier 14."); _tier15Days = ((BaseUnityPlugin)this).Config.Bind<int>("Tiers", "Tier15Days", 600, "In-game days alive in household to reach tier 15."); _buffMove = ((BaseUnityPlugin)this).Config.Bind<bool>("FamilyBuff", "BuffMoveSpeed", true, "Family buff affects move speed."); _buffDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("FamilyBuff", "BuffDamage", true, "Family buff affects damage."); _buffStaminaRegen = ((BaseUnityPlugin)this).Config.Bind<bool>("FamilyBuff", "BuffStaminaRegen", true, "Family buff affects stamina regen."); _buffHealthRegen = ((BaseUnityPlugin)this).Config.Bind<bool>("FamilyBuff", "BuffHealthRegen", true, "Family buff affects health regen."); _buffEitrRegen = ((BaseUnityPlugin)this).Config.Bind<bool>("FamilyBuff", "BuffEitrRegen", true, "Family buff affects eitr regen."); _enableMourning = ((BaseUnityPlugin)this).Config.Bind<bool>("Mourning", "EnableMourning", false, "Apply Mourning when a household member dies."); _mourningDurationSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Mourning", "DurationSeconds", 900f, "Mourning duration in seconds."); _mourningBasePenalty = ((BaseUnityPlugin)this).Config.Bind<float>("Mourning", "BasePenalty", 0.05f, "Tier 1 additive penalty (0.05=5%)."); _mourningMaxPenalty = ((BaseUnityPlugin)this).Config.Bind<float>("Mourning", "MaxPenalty", 0.32f, "Max penalty cap (0.32=32%)."); _mourningDoublesWithTier = ((BaseUnityPlugin)this).Config.Bind<bool>("Mourning", "DoublesWithTier", true, "If true, mourning penalty doubles each tier."); _mourningCarryWeightPenalty = ((BaseUnityPlugin)this).Config.Bind<float>("Mourning", "CarryWeightPenalty", -100f, "Carry weight penalty (negative reduces carry weight)."); _announce = ((BaseUnityPlugin)this).Config.Bind<bool>("Social", "AnnounceHouseholds", true, "Announce household events."); _familyProgressInTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "FamilyProgressInTooltip", true, "Show tier progress-to-next in Family tooltip."); _familyProgressToasts = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "FamilyProgressToasts", true, "Toast at 25/50/75/100% progress toward next tier."); _familyTierUpToasts = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "FamilyTierUpToasts", false, "Toast when Family tier increases."); _showErrorMessages = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowErrorMessages", false, "If true, show error/failure messages (RPC not ready, no invite, not found, etc). Default false = fail silently."); _progressSendIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "ProgressSendIntervalSeconds", 6f, "Server -> client progress update interval while Family active."); _dissolveRule = ((BaseUnityPlugin)this).Config.Bind<int>("Household", "DissolveRule", 0, "0=Default, 1=Hardcore."); _debugEnabledServer = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugCommands", false, "Enable server-authoritative debug commands."); _diagnosticsVerbose = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseDiagnostics", false, "Extra logs for troubleshooting."); BuildSeArrays(); _householdsPath = Path.Combine(Paths.ConfigPath, "pix.marriage.households.txt"); _harmony = new Harmony("Pix.Marriage"); _harmony.PatchAll(); } private void OnDestroy() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown try { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } if ((Object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { SaveHouseholdsIfDirty(force: true); } } private void Update() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown TryRegisterRpcsLate(); TryRegisterConsoleCommands(); Client_EnsureStatusEffectsRegistered_Throttled(); Client_UpdateMourning(); Client_TickFamilyTooltipRefresh(); if (!((Object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { if (!_householdsLoaded) { LoadHouseholdsOnce(); } _serverTickTimer += Time.deltaTime; if (_serverTickTimer >= 1f) { _serverTickTimer = 0f; ServerTick_RebuildPeerIdMaps(); ServerTick_AccrueBondSeconds_Stable(); ServerTick_RenotifyProposals(); ServerTick_CleanupStaleProposals(); ServerTick_CleanupDisconnectedCaches(); SaveHouseholdsIfDirty(force: false); } _serverProximityTimer += Time.deltaTime; float num = Mathf.Clamp(_proximityTickSeconds.Value, 0.05f, 2f); if (_serverProximityTimer >= num) { _serverProximityTimer = 0f; ServerTick_ProximityFamily_Strict(); } } } private static void TryRegisterRpcsLate() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { int hashCode = ((object)instance).GetHashCode(); if (!_rpcsRegistered || _rpcsInstanceHash != hashCode) { RegisterRpcs(instance); _rpcsRegistered = true; _rpcsInstanceHash = hashCode; } } } private static void RegisterRpcs(ZRoutedRpc rpc) { rpc.Register<string>("PX_Marry_Request", (Action<long, string>)RPC_Server_RequestMarriage); rpc.Register<bool>("PX_Marry_Response", (Action<long, bool>)RPC_Server_RespondMarriage); rpc.Register("PX_Marry_Divorce", (Action<long>)RPC_Server_Divorce); rpc.Register("PX_Household_Info", (Action<long>)RPC_Server_RequestHouseholdInfo); rpc.Register<int>("PX_Debug_MarrySelf", (Action<long, int>)RPC_Server_DebugMarrySelf); rpc.Register("PX_Debug_ClearMarriage", (Action<long>)RPC_Server_DebugClearMarriage); rpc.Register("PX_Debug_State", (Action<long>)RPC_Server_DebugState); rpc.Register<string, long>("PX_Marry_NotifyProposal", (Action<long, string, long>)RPC_Client_NotifyProposal); rpc.Register<string>("PX_Marry_NotifyToast", (Action<long, string>)RPC_Client_NotifyToast); rpc.Register<int>("PX_Family_SetTier", (Action<long, int>)RPC_Client_SetFamilyTier); rpc.Register<int, float>("PX_Family_SetProgress", (Action<long, int, float>)RPC_Client_SetFamilyProgress); rpc.Register<int, float>("PX_Mourning_Apply", (Action<long, int, float>)RPC_Client_ApplyMourning); rpc.Register("PX_Marry_PlayVfx", (Action<long>)RPC_Client_PlayVfx); } private static void TryRegisterConsoleCommands() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00e8: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0158: 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_014f: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown if (_consoleRegistered) { return; } _consoleRegistered = true; object obj = <>c.<>9__132_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { try { if (args?.Args == null || args.Args.Length < 2) { MessageCenter("Usage: /marry <playerName>"); } else { string s = string.Join(" ", args.Args, 1, args.Args.Length - 1); s = NormalizePlayerNameInput(s).Trim(new char[1] { '"' }); if (string.IsNullOrEmpty(s)) { MessageCenter("Usage: /marry <playerName>"); } else { Client_RequestMarriage(s); } } } catch { } }; <>c.<>9__132_0 = val; obj = (object)val; } new ConsoleCommand("marry", "Invite a player to your household. Usage: /marry <playerName>", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__132_1; if (obj2 == null) { ConsoleEvent val2 = delegate { try { Client_RespondMarriage(accept: true); } catch { } }; <>c.<>9__132_1 = val2; obj2 = (object)val2; } new ConsoleCommand("ido", "Accept the most recent household invite. Usage: /ido", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__132_2; if (obj3 == null) { ConsoleEvent val3 = delegate { try { Client_RespondMarriage(accept: false); } catch { } }; <>c.<>9__132_2 = val3; obj3 = (object)val3; } new ConsoleCommand("idont", "Decline the most recent household invite. Usage: /idont", (ConsoleEvent)obj3, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj4 = <>c.<>9__132_3; if (obj4 == null) { ConsoleEvent val4 = delegate { try { Client_RequestDivorce(); } catch { } }; <>c.<>9__132_3 = val4; obj4 = (object)val4; } new ConsoleCommand("divorce", "Leave your current household. Usage: /divorce", (ConsoleEvent)obj4, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj5 = <>c.<>9__132_4; if (obj5 == null) { ConsoleEvent val5 = delegate { try { Client_RequestHouseholdInfo(); } catch { } }; <>c.<>9__132_4 = val5; obj5 = (object)val5; } new ConsoleCommand("household", "Show your current household info. Usage: /household", (ConsoleEvent)obj5, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj6 = <>c.<>9__132_5; if (obj6 == null) { ConsoleEvent val6 = delegate(ConsoleEventArgs args) { try { int result = 1; if (args?.Args != null && args.Args.Length >= 2) { int.TryParse(args.Args[1], out result); } result = Mathf.Clamp(result, 1, MaxTierClamped()); if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Debug_MarrySelf", new object[1] { result }); } } catch { } }; <>c.<>9__132_5 = val6; obj6 = (object)val6; } new ConsoleCommand("px_marryself", "Debug: solo household + force bond to tier. Usage: px_marryself [tier(1-max)]", (ConsoleEvent)obj6, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj7 = <>c.<>9__132_6; if (obj7 == null) { ConsoleEvent val7 = delegate { try { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Debug_ClearMarriage", Array.Empty<object>()); } } catch { } }; <>c.<>9__132_6 = val7; obj7 = (object)val7; } new ConsoleCommand("px_marryclear", "Debug: leave household. Usage: px_marryclear", (ConsoleEvent)obj7, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj8 = <>c.<>9__132_7; if (obj8 == null) { ConsoleEvent val8 = delegate { try { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Debug_State", Array.Empty<object>()); } } catch { } }; <>c.<>9__132_7 = val8; obj8 = (object)val8; } new ConsoleCommand("px_marrydebug", "Debug: print state. Usage: px_marrydebug", (ConsoleEvent)obj8, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static void MessageCenter(string msg) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown try { if ((Object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, msg, 0, (Sprite)null, false); } } catch { } } private static bool ShowErrors() { try { return _showErrorMessages != null && _showErrorMessages.Value; } catch { return false; } } private static void ErrorCenter(string msg) { if (ShowErrors()) { MessageCenter(msg); } } private static void Server_ErrorToast(long targetRouteUid, string msg) { if (ShowErrors()) { Server_ToClientToast(targetRouteUid, msg); } } private static void Client_RequestHouseholdInfo() { try { if (ZRoutedRpc.instance == null) { ErrorCenter("RPC not ready yet."); } else { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Household_Info", Array.Empty<object>()); } } catch { } } private static void Client_RequestMarriage(string targetName) { if (ZRoutedRpc.instance == null) { ErrorCenter("RPC not ready yet."); return; } ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Marry_Request", new object[1] { targetName }); MessageCenter("Invite sent to " + targetName + "…"); } private static void Client_RespondMarriage(bool accept) { if (ZRoutedRpc.instance == null) { ErrorCenter("RPC not ready yet."); return; } ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Marry_Response", new object[1] { accept }); } private static void Client_RequestDivorce() { if (ZRoutedRpc.instance == null) { ErrorCenter("RPC not ready yet."); } else { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PX_Marry_Divorce", Array.Empty<object>()); } } private static void RPC_Client_NotifyProposal(long sender, string fromName, long fromUid) { MessageCenter("\ud83c\udfe0 " + fromName + " invited you to their household! Type /ido or /idont"); } private static void RPC_Client_NotifyToast(long sender, string msg) { MessageCenter(msg); } private static void RPC_Client_PlayVfx(long sender) { Client_PlayHeartsVfxAtPlayer(); } private static void RPC_Client_SetFamilyTier(long sender, int tier) { int num = MaxTierClamped(); int num2 = Mathf.Clamp(tier, 0, num); if (num2 != _clientFamilyTier) { _clientFamilyTier = num2; Client_ApplyFamilyTierLocal(num2); if (num2 <= 0) { _clientFamilyBondDays = 0f; Client_RefreshAllFamilyTooltips(0f); } else { _clientSuppressNextProgressToast = true; } } else if (num2 > 0) { Client_UpdateActiveFamilyTooltipForTier(num2); } if (num2 > 0 && _familyTierUpToasts.Value && num2 > _clientHighestEverTierSeen) { _clientHighestEverTierSeen = num2; MessageCenter("\ud83c\udfe0 Family reached Tier " + num2 + "!"); } } private static void RPC_Client_SetFamilyProgress(long sender, int tier, float bondDays) { int num = MaxTierClamped(); int num2 = Mathf.Clamp(tier, 0, num); _clientFamilyBondDays = Mathf.Max(0f, bondDays); if (_familyProgressInTooltip.Value && num2 > 0) { Client_RefreshFamilyTooltipForTier(num2, _clientFamilyBondDays); } if (num2 > 0) { Client_UpdateActiveFamilyTooltipForTier(num2); } if (!_familyProgressToasts.Value || num2 <= 0 || num2 >= num) { return; } int progressMilestoneBucket = GetProgressMilestoneBucket(num2, _clientFamilyBondDays); if (_clientSuppressNextProgressToast) { _clientFamilyMilestoneBucket = progressMilestoneBucket; _clientSuppressNextProgressToast = false; } else if (progressMilestoneBucket > 0 && progressMilestoneBucket > _clientFamilyMilestoneBucket) { _clientFamilyMilestoneBucket = progressMilestoneBucket; if (progressMilestoneBucket >= 100) { MessageCenter("\ud83c\udfe0 Family Tier " + num2 + " complete — next tier ready!"); return; } MessageCenter("\ud83c\udfe0 Family Tier " + num2 + ": " + progressMilestoneBucket + "% to Tier " + (num2 + 1)); } } private static void RPC_Client_ApplyMourning(long sender, int tier, float durationSeconds) { Client_ApplyMourning_Local(tier, durationSeconds); } private static void Client_ApplyMourning_Local(int tier, float durationSeconds) { if (_enableMourning.Value) { int num = MaxTierClamped(); int num2 = Mathf.Clamp(tier, 1, num); float num3 = Mathf.Max(1f, durationSeconds); if (num2 > _clientMourningTier) { _clientMourningTier = num2; } float time = Time.time; float num4 = Mathf.Max(0f, _clientMourningEndTime - time); _clientMourningEndTime = time + num4 + num3; Client_EnsureMourningTierSe(); } } private static void Client_UpdateMourning() { if (_enableMourning == null || !_enableMourning.Value) { if (_clientMourningEndTime > 0f) { _clientMourningEndTime = 0f; _clientMourningTier = 0; Client_ClearMourning(); } } else if (!(_clientMourningEndTime <= 0f)) { if (Time.time >= _clientMourningEndTime) { _clientMourningEndTime = 0f; _clientMourningTier = 0; Client_ClearMourning(); } else { Client_EnsureMourningTierSe(); } } } private static void Client_TickFamilyTooltipRefresh() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if (!((Object)Player.m_localPlayer == (Object)null) && _clientFamilyTier > 0) { float time = Time.time; if (!(time < _clientFamilyTooltipNextRefresh)) { _clientFamilyTooltipNextRefresh = time + 0.25f; Client_UpdateActiveFamilyTooltipForTier(_clientFamilyTier); } } } private static void EnsureLoadedOnServer() { if (!_householdsLoaded) { LoadHouseholdsOnce(); } } private static void LoadHouseholdsOnce() { _householdsLoaded = true; _serverBondAccrualRemainder = 0.0; _lastSaveRealtime = Time.realtimeSinceStartup; _lastBondAccrueRealtime = 0f; try { Households.Clear(); PidToHousehold.Clear(); _lastSentTier.Clear(); _lastSentProgressRealtime.Clear(); _lastSentTierRealtime.Clear(); if (!File.Exists(_householdsPath)) { return; } string[] array = File.ReadAllLines(_householdsPath); Household household = null; foreach (string text in array) { if (string.IsNullOrEmpty(text) || text.StartsWith("#")) { continue; } if (text.StartsWith("H\t", StringComparison.Ordinal)) { string[] array2 = text.Split(new char[1] { '\t' }); if (array2.Length >= 2) { household = new Household { id = array2[1] }; Households[household.id] = household; } } else { if (!text.StartsWith("M\t", StringComparison.Ordinal) || household == null) { continue; } string[] array3 = text.Split(new char[1] { '\t' }); if (array3.Length < 4) { continue; } string text2 = Unescape(array3[1]); if (!string.IsNullOrEmpty(text2)) { string text3 = Unescape(array3[2]); if (!double.TryParse(array3[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { result = 0.0; } int result2 = 0; if (array3.Length >= 5) { int.TryParse(array3[4], NumberStyles.Integer, CultureInfo.InvariantCulture, out result2); } Member value = new Member { pid = text2, name = (text3 ?? "Player"), bondSeconds = Math.Max(0.0, result), deaths = Mathf.Max(0, result2) }; household.members[text2] = value; PidToHousehold[text2] = household.id; } } } } catch { } } private static void SaveHouseholdsIfDirty(bool force) { if (!_householdsDirty && !force) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; float num = Mathf.Max(5f, _saveIntervalSeconds.Value); if (!force && realtimeSinceStartup - _lastSaveRealtime < num) { return; } _lastSaveRealtime = realtimeSinceStartup; try { List<string> list = new List<string>(); list.Add("# pix.marriage.households.txt"); list.Add("# H<TAB>householdId"); list.Add("# M<TAB>persistentId(escaped)<TAB>escapedName<TAB>bondSeconds<TAB>deaths"); list.Add("# NOTE: persistentId is a platform-safe string (not necessarily numeric)."); foreach (KeyValuePair<string, Household> household in Households) { Household value = household.Value; if (value == null) { continue; } list.Add("H\t" + value.id); foreach (KeyValuePair<string, Member> member in value.members) { Member value2 = member.Value; if (value2 != null && !string.IsNullOrEmpty(value2.pid)) { list.Add("M\t" + Escape(value2.pid) + "\t" + Escape(value2.name ?? "Player") + "\t" + value2.bondSeconds.ToString("R", CultureInfo.InvariantCulture) + "\t" + Mathf.Max(0, value2.deaths).ToString(CultureInfo.InvariantCulture)); } } } string text = _householdsPath + ".tmp"; File.WriteAllLines(text, list.ToArray()); File.Copy(text, _householdsPath, overwrite: true); File.Delete(text); _householdsDirty = false; } catch { } } private static string Escape(string s) { try { return Uri.EscapeDataString(s ?? ""); } catch { return ""; } } private static string Unescape(string s) { try { return Uri.UnescapeDataString(s ?? ""); } catch { return s ?? ""; } } private static void RPC_Server_DebugMarrySelf(long senderRouteUid, int tier) { EnsureLoadedOnServer(); ServerTick_RebuildPeerIdMaps(); tier = Mathf.Clamp(tier, 1, MaxTierClamped()); string persistentIdForRouteUid = GetPersistentIdForRouteUid(senderRouteUid); if (string.IsNullOrEmpty(persistentIdForRouteUid) || (persistentIdForRouteUid != "HOST" && persistentIdForRouteUid.Length < 2)) { Server_ErrorToast(senderRouteUid, "Could not resolve your stable ID yet. Try again in a few seconds."); return; } string nameForRouteUid = GetNameForRouteUid(senderRouteUid); _debugSoloFamily.Add(persistentIdForRouteUid); if (!PidToHousehold.TryGetValue(persistentIdForRouteUid, out var value) || string.IsNullOrEmpty(value)) { value = "H" + Guid.NewGuid().ToString("N"); Household household = new Household { id = value }; Households[value] = household; AddMemberToHousehold(household, persistentIdForRouteUid, nameForRouteUid); PidToHousehold[persistentIdForRouteUid] = value; _householdsDirty = true; } if (PidToHousehold.TryGetValue(persistentIdForRouteUid, out var value2) && Households.TryGetValue(value2, out var value3) && value3 != null && value3.members.TryGetValue(persistentIdForRouteUid, out var value4) && value4 != null) { value4.bondSeconds = TierToMinBondSeconds(tier); _householdsDirty = true; } _lastSentTier[senderRouteUid] = 0; _lastSentProgressRealtime.Remove(senderRouteUid); float bondDays = (float)(TierToMinBondSeconds(tier) / 1800.0); Server_ToClientFamily(senderRouteUid, tier); Server_ToClientFamilyProgress(senderRouteUid, tier, bondDays); } private static void RPC_Server_DebugClearMarriage(long senderRouteUid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if (!((Object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { EnsureLoadedOnServer(); ServerTick_RebuildPeerIdMaps(); if (!_debugEnabledServer.Value) { Server_ErrorToast(senderRouteUid, "Debug commands are disabled on this server."); return; } Server_LeaveHousehold(senderRouteUid); Server_ToClientFamily(senderRouteUid, 0); Server_ToClientFamilyProgress(senderRouteUid, 0, 0f); } } private static void RPC_Server_DebugState(long senderRouteUid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if ((Object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } EnsureLoadedOnServer(); ServerTick_RebuildPeerIdMaps(); if (!_debugEnabledServer.Value) { Server_ErrorToast(senderRouteUid, "Debug commands are disabled on this server."); return; } string persistentIdForRouteUid = GetPersistentIdForRouteUid(senderRouteUid); if (string.IsNullOrEmpty(persistentIdForRouteUid)) { Server_ErrorToast(senderRouteUid, "Could not resolve your stable ID yet."); return; } if (!PidToHousehold.TryGetValue(persistentIdForRouteUid, out var value) || string.IsNullOrEmpty(value)) { Server_ToClientToast(senderRouteUid, "Not in a household. pid=" + persistentIdForRouteUid); return; } if (!Households.TryGetValue(value, out var value2) || value2 == null) { Server_ToClientToast(senderRouteUid, "Household missing. pid=" + persistentIdForRouteUid + " hh=" + value); return; } double num = 0.0; int num2 = 0; if (value2.members.TryGetValue(persistentIdForRouteUid, out var value3) && value3 != null) { num = value3.bondSeconds; num2 = value3.deaths; } int tierFromBondSeconds = GetTierFromBondSeconds(num); Server_ToClientToast(senderRouteUid, "household=" + value + " members=" + value2.members.Count + " bondDays=" + (num / 1800.0).ToString("0.0", CultureInfo.InvariantCulture) + " tier=" + tierFromBondSeconds + " deaths=" + num2 + " pid=" + persistentIdForRouteUid); } private static void RPC_Server_Divorce(long senderRouteUid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if (!((Object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { EnsureLoadedOnServer(); ServerTick_RebuildPeerIdMaps(); Server_LeaveHousehold(senderRouteUid); } } private static void RPC_Server_RequestHouseholdInfo(long senderRouteUid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown try { if ((Object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } EnsureLoadedOnServer(); ServerTick_RebuildPeerIdMaps(); string persistentIdForRouteUid = GetPersistentIdForRouteUid(senderRouteUid); if (string.IsNullOrEmpty(persistentIdForRouteUid) && !IsHostUid(senderRouteUid)) { Server_ErrorToast(senderRouteUid, "Household info not ready yet (ID unresolved). Try again in a moment."); return; } if (string.IsNullOrEmpty(persistentIdForRouteUid) || !PidToHousehold.TryGetValue(persistentIdForRouteUid, out var value) || string.IsNullOrEmpty(value)) { Server_ErrorToast(senderRouteUid, "You are not in a household."); return; } if (!Households.TryGetValue(value, out var value2) || value2 == null || value2.members == null) { Server_ErrorToast(senderRouteUid, "Household data missing."); return; } int num = 0; float num2 = 0f; if (value2.members.TryGetValue(persistentIdForRouteUid, out var value3) && value3 != null) { num = GetTierFromBondSeconds(value3.bondSeconds); num2 = (float)(value3.bondSeconds / 1800.0); } List<string> list = new List<string>(); foreach (KeyValuePair<string, Member> member in value2.members) { Member value4 = member.Value; if (value4 != null) { string text = value4.name; if (string.IsNullOrEmpty(text)) { text = "Player"; } list.Add(text); } } Server_ToClientToast(senderRouteUid, "\ud83c\udfe0 Household " + value + " | Tier " + Mathf.Max(0, num) + " | Bond " + num2.ToString("0.0", CultureInfo.InvariantCulture) + " days"); if (list.Count > 0) { string text2 = string.Join(", ", list.ToArray()); if (text2.Length > 220) { text2 = text2.Substring(0, 217) + "..."; } Server_ToClientToast(senderRouteUid, "Members: " + text2); } } catch { } } private static void RPC_Server_RequestMarriage(long senderRouteUid, string targetName) { EnsureLoadedOnServer(); ServerTick_RebuildPeerIdMaps(); string persistentIdForRouteUid = GetPersistentIdForRouteUid(senderRouteUid); if (string.IsNullOrEmpty(persistentIdForRouteUid) && !IsHostUid(senderRouteUid)) { if (ShowErrors() && _diagnosticsVerbose != null && _diagnosticsVerbose.Value) { Server_ToClientToast(senderRouteUid, "Marriage: sender ID not ready; retry in a moment."); } return; } targetName = NormalizePlayerNameInput(targetName); if (string.IsNullOrEmpty(targetName)) { Server_ErrorToast(senderRouteUid, "Usage: /marry <playerName>"); return; } string nameForRouteUid = GetNameForRouteUid(senderRouteUid); if (!TryResolveTargetRouteUidByName(targetName, out var routeUid, out var displayName)) { Server_ErrorToast(senderRouteUid, "Could not find player '" + targetName + "'."); return; } if (routeUid == senderRouteUid) { Server_ErrorToast(senderRouteUid, "You can’t invite yourself."); return; } string persistentIdForRouteUid2 = GetPersistentIdForRouteUid(routeUid); if (!string.IsNullOrEmpty(persistentIdForRouteUid2) && PidToHousehold.ContainsKey(persistentIdForRouteUid2)) { Server_ErrorToast(senderRouteUid, displayName + " is already in a household."); return; } string fromHouseholdId = null; if (!string.IsNullOrEmpty(persistentIdForRouteUid) && PidToHousehold.TryGetValue(persistentIdForRouteUid, out var value)) { fromHouseholdId = value; } Proposal proposal = default(Proposal); proposal.FromRouteUid = senderRouteUid; proposal.FromPersistentId = persistentIdForRouteUid ?? ""; proposal.FromName = nameForRouteUid; proposal.FromHouseholdId = fromHouseholdId; proposal.LastNotifyTime = Time.realtimeSinceStartup; proposal.ToRouteUid = routeUid; proposal.ToPersistentId = persistentIdForRouteUid2 ?? ""; Proposal value2 = proposal; if (PendingByRoute.TryGetValue(routeUid, out var value3)) { if (!string.IsNullOrEmpty(value3.ToPersistentId)) { PendingByPid.Remove(value3.ToPersistentId); } PendingByRoute.Remove(routeUid); } if (!string.IsNullOrEmpty(persistentIdForRouteUid2) && PendingByPid.TryGetValue(persistentIdForRouteUid2, out var value4)) { if (value4.ToRouteUid != 0L) { PendingByRoute.Remove(value4.ToRouteUid); } PendingByPid.Remove(persistentIdForRouteUid2); } PendingByRoute[routeUid] = value2; if (!string.IsNullOrEmpty(persistentIdForRouteUid2)) { PendingByPid[persistentIdForRouteUid2] = value2; } if (IsHostUid(routeUid)) { RPC_Client_NotifyProposal(0L, nameForRouteUid, senderRouteUid); } else if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(routeUid, "PX_Marry_NotifyProposal", new object[2] { nameForRouteUid, senderRouteUid }); } Server_ToClientToast(senderRouteUid, "Invite sent to " + displayName + "."); } private static void RPC_Server_RespondMarriage(long senderRouteUid, bool accept) { EnsureLoadedOnServer(); ServerTick_RebuildPeerIdMaps(); string persistentIdForRouteUid = GetPersistentIdForRouteUid(senderRouteUid); Proposal value; bool flag = PendingByRoute.TryGetValue(senderRouteUid, out value); if (!flag && !string.IsNullOrEmpty(persistentIdForRouteUid)) { flag = PendingByPid.TryGetValue(persistentIdForRouteUid, out value); if (flag) { value.ToRouteUid = senderRouteUid; PendingByRoute[senderRouteUid] = value; } } if (!flag) { Server_ErrorToast(senderRouteUid, "No pending household invite."); return; } PendingByRoute.Remove(senderRouteUid); if (value.ToRouteUid != 0L && value.ToRouteUid != senderRouteUid) { PendingByRoute.Remove(value.ToRouteUid); } if (!string.IsNullOrEmpty(value.ToPersistentId)) { PendingByPid.Remove(value.ToPersistentId); } string nameForRouteUid = GetNameForRouteUid(senderRouteUid); string nameForRouteUid2 = GetNameForRouteUid(value.FromRouteUid); if (!accept) { Server_ToClientToast(value.FromRouteUid, nameForRouteUid + " declined your invite. " + GetRandomRejection()); Server_ToClientToast(senderRouteUid, "You declined."); return; } string fromPersistentId = value.FromPersistentId; string text = persistentIdForRouteUid; if (string.IsNullOrEmpty(text) && !IsHostUid(senderRouteUid)) { if (ShowErrors() && _diagnosticsVerbose != null && _diagnosticsVerbose.Value) { Server_ToClientToast(senderRouteUid, "Marriage: sender ID not ready; retrying shortly."); } return; } if (string.IsNullOrEmpty(fromPersistentId) && !IsHostUid(value.FromRouteUid)) { if (ShowErrors() && _diagnosticsVerbose != null && _diagnosticsVerbose.Value) { Server_ToClientToast(senderRouteUid, "Marriage: inviter ID not ready; retrying shortly."); } return; } if (!string.IsNullOrEmpty(text) && PidToHousehold.ContainsKey(text)) { Server_ErrorToast(senderRouteUid, "You are already in a household."); return; } string fromHouseholdId = value.FromHouseholdId; Household value2; if (string.IsNullOrEmpty(fromHouseholdId)) { if ((!string.IsNullOrEmpty(fromPersistentId) && PidToHousehold.ContainsKey(fromPersistentId)) || (!string.IsNullOrEmpty(text) && PidToHousehold.ContainsKey(text))) { ((BaseUnityPlugin)_self).Logger.LogWarning((object)("[Marriage] Aborting new household create; someone already has a household. fromPid=" + fromPersistentId + " toPid=" + text)); Server_ErrorToast(senderRouteUid, "Household could not be created (someone already has one)."); return; } fromHouseholdId = "H" + Guid.NewGuid().ToString("N"); Household household = new Household { id = fromHouseholdId }; Households[fromHouseholdId] = household; AddMemberToHousehold(household, fromPersistentId, nameForRouteUid2); AddMemberToHousehold(household, text, nameForRouteUid); if (!string.IsNullOrEmpty(fromPersistentId)) { PidToHousehold[fromPersistentId] = fromHouseholdId; } if (!string.IsNullOrEmpty(text)) { PidToHousehold[text] = fromHouseholdId; } _householdsDirty = true; if (_announce.Value && ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "PX_Marry_NotifyToast", new object[1] { "\ud83c\udfe0 " + nameForRouteUid2 + " and " + nameForRouteUid + " formed a Household!" }); } else { Server_ToClientToast(value.FromRouteUid, "Household formed with " + nameForRouteUid + "."); Server_ToClientToast(senderRouteUid, "Household formed with " + nameForRouteUid2 + "."); } if (ZRoutedRpc.instance != null) { if (IsHostUid(value.FromRouteUid)) { RPC_Client_PlayVfx(0L); } else { ZRoutedRpc.instance.InvokeRoutedRPC(value.FromRouteUid, "PX_Marry_PlayVfx", Array.Empty<object>()); } if (IsHostUid(senderRouteUid)) { RPC_Client_PlayVfx(0L); } else { ZRoutedRpc.instance.InvokeRoutedRPC(senderRouteUid, "PX_Marry_PlayVfx", Array.Empty<object>()); } } _lastSentTier[value.FromRouteUid] = 0; _lastSentTier[senderRouteUid] = 0; _lastSentProgressRealtime.Remove(value.FromRouteUid); _lastSentProgressRealtime.Remove(senderRouteUid); } else if (!Households.TryGetValue(fromHouseholdId, out value2) || value2 == null) { Server_ErrorToast(senderRouteUid, "Household missing (try again)."); } else { AddMemberToHousehold(value2, text, nameForRouteUid); if (!string.IsNullOrEmpty(text)) { PidToHousehold[text] = fromHouseholdId; } _householdsDirty = true; if (_announce.Value && ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "PX_Marry_NotifyToast", new object[1] { "\ud83c\udfe0 " + nameForRouteUid + " joined " + nameForRouteUid2 + "'s Household!" }); } else { Server_ToClientToast(senderRouteUid, "You joined " + nameForRouteUid2 + "'s Household."); Server_ToClientToast(value.FromRouteUid, nameForRouteUid + " joined your Household."); } _lastSentTier[senderRouteUid] = 0; _lastSentProgressRealtime.Remove(senderRouteUid); } } private static void Server_ToClientToast(long targetRouteUid, string msg) { if (IsHostUid(targetRouteUid)) { RPC_Client_NotifyToast(0L, msg); } else if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(targetRouteUid, "PX_Marry_NotifyToast", new object[1] { msg }); } } private static void Server_ToClientFamily(long targetRouteUid, int tier) { if (IsHostUid(targetRouteUid)) { RPC_Client_SetFamilyTier(0L, tier); } else if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(targetRouteUid, "PX_Family_SetTier", new object[1] { tier }); } } private static void Server_ToClientFamilyProgress(long targetRouteUid, int tier, float bondDays) { if (IsHostUid(targetRouteUid)) { RPC_Client_SetFamilyProgress(0L, tier, bondDays); } else if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(targetRouteUid, "PX_Family_SetProgress", new object[2] { tier, bondDays }); } } private static void Server_ToClientMourning(long targetRouteUid, int tier, float durationSeconds) { if (IsHostUid(targetRouteUid)) { Client_ApplyMourning_Local(tier, durationSeconds); } else if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(targetRouteUid, "PX_Mourning_Apply", new object[2] { tier, durationSeconds }); } } private void ServerTick_ProximityFamily_Strict() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) List<ZNetPeer> list = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeers() : null); if (list == null) { return; } float num = Mathf.Max(1f, _rangeMeters.Value); float num2 = num * num; int num3 = MaxTierClamped(); List<long> list2 = new List<long>(); for (int i = 0; i < list.Count; i++) { if (list[i] != null && list[i].m_uid != 0L) { list2.Add(list[i].m_uid); } } if (!IsDedicatedServer() && (Object)Player.m_localPlayer != (Object)null) { list2.Add(0L); } for (int j = 0; j < list2.Count; j++) { long routeUid = list2[j]; string persistentIdForRouteUid = GetPersistentIdForRouteUid(routeUid); if (string.IsNullOrEmpty(persistentIdForRouteUid) && !IsHostUid(routeUid)) { MaybeSendTier(routeUid, 0, 0f); continue; } if (string.IsNullOrEmpty(persistentIdForRouteUid) || !PidToHousehold.TryGetValue(persistentIdForRouteUid, out var value) || string.IsNullOrEmpty(value) || !Households.TryGetValue(value, out var value2) || value2 == null) { MaybeSendTier(routeUid, 0, 0f); continue; } if ((value2.members == null || value2.members.Count < 2) && !_debugSoloFamily.Contains(persistentIdForRouteUid)) { MaybeSendTier(routeUid, 0, 0f); continue; } int num4 = 0; float bondDays = 0f; if (value2.members.TryGetValue(persistentIdForRouteUid, out var value3) && value3 != null) { num4 = Mathf.Clamp(GetTierFromBondSeconds(value3.bondSeconds), 0, num3); bondDays = (float)(value3.bondSeconds / 1800.0); } if (num4 <= 0) { MaybeSendTier(routeUid, 0, 0f); } else if (value2.members.Count <= 1 && _debugSoloFamily.Contains(persistentIdForRouteUid)) { MaybeSendTier(routeUid, num4, bondDays); } else { if (!TryGetRouteUidPosition(routeUid, out var pos)) { continue; } bool flag = false; bool flag2 = false; foreach (KeyValuePair<string, Member> member in value2.members) { string key = member.Key; if (!(key == persistentIdForRouteUid) && TryGetRouteUidForPersistentId(key, out var routeUid2) && (IsHostUid(routeUid2) || (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.GetPeer(routeUid2) != null)) && TryGetRouteUidPosition(routeUid2, out var pos2)) { flag2 = true; Vector3 val = pos - pos2; if (((Vector3)(ref val)).sqrMagnitude <= num2) { flag = true; break; } } } if (flag) { MaybeSendTier(routeUid, num4, bondDays); } else if (flag2) { MaybeSendTier(routeUid, 0, 0f); } } } } private void MaybeSendTier(long routeUid, int tier, float bondDays) { if (!_lastSentTier.TryGetValue(routeUid, out var value)) { value = int.MinValue; } bool flag = value != tier; float realtimeSinceStartup = Time.realtimeSinceStartup; if (flag || (tier > 0 && (!_lastSentTierRealtime.TryGetValue(routeUid, out var value2) || realtimeSinceStartup - value2 >= 2f))) { _lastSentTier[routeUid] = tier; _lastSentTierRealtime[routeUid] = realtimeSinceStartup; Server_ToClientFamily(routeUid, tier); if (tier <= 0) { _lastSentProgressRealtime.Remove(routeUid); Server_ToClientFamilyProgress(routeUid, 0, 0f); } } if (tier > 0) { float num = Mathf.Clamp(_progressSendIntervalSeconds.Value, 1f, 60f); if (!_lastSentProgressRealtime.TryGetValue(routeUid, out var value3) || realtimeSinceStartup - value3 >= num || flag) { _lastSentProgressRealtime[routeUid] = realtimeSinceStartup; Server_ToClientFamilyProgress(routeUid, tier, Mathf.Max(0f, bondDays)); } } } private void ServerTick_RenotifyProposals() { if (PendingByRoute.Count == 0) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; List<long> list = new List<long>(PendingByRoute.Keys); for (int i = 0; i < list.Count; i++) { long num = list[i]; if (PendingByRoute.TryGetValue(num, out var value) && !(realtimeSinceStartup - value.LastNotifyTime < 5f) && (IsHostUid(num) || (ZRoutedRpc.instance != null && ZNet.instance.GetPeer(num) != null))) { if (IsHostUid(num)) { RPC_Client_NotifyProposal(0L, value.FromName, value.FromRouteUid); } else { ZRoutedRpc.instance.InvokeRoutedRPC(num, "PX_Marry_NotifyProposal", new object[2] { value.FromName, value.FromRouteUid }); } value.LastNotifyTime = realtimeSinceStartup; PendingByRoute[num] = value; } } } private void ServerTick_CleanupStaleProposals() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown if (PendingByRoute.Count == 0 && PendingByPid.Count == 0) { return; } HashSet<string> hashSet = new HashSet<string>(); HashSet<long> hashSet2 = new HashSet<long>(); List<ZNetPeer> list = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeers() : null); if (list != null) { for (int i = 0; i < list.Count; i++) { ZNetPeer val = list[i]; if (val != null) { hashSet2.Add(val.m_uid); string persistentIdForRouteUid = GetPersistentIdForRouteUid(val.m_uid); if (!string.IsNullOrEmpty(persistentIdForRouteUid)) { hashSet.Add(persistentIdForRouteUid); } } } } if (!IsDedicatedServer() && (Object)Player.m_localPlayer != (Object)null) { hashSet2.Add(0L); hashSet.Add("HOST"); } if (PendingByRoute.Count > 0) { List<long> list2 = new List<long>(); foreach (KeyValuePair<long, Proposal> item in PendingByRoute) { long key = item.Key; Proposal value = item.Value; if (!hashSet2.Contains(key) && (string.IsNullOrEmpty(value.ToPersistentId) || !hashSet.Contains(value.ToPersistentId))) { list2.Add(key); } } for (int j = 0; j < list2.Count; j++) { long key2 = list2[j]; if (PendingByRoute.TryGetValue(key2, out var value2) && !string.IsNullOrEmpty(value2.ToPersistentId)) { PendingByPid.Remove(value2.ToPersistentId); } PendingByRoute.Remove(key2); } } if (PendingByPid.Count <= 0) { return; } List<string> list3 = new List<string>(); foreach (KeyValuePair<string, Proposal> item2 in PendingByPid) { string key3 = item2.Key; Proposal value3 = item2.Value; if (!hashSet.Contains(key3) && (value3.ToRouteUid == 0L || !hashSet2.Contains(value3.ToRouteUid))) { list3.Add(key3); } } for (int k = 0; k < list3.Count; k++) { string key4 = list3[k]; if (PendingByPid.TryGetValue(key4, out var value4) && value4.ToRouteUid != 0L) { PendingByRoute.Remove(value4.ToRouteUid); } PendingByPid.Remove(key4); } } private static void ServerTick_CleanupDisconnectedCaches() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } List<ZNetPeer> peers = ZNet.instance.GetPeers(); HashSet<long> hashSet = new HashSet<long>(); if (peers != null) { for (int i = 0; i < peers.Count; i++) { if (peers[i] != null) { hashSet.Add(peers[i].m_uid); } } } if (!IsDedicatedServer() && (Object)Player.m_localPlayer != (Object)null) { hashSet.Add(0L); } List<long> list = new List<long>(); foreach (KeyValuePair<long, int> item in _lastSentTier) { if (!hashSet.Contains(item.Key)) { list.Add(item.Key); } } for (int j = 0; j < list.Count; j++) { long key = list[j]; _lastSentTier.Remove(key); _lastSentProgressRealtime.Remove(key); _lastSentTierRealtime.Remove(key); } } private static void Server_LeaveHousehold(long leaverRouteUid) { string persistentIdForRouteUid = GetPersistentIdForRouteUid(leaverRouteUid); if (string.IsNullOrEmpty(persistentIdForRouteUid) || !PidToHousehold.TryGetValue(persistentIdForRouteUid, out var value) || string.IsNullOrEmpty(value)) { Server_ErrorToast(leaverRouteUid, "You are not in a household."); return; } if (!Households.TryGetValue(value, out var value2) || value2 == null) { PidToHousehold.Remove(persistentIdForRouteUid); _householdsDirty = true; Server_ErrorToast(leaverRouteUid, "Household missing; you were removed."); return; } value2.members.Remove(persistentIdForRouteUid); PidToHousehold.Remove(persistentIdForRouteUid); _householdsDirty = true; _lastSentTier.Remove(leaverRouteUid); _lastSentProgressRealtime.Remove(leaverRouteUid); Server_ToClientFamily(leaverRouteUid, 0); Server_ToClientFamilyProgress(leaverRouteUid, 0, 0f); Server_ToClientToast(leaverRouteUid, "You left the household."); if (value2.members.Count > 1) { return; } foreach (KeyValuePair<string, Member> member in value2.members) { string key = member.Key; PidToHousehold.Remove(key); if (TryGetRouteUidForPersistentId(key, out var routeUid)) { _lastSentTier.Remove(routeUid); _lastSentProgressRealtime.Remove(routeUid); Server_ToClientFamily(routeUid, 0); Server_ToClientFamilyProgress(routeUid, 0, 0f); Server_ToClientToast(routeUid, "Your household dissolved."); } } Households.Remove(value); _householdsDirty = true; if (_announce.Value && ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "PX_Marry_NotifyToast", new object[1] { "\ud83d\uded6 Household dissolved." }); } } private static void Server_DissolveHousehold(string hhId, string reason) { try { if (string.IsNullOrEmpty(hhId) || !Households.TryGetValue(hhId, out var value) || value == null) { return; } List<string> list = new List<string>(value.members.Keys); for (int i = 0; i < list.Count; i++) { string text = list[i]; PidToHousehold.Remove(text); if (TryGetRouteUidForPersistentId(text, out var routeUid)) { _lastSentTier.Remove(routeUid); _lastSentProgressRealtime.Remove(routeUid); Server_ToClientFamily(routeUid, 0); Server_ToClientFamilyProgress(routeUid, 0, 0f); Server_ToClientToast(routeUid, reason); } } Households.Remove(hhId); _householdsDirty = true; if (_announce.Value && ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "PX_Marry_NotifyToast", new object[1] { "\ud83d\uded6 " + reason }); } } catch { } } private static bool Server_ShouldDissolve_AllMembersDiedOnce(Household hh) { try { if (hh == null || hh.members == null || hh.members.Count == 0) { return false; } foreach (KeyValuePair<string, Member> member in hh.members) { Member value = member.Value; if (value == null || value.deaths <= 0) { return false; } } return true; } catch { return false; } } private void ServerTick_AccrueBondSeconds_Stable() { //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown float realtimeSinceStartup = Time.realtimeSinceStartup; if (_lastBondAccrueRealtime <= 0f) { _lastBondAccrueRealtime = realtimeSinceStartup; return; } double num = realtimeSinceStartup - _lastBondAccrueRealtime; _lastBondAccrueRealtime = realtimeSinceStartup; if (num <= 0.0) { return; } if (num > 2.0) { num = 2.0; } _serverBondAccrualRemainder += num; if (_serverBondAccrualRemainder < 0.25) { return; } double num2 = Math.Floor(_serverBondAccrualRemainder / 0.25) * 0.25; _serverBondAccrualRemainder -= num2; if (num2 <= 0.0) { return; } List<ZNetPeer> list = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeers() : null); if (list == null) { return; } for (int i = 0; i < list.Count; i++) { ZNetPeer val = list[i]; if (val != null && val.m_uid != 0L) { long uid = val.m_uid; string persistentIdForRouteUid = GetPersistentIdForRouteUid(uid); if (!string.IsNullOrEmpty(persistentIdForRouteUid) && PidToHousehold.TryGetValue(persistentIdForRouteUid, out var value) && !string.IsNullOrEmpty(value) && Households.TryGetValue(value, out var value2) && value2 != null && value2.members.TryGetValue(persistentIdForRouteUid, out var value3) && value3 != null) { value3.bondSeconds += num2; _householdsDirty = true; } } } if (IsDedicatedServer() || !((Object)Player.m_localPlayer != (Object)null)) { return; } try { string key = "HOST"; if (PidToHousehold.TryGetValue(key, out var value4) && !string.IsNullOrEmpty(value4) && Households.TryGetValue(value4, out var value5) && value5 != null && value5.members.TryGetValue(key, out var value6) && value6 != null && !((Character)Player.m_localPlayer).IsDead()) { value6.bondSeconds += num2; _householdsDirty = true; } } catch { } } private static void AddMemberToHousehold(Household hh, string pid, string name) { if (hh == null || string.IsNullOrEmpty(pid)) { return; } if (!hh.members.TryGetValue(pid, out var value) || value == null) { double bondSeconds = 0.0; if (_startAtTier1 != null && _startAtTier1.Value) { bondSeconds = TierToMinBondSeconds(1); } value = new Member { pid = pid, name = (name ?? "Player"), bondSeconds = bondSeconds, deaths = 0 }; hh.members[pid] = value; } else if (!string.IsNullOrEmpty(name)) { value.name = name; } } private static string GetHostPlayerName() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown try { if ((Object)Player.m_localPlayer != (Object)null) { return Player.m_localPlayer.GetPlayerName(); } } catch { } return "Host"; } private static string GetNameForRouteUid(long routeUid) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (IsHostUid(routeUid)) { return GetHostPlayerName(); } ZNetPeer val = (((Object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeer(routeUid) : null); if (val != null && !string.IsNullOrEmpty(val.m_playerName)) { return val.m_playerName; } return "Player"; } private static bool TryResolveTargetRouteUidByName(string inputName, out long routeUid, out string displayName) { routeUid = 0L; displayName = ""; inputName = NormalizePlayerNameInput(inputName); if (string.IsNullOrEmpty(inputName)) { return false; } ZNetPeer val = FindPeerByNameSmart(inputName); if (val != null) { routeUid = val.m_uid; displayName = val.m_playerName ?? inputName; return true; } if (!IsDedicatedServer()) { string hostPlayerName = GetHostPlayerName(); if (!string.IsNullOrEmpty(hostPlayerName) && string.Equals(hostPlayerName, inputName, StringComparison.OrdinalIgnoreCase)) { routeUid = 0L; displayName = hostPlayerName; return true; } } return false; } private static bool TryResolvePersistentIdFromPlayer(Player player, out string pid) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown pid = null; if ((Object)player == (Object)null) { return false; } try { ZNetView component = ((Component)player).GetComponent<ZNetView>(); if ((Object)component == (Object)null) { return false; } ZDO zDO = component.GetZDO(); if (zDO == null) { return false; } ZDOID uid = zDO.m_uid; List<ZNetPeer> list = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeers() : null); if (list == null) { return false; } for (int i = 0; i < list.Count; i++) { ZNetPeer val = list[i]; if (val != null && ((ZDOID)(ref val.m_characterID)).Equals(uid)) { pid = GetPersistentIdForRouteUid(val.m_uid); return !string.IsNullOrEmpty(pid); } } if (!IsDedicatedServer() && (Object)Player.m_localPlayer != (Object)null && (Object)(object)player == (Object)(object)Player.m_localPlayer) { pid = "HOST"; return true; } } catch { } return false; } private static bool TryGetRouteUidPosition(long routeUid, out Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) pos = Vector3.zero; if (IsHostUid(routeUid)) { try { if ((Object)Player.m_localPlayer != (Object)null) { pos = ((Component)Player.m_localPlayer).transform.position; return true; } } catch { } return false; } ZNetPeer val = (((Object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeer(routeUid) : null); if (val == null) { return false; } return TryGetPeerPosition(val, out pos); } private static bool TryGetPeerPosition(ZNetPeer peer, out Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_003a: 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_004f: Unknown result type (might be due to invalid IL or missing references) pos = Vector3.zero; if (peer == null || ZDOMan.instance == null) { return false; } try { ZDOID characterID = peer.m_characterID; if (((ZDOID)(ref characterID)).Equals(default(ZDOID))) { return false; } ZDO zDO = ZDOMan.instance.GetZDO(characterID); if (zDO == null) { return false; } pos = zDO.GetPosition(); return true; } catch { return false; } } private static void Client_EnsureStatusEffectsRegistered_Throttled() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown try { if ((Object)ZNet.instance == (Object)null || (ZNet.instance.IsServer() && IsDedicatedServer())) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (realtimeSinceStartup < _clientEnsureSeNextTry) { return; } ObjectDB instance = ObjectDB.instance; if ((Object)instance == (Object)null || instance.m_StatusEffects == null) { _clientEnsureSeNextTry = realtimeSinceStartup + 1.5f; return; } int num = MaxTierClamped(); if (FamilySeNames == null || FamilySeNames.Length != num || MourningSeNames == null || MourningSeNames.Length != num) { BuildSeArrays(); } StatusEffect val = FindStatusEffectByNameOrHash(instance, FamilySeNames[0], _familySeHashes[0]); StatusEffect val2 = FindStatusEffectByNameOrHash(instance, MourningSeNames[0], _mourningSeHashes[0]); if ((Object)val == (Object)null || (Object)val2 == (Object)null) { TryRegisterStatusEffects(instance); val = FindStatusEffectByNameOrHash(instance, FamilySeNames[0], _familySeHashes[0]); val2 = FindStatusEffectByNameOrHash(instance, MourningSeNames[0], _mourningSeHashes[0]); if ((Object)val != (Object)null && (Object)val2 != (Object)null) { _clientSeEnsured = true; _clientEnsureSeNextTry = realtimeSinceStartup + 10f; } else { _clientEnsureSeNextTry = realtimeSinceStartup + 1.5f; } } else { _clientSeEnsured = true; _clientEnsureSeNextTry = realtimeSinceStartup + 10f; } } catch { } } private static void Client_ClearMourning() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)localPlayer == (Object)null) { return; } SEMan sEMan = ((Character)localPlayer).GetSEMan(); if (sEMan == null) { return; } int num = MaxTierClamped(); for (int i = 0; i < num; i++) { if (sEMan.HaveStatusEffect(_mourningSeHashes[i])) { sEMan.RemoveStatusEffect(_mourningSeHashes[i], true); } } } private static void Client_EnsureMourningTierSe() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)localPlayer == (Object)null) { return; } SEMan sEMan = ((Character)localPlayer).GetSEMan(); if (sEMan == null) { return; } int num = MaxTierClamped(); for (int i = 0; i < num; i++) { if (sEMan.HaveStatusEffect(_mourningSeHashes[i])) { sEMan.RemoveStatusEffect(_mourningSeHashes[i], true); } } int num2 = Mathf.Clamp(_clientMourningTier, 1, num) - 1; if (!sEMan.HaveStatusEffect(_mourningSeHashes[num2])) { sEMan.AddStatusEffect(_mourningSeHashes[num2], true, 0, 0f); } } private static void Client_UpdateActiveFamilyTooltipForTier(int tier) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown try { if ((Object)Player.m_localPlayer == (Object)null) { return; } SEMan sEMan = ((Character)Player.m_localPlayer).GetSEMan(); if (sEMan != null) { int num = MaxTierClamped(); int num2 = Mathf.Clamp(tier, 1, num); StatusEffect statusEffect = sEMan.GetStatusEffect(_familySeHashes[num2 - 1]); if (!((Object)statusEffect == (Object)null)) { float tierBonus = GetTierBonus(num2); statusEffect.m_tooltip = BuildFamilyTooltip(num2, tierBonus, _clientFamilyBondDays); statusEffect.m_icon = _familyIcon ?? GetPreferredFallbackIcon(); } } } catch { } } private static void Client_ApplyFamilyTierLocal(int tier) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Player localPlayer = Player.m_localPlayer; if ((Object)localPlayer == (Object)null) { return; } SEMan sEMan = ((Character)localPlayer).GetSEMan(); if (sEMan == null) { return; } int num = MaxTierClamped(); for (int i = 0; i < num; i++) { if (sEMan.HaveStatusEffect(_familySeHashes[i])) { sEMan.RemoveStatusEffect(_familySeHashes[i], true); } } if (tier >= 1 && tier <= num) { int num2 = tier - 1; if (!sEMan.HaveStatusEffect(_familySeHashes[num2])) { sEMan.AddStatusEffect(_familySeHashes[num2], true, 0, 0f); } Client_UpdateActiveFamilyTooltipForTier(tier); } } private static void Client_RefreshAllFamilyTooltips(float bondDays) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown if (!((Object)ObjectDB.instance == (Object)null) && ObjectDB.instance.m_StatusEffects != null) { int num = MaxTierClamped(); for (int i = 1; i <= num; i++) { Client_RefreshFamilyTooltipForTier(i, bondDays); } } } private static void Client_RefreshFamilyTooltipForTier(int tier, float bondDays) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown int num = MaxTierClamped(); if (tier >= 1 && tier <= num && !((Object)ObjectDB.instance == (Object)null)) { StatusEffect val = FindStatusEffectByNameOrHash(ObjectDB.instance, FamilySeNames[tier - 1], _familySeHashes[tier - 1]); if (!((Object)val == (Object)null)) { float tierBonus = GetTierBonus(tier); val.m_tooltip = BuildFamilyTooltip(tier, tierBonus, bondDays); val.m_icon = _familyIcon ?? GetPreferredFallbackIcon(); } } } private static void TryRegisterStatusEffects(ObjectDB odb) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown if (!((Object)odb == (Object)null) && odb.m_StatusEffects != null) { TryLoadIconsOnce(); int num = MaxTierClamped(); if (FamilySeNames == null || FamilySeNames.Length != num || MourningSeNames == null || MourningSeNames.Length != num) { BuildSeArrays(); } for (int i = 1; i <= num; i++) { EnsureFamilySe(odb, i); EnsureMourningSe(odb, i); } Client_RefreshAllFamilyTooltips(_clientFamilyBondDays); } } private static StatusEffect FindStatusEffectByNameOrHash(ObjectDB odb, string name, int hash) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown try { List<StatusEffect> statusEffects = odb.m_StatusEffects; for (int i = 0; i < statusEffects.Count; i++) { StatusEffect val = statusEffects[i]; if (!((Object)val == (Object)null)) { string text = ((Object)val).name ?? ""; if (!string.IsNullOrEmpty(text) && string.Equals(text, name, StringComparison.Ordinal)) { return val; } if (!string.IsNullOrEmpty(text) && text.GetStableHashCode() == hash) { return val; } } } } catch { } return null; } private static Sprite GetPreferredFallbackIcon() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown try { ObjectDB instance = ObjectDB.instance; if ((Object)instance == (Object)null || instance.m_StatusEffects == null) { return null; } string[] array = new string[8] { "SE_Rested", "Rested", "SE_Shelter", "Shelter", "SE_FeatherFall", "FeatherFall", "SE_SlowFall", "SlowFall" }; foreach (string value in array) { for (int j = 0; j < instance.m_StatusEffects.Count; j++) { StatusEffect val = instance.m_StatusEffects[j]; if (!((Object)val == (Object)null)) { string text = ((Object)val).name ?? ""; if (text.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0 && (Object)val.m_icon != (Object)null) { return val.m_icon; } } } } for (int k = 0; k < instance.m_StatusEffects.Count; k++) { StatusEffect val2 = instance.m_StatusEffects[k]; if ((Object)val2 != (Object)null && (Object)val2.m_icon != (Object)null) { return val2.m_icon; } } } catch { } return null; } private static void EnsureFamilySe(ObjectDB odb, int tier) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_00f0: 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) int num = MaxTierClamped(); if (tier < 1 || tier > num) { return; } string name = FamilySeNames[tier - 1]; int hash = _familySeHashes[tier - 1]; float tierBonus = GetTierBonus(tier); StatusEffect val = FindStatusEffectByNameOrHash(odb, name, hash); if ((Object)val != (Object)null) { val.m_name = "Family"; val.m_tooltip = BuildFamilyTooltip(tier, tierBonus, 0f); val.m_icon = _familyIcon ?? GetPreferredFallbackIcon(); if (val is SE_PX_FamilyTier sE_PX_FamilyTier) { sE_PX_FamilyTier.Tier = tier; } SE_Stats val2 = (SE_Stats)(object)((val is SE_Stats) ? val : null); if (val2 != null) { ApplyFamilyStats(val2, tierBonus); } } else { SE_PX_FamilyTier sE_PX_FamilyTier2 = ScriptableObject.CreateInstance<SE_PX_FamilyTier>(); ((Object)sE_PX_FamilyTier2).name = name; sE_PX_FamilyTier2.Tier = tier; ((StatusEffect)sE_PX_FamilyTier2).m_name = "Family"; ((StatusEffect)sE_PX_FamilyTier2).m_tooltip = BuildFamilyTooltip(tier, tierBonus, 0f); ((StatusEffect)sE_PX_FamilyTier2).m_icon = _familyIcon ?? GetPreferredFallbackIcon(); ((StatusEffect)sE_PX_FamilyTier2).m_startMessageType = (MessageType)1; ((StatusEffect)sE_PX_FamilyTier2).m_startMessage = ""; ((StatusEffect)sE_PX_FamilyTier2).m_stopMessageType = (MessageType)1; ((StatusEffect)sE_PX_FamilyTier2).m_stopMessage = ""; ApplyFamilyStats((SE_Stats)(object)sE_PX_FamilyTier2, tierBonus); odb.m_StatusEffects.Add((StatusEffect)(object)sE_PX_FamilyTier2); } } private static void EnsureMourningSe(ObjectDB odb, int tier) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_008f: Expected O, but got Unknown int num = MaxTierClamped(); if (tier < 1 || tier > num) { return; } string name = MourningSeNames[tier - 1]; int hash = _mourningSeHashes[tier - 1]; float mourningPenalty = GetMourningPenalty(tier); StatusEffect val = FindStatusEffectByNameOrHash(odb, name, hash); if ((Object)val != (Object)null) { val.m_name = "Mourning"; val.m_tooltip = BuildMourningTooltip(tier, mourningPenalty); if ((Object)_mourningIcon != (Object)null) { val.m_icon = _mourningIcon; } else if ((Object)val.m_icon == (Object)null) { val.m_icon = GetPreferredFallbackIcon(); } SE_Stats val2 = (SE_Stats)(object)((val is SE_Stats) ? val : null); if (val2 != null) { ApplyMourningStats(val2, mourningPenalty); } } else { SE_Stats val3 = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val3).name = name; ((StatusEffect)val3).m_name = "Mourning"; ((StatusEffect)val3).m_tooltip = BuildMourningTooltip(tier, mourningPenalty); ((StatusEffect)val3).m_icon = _mourningIcon ?? GetPreferredFallbackIcon(); ((StatusEffect)val3).m_startMessageType = (MessageType)1; ((StatusEffect)val3).m_startMessage = ""; ((StatusEffect)val3).m_stopMessageType = (MessageType)1; ((StatusEffect)val3).m_stopMessage = ""; ApplyMourningStats(val3, mourningPenalty); odb.m_StatusEffects.Add((StatusEffect)(object)val3); } } private static void ApplyFamilyStats(SE_Stats se, float bonus) { try { se.m_speedModifier = (_buffMove.Value ? bonus : 0f); se.m_damageModifier = (_buffDamage.Value ? bonus : 0f); se.m_staminaRegenMultiplier = (_buffStaminaRegen.Value ? (1f + bonus) : 1f); se.m_healthRegenMultiplier = (_buffHealthRegen.Value ? (1f + bonus) : 1f); se.m_eitrRegenMultiplier = (_buffEitrRegen.Value ? (1f + bonus) : 1f); } catch { } } private static void ApplyMourningStats(SE_Stats se, float penalty) { try { se.m_speedModifier = 0f - penalty; se.m_damageModifier = 0f - penalty; se.m_staminaRegenMultiplier = Mathf.Clamp(1f - penalty, 0.05f, 10f); se.m_healthRegenMultiplier = se.m_staminaRegenMultiplier; se.m_eitrRegenMultiplier = se.m_staminaRegenMultiplier; se.m_addMaxCarryWeight = _mourningCarryWeightPenalty.Value; } catch { } } private static ZNetPeer FindPeerByNameSmart(string input) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown input = NormalizePlayerNameInput(input); if (string.IsNullOrEmpty(input)) { return null; } List<ZNetPeer> list = (((Object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeers() : null); if (list == null) { return null; } for (int i = 0; i < list.Count; i++) { ZNetPeer val = list[i]; if (val != null && string.Equals(val.m_playerName ?? "", input, StringComparison.OrdinalIgnoreCase)) { return val; } } for (int j = 0; j < list.Count; j++) { ZNetPeer val2 = list[j]; if (val2 != null) { string text = val2.m_playerName ?? ""; if (text.StartsWith(input, StringComparison.OrdinalIgnoreCase)) { return val2; } } } ZNetPeer val3 = null; for (int k = 0; k < list.Count; k++) { ZNetPeer val4 = list[k]; if (val4 == null) { continue; } string text2 = val4.m_playerName ?? ""; if (text2.IndexOf(input, StringComparison.OrdinalIgnoreCase) >= 0) { if (val3 != null) { return null; } val3 = val4; } } return val3; } private static string NormalizePlayerNameInput(string s) { if (string.IsNullOrEmpty(s)) { return ""; } s = s.Trim(); while (s.Contains(" ")) { s = s.Replace(" ", " "); } return s; } private static void Client_PlayHeartsVfxAtPlayer() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) try { Player localPlayer = Player.m_localPlayer; if (!((Object)localPlayer == (Object)null)) { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("vfx_Potion_health_medium") : null); if (!((Object)val == (Object)null)) { Object.Instantiate<GameObject>(val, ((Component)localPlayer).transform.position + Vector3.up * 1.5f, Quaternion.identity); } } } catch { } } private static string GetRandomRejection() { try { if (RejectionLines == null || RejectionLines.Length == 0) { return "Declined."; } return RejectionLines[Random.Range(0, RejectionLines.Length)]; } catch { return "Declined."; } } private static int MaxTierClamped() { return 15; } private static void BuildSeArrays() { int num = MaxTierClamped(); FamilySeNames = new string[num]; _familySeHashes = new int[num]; for (int i = 0; i < num; i++) { FamilySeNames[i] = "SE_PX_Marriage_Family_" + (i + 1).ToString(CultureInfo.InvariantCulture); _familySeHashes[i] = FamilySeNames[i].GetStableHashCode(); } MourningSeNames = new string[num]; _mourningSeHashes = new int[num]; for (int j = 0; j < num; j++) { MourningSeNames[j] = "SE_PX_Marriage_Mourning_" + (j + 1).ToString(CultureInfo.InvariantCulture); _mourningSeHashes[j] = MourningSeNames[j].GetStableHashCode(); } } private static float GetTierThresholdDays(int tier) { tier = Mathf.Clamp(tier, 1, MaxTierClamped()); return tier switch { 1 => _tier1Days.Value, 2 => _tier2Days.Value, 3 =>