using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using System.Xml.Serialization; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Steamworks; using Steamworks.Data; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [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: AssemblyCompany("MuckReplayable")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MuckReplayable")] [assembly: AssemblyTitle("MuckReplayable")] [assembly: AssemblyVersion("1.0.0.0")] namespace MuckReforged; public sealed class AggroController : MonoBehaviour { private enum AggroState { Idle, Chasing, Searching, Returning } private Mob _mob; private Vector3 _homePosition; private Vector3 _lastSeenPosition; private int _currentPlayerId = -1; private float _lastSeenAt = float.NegativeInfinity; private float _farSince = -1f; private float _returnStartedAt = float.NegativeInfinity; private float _nextBlockingBuildScanAt; private Transform _cachedBlockingBuild; private int _lineOfSightFrame = -1; private int _lineOfSightPlayerId = -1; private bool _lineOfSightResult; private AggroState _state; private bool IsBoss { get { if ((Object)(object)_mob != (Object)null && (Object)(object)_mob.mobType != (Object)null) { return _mob.mobType.boss; } return false; } } private bool IsRanged { get { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 if ((Object)(object)_mob != (Object)null && (Object)(object)_mob.mobType != (Object)null) { if (!_mob.mobType.ranged) { return (int)_mob.mobType.behaviour == 2; } return true; } return false; } } private void Awake() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) _mob = ((Component)this).GetComponent(); _homePosition = ((Component)this).transform.position; _lastSeenPosition = _homePosition; _state = AggroState.Idle; } internal void MarkDamagedBy(int playerId) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (TryGetLivingPlayer(playerId, out var player)) { _currentPlayerId = playerId; _lastSeenPosition = ((Component)player).transform.position; _lastSeenAt = Time.time; _farSince = -1f; _state = AggroState.Chasing; SetPlayerTarget(player); } } internal Vector3 GetNextDestination() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) if ((Object)(object)_mob == (Object)null || (Object)(object)_mob.mobType == (Object)null) { return Vector3.zero; } if ((_mob.IsAttacking() && _mob.stopOnAttack) || _mob.knocked || !_mob.ready) { return Vector3.zero; } return (Vector3)(_state switch { AggroState.Idle => TickIdle(), AggroState.Chasing => TickChasing(), AggroState.Searching => TickSearching(), AggroState.Returning => TickReturning(), _ => Vector3.zero, }); } internal float GetNextThinkDelay() { float num; switch (_state) { case AggroState.Chasing: case AggroState.Searching: num = 0.5f; break; case AggroState.Returning: num = 1f; break; default: num = 0.75f; break; } return num + (float)Mathf.Abs(((Object)this).GetInstanceID() % 23) * 0.011f; } private Vector3 TickIdle() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) PlayerManager val = FindClosestVisiblePlayer(AcquireDistance()); if ((Object)(object)val == (Object)null) { ClearTarget(); return Vector3.zero; } BeginChasing(val); return DestinationFor(val); } private Vector3 TickChasing() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if (!TryGetLivingPlayer(_currentPlayerId, out var player)) { BeginReturning(); return _homePosition; } float num = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); float num2 = Vector3.Distance(_homePosition, ((Component)this).transform.position); if (num > DisengageDistance() || num2 > HomeLeashDistance()) { if (_farSince < 0f) { _farSince = Time.time; } else if (Time.time - _farSince >= Plugin.Settings.FarTargetGraceSeconds.Value) { BeginReturning(); return _homePosition; } } else { _farSince = -1f; } if (HasLineOfSight(player) || num <= Plugin.Settings.ProximityAcquireDistance.Value) { _lastSeenPosition = ((Component)player).transform.position; _lastSeenAt = Time.time; SetPlayerTarget(player); return DestinationFor(player); } _state = AggroState.Searching; ClearTarget(); return _lastSeenPosition; } private Vector3 TickSearching() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (TryGetLivingPlayer(_currentPlayerId, out var player)) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); if (num <= AcquireDistance() && (num <= Plugin.Settings.ProximityAcquireDistance.Value || HasLineOfSight(player))) { BeginChasing(player); return DestinationFor(player); } } if (Time.time - _lastSeenAt <= LostSightSeconds()) { ClearTarget(); return _lastSeenPosition; } BeginReturning(); return _homePosition; } private Vector3 TickReturning() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (Vector3.Distance(((Component)this).transform.position, _homePosition) <= Plugin.Settings.ReturnArrivalDistance.Value) { _state = AggroState.Idle; _currentPlayerId = -1; _farSince = -1f; ClearTarget(); if ((Object)(object)_mob.agent != (Object)null && _mob.agent.isOnNavMesh) { _mob.agent.ResetPath(); } return Vector3.zero; } if (Time.time - _returnStartedAt >= Plugin.Settings.ReturnReacquireCooldown.Value) { PlayerManager val = FindClosestVisiblePlayer(AcquireDistance()); if ((Object)(object)val != (Object)null && Vector3.Distance(_homePosition, ((Component)val).transform.position) <= HomeLeashDistance()) { BeginChasing(val); return DestinationFor(val); } } ClearTarget(); return _homePosition; } private void BeginChasing(PlayerManager player) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) _state = AggroState.Chasing; _currentPlayerId = player.id; _lastSeenPosition = ((Component)player).transform.position; _lastSeenAt = Time.time; _farSince = -1f; SetPlayerTarget(player); } private void BeginReturning() { _state = AggroState.Returning; _returnStartedAt = Time.time; _currentPlayerId = -1; _farSince = -1f; ClearTarget(); } private Vector3 DestinationFor(PlayerManager player) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Settings.AttackBlockingBuildings.Value && TryFindBlockingBuild(player, out var result)) { _mob.target = result; _mob.targetPlayerId = -1; return result.position; } SetPlayerTarget(player); float num = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); if (num <= 12f || _mob.mobType.followPlayerAccuracy >= 0.999f) { return ((Component)player).transform.position; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)); val *= num * (1f - _mob.mobType.followPlayerAccuracy); return ((Component)player).transform.position + val; } private bool TryFindBlockingBuild(PlayerManager player, out Transform result) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) result = null; if (_mob.mobType.ignoreBuilds || HasLineOfSight(player) || (Object)(object)ResourceManager.Instance == (Object)null || ResourceManager.Instance.builds == null) { _cachedBlockingBuild = null; return false; } float value = Plugin.Settings.BuildingAttackDistance.Value; if ((Object)(object)_cachedBlockingBuild != (Object)null) { Vector3 val = _cachedBlockingBuild.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude <= value * value) { result = _cachedBlockingBuild; return true; } _cachedBlockingBuild = null; } if (Time.time < _nextBlockingBuildScanAt) { return false; } _nextBlockingBuildScanAt = Time.time + 2.1f + (float)Mathf.Abs(((Object)this).GetInstanceID() % 29) * 0.037f; float num = value; Vector3 val2 = ((Component)player).transform.position - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; foreach (KeyValuePair build in ResourceManager.Instance.builds) { GameObject value2 = build.Value; if (!((Object)(object)value2 == (Object)null)) { Vector3 val3 = value2.transform.position - ((Component)this).transform.position; float magnitude = ((Vector3)(ref val3)).magnitude; if (!(magnitude >= num) && !(Vector3.Dot(normalized, ((Vector3)(ref val3)).normalized) < 0.35f)) { num = magnitude; result = value2.transform; } } } _cachedBlockingBuild = result; return (Object)(object)result != (Object)null; } private PlayerManager FindClosestVisiblePlayer(float maxDistance) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (GameManager.players == null) { return null; } PlayerManager result = null; float num = maxDistance; foreach (PlayerManager value in GameManager.players.Values) { if (!((Object)(object)value == (Object)null) && !value.dead && !value.disconnected) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)value).transform.position); if (!(num2 >= num) && (!(num2 > Plugin.Settings.ProximityAcquireDistance.Value) || HasLineOfSight(value))) { result = value; num = num2; } } } return result; } private bool HasLineOfSight(PlayerManager player) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } if (_lineOfSightFrame == Time.frameCount && _lineOfSightPlayerId == player.id) { return _lineOfSightResult; } Vector3 val = ((Component)this).transform.position + Vector3.up * 1.2f; Vector3 val2 = ((Component)player).transform.position + Vector3.up * 1.2f - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude <= 0.01f) { return CacheLineOfSight(player.id, result: true); } int num = -5; if ((Object)(object)MobManager.Instance != (Object)null && ((LayerMask)(ref MobManager.Instance.whatIsRaycastable)).value != 0) { num = ((LayerMask)(ref MobManager.Instance.whatIsRaycastable)).value; } RaycastHit val3 = default(RaycastHit); if (!Physics.Raycast(val, ((Vector3)(ref val2)).normalized, ref val3, magnitude + 0.5f, num, (QueryTriggerInteraction)1)) { return CacheLineOfSight(player.id, result: true); } PlayerManager componentInParent = ((Component)((RaycastHit)(ref val3)).transform).GetComponentInParent(); return CacheLineOfSight(player.id, (Object)(object)componentInParent == (Object)(object)player); } private bool CacheLineOfSight(int playerId, bool result) { _lineOfSightFrame = Time.frameCount; _lineOfSightPlayerId = playerId; _lineOfSightResult = result; return result; } private bool TryGetLivingPlayer(int playerId, out PlayerManager player) { player = null; if (playerId < 0 || GameManager.players == null || !GameManager.players.TryGetValue(playerId, out player)) { return false; } if ((Object)(object)player != (Object)null && !player.dead) { return !player.disconnected; } return false; } private void SetPlayerTarget(PlayerManager player) { _mob.target = ((Component)player).transform; _mob.targetPlayerId = player.id; } private void ClearTarget() { _mob.target = null; _mob.targetPlayerId = -1; } private float AcquireDistance() { if (IsBoss) { return Plugin.Settings.BossAcquireDistance.Value; } if (!IsRanged) { return Plugin.Settings.MeleeAcquireDistance.Value; } return Plugin.Settings.RangedAcquireDistance.Value; } private float DisengageDistance() { if (IsBoss) { return Plugin.Settings.BossDisengageDistance.Value; } if (!IsRanged) { return Plugin.Settings.MeleeDisengageDistance.Value; } return Plugin.Settings.RangedDisengageDistance.Value; } private float HomeLeashDistance() { if (IsBoss) { return Plugin.Settings.BossHomeLeash.Value; } if (!IsRanged) { return Plugin.Settings.MeleeHomeLeash.Value; } return Plugin.Settings.RangedHomeLeash.Value; } private float LostSightSeconds() { if (IsBoss) { return Plugin.Settings.BossLostSightSeconds.Value; } if (!IsRanged) { return Plugin.Settings.MeleeLostSightSeconds.Value; } return Plugin.Settings.RangedLostSightSeconds.Value; } } [HarmonyPatch(typeof(MobServerEnemy), "FindNextPosition")] internal static class MobServerEnemyFindNextPositionPatch { private static bool Prefix(MobServerEnemy __instance, ref Vector3 __result) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Settings.EnableAggro.Value) { return true; } AggroController aggroController = ((Component)__instance).GetComponent(); if ((Object)(object)aggroController == (Object)null) { aggroController = ((Component)__instance).gameObject.AddComponent(); } ((MonoBehaviour)__instance).Invoke("SyncFindNextPosition", aggroController.GetNextThinkDelay()); __result = aggroController.GetNextDestination(); return false; } } [HarmonyPatch(typeof(Hitable), "Damage")] internal static class HitableDamageAggroPatch { private static void Prefix(Hitable __instance, int newHp, int fromClient) { if (!Plugin.Settings.EnableAggro.Value || !LocalClient.serverOwner || newHp >= __instance.hp) { return; } HitableMob val = (HitableMob)(object)((__instance is HitableMob) ? __instance : null); if (!((Object)(object)val == (Object)null)) { AggroController aggroController = ((Component)val).GetComponent(); if ((Object)(object)aggroController == (Object)null) { aggroController = ((Component)val).gameObject.AddComponent(); } aggroController.MarkDamagedBy(fromClient); } } } [HarmonyPatch(typeof(Mob), "SetTarget")] internal static class MobSetTargetPatch { private static bool Prefix(Mob __instance, int targetId) { if ((Object)(object)__instance == (Object)null) { return false; } if ((Object)(object)__instance.agent != (Object)null && __instance.agent.isOnNavMesh && targetId >= 0 && GameManager.players != null && GameManager.players.TryGetValue(targetId, out var value) && (Object)(object)value != (Object)null) { __instance.targetPlayerId = targetId; __instance.target = ((Component)value).transform; return false; } __instance.targetPlayerId = -1; __instance.target = null; return false; } } internal static class ArtifactBalance { private static readonly FieldInfo JuiceSpeed = AccessTools.Field(typeof(PowerupInventory), "juiceSpeed"); internal static int Stacks(int[] powerups, string name) { if (powerups == null && (Object)(object)PowerupInventory.Instance != (Object)null) { powerups = (int[])AccessTools.Field(typeof(PowerupInventory), "powerups")?.GetValue(PowerupInventory.Instance); } if (powerups == null || ItemManager.Instance?.stringToPowerupId == null || !ItemManager.Instance.stringToPowerupId.TryGetValue(name, out var value) || value < 0 || value >= powerups.Length) { return 0; } return Mathf.Max(0, powerups[value]); } internal static float Curve(int stacks, float speed, float maximum) { return PowerupInventory.CumulativeDistribution(Mathf.Max(0, stacks), speed, maximum); } internal static float Defense(int stacks) { return Curve(stacks, 0.12f, 35f); } internal static float Dumbbell(int stacks) { return 1f + Curve(stacks, 0.07f, 1.5f); } internal static float Berserk(int stacks, float missingHp) { return 1f + Mathf.Clamp01(missingHp) * Curve(stacks, 0.22f, 1.4f); } internal static float Stamina(int stacks) { return 1f + Curve(stacks, 0.13f, 1.5f); } internal static float Healing(int stacks) { return Curve(stacks, 0.09f, 0.75f); } internal static float Resource(int stacks) { return 1f + Curve(stacks, 0.22f, 2.5f); } internal static float Loot(int stacks) { return 1f + Curve(stacks, 0.17f, 0.9f); } internal static float AttackSpeed(int stacks) { return 1f + Curve(stacks, 0.13f, 0.85f); } internal static float Hunger(int stacks) { return 1f - Curve(stacks, 0.16f, 0.65f); } internal static float Juice(int stacks) { return 1f + Curve(stacks, 0.3f, 0.6f); } internal static float Robin(int stacks) { return 1f + Curve(stacks, 0.12f, 1f); } internal static float Speed(int stacks) { return 1f + Curve(stacks, 0.12f, 0.65f); } internal static float Adrenaline(int stacks) { return 1f + Curve(stacks, 0.55f, 0.75f); } internal static float Crit(int stacks) { return 0.18f + Curve(stacks, 0.12f, 0.52f); } internal static float Jump(int stacks) { return 1f + Curve(stacks, 0.13f, 1.2f); } internal static float Wings(int stacks) { if (stacks > 0) { return 1f + Curve(stacks, 0.32f, 1.5f); } return 1f; } internal static float Lifesteal(int stacks) { return Curve(stacks, 0.11f, 0.35f); } internal static float KnockbackChance(int stacks) { return Curve(stacks, 0.2f, 0.65f); } internal static float SniperChance(int stacks) { if (stacks > 0) { return 0.05f + Curve(stacks, 0.13f, 0.23f); } return 0f; } internal static float SniperDamage(int stacks) { if (stacks > 0) { return 2.2f + Curve(stacks, 0.16f, 2.8f); } return 1f; } internal static float LightningChance(int stacks) { return Curve(stacks, 0.14f, 0.35f); } internal static float LightningDamage(int stacks) { return 2f + Curve(stacks, 0.14f, 0.75f); } internal static float Enforcer(int stacks, float speed) { if (stacks > 0) { return 1f + Curve(stacks, 0.3f, 1.2f) * Mathf.Clamp01(Mathf.Max(0f, speed) / 22f); } return 1f; } internal static int BonusHp(int stacks) { return Mathf.Max(0, stacks) * 8; } internal static int BonusShield(int stacks) { return Mathf.Max(0, stacks) * 8; } internal static float JuiceSpeedMultiplier(PowerupInventory instance) { if (!((Object)(object)instance != (Object)null) || !(JuiceSpeed != null)) { return 1f; } return Mathf.Max(1f, (float)JuiceSpeed.GetValue(instance)); } internal static float LowHpRatio() { PlayerStatus instance = PlayerStatus.Instance; if (!((Object)(object)instance == (Object)null) && instance.maxHp > 0) { return ((float)instance.maxHp - instance.hp) / (float)instance.maxHp; } return 0f; } } [HarmonyPatch(typeof(PowerupInventory), "GetDefenseMultiplier")] internal static class BalancedDefenseArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Defense(ArtifactBalance.Stacks(playerPowerups, "Danis Milk")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetStrengthMultiplier")] internal static class BalancedStrengthArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = 1.3f * ArtifactBalance.Dumbbell(ArtifactBalance.Stacks(playerPowerups, "Dumbbell")) * ArtifactBalance.Berserk(ArtifactBalance.Stacks(playerPowerups, "Berserk"), ArtifactBalance.LowHpRatio()); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetAttackSpeedMultiplier")] internal static class BalancedAttackSpeedArtifactPatch { private static bool Prefix(PowerupInventory __instance, int[] playerPowerups, ref float __result) { float num = (((Object)(object)PlayerStatus.Instance != (Object)null && PlayerStatus.Instance.adrenalineBoost) ? ArtifactBalance.Adrenaline(ArtifactBalance.Stacks(playerPowerups, "Adrenaline")) : 1f); __result = 1.5f * ArtifactBalance.AttackSpeed(ArtifactBalance.Stacks(playerPowerups, "Orange Juice")) * num * ArtifactBalance.JuiceSpeedMultiplier(__instance); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetStaminaMultiplier")] internal static class BalancedStaminaArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { float num = (((Object)(object)PlayerStatus.Instance != (Object)null && PlayerStatus.Instance.adrenalineBoost) ? ArtifactBalance.Adrenaline(ArtifactBalance.Stacks(playerPowerups, "Adrenaline")) : 1f); __result = ArtifactBalance.Stamina(ArtifactBalance.Stacks(playerPowerups, "Peanut Butter")) * num; return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetHealingMultiplier")] internal static class BalancedHealingArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Healing(ArtifactBalance.Stacks(playerPowerups, "Broccoli")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetResourceMultiplier")] internal static class BalancedResourceArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 __result = ArtifactBalance.Resource(ArtifactBalance.Stacks(playerPowerups, "Checkered Shirt")); if (GameManager.gameSettings != null && (int)GameManager.gameSettings.gameMode == 1) { __result += 1.25f; } return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetLootMultiplier")] internal static class BalancedLootArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Loot(ArtifactBalance.Stacks(playerPowerups, "Piggybank")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetSniperScopeMultiplier")] internal static class BalancedSniperArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { int num = ArtifactBalance.Stacks(playerPowerups, "Sniper Scope"); __result = ((num > 0 && Random.value < ArtifactBalance.SniperChance(num)) ? ArtifactBalance.SniperDamage(num) : 1f); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetSniperScopeDamageMultiplier")] internal static class BalancedSniperDamageArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.SniperDamage(ArtifactBalance.Stacks(playerPowerups, "Sniper Scope")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetLightningMultiplier")] internal static class BalancedLightningArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { int num = ArtifactBalance.Stacks(playerPowerups, "Knuts Hammer"); __result = ((num > 0 && Random.value < ArtifactBalance.LightningChance(num)) ? ArtifactBalance.LightningDamage(num) : (-1f)); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetHpMultiplier")] internal static class BalancedHpArtifactPatch { private static bool Prefix(int[] playerPowerups, ref int __result) { __result = ArtifactBalance.BonusHp(ArtifactBalance.Stacks(playerPowerups, "Red Pill")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetShield")] internal static class BalancedShieldArtifactPatch { private static bool Prefix(int[] playerPowerups, ref int __result) { __result = ArtifactBalance.BonusShield(ArtifactBalance.Stacks(playerPowerups, "Blue Pill")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetHungerMultiplier")] internal static class BalancedHungerArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Hunger(ArtifactBalance.Stacks(playerPowerups, "Spooo Bean")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetJuiceMultiplier")] internal static class BalancedJuiceArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Juice(ArtifactBalance.Stacks(playerPowerups, "Juice")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetRobinMultiplier")] internal static class BalancedRobinArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Robin(ArtifactBalance.Stacks(playerPowerups, "Robin Hood Hat")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetEnforcerMultiplier")] internal static class BalancedEnforcerArtifactPatch { private static bool Prefix(int[] playerPowerups, float speed, ref float __result) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) float num; if (!(speed >= 0f)) { PlayerMovement instance = PlayerMovement.Instance; if (instance == null) { num = 0f; } else { Vector3 velocity = instance.GetVelocity(); num = ((Vector3)(ref velocity)).magnitude; } } else { num = speed; } float speed2 = num; __result = ArtifactBalance.Enforcer(ArtifactBalance.Stacks(playerPowerups, "Enforcer"), speed2); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetSpeedMultiplier")] internal static class BalancedSpeedArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { float num = (((Object)(object)PlayerStatus.Instance != (Object)null && PlayerStatus.Instance.adrenalineBoost) ? ArtifactBalance.Adrenaline(ArtifactBalance.Stacks(playerPowerups, "Adrenaline")) : 1f); float num2 = PlayerStatus.Instance?.currentSpeedArmorMultiplier ?? 1f; __result = ArtifactBalance.Speed(ArtifactBalance.Stacks(playerPowerups, "Sneaker")) * num * num2; return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetAdrenalineBoost")] internal static class BalancedAdrenalineArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Adrenaline(ArtifactBalance.Stacks(playerPowerups, "Adrenaline")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetCritChance")] internal static class BalancedCritArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Crit(ArtifactBalance.Stacks(playerPowerups, "Horseshoe")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetJumpMultiplier")] internal static class BalancedJumpArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Jump(ArtifactBalance.Stacks(playerPowerups, "Jetpack")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetExtraJumps")] internal static class BalancedFrogArtifactPatch { private static bool Prefix(int[] playerPowerups, ref int __result) { __result = Mathf.Min(3, ArtifactBalance.Stacks(playerPowerups, "Janniks Frog")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetFallWingsMultiplier")] internal static class BalancedWingsArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Wings(ArtifactBalance.Stacks(playerPowerups, "Wings of Glory")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetKnockbackMultiplier")] internal static class BalancedBulldozerArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ((Random.value < ArtifactBalance.KnockbackChance(ArtifactBalance.Stacks(playerPowerups, "Bulldozer"))) ? 1f : 0f); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetLifestealMultiplier")] internal static class BalancedLifestealArtifactPatch { private static bool Prefix(int[] playerPowerups, ref float __result) { __result = ArtifactBalance.Lifesteal(ArtifactBalance.Stacks(playerPowerups, "Crimson Dagger")); return false; } } [HarmonyPatch(typeof(PowerupInventory), "GetMaxDraculaStacks")] internal static class BalancedDraculaCapPatch { private static bool Prefix(ref int __result) { __result = ArtifactBalance.Stacks(null, "Dracula") * 25; return false; } } internal sealed class ArtifactOffer { internal int ChestId; internal int PlayerId; internal int[] Choices; internal float ExpiresAt; } internal static class ArtifactChoiceService { private sealed class DeterministicRoll { private uint state; internal DeterministicRoll(int seed) { state = ((seed == 0) ? 2738958700u : ((uint)seed)); } internal uint Next() { state ^= state << 13; state ^= state >> 17; state ^= state << 5; return state; } internal int Range(int max) { if (max > 1) { return (int)(Next() % (uint)max); } return 0; } internal float NextFloat() { return (float)(Next() & 0xFFFFFF) / 16777216f; } } internal const int ChoicePacketId = 240; private static readonly Dictionary ServerOffers = new Dictionary(); private static readonly MethodInfo SendTcp = AccessTools.Method(typeof(ClientSend), "SendTCPData", (Type[])null, (Type[])null); private static readonly FieldInfo PowerupsField = AccessTools.Field(typeof(PowerupInventory), "powerups"); internal static int[] GenerateChoices(LootContainerInteract chest) { if ((Object)(object)chest == (Object)null || (Object)(object)ItemManager.Instance == (Object)null) { return Array.Empty(); } int[] array = GenerateChoices(chest.GetId(), chest.white, chest.blue, chest.gold); if (chest.testPowerup && (Object)(object)chest.powerupToTest != (Object)null && array.Length == 3 && ItemManager.Instance.allPowerups.ContainsKey(chest.powerupToTest.id)) { int id = chest.powerupToTest.id; int num = Array.IndexOf(array, id); if (num > 0) { array[num] = array[0]; } array[0] = id; } return array; } internal static int[] GenerateChoices(int chestId, float white, float blue, float gold) { Dictionary all = ItemManager.Instance?.allPowerups; if (all == null) { return Array.Empty(); } List list = (from pair in all where (Object)(object)pair.Value != (Object)null select pair.Key into value orderby value select value).ToList(); if (list.Count < 3) { return Array.Empty(); } List white2 = list.Where((int id) => (int)all[id].tier == 0).ToList(); List blue2 = list.Where((int id) => (int)all[id].tier == 1).ToList(); List orange = list.Where((int id) => (int)all[id].tier == 2).ToList(); DeterministicRoll deterministicRoll = new DeterministicRoll(GameManager.GetSeed() * 486187739 + chestId * 16777619 + 219671); List result = new List(3); for (int num = 0; num < 3; num++) { int num2 = -1; for (int num3 = 0; num3 < 20; num3++) { if (num2 >= 0 && !result.Contains(num2)) { break; } List list2 = PickTier(deterministicRoll, white2, blue2, orange, white, blue, gold); if (list2.Count > 0) { num2 = list2[deterministicRoll.Range(list2.Count)]; } } if (num2 < 0 || result.Contains(num2)) { num2 = list.First((int value) => !result.Contains(value)); } result.Add(num2); } return result.ToArray(); } private static List PickTier(DeterministicRoll random, List white, List blue, List orange, float whiteWeight, float blueWeight, float orangeWeight) { whiteWeight = ((white.Count > 0) ? Mathf.Max(0f, whiteWeight) : 0f); blueWeight = ((blue.Count > 0) ? Mathf.Max(0f, blueWeight) : 0f); orangeWeight = ((orange.Count > 0) ? Mathf.Max(0f, orangeWeight) : 0f); float num = whiteWeight + blueWeight + orangeWeight; if (num <= 0f) { whiteWeight = ((white.Count > 0) ? 1f : 0f); blueWeight = ((blue.Count > 0) ? 1f : 0f); orangeWeight = ((orange.Count > 0) ? 1f : 0f); num = whiteWeight + blueWeight + orangeWeight; } float num2 = random.NextFloat() * num; if (num2 < whiteWeight) { return white; } if (num2 < whiteWeight + blueWeight) { return blue; } return orange; } internal static bool RegisterServerOffer(LootContainerInteract chest, int fromClient) { if ((Object)(object)chest == (Object)null || fromClient < 0) { return false; } int[] array = GenerateChoices(chest); if (array.Length != 3) { return false; } long[] array2 = (from pair in ServerOffers where pair.Value.PlayerId == fromClient select pair.Key).ToArray(); foreach (long key in array2) { ServerOffers.Remove(key); } ArtifactOffer artifactOffer = new ArtifactOffer { ChestId = chest.GetId(), PlayerId = fromClient, Choices = array, ExpiresAt = Time.unscaledTime + 1800f }; ServerOffers[OfferKey(fromClient, artifactOffer.ChestId)] = artifactOffer; Plugin.Log.LogInfo((object)string.Format("Artifact offer chest={0}, player={1}, choices={2}", artifactOffer.ChestId, fromClient, string.Join(",", array))); return true; } internal static void Reset() { ServerOffers.Clear(); } internal static void ForgetPlayer(int playerId) { long[] array = (from pair in ServerOffers where pair.Value.PlayerId == playerId select pair.Key).ToArray(); foreach (long key in array) { ServerOffers.Remove(key); } } internal static void SubmitChoice(int chestId, int powerupId) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown if ((Object)(object)LocalClient.instance == (Object)null) { return; } if (LocalClient.serverOwner) { HandleChoice(LocalClient.instance.myId, chestId, powerupId); return; } try { Packet val = new Packet(240); try { val.Write(chestId); val.Write(powerupId); SendTcp?.Invoke(null, new object[1] { val }); } finally { ((IDisposable)val)?.Dispose(); } } catch (Exception ex) { Plugin.Log.LogError((object)("Could not send artifact choice: " + ex)); } } internal static void HandleChoicePacket(int fromClient, Packet packet) { try { HandleChoice(fromClient, packet.ReadInt(true), packet.ReadInt(true)); } catch (Exception ex) { Plugin.Log.LogWarning((object)$"Rejected malformed artifact choice from {fromClient}: {ex.Message}"); } } private static void HandleChoice(int fromClient, int chestId, int powerupId) { long key = OfferKey(fromClient, chestId); Client value2; Powerup value3; if (!ServerOffers.TryGetValue(key, out var value) || value.ExpiresAt < Time.unscaledTime || value.Choices == null || !value.Choices.Contains(powerupId)) { Plugin.Log.LogWarning((object)$"Rejected unoffered artifact {powerupId} from player {fromClient}, chest {chestId}"); ServerOffers.Remove(key); } else if (Server.clients == null || !Server.clients.TryGetValue(fromClient, out value2) || value2?.player == null || ItemManager.Instance?.allPowerups == null || !ItemManager.Instance.allPowerups.TryGetValue(powerupId, out value3)) { ServerOffers.Remove(key); } else { ServerOffers.Remove(key); Grant(fromClient, value2.player, value3); } } private static void Grant(int fromClient, Player serverPlayer, Powerup powerup) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) PlayerManager value; Vector3 val = ((GameManager.players != null && GameManager.players.TryGetValue(fromClient, out value) && (Object)(object)value != (Object)null) ? (((Component)value).transform.position + Vector3.up * 1.2f) : Vector3.zero); int nextId = ItemManager.Instance.GetNextId(); ItemManager.Instance.DropPowerupAtPosition(powerup.id, val, nextId); ServerSend.DropPowerupAtPosition(powerup.id, nextId, val); if (serverPlayer.powerups != null && powerup.id >= 0 && powerup.id < serverPlayer.powerups.Length) { serverPlayer.powerups[powerup.id]++; } if ((Object)(object)GameManager.instance != (Object)null) { GameManager.instance.powerupsPickedup = true; } if (serverPlayer.stats != null) { serverPlayer.stats.TryGetValue("Powerups", out var value2); serverPlayer.stats["Powerups"] = value2 + 1; } if ((Object)(object)LocalClient.instance != (Object)null && fromClient == LocalClient.instance.myId && (Object)(object)PowerupInventory.Instance != (Object)null) { PowerupInventory.Instance.AddPowerup(powerup.name, powerup.id, nextId); } ItemManager.Instance.PickupItem(nextId); ServerSend.PickupItem(fromClient, nextId); Plugin.Log.LogInfo((object)$"Granted chosen artifact {powerup.name} ({powerup.id}) to player {fromClient}"); } internal static int CurrentStacks(int powerupId) { if ((Object)(object)PowerupInventory.Instance == (Object)null || PowerupsField == null) { return 0; } int[] array = (int[])PowerupsField.GetValue(PowerupInventory.Instance); if (array == null || powerupId < 0 || powerupId >= array.Length) { return 0; } return array[powerupId]; } private static long OfferKey(int playerId, int chestId) { return ((long)playerId << 32) ^ (uint)chestId; } } internal sealed class ArtifactChoiceOverlay : MonoBehaviour { private static ArtifactChoiceOverlay instance; private int chestId; private Powerup[] choices; private CursorLockMode previousLock; private bool previousCursor; private bool previousInputActive; private bool inputCaptured; private GUIStyle titleStyle; private GUIStyle nameStyle; private GUIStyle bodyStyle; private GUIStyle tierStyle; internal static void Show(LootContainerInteract chest) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown if (!Plugin.Settings.EnableArtifactChoices.Value || (Object)(object)chest == (Object)null || (Object)(object)ItemManager.Instance == (Object)null) { return; } int[] array = ArtifactChoiceService.GenerateChoices(chest); if (array.Length != 3) { return; } if ((Object)(object)instance == (Object)null) { GameObject val = new GameObject("Muck Replayable Artifact Choice"); Object.DontDestroyOnLoad((Object)val); instance = val.AddComponent(); } Dictionary allPowerups = ItemManager.Instance.allPowerups; if (allPowerups == null) { return; } List list = new List(3); int[] array2 = array; foreach (int key in array2) { if (!allPowerups.TryGetValue(key, out var value) || (Object)(object)value == (Object)null) { return; } list.Add(value); } instance.Open(chest.GetId(), list.ToArray()); } private void Open(int id, Powerup[] offered) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (offered != null && offered.Length == 3 && !offered.Any((Powerup powerup) => (Object)(object)powerup == (Object)null)) { if (!inputCaptured) { previousLock = Cursor.lockState; previousCursor = Cursor.visible; previousInputActive = (Object)(object)PlayerInput.Instance != (Object)null && PlayerInput.Instance.active; inputCaptured = true; } chestId = id; choices = offered; if ((Object)(object)PlayerInput.Instance != (Object)null) { PlayerInput.Instance.active = false; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private void Update() { if (choices != null && (Object)(object)GameManager.instance == (Object)null) { Close(); } else if (choices != null && (Object)(object)PlayerInput.Instance != (Object)null && PlayerInput.Instance.active) { PlayerInput.Instance.active = false; } } private void OnGUI() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) if (choices != null && choices.Length == 3) { LocalizationService.ApplyGuiFont(); ReforgedGuiTheme.Ensure(); EnsureStyles(); GUI.depth = -2000; ReforgedGuiTheme.DrawDim(); float num = Mathf.Min((float)Screen.width * 0.9f, 1280f); float num2 = Mathf.Min((float)Screen.height * 0.78f, 690f); Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2); GUI.Box(val, GUIContent.none, ReforgedGuiTheme.Window); GUI.Label(new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).y + 18f, ((Rect)(ref val)).width - 48f, 44f), Header(), titleStyle); GUI.Label(new Rect(((Rect)(ref val)).x + 24f, ((Rect)(ref val)).y + 59f, ((Rect)(ref val)).width - 48f, 26f), Subtitle(), bodyStyle); float num3 = 14f; float num4 = (((Rect)(ref val)).width - 40f - num3 * 2f) / 3f; Rect card = default(Rect); for (int i = 0; i < 3; i++) { ((Rect)(ref card))..ctor(((Rect)(ref val)).x + 20f + (float)i * (num4 + num3), ((Rect)(ref val)).y + 92f, num4, ((Rect)(ref val)).height - 112f); DrawCard(card, choices[i]); } } } private void DrawCard(Rect card, Powerup powerup) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) Color outlineColor = powerup.GetOutlineColor(); ReforgedGuiTheme.DrawCard(card, (Color?)new Color(outlineColor.r * 0.35f + 0.65f, outlineColor.g * 0.35f + 0.65f, outlineColor.b * 0.35f + 0.65f, 1f)); GUI.Label(new Rect(((Rect)(ref card)).x + 12f, ((Rect)(ref card)).y + 8f, ((Rect)(ref card)).width - 24f, 24f), TierName(powerup.tier), tierStyle); float num = Mathf.Clamp(((Rect)(ref card)).height * 0.21f, 76f, 116f); Rect rect = default(Rect); ((Rect)(ref rect))..ctor(((Rect)(ref card)).x + (((Rect)(ref card)).width - num) * 0.5f, ((Rect)(ref card)).y + 36f, num, num); ReforgedGuiTheme.DrawCard(new Rect(((Rect)(ref rect)).x - 7f, ((Rect)(ref rect)).y - 7f, ((Rect)(ref rect)).width + 14f, ((Rect)(ref rect)).height + 14f)); DrawSprite(powerup.sprite, rect); float num2 = ((Rect)(ref rect)).yMax + 7f; GUI.Label(new Rect(((Rect)(ref card)).x + 12f, num2, ((Rect)(ref card)).width - 24f, 48f), ArtifactEffectFormatter.DisplayName(powerup.name), nameStyle); int num3 = ArtifactChoiceService.CurrentStacks(powerup.id); float num4 = num2 + 49f; GUI.Label(new Rect(((Rect)(ref card)).x + 16f, num4, ((Rect)(ref card)).width - 32f, 46f), StackLine(num3), bodyStyle); float num5 = num4 + 44f; GUI.Label(new Rect(((Rect)(ref card)).x + 16f, num5, ((Rect)(ref card)).width - 32f, 76f), ArtifactEffectFormatter.Describe(powerup.name, num3), bodyStyle); float num6 = ((Rect)(ref card)).yMax - 54f; float num7 = num5 + 76f; GUI.Label(new Rect(((Rect)(ref card)).x + 16f, num7, ((Rect)(ref card)).width - 32f, Mathf.Max(20f, num6 - num7 - 6f)), ArtifactEffectFormatter.Description(powerup.name, powerup.description), bodyStyle); if (GUI.Button(new Rect(((Rect)(ref card)).x + 18f, num6, ((Rect)(ref card)).width - 36f, 40f), ChooseText(), ReforgedGuiTheme.PrimaryButton)) { ArtifactChoiceService.SubmitChoice(chestId, powerup.id); Close(); } } private void Close() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) choices = null; if (inputCaptured) { if ((Object)(object)PlayerInput.Instance != (Object)null) { PlayerInput.Instance.active = previousInputActive; } Cursor.lockState = previousLock; Cursor.visible = previousCursor; inputCaptured = false; } } private void OnDestroy() { Close(); if ((Object)(object)instance == (Object)(object)this) { instance = null; } } private void EnsureStyles() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown if (titleStyle != null) { LocalizationService.ApplyGuiFont(titleStyle, nameStyle, bodyStyle, tierStyle); return; } ReforgedGuiTheme.Ensure(); titleStyle = new GUIStyle(ReforgedGuiTheme.Title) { alignment = (TextAnchor)4, fontSize = 28 }; nameStyle = new GUIStyle(ReforgedGuiTheme.Heading) { alignment = (TextAnchor)4, fontSize = 22 }; bodyStyle = new GUIStyle(ReforgedGuiTheme.Label) { alignment = (TextAnchor)1, fontSize = 15 }; tierStyle = new GUIStyle(ReforgedGuiTheme.Muted) { alignment = (TextAnchor)4, fontSize = 14, fontStyle = (FontStyle)1 }; LocalizationService.ApplyGuiFont(titleStyle, nameStyle, bodyStyle, tierStyle); } private static void DrawSprite(Sprite sprite, Rect rect) { //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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sprite == (Object)null) && !((Object)(object)sprite.texture == (Object)null)) { Rect textureRect = sprite.textureRect; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)sprite.texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)sprite.texture).height); GUI.DrawTextureWithTexCoords(rect, (Texture)(object)sprite.texture, val, true); } } private static string Header() { return LocalizationService.T("artifact_header"); } private static string Subtitle() { return LocalizationService.T("artifact_subtitle"); } private static string StackLine(int stacks) { return string.Format(LocalizationService.T("artifact_stack"), stacks, stacks + 1); } private static string ChooseText() { return LocalizationService.T("artifact_choose"); } private static string TierName(PowerTier tier) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)tier != 0) { if ((int)tier != 1) { return LocalizationService.T("tier_legendary"); } return LocalizationService.T("tier_rare"); } return LocalizationService.T("tier_common"); } } internal static class ArtifactEffectFormatter { internal static string DisplayName(string name) { return name ?? string.Empty; } internal static string Description(string name, string original) { return original ?? string.Empty; } internal static string Describe(string name, int current) { int num = current + 1; return name switch { "Red Pill" => $"Max HP: {100 + ArtifactBalance.BonusHp(current)} → {100 + ArtifactBalance.BonusHp(num)}", "Blue Pill" => $"Shield: {ArtifactBalance.BonusShield(current)} → {ArtifactBalance.BonusShield(num)}", "Dumbbell" => Bonus("Base damage", ArtifactBalance.Dumbbell(current), ArtifactBalance.Dumbbell(num)), "Peanut Butter" => Bonus("Stamina efficiency", ArtifactBalance.Stamina(current), ArtifactBalance.Stamina(num)), "Broccoli" => Percent("Healing factor", ArtifactBalance.Healing(current), ArtifactBalance.Healing(num)), "Dracula" => $"+1 max HP per kill · cap {current * 25} → {num * 25}", "Janniks Frog" => $"Extra jumps: {Mathf.Min(3, current)} → {Mathf.Min(3, num)} (cap 3)", "Berserk" => Bonus("Damage at 1 HP", ArtifactBalance.Berserk(current, 1f), ArtifactBalance.Berserk(num, 1f)), "Crimson Dagger" => Percent("Lifesteal", ArtifactBalance.Lifesteal(current), ArtifactBalance.Lifesteal(num)), "Horseshoe" => Percent("Critical chance", ArtifactBalance.Crit(current), ArtifactBalance.Crit(num)), "Orange Juice" => Bonus("Attack speed", ArtifactBalance.AttackSpeed(current), ArtifactBalance.AttackSpeed(num)), "Sneaker" => Bonus("Move speed", ArtifactBalance.Speed(current), ArtifactBalance.Speed(num)), "Piggybank" => Bonus("Bonus loot", ArtifactBalance.Loot(current), ArtifactBalance.Loot(num)), "Checkered Shirt" => Bonus("Resource yield", ArtifactBalance.Resource(current), ArtifactBalance.Resource(num)), "Spooo Bean" => Percent("Hunger drain reduction", 1f - ArtifactBalance.Hunger(current), 1f - ArtifactBalance.Hunger(num)), "Juice" => Bonus("Post-kill speed", ArtifactBalance.Juice(current), ArtifactBalance.Juice(num)), "Robin Hood Hat" => Bonus("Ranged damage", ArtifactBalance.Robin(current), ArtifactBalance.Robin(num)), "Jetpack" => Bonus("Jump height", ArtifactBalance.Jump(current), ArtifactBalance.Jump(num)), "Wings of Glory" => Bonus("Falling attack damage", ArtifactBalance.Wings(current), ArtifactBalance.Wings(num)), "Bulldozer" => Percent("Knockback chance", ArtifactBalance.KnockbackChance(current), ArtifactBalance.KnockbackChance(num)), "Adrenaline" => Bonus("Low-HP speed", ArtifactBalance.Adrenaline(current), ArtifactBalance.Adrenaline(num)), "Enforcer" => Bonus("Damage at full momentum", ArtifactBalance.Enforcer(current, 22f), ArtifactBalance.Enforcer(num, 22f)), "Danis Milk" => Value("Defense", ArtifactBalance.Defense(current), ArtifactBalance.Defense(num)), "Sniper Scope" => Percent("Snipe chance", ArtifactBalance.SniperChance(current), ArtifactBalance.SniperChance(num)) + "\n" + Value("Snipe damage", ArtifactBalance.SniperDamage(current), ArtifactBalance.SniperDamage(num), "x"), "Knuts Hammer" => Percent("Lightning chance", ArtifactBalance.LightningChance(current), ArtifactBalance.LightningChance(num)) + "\n" + Value("Lightning damage", ArtifactBalance.LightningDamage(current), ArtifactBalance.LightningDamage(num), "x"), _ => $"Effect stack {current} → {num}", }; } private static string Bonus(string label, float before, float after) { return $"{label}: +{Mathf.Max(0f, before - 1f) * 100f:0.#}% → +{Mathf.Max(0f, after - 1f) * 100f:0.#}%"; } private static string Percent(string label, float before, float after) { return $"{label}: {before * 100f:0.#}% → {after * 100f:0.#}%"; } private static string Value(string label, float before, float after, string suffix = "") { return $"{label}: {before:0.##}{suffix} → {after:0.##}{suffix}"; } } [HarmonyPatch(typeof(LootContainerInteract), "ServerExecute")] internal static class ThreeChoiceArtifactServerPatch { private static bool Prefix(LootContainerInteract __instance, int fromClient) { if (!Plugin.Settings.EnableArtifactChoices.Value || !LocalClient.serverOwner) { return true; } return !ArtifactChoiceService.RegisterServerOffer(__instance, fromClient); } } [HarmonyPatch(typeof(LootContainerInteract), "LocalExecute")] internal static class ThreeChoiceArtifactUiPatch { private static void Postfix(LootContainerInteract __instance) { ArtifactChoiceOverlay.Show(__instance); } } [HarmonyPatch(typeof(Server), "InitializeServerPackets")] internal static class ArtifactChoicePacketRegistrationPatch { private static void Postfix() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (Server.PacketHandlers != null) { Server.PacketHandlers[240] = new PacketHandler(ArtifactChoiceService.HandleChoicePacket); } } } [HarmonyPatch(typeof(GameManager), "Awake")] internal static class ResetArtifactOffersPatch { private static void Prefix() { ArtifactChoiceService.Reset(); } } [HarmonyPatch(typeof(ServerHandle), "DisconnectPlayer")] internal static class RemoveDisconnectedArtifactOffersPatch { private static void Prefix(int fromClient) { ArtifactChoiceService.ForgetPlayer(fromClient); } } internal static class BalanceCurves { internal static float EnemyHealth(Difficulty difficulty, int day) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) day = Mathf.Max(0, day); if (day > 20) { return EnemyHealthBeforeSoftCap(difficulty, 20) * (1f + PostTwentyGrowth(difficulty) * (float)(day - 20)); } return EnemyHealthBeforeSoftCap(difficulty, day); } internal static float EnemyDamage(Difficulty difficulty, int day) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) day = Mathf.Max(0, day); if (day > 20) { return EnemyDamageBeforeSoftCap(difficulty, 20) * (1f + PostTwentyGrowth(difficulty) * (float)(day - 20)); } return EnemyDamageBeforeSoftCap(difficulty, day); } internal static float ChestPriceCap(Difficulty difficulty) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)difficulty != 0) { if ((int)difficulty == 2) { return Plugin.Settings.GamerChestPriceCap.Value; } return Plugin.Settings.NormalChestPriceCap.Value; } return Plugin.Settings.EasyChestPriceCap.Value; } private static float EnemyHealthBeforeSoftCap(Difficulty difficulty, int day) { //IL_0003: 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_0008: Invalid comparison between Unknown and I4 float num = day; if ((int)difficulty != 0) { if ((int)difficulty == 2) { return 1.3f + 0.22f * num + 0.013f * num * num; } return 1.05f + 0.14f * num + 0.0048f * num * num; } return 0.9f + 0.1f * num + 0.0015f * num * num; } private static float EnemyDamageBeforeSoftCap(Difficulty difficulty, int day) { //IL_0003: 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_0008: Invalid comparison between Unknown and I4 float num = day; if ((int)difficulty != 0) { if ((int)difficulty == 2) { return 1.65f + 0.2f * num + 0.016f * num * num; } return 0.9f + 0.12f * num + 0.005f * num * num; } return 0.4f + 0.07f * num + 0.00075f * num * num; } private static float PostTwentyGrowth(Difficulty difficulty) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)difficulty != 0) { if ((int)difficulty == 2) { return 0.035f; } return 0.025f; } return 0.015f; } } [HarmonyPatch(typeof(PlayerMovement), "Awake")] internal static class PlayerMovementSpeedPatch { private static readonly FieldInfo MoveSpeed = AccessTools.Field(typeof(PlayerMovement), "moveSpeed"); private static readonly FieldInfo MaxWalkSpeed = AccessTools.Field(typeof(PlayerMovement), "maxWalkSpeed"); private static readonly FieldInfo MaxRunSpeed = AccessTools.Field(typeof(PlayerMovement), "maxRunSpeed"); private static readonly FieldInfo MaxSpeed = AccessTools.Field(typeof(PlayerMovement), "maxSpeed"); private static readonly FieldInfo SwimSpeed = AccessTools.Field(typeof(PlayerMovement), "swimSpeed"); private static void Postfix(PlayerMovement __instance) { if (!((Object)(object)__instance == (Object)null)) { float multiplier = Mathf.Clamp(Plugin.Settings.PlayerMoveSpeedMultiplier.Value, 0.5f, 3f); Scale(__instance, MoveSpeed, multiplier); Scale(__instance, MaxWalkSpeed, multiplier); Scale(__instance, MaxRunSpeed, multiplier); Scale(__instance, MaxSpeed, multiplier); Scale(__instance, SwimSpeed, multiplier); } } private static void Scale(PlayerMovement instance, FieldInfo field, float multiplier) { if (field != null) { field.SetValue(instance, (float)field.GetValue(instance) * multiplier); } } } [HarmonyPatch(typeof(PlayerStatus), "Awake")] internal static class StaminaEconomyPatch { private static readonly FieldInfo DrainRate = AccessTools.Field(typeof(PlayerStatus), "staminaDrainRate"); private static readonly FieldInfo JumpDrain = AccessTools.Field(typeof(PlayerStatus), "jumpDrain"); private static readonly FieldInfo RegenRate = AccessTools.Field(typeof(PlayerStatus), "staminaRegenRate"); private static readonly FieldInfo HungerDrainRate = AccessTools.Field(typeof(PlayerStatus), "hungerDrainRate"); private static void Postfix(PlayerStatus __instance) { if (!((Object)(object)__instance == (Object)null)) { float num = Mathf.Clamp(Plugin.Settings.StaminaDrainMultiplier.Value, 0f, 2f); if (DrainRate != null) { DrainRate.SetValue(__instance, (float)DrainRate.GetValue(__instance) * num); } if (JumpDrain != null) { JumpDrain.SetValue(__instance, (float)JumpDrain.GetValue(__instance) * Mathf.Clamp(Plugin.Settings.JumpStaminaMultiplier.Value, 0f, 2f)); } if (RegenRate != null) { RegenRate.SetValue(__instance, (float)RegenRate.GetValue(__instance) * Mathf.Clamp(Plugin.Settings.StaminaRegenMultiplier.Value, 0.1f, 5f)); } if (HungerDrainRate != null) { float num2 = Mathf.Clamp(Plugin.Settings.HungerDrainMultiplier.Value, 0f, 2f); HungerDrainRate.SetValue(__instance, (float)HungerDrainRate.GetValue(__instance) * num2); } } } } [HarmonyPatch(typeof(HitableResource), "Hit")] internal static class ResourceDamagePatch { private static bool Prefix(HitableResource __instance, ref int damage, int hitEffect, int hitWeaponType) { if (damage <= 0) { return true; } if (hitWeaponType != -1 && StructureUpgradeService.TryUseHammer(__instance)) { return false; } switch (hitWeaponType) { case -1: if ((((Object)(object)__instance != (Object)null && ResourceManager.Instance?.builds != null && ResourceManager.Instance.builds.ContainsKey(((Hitable)__instance).GetId())) || ((Object)(object)__instance != (Object)null && ((Component)((Component)__instance).transform.root).CompareTag("Build"))) && hitEffect != 1) { damage = Mathf.Max(1, Mathf.RoundToInt((float)damage * Mathf.Clamp(Plugin.Settings.BuildDamageMultiplier.Value, 0.05f, 1f))); } return true; case 1: return true; default: damage = Mathf.Max(1, Mathf.RoundToInt((float)damage * Plugin.Settings.ResourceDamageMultiplier.Value)); return true; } } } [HarmonyPatch(typeof(GameManager), "MobHpMultiplier")] internal static class MobHealthCurvePatch { private static void Postfix(GameManager __instance, ref float __result) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Settings.EnableDifficultyCurves.Value && GameManager.gameSettings != null) { __result = BalanceCurves.EnemyHealth(GameManager.gameSettings.difficulty, __instance.currentDay); } } } [HarmonyPatch(typeof(GameManager), "MobDamageMultiplier")] internal static class MobDamageCurvePatch { private static void Postfix(GameManager __instance, ref float __result) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Settings.EnableDifficultyCurves.Value && GameManager.gameSettings != null) { __result = BalanceCurves.EnemyDamage(GameManager.gameSettings.difficulty, __instance.currentDay); } } } [HarmonyPatch(typeof(GameManager), "ChestPriceMultiplier")] internal static class ChestPriceCapPatch { private static void Postfix(ref float __result) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Settings.EnableDifficultyCurves.Value && GameManager.gameSettings != null) { __result = Mathf.Min(__result, BalanceCurves.ChestPriceCap(GameManager.gameSettings.difficulty)); } } } [HarmonyPatch(typeof(GameSettings), "DayLength")] internal static class DayLengthPatch { private static void Postfix(GameSettings __instance, ref int __result) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if (!Plugin.Settings.EnableDifficultyCurves.Value) { return; } Difficulty difficulty = __instance.difficulty; if ((int)difficulty != 0) { if ((int)difficulty == 2) { __result = Mathf.RoundToInt((float)Plugin.Settings.GamerDayLength.Value * 1.3f); } else { __result = Mathf.RoundToInt((float)Plugin.Settings.NormalDayLength.Value * 1.3f); } } else { __result = Mathf.RoundToInt((float)Plugin.Settings.EasyDayLength.Value * 1.3f); } } } [HarmonyPatch(typeof(ItemManager), "InitAllItems")] internal static class ItemEconomyPatch { private static readonly HashSet PatchedItems = new HashSet(); private static readonly HashSet PatchedFuels = new HashSet(); private static void Postfix(ItemManager __instance) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Invalid comparison between Unknown and I4 if (__instance.allScriptableItems == null) { return; } InventoryItem[] allScriptableItems = __instance.allScriptableItems; foreach (InventoryItem val in allScriptableItems) { if (!((Object)(object)val == (Object)null) && PatchedItems.Add(((Object)val).GetInstanceID())) { if (val.stackable && (int)val.type == 0) { val.max = Mathf.Max(val.max, Plugin.Settings.MaterialStackSize.Value); } if (val.stackable && (int)val.tag == 8) { val.max = Mathf.Max(val.max, Plugin.Settings.ArrowStackSize.Value); } if (val.processable && val.processTime > 0f) { val.processTime = Mathf.Max(0.1f, val.processTime * Plugin.Settings.SmeltTimeMultiplier.Value); } if ((Object)(object)val.fuel != (Object)null && PatchedFuels.Add(((Object)val.fuel).GetInstanceID())) { val.fuel.maxUses = Mathf.Max(1, Mathf.RoundToInt((float)val.fuel.maxUses * Plugin.Settings.FuelUseMultiplier.Value)); } } } Plugin.Log.LogInfo((object)"Applied stack, smelting, and fuel economy changes."); } } internal static class BedRegistry { private const string AssetName = "MuckReplayable_Bed"; private static Mesh mesh; internal static InventoryItem Item { get; private set; } internal static void Install(ItemManager manager) { //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) if (manager?.allItems == null || manager.allScriptableItems == null) { return; } Item = ((IEnumerable)manager.allItems.Values).FirstOrDefault((Func)((InventoryItem value) => (Object)(object)value != (Object)null && ((Object)value).name == "MuckReplayable_Bed")); if ((Object)(object)Item != (Object)null) { return; } InventoryItem val = ((IEnumerable)manager.allItems.Values).FirstOrDefault((Func)((InventoryItem value) => (Object)(object)value != (Object)null && value.name == "Wood Floor")); InventoryItem val2 = ((IEnumerable)manager.allItems.Values).FirstOrDefault((Func)((InventoryItem value) => (Object)(object)value != (Object)null && value.name == "Wood")); InventoryItem val3 = ((IEnumerable)manager.allItems.Values).FirstOrDefault((Func)((InventoryItem value) => (Object)(object)value != (Object)null && value.name == "Workbench")); if ((Object)(object)val?.prefab == (Object)null || (Object)(object)val.material == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { Plugin.Log.LogWarning((object)"Bed registration skipped because a vanilla source asset was unavailable."); return; } mesh = (((Object)(object)mesh != (Object)null) ? mesh : CreateBedMesh()); InventoryItem val4 = ScriptableObject.CreateInstance(); ((Object)val4).name = "MuckReplayable_Bed"; val4.id = manager.allItems.Keys.Max() + 1; val4.name = "Bed"; val4.description = "Sleep at night. When every living player is in a bed, night passes seven times faster."; val4.type = (ItemType)0; val4.tag = (ItemTag)0; val4.tier = 1; val4.stackable = true; val4.max = 20; val4.amount = 1; val4.craftable = true; val4.craftAmount = 1; val4.stationRequirement = val3; val4.requirements = (CraftRequirement[])(object)new CraftRequirement[1] { new CraftRequirement { item = val2, amount = 15 } }; val4.mesh = mesh; val4.material = Object.Instantiate(val.material); ((Object)val4.material).name = "Muck Replayable Bed Material"; if (val4.material.HasProperty("_Color")) { val4.material.color = new Color(0.63f, 0.25f, 0.18f); } val4.sprite = CreateIcon(); val4.rotationOffset = new Vector3(12f, 35f, -8f); val4.positionOffset = new Vector3(-0.05f, -0.34f, 0.48f); val4.scale = 0.32f; val4.buildable = true; val4.grid = true; val4.buildRotation = val.buildRotation; val4.prefab = CreatePrefab(val.prefab, manager, val4.material); val4.attackTypes = Array.Empty(); Object.DontDestroyOnLoad((Object)(object)val4); Object.DontDestroyOnLoad((Object)(object)val4.material); manager.allItems[val4.id] = val4; manager.allScriptableItems = manager.allScriptableItems.Concat((IEnumerable)(object)new InventoryItem[1] { val4 }).ToArray(); Item = val4; Plugin.Log.LogInfo((object)$"Registered craftable Bed (item ID {val4.id})."); } internal static void InjectCrafting(CraftingUI crafting) { if ((Object)(object)Item == (Object)null || crafting?.tabs == null || ((object)OtherInput.Instance?.workbench != crafting && !crafting.tabs.Any((Tab tab) => (tab?.items ?? Array.Empty()).Any((InventoryItem value) => (Object)(object)value != (Object)null && value.name == "Wood Axe")))) { return; } for (int num = 0; num < crafting.tabs.Length; num++) { InventoryItem[] array = crafting.tabs[num]?.items ?? Array.Empty(); if (array.Any((InventoryItem value) => (Object)(object)value != (Object)null && value.name == "Wood Floor") && array.Any((InventoryItem value) => (Object)(object)value != (Object)null && (value.name == "Wood Wall" || value.name == "Workbench"))) { crafting.tabs[num].items = (from value in array.Concat((IEnumerable)(object)new InventoryItem[1] { Item }) where (Object)(object)value != (Object)null group value by value.id into @group select @group.First()).ToArray(); return; } } if (crafting.tabs.Length != 0) { int num2 = crafting.tabs.Length - 1; InventoryItem[] first = crafting.tabs[num2]?.items ?? Array.Empty(); crafting.tabs[num2].items = (from value in first.Concat((IEnumerable)(object)new InventoryItem[1] { Item }) where (Object)(object)value != (Object)null group value by value.id into @group select @group.First()).ToArray(); } } internal static bool IsCraftingReady() { if ((Object)(object)Item != (Object)null) { return Resources.FindObjectsOfTypeAll().Any((CraftingUI crafting) => (crafting?.tabs ?? Array.Empty()).Any(delegate(Tab tab) { InventoryItem[] source = tab?.items ?? Array.Empty(); return source.Any((InventoryItem value) => (Object)(object)value != (Object)null && value.id == Item.id) && source.Any((InventoryItem value) => (Object)(object)value != (Object)null && value.name == "Wood Floor"); })); } return false; } private static GameObject CreatePrefab(GameObject source, ItemManager manager, Material material) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(source); ((Object)val).name = "Muck Replayable Bed Prefab"; Renderer[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } GameObject val2 = new GameObject("Bed Visual"); val2.transform.SetParent(val.transform, false); val2.AddComponent().sharedMesh = mesh; ((Renderer)val2.AddComponent()).sharedMaterial = material; GameObject val3 = new GameObject("Bed Interaction"); val3.transform.SetParent(val.transform, false); val3.transform.localPosition = new Vector3(0f, 0.55f, 0f); BoxCollider obj = val3.AddComponent(); ((Collider)obj).isTrigger = true; obj.size = new Vector3(1.8f, 1.2f, 3.2f); InventoryItem? obj2 = ((IEnumerable)manager.allItems.Values).FirstOrDefault((Func)((InventoryItem value) => (Object)(object)value != (Object)null && value.name == "Chest")); object obj3; if (obj2 == null) { obj3 = null; } else { GameObject prefab = obj2.prefab; obj3 = ((prefab != null) ? prefab.GetComponentInChildren(true) : null); } ChestInteract val4 = (ChestInteract)obj3; val3.layer = (((Object)(object)val4 != (Object)null) ? ((Component)val4).gameObject.layer : val.layer); val3.AddComponent(); val.transform.position = Vector3.down * 10000f; val.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val); return val; } private static Mesh CreateBedMesh() { //IL_001d: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0103: Expected O, but got Unknown List list = new List(); List list2 = new List(); AddBox(list, list2, new Vector3(0f, 0.35f, 0f), new Vector3(1.8f, 0.35f, 3.2f)); AddBox(list, list2, new Vector3(0f, 0.72f, -1.32f), new Vector3(1.9f, 1.15f, 0.22f)); AddBox(list, list2, new Vector3(-0.72f, 0.12f, 0f), new Vector3(0.18f, 0.65f, 3.1f)); AddBox(list, list2, new Vector3(0.72f, 0.12f, 0f), new Vector3(0.18f, 0.65f, 3.1f)); Mesh val = new Mesh { name = "Muck Replayable Bed Mesh", vertices = list.ToArray(), triangles = list2.ToArray() }; val.RecalculateNormals(); val.RecalculateBounds(); Object.DontDestroyOnLoad((Object)val); return val; } private static void AddBox(List vertices, List triangles, Vector3 center, Vector3 size) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) int start = vertices.Count; Vector3 val = size * 0.5f; vertices.AddRange((IEnumerable)(object)new Vector3[8] { center + new Vector3(0f - val.x, 0f - val.y, 0f - val.z), center + new Vector3(val.x, 0f - val.y, 0f - val.z), center + new Vector3(val.x, val.y, 0f - val.z), center + new Vector3(0f - val.x, val.y, 0f - val.z), center + new Vector3(0f - val.x, 0f - val.y, val.z), center + new Vector3(val.x, 0f - val.y, val.z), center + new Vector3(val.x, val.y, val.z), center + new Vector3(0f - val.x, val.y, val.z) }); int[] source = new int[36] { 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 3, 7, 6, 3, 6, 2, 1, 2, 6, 1, 6, 5, 0, 4, 7, 0, 7, 3 }; triangles.AddRange(source.Select((int value) => start + value)); } private static Sprite CreateIcon() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { name = "Bed Icon", filterMode = (FilterMode)0 }; Color[] array = Enumerable.Repeat(Color.clear, 4096).ToArray(); for (int i = 16; i < 46; i++) { for (int j = 8; j < 56; j++) { array[i * 64 + j] = ((i > 38) ? new Color(0.34f, 0.18f, 0.09f) : new Color(0.75f, 0.24f, 0.18f)); } } for (int k = 38; k < 50; k++) { for (int l = 8; l < 20; l++) { array[k * 64 + l] = new Color(0.92f, 0.83f, 0.65f); } } val.SetPixels(array); val.Apply(false, true); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f); Object.DontDestroyOnLoad((Object)(object)val); Object.DontDestroyOnLoad((Object)(object)obj); return obj; } } internal sealed class BedInteract : MonoBehaviour, Interactable { public void Interact() { HitableResource componentInChildren = ((Component)((Component)this).transform.root).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { SleepService.RequestLocal(((Hitable)componentInChildren).GetId()); } } public void LocalExecute() { } public void AllExecute() { } public void ServerExecute(int fromClient = -1) { } public void RemoveObject() { } public string GetName() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!SleepService.IsNight) { return "Bed\n(Can only sleep at night)"; } return $"Sleep\n(Press \"{InputManager.interact}\")"; } public bool IsStarted() { return false; } } internal static class SleepService { internal const int RequestPacketId = 248; internal const int SyncPacketId = 249; private static readonly HashSet Sleeping = new HashSet(); private static readonly Dictionary Beds = new Dictionary(); private static readonly MethodInfo ClientSendTcp = AccessTools.Method(typeof(ClientSend), "SendTCPData", new Type[1] { typeof(Packet) }, (Type[])null); private static readonly MethodInfo ServerSendAll = AccessTools.Method(typeof(ServerSend), "SendTCPDataToAll", new Type[1] { typeof(Packet) }, (Type[])null); internal static bool IsNight { get { if (DayCycle.time > 0.5f) { return DayCycle.time < 0.99f; } return false; } } internal static bool LocalSleeping { get { if ((Object)(object)LocalClient.instance != (Object)null) { return Sleeping.Contains(LocalClient.instance.myId); } return false; } } internal static bool FastNight { get { if (!IsNight || GameManager.players == null) { return false; } int[] array = (from player in GameManager.players.Values where (Object)(object)player != (Object)null && !player.dead && !player.disconnected select player.id).ToArray(); if (array.Length != 0) { return array.All(Sleeping.Contains); } return false; } } internal static void Reset() { Sleeping.Clear(); Beds.Clear(); } internal static void RequestLocal(int bedId) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown if ((Object)(object)LocalClient.instance == (Object)null || (Object)(object)GameManager.instance == (Object)null) { return; } bool flag = !LocalSleeping; if (flag && !IsNight) { ReforgedRuntime.Instance?.Notify("Beds can only be used at night.", 3f); return; } if (LocalClient.serverOwner) { SetServer(LocalClient.instance.myId, bedId, flag); return; } Packet val = new Packet(248); try { val.Write(bedId); val.Write(flag); ClientSendTcp?.Invoke(null, new object[1] { val }); } finally { ((IDisposable)val)?.Dispose(); } } internal static void ReceiveRequest(int fromClient, Packet packet) { try { SetServer(fromClient, packet.ReadInt(true), packet.ReadBool(true)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Rejected bed request: " + ex.Message)); } } private static void SetServer(int playerId, int bedId, bool sleep) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (sleep) { if (!IsNight || !GameManager.players.TryGetValue(playerId, out var value) || (Object)(object)value == (Object)null || value.dead || ResourceManager.Instance?.list == null || !ResourceManager.Instance.list.TryGetValue(bedId, out var value2) || (Object)(object)value2.GetComponentInChildren() == (Object)null || Beds.Any((KeyValuePair pair) => pair.Key != playerId && pair.Value == bedId) || (Server.clients.TryGetValue(playerId, out var value3) && value3?.player != null && Vector3.Distance(value3.player.pos, value2.transform.position) > 8f)) { return; } Sleeping.Add(playerId); Beds[playerId] = bedId; } else { Sleeping.Remove(playerId); Beds.Remove(playerId); } Broadcast(playerId, bedId, sleep); } private static void Broadcast(int playerId, int bedId, bool sleeping) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Packet val = new Packet(249); try { val.Write(playerId); val.Write(bedId); val.Write(sleeping); ServerSendAll?.Invoke(null, new object[1] { val }); ApplyState(playerId, bedId, sleeping); } finally { ((IDisposable)val)?.Dispose(); } } internal static void ReceiveSync(Packet packet) { try { ApplyState(packet.ReadInt(true), packet.ReadInt(true), packet.ReadBool(true)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Rejected bed state: " + ex.Message)); } } private static void ApplyState(int playerId, int bedId, bool sleeping) { //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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if (sleeping) { Sleeping.Add(playerId); Beds[playerId] = bedId; } else { Sleeping.Remove(playerId); Beds.Remove(playerId); } if (sleeping && (Object)(object)LocalClient.instance != (Object)null && playerId == LocalClient.instance.myId && ResourceManager.Instance?.list != null && ResourceManager.Instance.list.TryGetValue(bedId, out var value) && (Object)(object)PlayerMovement.Instance != (Object)null) { ((Component)PlayerMovement.Instance).transform.position = value.transform.position + Vector3.up * 1.05f; PlayerMovement.Instance.GetRb().velocity = Vector3.zero; } } internal static void WakeLocal() { if (LocalSleeping && Beds.TryGetValue(LocalClient.instance.myId, out var value)) { RequestLocal(value); } } internal static void ValidateServerState() { if (!LocalClient.serverOwner) { return; } int[] array = Sleeping.ToArray(); foreach (int num in array) { if (!IsNight || !GameManager.players.TryGetValue(num, out var value) || !((Object)(object)value != (Object)null) || value.dead || !Beds.TryGetValue(num, out var value2) || ResourceManager.Instance?.list == null || !ResourceManager.Instance.list.ContainsKey(value2)) { SetServer(num, Beds.TryGetValue(num, out var value3) ? value3 : (-1), sleep: false); } } } internal static void ApplyRemotePose() { //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_0083: Unknown result type (might be due to invalid IL or missing references) if (GameManager.players == null) { return; } foreach (PlayerManager value in GameManager.players.Values) { if (!((Object)(object)value?.onlinePlayer?.upperBody == (Object)null)) { Vector3 localEulerAngles = value.onlinePlayer.upperBody.localEulerAngles; localEulerAngles.z = (Sleeping.Contains(value.id) ? 88f : 0f); value.onlinePlayer.upperBody.localEulerAngles = localEulerAngles; } } } } [DefaultExecutionOrder(11000)] internal sealed class SleepController : MonoBehaviour { private bool inputSuppressed; private float nextValidation; private void Update() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime >= nextValidation) { nextValidation = Time.unscaledTime + 0.25f; SleepService.ValidateServerState(); } bool localSleeping = SleepService.LocalSleeping; if (localSleeping && !inputSuppressed && (Object)(object)PlayerInput.Instance != (Object)null) { inputSuppressed = true; PlayerInput.Instance.active = false; ReforgedRuntime.Instance?.Notify("Sleeping… everyone asleep makes night pass ×7. Press E or a movement key to wake.", 5f); } if (localSleeping && (Input.GetKeyDown(InputManager.interact) || Input.GetKeyDown(InputManager.forward) || Input.GetKeyDown(InputManager.backwards) || Input.GetKeyDown(InputManager.left) || Input.GetKeyDown(InputManager.right) || Input.GetKeyDown(InputManager.jump))) { SleepService.WakeLocal(); } if (!localSleeping && inputSuppressed) { inputSuppressed = false; if ((Object)(object)PlayerInput.Instance != (Object)null) { PlayerInput.Instance.active = true; } } SleepService.ApplyRemotePose(); } private void LateUpdate() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (SleepService.LocalSleeping && !((Object)(object)MoveCamera.Instance == (Object)null)) { ((Component)MoveCamera.Instance).transform.position = ((Component)PlayerMovement.Instance).transform.position + Vector3.up * 0.65f; Transform transform = ((Component)MoveCamera.Instance).transform; transform.rotation *= Quaternion.Euler(0f, 0f, 78f); } } } [HarmonyPatch(typeof(Server), "InitializeServerPackets")] internal static class BedServerPacketPatch { private static void Postfix() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (Server.PacketHandlers != null) { Server.PacketHandlers[248] = new PacketHandler(SleepService.ReceiveRequest); } } } [HarmonyPatch(typeof(LocalClient), "InitializeClientData")] internal static class BedClientPacketPatch { private static void Postfix() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (LocalClient.packetHandlers != null) { LocalClient.packetHandlers[249] = new PacketHandler(SleepService.ReceiveSync); } } } [HarmonyPatch(typeof(BuildManager), "BuildItem")] internal static class ActivateBedBuildPatch { private static void Postfix(int itemID, GameObject __result) { if ((Object)(object)BedRegistry.Item != (Object)null && itemID == BedRegistry.Item.id && (Object)(object)__result != (Object)null) { __result.SetActive(true); } } } [HarmonyPatch(typeof(DayCycle), "Update")] internal static class SleepingNightSpeedPatch { private static void Prefix(DayCycle __instance, out float __state) { __state = __instance.timeSpeed; if (SleepService.FastNight) { __instance.timeSpeed *= 7f; } } private static void Postfix(DayCycle __instance, float __state) { __instance.timeSpeed = __state; } } [HarmonyPatch(typeof(PlayerStatus), "HandleDamage")] internal static class DamageWakesSleepingPlayerPatch { private static void Postfix() { SleepService.WakeLocal(); } } [HarmonyPatch(typeof(GameManager), "Awake")] internal static class SleepResetPatch { private static void Prefix() { SleepService.Reset(); } } [HarmonyPatch(typeof(UseInventory), "Use")] internal static class AttackStaminaPatch { private static readonly FieldInfo CurrentItem = AccessTools.Field(typeof(UseInventory), "currentItem"); private static readonly FieldInfo JumpDrain = AccessTools.Field(typeof(PlayerStatus), "jumpDrain"); private static void Prefix(UseInventory __instance) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 if (ShieldNetwork.LocalBlocking || (Object)(object)__instance == (Object)null || (Object)(object)PlayerStatus.Instance == (Object)null || CurrentItem == null || JumpDrain == null) { return; } object? value = CurrentItem.GetValue(__instance); InventoryItem val = (InventoryItem)((value is InventoryItem) ? value : null); if ((Object)(object)val == (Object)null || (int)val.tag == 2 || (Object)(object)OtherInput.Instance == (Object)null || OtherInput.Instance.IsAnyMenuOpen()) { return; } Animator animator = __instance.animator; if (!((Object)(object)animator == (Object)null) && animator.GetCurrentAnimatorClipInfo(0).Length != 0) { string name = ((Object)((AnimatorClipInfo)(ref animator.GetCurrentAnimatorClipInfo(0)[0])).clip).name; if (!name.Contains("Attack") && !name.Contains("Equip") && !name.Contains("Eat") && !name.Contains("Charge") && !name.Contains("Shoot")) { float num = Mathf.Max(0f, (float)JumpDrain.GetValue(PlayerStatus.Instance)); float num2 = (((Object)(object)PowerupInventory.Instance != (Object)null) ? Mathf.Max(0.1f, PowerupInventory.Instance.GetStaminaMultiplier((int[])null)) : 1f); PlayerStatus.Instance.stamina = Mathf.Max(0f, PlayerStatus.Instance.stamina - num / num2); StaminaRegenerationGate.MarkSpent(); } } } } [HarmonyPatch(typeof(DayCycle), "Awake")] internal static class NightLengthPatch { private static void Postfix(DayCycle __instance) { if ((Object)(object)__instance != (Object)null) { __instance.nightDuration *= 0.61538464f; } } } [HarmonyPatch(typeof(Mob), "SetSpeed")] internal static class FinalBossSpeedPatch { private static void Prefix(Mob __instance, ref float multiplier) { if (__instance is BobMob) { multiplier *= 1.2f; } } } [HarmonyPatch(typeof(MobServerDragon), "FindNodes")] internal static class FinalBossTravelPatch { private static void Postfix(ref List ___nodes) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (___nodes != null && !((Object)(object)Boat.Instance == (Object)null)) { Vector3 val = Boat.Instance.rbTransform.position + Vector3.up * 90f; for (int i = 0; i < ___nodes.Count; i++) { Vector3 val2 = ___nodes[i] - val; ___nodes[i] = val + new Vector3(val2.x * 1.85f, val2.y * 1.2f, val2.z * 1.85f); } } } } [HarmonyPatch(typeof(LaserTest), "DamageEffect")] internal static class GuardianLaserDamagePatch { private static bool Prefix(LaserTest __instance) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance?.damageFx == (Object)null || (Object)(object)__instance.hitParticles == (Object)null) { return false; } HitboxDamage[] componentsInChildren = Object.Instantiate(__instance.damageFx, __instance.hitParticles.position, __instance.hitParticles.rotation).GetComponentsInChildren(true); foreach (HitboxDamage val in componentsInChildren) { val.baseDamage = Mathf.Max(1, Mathf.RoundToInt((float)val.baseDamage * 0.5f)); } return false; } } [HarmonyPatch(typeof(GuardianSpikes), "Awake")] internal static class GuardianSpikeWarningPatch { private static void Postfix(ref EnemyAttackIndicator ___indicator) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)___indicator != (Object)null) { Transform transform = ((Component)___indicator).transform; transform.localScale *= 0.5f; } } } [HarmonyPatch(typeof(GuardianSpikes), "SpawnAttack")] internal static class GuardianSpikeRangePatch { private static bool Prefix(GuardianSpikes __instance) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) if ((Object)(object)__instance?.spikeAttack == (Object)null) { return false; } EnemyAttackIndicator value = Traverse.Create((object)__instance).Field("indicator").GetValue(); if ((Object)(object)value == (Object)null) { return false; } GameObject obj = Object.Instantiate(__instance.spikeAttack, ((Component)value).transform.position, __instance.spikeAttack.transform.rotation); Transform transform = obj.transform; transform.localScale *= 0.5f; HitboxDamage componentInChildren = obj.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)__instance.projectile != (Object)null) { componentInChildren.baseDamage = __instance.projectile.damage; } Object.Destroy((Object)(object)((Component)__instance).gameObject); return false; } } internal static class DetailedMapService { private sealed class LandmarkCandidate { internal string Key; internal string Label; internal string MarkerName; internal Transform Transform; internal Texture2D Texture; internal Color Color; internal float Scale; internal float DiscoveryRadius; } private static readonly List Landmarks = new List(); private static readonly Dictionary Candidates = new Dictionary(); private static readonly HashSet Discovered = new HashSet(StringComparer.Ordinal); private static Map landmarkMap; private static Texture2D detailedTexture; private static Texture2D caveMarkerTexture; private static Texture2D shipMarkerTexture; private static Texture2D villageMarkerTexture; private static Texture2D traderMarkerTexture; private static float nextDiscoveryScan; private static float nextVillageScan; private static int knownVillageCount = -1; private static int stableVillageScans; internal static void ApplyDetailedTexture(Map map) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)map == (Object)null || MapGenerator.Instance?.heightMap == null || (Object)(object)MapGenerator.Instance.textureData == (Object)null) { return; } try { int num = Mathf.Clamp(Plugin.Settings.DetailedMapResolution.Value, 512, 2048); float[,] heightMap = MapGenerator.Instance.heightMap; int length = heightMap.GetLength(0); int length2 = heightMap.GetLength(1); if (length < 2 || length2 < 2) { return; } Texture2D val = new Texture2D(num, num, (TextureFormat)4, true) { name = "Muck Replayable Detailed Map", filterMode = (FilterMode)2, wrapMode = (TextureWrapMode)1, anisoLevel = 4 }; Color[] array = (Color[])(object)new Color[num * num]; float[] array2 = new float[array.Length]; Vector3 val2 = new Vector3(-0.55f, 0.78f, 0.3f); Vector3 normalized = ((Vector3)(ref val2)).normalized; for (int i = 0; i < num; i++) { float num2 = (float)i / (float)(num - 1); float v = 1f - num2; for (int j = 0; j < num; j++) { float u = (float)j / (float)(num - 1); array2[i * num + j] = Sample(heightMap, length, length2, u, v); } } int num3 = Mathf.Max(1, Mathf.RoundToInt(((float)num - 1f) / ((float)length - 1f))); int num4 = Mathf.Max(1, Mathf.RoundToInt(((float)num - 1f) / ((float)length2 - 1f))); for (int k = 0; k < num; k++) { int num5 = Mathf.Max(0, k - num4); int num6 = Mathf.Min(num - 1, k + num4); for (int l = 0; l < num; l++) { int num7 = k * num + l; float num8 = array2[num7]; Color val3 = TextureGenerator.GetColor(num8, MapGenerator.Instance.textureData); int num9 = Mathf.Max(0, l - num3); int num10 = Mathf.Min(num - 1, l + num3); float num11 = array2[k * num + num9]; float num12 = array2[k * num + num10]; float num13 = array2[num5 * num + l]; float num14 = array2[num6 * num + l]; val2 = new Vector3((num11 - num12) * 18f, 2f, (num13 - num14) * 18f); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; float num15 = Mathf.Clamp(0.82f + Vector3.Dot(normalized2, normalized) * 0.24f, 0.68f, 1.14f); val3.r = Mathf.Clamp01(val3.r * num15); val3.g = Mathf.Clamp01(val3.g * num15); val3.b = Mathf.Clamp01(val3.b * num15); float num16 = Mathf.Abs(num12 - num11) + Mathf.Abs(num14 - num13); float num17 = Mathf.Abs(Mathf.Repeat(num8 * 28f, 1f) - 0.5f); if (num16 > 0.002f && num17 < 0.025f) { val3 = Color.Lerp(val3, Color.black, 0.12f); } array[num7] = val3; } } val.SetPixels(array); val.Apply(true, false); if ((Object)(object)map.mapTextureMaterial != (Object)null) { map.mapTextureMaterial.mainTexture = (Texture)(object)val; } if ((Object)(object)map.mapRender != (Object)null) { map.mapRender.texture = (Texture)(object)val; if ((Object)(object)map.mapTextureMaterial != (Object)null) { ((Graphic)map.mapRender).material = map.mapTextureMaterial; } } if ((Object)(object)detailedTexture != (Object)null) { Object.Destroy((Object)(object)detailedTexture); } detailedTexture = val; Plugin.Log.LogInfo((object)$"Generated detailed {num}x{num} map from {length}x{length2} terrain data."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Detailed map generation failed; keeping vanilla map: " + ex.Message)); } } internal static void RefreshLandmarks() { //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Settings.ShowMapLandmarks.Value || (Object)(object)Map.Instance == (Object)null || (Object)(object)Map.Instance.mapMarkerPrefab == (Object)null) { return; } Map instance = Map.Instance; if ((Object)(object)landmarkMap != (Object)(object)instance) { Landmarks.Clear(); landmarkMap = instance; } else { foreach (MapMarker landmark in Landmarks) { if (landmark != null && (Object)(object)landmark.marker != (Object)null && instance.mapMarkers.Contains(landmark)) { instance.RemoveMarker(landmark); } } Landmarks.Clear(); } EnsureMarkerTextures(); Candidates.Clear(); List list = (from value in (from value in CaveNetwork.Entrances.Concat(from cave in Object.FindObjectsOfType() where (Object)(object)cave != (Object)null select ((Component)cave).transform) where (Object)(object)value != (Object)null select value).Distinct() orderby value.position.x, value.position.z select value).ToList(); for (int num = 0; num < list.Count; num++) { string text = PositionKey("cave", list[num].position); if (Discovered.Contains("cave:" + num)) { Discovered.Add(text); } AddCandidate(new LandmarkCandidate { Key = text, Label = "Cave", MarkerName = "Muck Replayable Cave Marker", Transform = list[num], Texture = caveMarkerTexture, Color = new Color(0.45f, 0.88f, 1f, 1f), Scale = 0.72f, DiscoveryRadius = 72f }); } List list2 = FindVillages(); RegisterVillageCandidates(list2); knownVillageCount = list2.Count; stableVillageScans = 0; List list3 = (from @group in (from value in Object.FindObjectsOfType() where (Object)(object)value != (Object)null select ((Component)value).transform into value where (Object)(object)value != (Object)null select value).GroupBy((Func)((Transform value) => new Vector2Int(Mathf.RoundToInt(value.position.x / 5f), Mathf.RoundToInt(value.position.z / 5f)))) select @group.First() into value orderby value.position.x, value.position.z select value).ToList(); for (int num2 = 0; num2 < list3.Count; num2++) { AddCandidate(new LandmarkCandidate { Key = "trader:" + num2, Label = "Trader", MarkerName = "Muck Replayable Trader Marker", Transform = list3[num2], Texture = traderMarkerTexture, Color = new Color(0.38f, 1f, 0.62f, 1f), Scale = 0.66f, DiscoveryRadius = 82f }); } if ((Object)(object)Boat.Instance != (Object)null) { AddCandidate(new LandmarkCandidate { Key = "ship", Label = "Ship", MarkerName = "Muck Replayable Ship Marker", Transform = ((Component)Boat.Instance).transform, Texture = shipMarkerTexture, Color = new Color(1f, 0.78f, 0.22f, 1f), Scale = 0.82f, DiscoveryRadius = 145f }); } foreach (string item in Discovered) { AddMarkerFor(item); } } internal static void TickDiscovery() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Settings.ShowMapLandmarks.Value || Time.unscaledTime < nextDiscoveryScan || (Object)(object)PlayerMovement.Instance == (Object)null || (Object)(object)Map.Instance == (Object)null) { return; } nextDiscoveryScan = Time.unscaledTime + 0.5f; if (Candidates.Count == 0 || (Object)(object)landmarkMap != (Object)(object)Map.Instance) { RefreshLandmarks(); } if (Time.unscaledTime >= nextVillageScan) { nextVillageScan = Time.unscaledTime + 10f; List list = FindVillages(); if (list.Count != knownVillageCount) { knownVillageCount = list.Count; stableVillageScans = 0; RegisterVillageCandidates(list); } else if (++stableVillageScans >= 3) { nextVillageScan = float.PositiveInfinity; } } Vector3 position = ((Component)PlayerMovement.Instance).transform.position; foreach (LandmarkCandidate value in Candidates.Values) { if ((Object)(object)value.Transform == (Object)null || Discovered.Contains(value.Key)) { continue; } Vector3 val = value.Transform.position - position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude > value.DiscoveryRadius * value.DiscoveryRadius)) { Discovered.Add(value.Key); AddMarkerFor(value.Key); string text = value.Label + " discovered — it is now marked on the map."; StatusMessage instance = StatusMessage.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.status != (Object)null && (Object)(object)instance.statusText != (Object)null && (Object)(object)instance.status.transform.parent != (Object)null) { instance.DisplayMessage(text); } Plugin.Log.LogInfo((object)$"Landmark discovered: {value.Key} at {value.Transform.position}"); } } } internal static IEnumerable GetDiscoveredKeys() { return Discovered.ToArray(); } internal static void ImportDiscoveredKeys(IEnumerable keys) { Discovered.Clear(); if (keys != null) { foreach (string item in keys.Where((string value) => !string.IsNullOrWhiteSpace(value))) { Discovered.Add(item.Trim()); } } RefreshLandmarks(); } internal static void ResetLandmarks() { Landmarks.Clear(); Candidates.Clear(); Discovered.Clear(); landmarkMap = null; nextDiscoveryScan = 0f; nextVillageScan = 0f; knownVillageCount = -1; stableVillageScans = 0; if ((Object)(object)detailedTexture != (Object)null) { Object.Destroy((Object)(object)detailedTexture); detailedTexture = null; } } private static float Sample(float[,] heightMap, int width, int height, float u, float v) { float num = Mathf.Clamp01(u) * (float)(width - 1); float num2 = Mathf.Clamp01(v) * (float)(height - 1); int num3 = Mathf.FloorToInt(num); int num4 = Mathf.FloorToInt(num2); int num5 = Mathf.Min(num3 + 1, width - 1); int num6 = Mathf.Min(num4 + 1, height - 1); float num7 = num - (float)num3; float num8 = num2 - (float)num4; return Mathf.Lerp(Mathf.Lerp(heightMap[num3, num4], heightMap[num5, num4], num7), Mathf.Lerp(heightMap[num3, num6], heightMap[num5, num6], num7), num8); } private static void EnsureMarkerTextures() { if ((Object)(object)caveMarkerTexture == (Object)null) { caveMarkerTexture = CreateMarkerTexture("Muck Replayable Cave Icon", (float x, float y) => Mathf.Abs(x) + Mathf.Abs(y) <= 0.78f); } if ((Object)(object)shipMarkerTexture == (Object)null) { shipMarkerTexture = CreateMarkerTexture("Muck Replayable Ship Icon", (float x, float y) => y >= -0.65f && y <= 0.72f && Mathf.Abs(x) <= 0.75f - y * 0.45f); } if ((Object)(object)villageMarkerTexture == (Object)null) { villageMarkerTexture = CreateMarkerTexture("Muck Replayable Village Icon", (float x, float y) => (y >= -0.65f && y <= 0.15f && Mathf.Abs(x) <= 0.62f) || (y > 0.05f && y <= 0.72f && Mathf.Abs(x) + y * 0.82f <= 0.78f)); } if ((Object)(object)traderMarkerTexture == (Object)null) { traderMarkerTexture = CreateMarkerTexture("Muck Replayable Trader Icon", (float x, float y) => x * x + (y - 0.38f) * (y - 0.38f) <= 0.18f || (y >= -0.72f && y <= 0.12f && Mathf.Abs(x) <= 0.48f * (1f + y))); } } private static void AddCandidate(LandmarkCandidate candidate) { if (!((Object)(object)candidate?.Transform == (Object)null) && !string.IsNullOrEmpty(candidate.Key)) { Candidates[candidate.Key] = candidate; } } private static List FindVillages() { return (from value in (from value in Object.FindObjectsOfType() where (Object)(object)value != (Object)null select ((Component)value).transform into value where (Object)(object)value != (Object)null select value).Distinct() orderby value.position.x, value.position.z select value).ToList(); } private static void RegisterVillageCandidates(IReadOnlyList villages) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (villages == null) { return; } for (int i = 0; i < villages.Count; i++) { string text = PositionKey("village", villages[i].position); if (Discovered.Contains("village:" + i)) { Discovered.Add(text); } AddCandidate(new LandmarkCandidate { Key = text, Label = "Village", MarkerName = "Muck Replayable Village Marker", Transform = villages[i], Texture = villageMarkerTexture, Color = new Color(1f, 0.62f, 0.24f, 1f), Scale = 0.76f, DiscoveryRadius = 105f }); if (Discovered.Contains(text)) { AddMarkerFor(text); } } } private static string PositionKey(string kind, Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return $"{kind}:{Mathf.RoundToInt(position.x)}:{Mathf.RoundToInt(position.z)}"; } private static void AddMarkerFor(string key) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Map.Instance == (Object)null) && Candidates.TryGetValue(key, out var candidate) && !((Object)(object)candidate.Transform == (Object)null) && !Landmarks.Any((MapMarker value) => (Object)(object)value?.marker != (Object)null && ((Object)value.marker).name == candidate.MarkerName + " " + key)) { MapMarker val = Map.Instance.AddMarker(candidate.Transform, (MarkerType)3, (Texture)(object)candidate.Texture, candidate.Color, candidate.Label, candidate.Scale); ((Object)val.marker).name = candidate.MarkerName + " " + key; Landmarks.Add(val); } } private static Texture2D CreateMarkerTexture(string name, Func filled) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false) { name = name, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[1024]; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { float arg = (float)j / 31f * 2f - 1f; float arg2 = (float)i / 31f * 2f - 1f; array[i * 32 + j] = (filled(arg, arg2) ? Color.white : Color.clear); } } val.SetPixels(array); val.Apply(false, true); Object.DontDestroyOnLoad((Object)(object)val); return val; } } [HarmonyPatch(typeof(Map), "GenerateMap")] internal static class DetailedMapGenerationPatch { private static void Postfix(Map __instance) { DetailedMapService.ApplyDetailedTexture(__instance); DetailedMapService.RefreshLandmarks(); } } internal static class LocalizationService { private static readonly Dictionary Text = new Dictionary(StringComparer.OrdinalIgnoreCase) { ["title"] = "Muck Replayable", ["lobbies"] = "Lobbies", ["saves"] = "Saves", ["refresh"] = "Refresh", ["quick_join"] = "Quick Join", ["public_host"] = "Host Public", ["friends_host"] = "Host Friends", ["private_host"] = "Host Invite-only", ["join"] = "Join", ["players"] = "players", ["slot"] = "Slot", ["save_now"] = "Save now", ["continue"] = "Continue as host", ["empty"] = "Empty", ["close"] = "Close [F6]", ["saved"] = "Run saved", ["host_only"] = "Only the host can save the world", ["no_lobbies"] = "No compatible public lobbies", ["lobby_disabled"] = "Lobby browser is disabled in the config.", ["save_help"] = "F5: save active slot F9: continue active slot Autosave: {0}s", ["day"] = "Day", ["seed"] = "seed", ["lobby_refresh_failed"] = "Lobby refresh failed: ", ["lobby_created"] = "Lobby created.", ["lobby_create_failed"] = "Could not create lobby: ", ["creative_not_ready"] = "Creative flight is not ready yet.", ["creative_flight_enabled"] = "Creative flight enabled • WASD / Space / Ctrl • Shift to boost", ["creative_flight_disabled"] = "Creative flight disabled", ["creative_catalog_title"] = "Muck Replayable Creative Catalog", ["creative_hud_on"] = "Creative • F7 catalog • F8 flight\nF4 sort backpack • FLIGHT ON", ["creative_hud_off"] = "Creative • F7 catalog • F8 flight\nF4 sort backpack • Flight off", ["spectating"] = "Spectating: {0}", ["spectator_free_camera"] = "Free camera", ["spectator_free_controls"] = "WASD / Space / Ctrl move • Shift boost • F follow player", ["spectator_follow_controls"] = "LMB/RMB cycle • Wheel zoom • F free camera", ["catalog_items"] = "Items", ["catalog_artifacts"] = "Artifacts", ["catalog_close"] = "Close [F7]", ["catalog_search"] = "Search", ["catalog_spawn_hint"] = "Clicking an entry spawns a networked stack in front of your character.", ["sort_held"] = "Put down the held item before sorting.", ["sort_done"] = "Backpack sorted and partial stacks combined.", ["save_slot_invalid"] = "Save slot {0} is empty or unreadable.", ["save_world_loading"] = "The world is still loading; save again when play begins.", ["save_failed"] = "Save failed: {0}", ["load_timeout"] = "Load failed: the world did not finish initializing.", ["loaded_day_seed"] = "Loaded day {0} • seed {1}", ["load_partial_failed"] = "Load partially failed: {0}", ["save_slots_full"] = "All 24 world slots are occupied. Open Worlds and save over a world you no longer need.", ["leave_run_before_load"] = "Leave the current run before loading another save. Hot-loading would mix two world seeds.", ["steam_not_ready"] = "Steam manager is not ready.", ["saved_lobby_failed"] = "Could not create a lobby for the saved run.", ["saved_scene_not_ready"] = "The lobby scene is not ready; the saved run was not started.", ["saved_prepare_failed"] = "The saved run could not prepare its lobby.", ["saved_lobby_closed"] = "The lobby closed before the saved run could start.", ["lobby_vanilla"] = "This is a vanilla lobby. Disable Muck Replayable before joining it.", ["lobby_rules_mismatch"] = "Lobby rules do not match your Reforged config. Use the same world/gameplay settings as the host.", ["lobby_protocol_mismatch"] = "Incompatible Muck Replayable protocol: host {0}, local {1}", ["artifact_header"] = "Choose one artifact", ["artifact_subtitle"] = "You receive only the chosen artifact. Compare current stacks and the next effect.", ["artifact_stack"] = "Current {0} → After pick {1}", ["artifact_choose"] = "Choose this artifact", ["tier_common"] = "COMMON", ["tier_rare"] = "RARE", ["tier_legendary"] = "LEGENDARY" }; internal static string T(string key) { string text; if (!Text.TryGetValue(key ?? string.Empty, out var value)) { text = key; if (text == null) { return string.Empty; } } else { text = value; } return text; } internal static void ApplyGuiFont() { } internal static void ApplyGuiFont(params GUIStyle[] styles) { } } internal static class LateJoinService { internal enum LobbyAccess { Closed, Public, Private } internal const int BootstrapPacketId = 242; internal const int PlayerAddedPacketId = 243; private static readonly HashSet PendingPlayers = new HashSet(); private static readonly MethodInfo SendTcp = AccessTools.Method(typeof(ServerSend), "SendTCPData", new Type[2] { typeof(int), typeof(Packet) }, (Type[])null); internal static LobbyAccess Access { get; private set; } internal static bool IsPublic => Access == LobbyAccess.Public; internal static bool IsPrivate => Access == LobbyAccess.Private; internal static void Reset() { PendingPlayers.Clear(); Access = LobbyAccess.Closed; } internal static void OpenPublicGame(Lobby lobby) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (((Lobby)(ref lobby)).Id.Value != 0L && LocalClient.serverOwner) { ((Lobby)(ref lobby)).SetPublic(); ((Lobby)(ref lobby)).SetJoinable(true); LobbyMetadata.Apply(lobby); ((Lobby)(ref lobby)).SetData("MRInProgress", "1"); GameManager instance = GameManager.instance; ((Lobby)(ref lobby)).SetData("MRDay", ((instance != null) ? instance.currentDay : 0).ToString()); if (GameManager.gameSettings != null) { GameManager.gameSettings.multiplayer = (Multiplayer)1; } Time.timeScale = 1f; Access = LobbyAccess.Public; ReforgedRuntime.Instance?.Notify("This run is now public. Players can join it from Public Servers.", 6f); Plugin.Log.LogInfo((object)"Opened the active run to public late joining."); } } internal static void ClosePublicGame(Lobby lobby) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (((Lobby)(ref lobby)).Id.Value != 0L && LocalClient.serverOwner) { ((Lobby)(ref lobby)).SetJoinable(false); ((Lobby)(ref lobby)).SetFriendsOnly(); ((Lobby)(ref lobby)).SetData("MRInProgress", "0"); Access = LobbyAccess.Closed; ReforgedRuntime.Instance?.Notify("Public joining is closed. Current players stay connected.", 5f); Plugin.Log.LogInfo((object)"Closed public late joining for the active run."); } } internal static void OpenPrivateGame(Lobby lobby) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (((Lobby)(ref lobby)).Id.Value != 0L && LocalClient.serverOwner) { ((Lobby)(ref lobby)).SetPrivate(); ((Lobby)(ref lobby)).SetJoinable(true); LobbyMetadata.Apply(lobby); ((Lobby)(ref lobby)).SetData("MRInProgress", "1"); GameManager instance = GameManager.instance; ((Lobby)(ref lobby)).SetData("MRDay", ((instance != null) ? instance.currentDay : 0).ToString()); if (GameManager.gameSettings != null) { GameManager.gameSettings.multiplayer = (Multiplayer)1; } Time.timeScale = 1f; Access = LobbyAccess.Private; ReforgedRuntime.Instance?.Notify("This run is now private. Invite players through Steam.", 6f); Plugin.Log.LogInfo((object)"Opened the active run for private invited late joining."); } } internal static bool HandleMemberJoined(Lobby lobby, Friend friend) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (!LocalClient.serverOwner || (Object)(object)GameManager.instance == (Object)null || (int)GameManager.state != 1 || ((Lobby)(ref lobby)).GetData("MRInProgress") != "1" || (Object)(object)SteamManager.Instance == (Object)null) { return false; } if (friend.Id.Value == SteamManager.Instance.PlayerSteamId.Value) { return true; } try { SteamManager.Instance.LobbyPartner = friend; SteamManager.Instance.lobbyOwnerSteamId = ((Lobby)(ref lobby)).Owner.Id; AccessTools.Method(typeof(SteamManager), "AcceptP2P", (Type[])null, (Type[])null)?.Invoke(SteamManager.Instance, new object[1] { friend.Id }); if (!SteamLobby.steamIdToClientId.ContainsKey(friend.Id.Value)) { SteamLobby.Instance.AddPlayerToLobby(friend); } if (!SteamLobby.steamIdToClientId.TryGetValue(friend.Id.Value, out var value)) { return true; } PendingPlayers.Add(value); GameSettings gameSettings = GameManager.gameSettings; gameSettings.multiplayer = (Multiplayer)1; ServerSend.StartGame(value, gameSettings); Plugin.Log.LogInfo((object)$"Prepared in-progress join for {((Friend)(ref friend)).Name} as player {value}."); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not prepare late join: " + ex)); } return true; } internal static bool FinishLateJoin(int playerId) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) if (!PendingPlayers.Contains(playerId) || Server.clients == null || !Server.clients.TryGetValue(playerId, out var value) || value?.player == null) { return false; } try { value.player.ready = true; ServerSend.PlayerFinishedLoading(playerId); Vector3 val = (((Object)(object)PlayerMovement.Instance != (Object)null) ? (((Component)PlayerMovement.Instance).transform.position + ((Component)PlayerMovement.Instance).transform.right * 3f + Vector3.up) : (Vector3.up * 3f)); value.player.pos = val; if (GameManager.players != null && !GameManager.players.ContainsKey(playerId)) { GameManager.instance.SpawnPlayer(playerId, value.player.username, value.player.color, val, 0f); } foreach (Client value2 in Server.clients.Values) { if (value2?.player != null && value2.player.id != playerId && value2.player.id != LocalClient.instance.myId) { SendPlayerAdded(value2.player.id, value.player, val); } } SendBootstrap(playerId); SendMobSnapshot(playerId); StructureUpgradeService.SendSnapshot(playerId); ServerSend.SendChatMessage(-1, "Server", value.player.username + " joined the running world."); Plugin.Log.LogInfo((object)$"Completed in-progress join bootstrap for player {playerId}."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Late join bootstrap failed for player {playerId}: {arg}"); } finally { PendingPlayers.Remove(playerId); } return true; } private static void SendBootstrap(int toClient) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (SendTcp == null || Server.clients == null) { return; } Packet val = new Packet(242); try { List list = (from val3 in Server.clients.Values where val3?.player != null select val3.player).ToList(); val.Write(list.Count); foreach (Player item in list) { PlayerManager value; Vector3 val2 = ((GameManager.players != null && GameManager.players.TryGetValue(item.id, out value) && (Object)(object)value != (Object)null) ? ((Component)value).transform.position : item.pos); val.Write(item.id); val.Write(item.username ?? "Player"); val.Write(new Vector3(item.color.r, item.color.g, item.color.b)); val.Write(val2); val.Write(item.yOrientation); } GameManager instance = GameManager.instance; val.Write((instance != null) ? instance.currentDay : 0); val.Write(DayCycle.time); val.Write(RunSaveService.CaptureWorldSnapshotBase64()); SendTcp.Invoke(null, new object[2] { toClient, val }); } finally { ((IDisposable)val)?.Dispose(); } } private static void SendPlayerAdded(int toClient, Player player, Vector3 position) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (SendTcp == null || player == null) { return; } Packet val = new Packet(243); try { val.Write(player.id); val.Write(player.username ?? "Player"); val.Write(new Vector3(player.color.r, player.color.g, player.color.b)); val.Write(position); val.Write(player.yOrientation); SendTcp.Invoke(null, new object[2] { toClient, val }); } finally { ((IDisposable)val)?.Dispose(); } } private static void SendMobSnapshot(int toClient) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (SendTcp == null || MobManager.Instance?.mobs == null || MobSpawner.Instance?.allMobs == null) { return; } int num = 0; foreach (Mob item in MobManager.Instance.mobs.Values.Where((Mob value) => (Object)(object)value != (Object)null)) { int num2 = Array.IndexOf(MobSpawner.Instance.allMobs, item.mobType); if (num2 >= 0) { Guardian component = ((Component)item).GetComponent(); int num3 = ((!((Object)(object)component != (Object)null)) ? (-1) : ((int)component.type)); Packet val = new Packet(30); try { val.Write(((Component)item).transform.position); val.Write(num2); val.Write(item.id); val.Write(item.multiplier); val.Write(item.bossMultiplier); val.Write(num3); SendTcp.Invoke(null, new object[2] { toClient, val }); num++; } finally { ((IDisposable)val)?.Dispose(); } } } Plugin.Log.LogInfo((object)$"Sent {num} active mobs to late-joining player {toClient}."); } internal static void ReceiveBootstrap(Packet packet) { try { int num = Mathf.Clamp(packet.ReadInt(true), 1, SteamLobby.lobbySize); for (int i = 0; i < num; i++) { SpawnPacketPlayer(packet); } int num2 = Mathf.Max(0, packet.ReadInt(true)); float num3 = packet.ReadFloat(true); string encoded = packet.ReadString(true); if ((Object)(object)NetworkController.Instance != (Object)null) { NetworkController.Instance.nPlayers = num; } GameManager.instance.StartGame(); GameManager.instance.UpdateDay(num2); DayCycle.time = Mathf.Repeat(num3, 1f); ReforgedRuntime.Instance?.StartManagedCoroutine(RunSaveService.ApplyWorldSnapshotBase64(encoded)); } catch (Exception ex) { Plugin.Log.LogError((object)("Rejected late-join bootstrap: " + ex)); } } internal static void ReceivePlayerAdded(Packet packet) { try { SpawnPacketPlayer(packet); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Rejected late-join player packet: " + ex.Message)); } } private static void SpawnPacketPlayer(Packet packet) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) int num = packet.ReadInt(true); string text = packet.ReadString(true); Vector3 val = packet.ReadVector3(true); Vector3 val2 = packet.ReadVector3(true); float num2 = packet.ReadFloat(true); if (num >= 0 && num < SteamLobby.lobbySize && PacketSanitizer.ValidVector(val2)) { GameManager.instance.SpawnPlayer(num, text, new Color(val.x, val.y, val.z), val2, num2); } } } [HarmonyPatch(typeof(SteamManager), "OnLobbyMemberJoinedCallback")] internal static class RunningLobbyMemberJoinedPatch { private static bool Prefix(Lobby lobby, Friend friend) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return !LateJoinService.HandleMemberJoined(lobby, friend); } } [HarmonyPatch(typeof(ServerHandle), "PlayerFinishedLoading")] internal static class RunningLobbyFinishedLoadingPatch { private static bool Prefix(int fromClient) { return !LateJoinService.FinishLateJoin(fromClient); } } [HarmonyPatch(typeof(LocalClient), "InitializeClientData")] internal static class LateJoinPacketRegistrationPatch { private static void Postfix() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown if (LocalClient.packetHandlers != null) { LocalClient.packetHandlers[242] = new PacketHandler(LateJoinService.ReceiveBootstrap); LocalClient.packetHandlers[243] = new PacketHandler(LateJoinService.ReceivePlayerAdded); } } } [HarmonyPatch(typeof(GameManager), "Awake")] internal static class ResetLateJoinPatch { private static void Prefix() { LateJoinService.Reset(); } } internal static class LobbyMetadata { internal static string RulesSignature => string.Join(";", "art=" + Flag(Plugin.Settings.EnableArtifactChoices.Value), "mobs=3:" + Flag(Plugin.Settings.EnableNewMonsterTypes.Value), "shields=3", "beds=1", "creative=" + Flag(Plugin.Settings.EnableCreativeOverhaul.Value), "island=" + Flag(Plugin.Settings.EnableExpandedIsland.Value) + ":" + Plugin.Settings.IslandChunkSize.Value, "caves=" + Flag(Plugin.Settings.EnableCaveNetwork.Value) + ":" + Flag(Plugin.Settings.MoveOresIntoCaves.Value) + ":" + Plugin.Settings.CaveOreNodesPerTunnel.Value + ":" + Plugin.Settings.SurfaceOreNodeCount.Value, "curves=" + Flag(Plugin.Settings.EnableDifficultyCurves.Value), $"days={Plugin.Settings.EasyDayLength.Value},{Plugin.Settings.NormalDayLength.Value},{Plugin.Settings.GamerDayLength.Value}", "resource=" + Plugin.Settings.ResourceDamageMultiplier.Value.ToString("0.###", CultureInfo.InvariantCulture), "move=" + Plugin.Settings.PlayerMoveSpeedMultiplier.Value.ToString("0.###", CultureInfo.InvariantCulture), "stamina=" + Plugin.Settings.StaminaDrainMultiplier.Value.ToString("0.###", CultureInfo.InvariantCulture), "jump=" + Plugin.Settings.JumpStaminaMultiplier.Value.ToString("0.###", CultureInfo.InvariantCulture), "hunger=" + Plugin.Settings.HungerDrainMultiplier.Value.ToString("0.###", CultureInfo.InvariantCulture), "buildDamage=" + Plugin.Settings.BuildDamageMultiplier.Value.ToString("0.###", CultureInfo.InvariantCulture), $"economy={Plugin.Settings.MaterialStackSize.Value},{Plugin.Settings.ArrowStackSize.Value}," + Plugin.Settings.SmeltTimeMultiplier.Value.ToString("0.###", CultureInfo.InvariantCulture) + "," + Plugin.Settings.FuelUseMultiplier.Value.ToString("0.###", CultureInfo.InvariantCulture)); internal static void Apply(Lobby lobby) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (((Lobby)(ref lobby)).Id.Value != 0L) { ((Lobby)(ref lobby)).SetData("MRProtocol", "15"); ((Lobby)(ref lobby)).SetData("MRVersion", "0.9.4"); ((Lobby)(ref lobby)).SetData("MRRules", RulesSignature); SteamManager instance = SteamManager.Instance; ((Lobby)(ref lobby)).SetData("MRName", (((instance != null) ? instance.PlayerName : null) ?? "Muck") + " • Replayable"); ((Lobby)(ref lobby)).SetData("MRFeatures", "aggro,worlds,natural-caves,traders,armored-mobs,artifact-choice,late-join,upgrades,tiered-shields,beds,third-person,continue-after-victory"); ((Lobby)(ref lobby)).SetData("MRSave", (RunSaveService.Pending == null) ? "new" : "continue"); if ((Object)(object)GameManager.instance == (Object)null) { ((Lobby)(ref lobby)).SetData("MRInProgress", "0"); } ((Lobby)(ref lobby)).SetData("Version", Application.version + "-MR15"); } } private static string Flag(bool value) { if (!value) { return "0"; } return "1"; } } [HarmonyPatch(typeof(SteamManager), "OnLobbyCreatedCallback")] internal static class LobbyCreatedMetadataPatch { private static void Postfix(Result result, Lobby lobby) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) if ((int)result == 1) { LobbyMetadata.Apply(lobby); } } } [HarmonyPatch(typeof(SteamManager), "OnLobbyEnteredCallback")] internal static class LobbyCompatibilityPatch { private static bool Prefix(Lobby lobby) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) string data = ((Lobby)(ref lobby)).GetData("MRProtocol"); if (string.IsNullOrEmpty(data)) { Reject(lobby, LocalizationService.T("lobby_vanilla")); return false; } if (data == "15") { string data2 = ((Lobby)(ref lobby)).GetData("MRRules"); if (string.IsNullOrEmpty(data2) || data2 != LobbyMetadata.RulesSignature) { Reject(lobby, LocalizationService.T("lobby_rules_mismatch")); return false; } if (((Lobby)(ref lobby)).MemberCount < 1) { ((Lobby)(ref lobby)).Leave(); return false; } if (((Lobby)(ref lobby)).GetData("MRInProgress") == "1") { LocalClient.serverOwner = false; AccessTools.Field(typeof(SteamManager), "originalLobbyOwnerId")?.SetValue(SteamManager.Instance, ((Lobby)(ref lobby)).Owner.Id); AccessTools.Method(typeof(SteamManager), "AcceptP2P", (Type[])null, (Type[])null)?.Invoke(SteamManager.Instance, new object[1] { ((Lobby)(ref lobby)).Owner.Id }); ((Lobby)(ref lobby)).SendChatString("incoming player info"); ReforgedRuntime.Instance?.Notify("Joining running world...", 8f); return false; } LobbyVisuals.Instance.OpenLobby(lobby); LocalClient.serverOwner = false; AccessTools.Field(typeof(SteamManager), "originalLobbyOwnerId")?.SetValue(SteamManager.Instance, ((Lobby)(ref lobby)).Owner.Id); if (((Lobby)(ref lobby)).MemberCount != 1) { AccessTools.Method(typeof(SteamManager), "AcceptP2P", (Type[])null, (Type[])null)?.Invoke(SteamManager.Instance, new object[1] { ((Lobby)(ref lobby)).Owner.Id }); ((Lobby)(ref lobby)).SendChatString("incoming player info"); } return false; } Reject(lobby, string.Format(LocalizationService.T("lobby_protocol_mismatch"), data, "15")); return false; } private static void Reject(Lobby lobby, string message) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) ReforgedRuntime.Instance?.Notify(message, 8f); ((Lobby)(ref lobby)).Leave(); ReforgedRuntime.Instance?.StartManagedCoroutine(DeferredLeave(((Lobby)(ref lobby)).Id.Value)); } private static IEnumerator DeferredLeave(ulong rejectedLobbyId) { yield return null; if ((Object)(object)SteamManager.Instance != (Object)null && ((Lobby)(ref SteamManager.Instance.currentLobby)).Id.Value == rejectedLobbyId) { SteamManager.Instance.leaveLobby(); } } } [HarmonyPatch(typeof(SteamLobby), "MakeSettings")] internal static class SavedGameSettingsPatch { private static void Postfix(ref GameSettings __result) { RunSaveData pending = RunSaveService.Pending; if (pending != null) { __result.Seed = pending.Seed; __result.difficulty = (Difficulty)pending.Difficulty; __result.gameMode = (GameMode)pending.GameMode; __result.friendlyFire = (FriendlyFire)pending.FriendlyFire; return; } LobbySettings instance = LobbySettings.Instance; object value; if (instance == null) { value = null; } else { TMP_InputField seed = instance.seed; value = ((seed != null) ? seed.text : null); } if (string.IsNullOrWhiteSpace((string?)value)) { __result.Seed = NewWorldSeedService.Next(); } } } internal static class NewWorldSeedService { private static int counter = Environment.TickCount; internal static int Next() { byte[] value = Guid.NewGuid().ToByteArray(); int num = BitConverter.ToInt32(value, 0) ^ BitConverter.ToInt32(value, 4) ^ BitConverter.ToInt32(value, 8) ^ BitConverter.ToInt32(value, 12) ^ Interlocked.Increment(ref counter) ^ (int)DateTime.UtcNow.Ticks; if (num == 0) { num = 1; } Plugin.Log.LogInfo((object)$"Generated unique blank-seed world seed {num}."); return num; } } [HarmonyPatch(typeof(SteamLobby), "StartGame")] internal static class LobbyStartMetadataPatch { private static void Prefix() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SteamManager.Instance != (Object)null) { LobbyMetadata.Apply(SteamManager.Instance.currentLobby); } } } internal static class ReforgedModes { internal static bool Creative { get { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 if (Plugin.Settings != null && Plugin.Settings.EnableCreativeOverhaul.Value && GameManager.gameSettings != null && (int)GameManager.gameSettings.gameMode == 2) { return (int)GameManager.state == 1; } return false; } } } internal static class CreativeSpawnService { internal const int SpawnRequestPacketId = 242; private static readonly MethodInfo SendTcp = AccessTools.Method(typeof(ClientSend), "SendTCPData", (Type[])null, (Type[])null); private static readonly Dictionary LastRequest = new Dictionary(); internal static void Reset() { LastRequest.Clear(); } internal static void Request(bool powerup, int id) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (!ReforgedModes.Creative || (Object)(object)LocalClient.instance == (Object)null) { return; } if (LocalClient.serverOwner) { Spawn(LocalClient.instance.myId, powerup, id); return; } try { Packet val = new Packet(242); try { val.Write(powerup); val.Write(id); SendTcp?.Invoke(null, new object[1] { val }); } finally { ((IDisposable)val)?.Dispose(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not request Creative item: " + ex.Message)); } } internal static void Receive(int fromClient, Packet packet) { try { Spawn(fromClient, packet.ReadBool(true), packet.ReadInt(true)); } catch (Exception ex) { Plugin.Log.LogWarning((object)$"Rejected malformed Creative request from {fromClient}: {ex.Message}"); } } private static void Spawn(int fromClient, bool powerup, int id) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) if (!ReforgedModes.Creative || !InteractionGuard.TryPlayer(fromClient, out var player) || (Object)(object)ItemManager.Instance == (Object)null) { return; } float unscaledTime = Time.unscaledTime; if (LastRequest.TryGetValue(fromClient, out var value) && unscaledTime - value < 0.08f) { return; } LastRequest[fromClient] = unscaledTime; Vector3 val = ((Component)player).transform.position + Vector3.up * 1.4f + ((Component)player).transform.forward * 1.8f; if (!PacketSanitizer.ValidVector(val)) { return; } int nextId = ItemManager.Instance.GetNextId(); InventoryItem value2; if (powerup) { if (ItemManager.Instance.allPowerups != null && ItemManager.Instance.allPowerups.ContainsKey(id)) { ItemManager.Instance.DropPowerupAtPosition(id, val, nextId); ServerSend.DropPowerupAtPosition(id, nextId, val); } } else if (ItemManager.Instance.allItems != null && ItemManager.Instance.allItems.TryGetValue(id, out value2) && !((Object)(object)value2 == (Object)null)) { int num = ((!value2.stackable) ? 1 : Mathf.Max(1, value2.max)); ItemManager.Instance.DropItemAtPosition(id, num, val, nextId); ServerSend.DropItemAtPosition(id, num, nextId, val); } } } internal sealed class EnhancedModeController : MonoBehaviour { private Rect catalogWindow = new Rect(55f, 45f, 720f, 650f); private Vector2 catalogScroll; private string search = string.Empty; private bool catalogVisible; private bool powerupTab; private CursorLockMode previousLock; private bool previousCursor; private bool previousInputActive; private Rigidbody flightBody; private bool oldGravity; private float oldDrag; internal static EnhancedModeController Instance { get; private set; } internal static bool Flying { get; private set; } private void Awake() { Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void OnDestroy() { SetCatalog(value: false); SetFlight(value: false); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void Update() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 bool num = (Object)(object)GameManager.instance != (Object)null && (int)GameManager.state == 1; if (catalogVisible) { SetCatalog(value: false); } if (Flying) { SetFlight(value: false); } if (num && Input.GetKeyDown((KeyCode)285)) { InventorySorter.SortBackpack(); } } private static void KeepCreativeVitalsFull() { PlayerStatus instance = PlayerStatus.Instance; if (!((Object)(object)instance == (Object)null) && !instance.IsPlayerDead()) { instance.hp = instance.maxHp; instance.shield = instance.maxShield; instance.stamina = instance.maxStamina; instance.hunger = instance.maxHunger; } } private void SetCatalog(bool value) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (catalogVisible == value) { return; } if (value && Flying) { SetFlight(value: false); } catalogVisible = value; if (value) { previousLock = Cursor.lockState; previousCursor = Cursor.visible; previousInputActive = (Object)(object)PlayerInput.Instance != (Object)null && PlayerInput.Instance.active; if ((Object)(object)PlayerInput.Instance != (Object)null) { PlayerInput.Instance.active = false; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } else { if ((Object)(object)PlayerInput.Instance != (Object)null) { PlayerInput.Instance.active = previousInputActive; } Cursor.lockState = previousLock; Cursor.visible = previousCursor; } } private void SetFlight(bool value) { //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (Flying == value) { return; } if (value && ((Object)(object)PlayerMovement.Instance == (Object)null || (Object)(object)PlayerMovement.Instance.playerCam == (Object)null || (Object)(object)PlayerMovement.Instance.GetRb() == (Object)null)) { ReforgedRuntime.Instance?.Notify(LocalizationService.T("creative_not_ready")); return; } Flying = value; if (value) { flightBody = (((Object)(object)PlayerMovement.Instance != (Object)null) ? PlayerMovement.Instance.GetRb() : null); if ((Object)(object)flightBody != (Object)null) { oldGravity = flightBody.useGravity; oldDrag = flightBody.drag; flightBody.useGravity = false; flightBody.drag = 0f; flightBody.velocity = Vector3.zero; } ReforgedRuntime.Instance?.Notify(LocalizationService.T("creative_flight_enabled"), 5f); } else { if ((Object)(object)flightBody != (Object)null) { flightBody.useGravity = oldGravity; flightBody.drag = oldDrag; flightBody.velocity = Vector3.zero; } flightBody = null; if ((Object)(object)GameManager.instance != (Object)null) { ReforgedRuntime.Instance?.Notify(LocalizationService.T("creative_flight_disabled")); } } } private void UpdateFlight() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)flightBody == (Object)null || (Object)(object)PlayerMovement.Instance == (Object)null || (Object)(object)PlayerMovement.Instance.playerCam == (Object)null) { SetFlight(value: false); return; } Transform playerCam = PlayerMovement.Instance.playerCam; Vector3 val = Vector3.zero; if (Input.GetKey(InputManager.forward)) { val += playerCam.forward; } if (Input.GetKey(InputManager.backwards)) { val -= playerCam.forward; } if (Input.GetKey(InputManager.right)) { val += playerCam.right; } if (Input.GetKey(InputManager.left)) { val -= playerCam.right; } if (Input.GetKey(InputManager.jump)) { val += Vector3.up; } if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)99)) { val -= Vector3.up; } float num = (Input.GetKey(InputManager.sprint) ? 45f : 16f); flightBody.velocity = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? (((Vector3)(ref val)).normalized * num) : Vector3.zero); } private void OnGUI() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) LocalizationService.ApplyGuiFont(); ReforgedGuiTheme.Ensure(); if (Plugin.Settings.EnableEnhancedSpectator.Value && SpectatorFix.Active) { bool num = SpectatorFix.TargetName == "Free camera"; string arg = (num ? LocalizationService.T("spectator_free_camera") : SpectatorFix.TargetName); string text = LocalizationService.T(num ? "spectator_free_controls" : "spectator_follow_controls"); GUI.Box(new Rect(((float)Screen.width - 500f) * 0.5f, 12f, 500f, 54f), string.Format(LocalizationService.T("spectating"), arg) + "\n" + text, ReforgedGuiTheme.Hud); } } private void DrawCatalog(int id) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(22f, 12f, ((Rect)(ref catalogWindow)).width - 90f, 36f), LocalizationService.T("creative_catalog_title"), ReforgedGuiTheme.Title); if (GUI.Button(new Rect(((Rect)(ref catalogWindow)).width - 58f, 12f, 36f, 36f), "×", ReforgedGuiTheme.CloseButton)) { SetCatalog(value: false); return; } GUILayout.Space(52f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button(LocalizationService.T("catalog_items"), (!powerupTab) ? ReforgedGuiTheme.ActiveTab : ReforgedGuiTheme.Tab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) })) { powerupTab = false; } if (GUILayout.Button(LocalizationService.T("catalog_artifacts"), powerupTab ? ReforgedGuiTheme.ActiveTab : ReforgedGuiTheme.Tab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) })) { powerupTab = true; } GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(LocalizationService.T("catalog_search"), ReforgedGuiTheme.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(76f) }); search = GUILayout.TextField(search ?? string.Empty, ReforgedGuiTheme.Input, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }); GUILayout.EndHorizontal(); GUILayout.Label(LocalizationService.T("catalog_spawn_hint"), ReforgedGuiTheme.Muted, Array.Empty()); catalogScroll = GUILayout.BeginScrollView(catalogScroll, ReforgedGuiTheme.Card); if ((Object)(object)ItemManager.Instance != (Object)null) { if (powerupTab) { DrawPowerups(); } else { DrawItems(); } } GUILayout.EndScrollView(); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref catalogWindow)).width - 70f, 58f)); } private void DrawItems() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) IOrderedEnumerable orderedEnumerable = from item in ItemManager.Instance.allItems.Values where (Object)(object)item != (Object)null && Matches(item.name) orderby item.type, item.tier, item.name select item; int num = 0; foreach (InventoryItem item in orderedEnumerable) { if (num == 0) { GUILayout.BeginHorizontal(Array.Empty()); } string arg = (item.stackable ? $" ×{Mathf.Max(1, item.max)}" : string.Empty); if (GUILayout.Button($"{item.name}{arg} • {item.type}", ReforgedGuiTheme.CardButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(214f), GUILayout.Height(52f) })) { CreativeSpawnService.Request(powerup: false, item.id); } num++; if (num == 3) { GUILayout.EndHorizontal(); num = 0; } } if (num != 0) { GUILayout.EndHorizontal(); } } private void DrawPowerups() { //IL_0097: Unknown result type (might be due to invalid IL or missing references) IOrderedEnumerable orderedEnumerable = from powerup in ItemManager.Instance.allPowerups.Values where (Object)(object)powerup != (Object)null && Matches(powerup.name) orderby powerup.tier, powerup.name select powerup; int num = 0; foreach (Powerup item in orderedEnumerable) { if (num == 0) { GUILayout.BeginHorizontal(Array.Empty()); } if (GUILayout.Button(ArtifactEffectFormatter.DisplayName(item.name) + " • " + TierDisplay(item.tier), ReforgedGuiTheme.CardButton, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(214f), GUILayout.Height(52f) })) { CreativeSpawnService.Request(powerup: true, item.id); } num++; if (num == 3) { GUILayout.EndHorizontal(); num = 0; } } if (num != 0) { GUILayout.EndHorizontal(); } } private bool Matches(string value) { if (!string.IsNullOrWhiteSpace(search)) { return (value ?? string.Empty).IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static string TierDisplay(PowerTier tier) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)tier != 0) { if ((int)tier != 1) { return LocalizationService.T("tier_legendary"); } return LocalizationService.T("tier_rare"); } return LocalizationService.T("tier_common"); } } internal static class SpectatorFix { private static float orbitDistance = 8f; private static bool rotationReady; internal static string TargetName { get; private set; } = "Free camera"; internal static bool Active { get { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 if ((Object)(object)MoveCamera.Instance != (Object)null && (Object)(object)PlayerStatus.Instance != (Object)null && PlayerStatus.Instance.IsPlayerDead()) { if ((int)MoveCamera.Instance.state != 2) { return (int)MoveCamera.Instance.state == 3; } return true; } return false; } } internal static bool RotationReady { get { return rotationReady; } set { rotationReady = value; } } internal static float OrbitDistance { get { return orbitDistance; } set { orbitDistance = Mathf.Clamp(value, 3f, 18f); } } internal static void Reset() { orbitDistance = 8f; rotationReady = false; TargetName = "Free camera"; } internal static bool Valid(PlayerManager player) { if ((Object)(object)player != (Object)null && !player.dead && !player.disconnected && (Object)(object)((Component)player).gameObject != (Object)null) { return ((Component)player).gameObject.activeInHierarchy; } return false; } internal static PlayerManager Select(int currentId, int direction) { if (GameManager.players == null) { return null; } List list = (from player in GameManager.players.Values.Where(Valid) orderby player.id select player).ToList(); if (list.Count == 0) { return null; } int num = list.FindIndex((PlayerManager player) => player.id == currentId); if (num < 0) { if (direction >= 0) { return list[0]; } return list[list.Count - 1]; } num = (num + direction + list.Count) % list.Count; return list[num]; } internal static void SetTargetName(PlayerManager target) { TargetName = target?.username ?? "Free camera"; } } internal static class InventorySorter { internal static void SortBackpack() { InventoryUI instance = InventoryUI.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.inventoryParent == (Object)null || instance.HoldingItem()) { ReforgedRuntime.Instance?.Notify(LocalizationService.T("sort_held")); return; } InventoryCell[] array = (from cell in ((Component)instance.inventoryParent).GetComponentsInChildren(true) where (Object)(object)cell != (Object)null && (int)cell.cellType == 0 select cell).ToArray(); List list = (from cell in array where (Object)(object)cell.currentItem != (Object)null select cell.currentItem).ToList(); if (list.Count == 0) { return; } var list2 = (from item in list group item by item.id into @group select new { Prototype = @group.First(), Instances = @group.ToList(), Total = @group.Sum((InventoryItem item) => Mathf.Max(1, item.amount)) } into @group orderby @group.Prototype.type, @group.Prototype.tier descending, @group.Prototype.name select @group).ToList(); InventoryCell[] array2 = array; for (int num = 0; num < array2.Length; num++) { array2[num].currentItem = null; } int num2 = 0; foreach (var item in list2) { int num3 = item.Total; int num4 = ((!item.Prototype.stackable) ? 1 : Mathf.Max(1, item.Prototype.max)); int num5 = 0; while (num3 > 0 && num2 < array.Length) { InventoryItem val = item.Instances[num5++]; int num6 = Mathf.Min(num4, num3); val.Copy(item.Prototype, num6); array[num2++].currentItem = val; num3 -= num6; } } array2 = array; for (int num = 0; num < array2.Length; num++) { array2[num].UpdateCell(); } Hotbar instance2 = Hotbar.Instance; if (instance2 != null) { instance2.UpdateHotbar(); } ReforgedRuntime.Instance?.Notify(LocalizationService.T("sort_done")); } } [HarmonyPatch(typeof(Server), "InitializeServerPackets")] internal static class CreativePacketRegistrationPatch { private static void Postfix() { } } [HarmonyPatch(typeof(GameManager), "Awake")] internal static class ResetModeFixesPatch { private static void Prefix() { SpectatorFix.Reset(); } } [HarmonyPatch(typeof(PlayerStatus), "HandleDamage")] internal static class CreativeInvulnerabilityPatch { private static bool Prefix() { return true; } } [HarmonyPatch(typeof(ServerHandle), "PlayerHit")] internal static class CreativeServerInvulnerabilityPatch { private static bool Prefix() { return true; } } [HarmonyPatch(typeof(Hotbar), "UseItem")] internal static class CreativeInfiniteHeldItemsPatch { private static bool Prefix() { return true; } } [HarmonyPatch(typeof(InventoryUI), "GetMoney")] internal static class CreativeMoneyPatch { private static void Postfix(ref int __result) { } } [HarmonyPatch(typeof(InventoryUI), "UseMoney")] internal static class CreativeFreePurchasesPatch { private static bool Prefix() { return true; } } [HarmonyPatch(typeof(InventoryUI), "IsCraftable")] internal static class CreativeCraftablePatch { private static void Postfix(ref bool __result) { if (ReforgedModes.Creative) { __result = true; } } } [HarmonyPatch(typeof(InventoryUI), "HasItem")] internal static class CreativeHasItemPatch { private static void Postfix(ref bool __result) { if (ReforgedModes.Creative) { __result = true; } } } [HarmonyPatch(typeof(InventoryUI), "RemoveItem")] internal static class CreativeResourceConsumptionPatch { private static bool Prefix() { return !ReforgedModes.Creative; } } [HarmonyPatch(typeof(InventoryUI), "CanRepair")] internal static class CreativeCanRepairPatch { private static void Postfix(ref bool __result) { if (ReforgedModes.Creative) { __result = true; } } } [HarmonyPatch(typeof(InventoryUI), "Repair")] internal static class CreativeFreeRepairPatch { private static bool Prefix(ref bool __result) { if (!ReforgedModes.Creative) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(InventoryUI), "CraftItem")] internal static class CreativeCraftPatch { private sealed class CraftState { internal CraftRequirement[] Requirements; } private static void Prefix(InventoryItem item, out CraftState __state) { __state = null; if (ReforgedModes.Creative && !((Object)(object)item == (Object)null)) { __state = new CraftState { Requirements = item.requirements }; item.requirements = Array.Empty(); } } private static void Postfix(InventoryItem item, CraftState __state) { if (__state != null && (Object)(object)item != (Object)null) { item.requirements = __state.Requirements; } } private static Exception Finalizer(InventoryItem item, CraftState __state, Exception __exception) { if (__state != null && (Object)(object)item != (Object)null) { item.requirements = __state.Requirements; } return __exception; } } [HarmonyPatch(typeof(PlayerMovement), "Movement")] internal static class CreativeFlightMovementPatch { private static bool Prefix() { return true; } } [HarmonyPatch(typeof(UiEvents), "IsSoftUnlocked")] internal static class CreativeRecipeUnlockPatch { private static bool Prefix(int id, ref bool __result) { if (!ReforgedModes.Creative && !ShieldRegistry.TryGet(id, out var _)) { InventoryItem item = BedRegistry.Item; if (item == null || item.id != id) { return true; } } __result = true; return false; } } [HarmonyPatch(typeof(InventoryUI), "FillCellList")] internal static class HotbarFirstPickupPatch { private static void Postfix(InventoryUI __instance, ref List ___cells) { if (Plugin.Settings.HotbarFirstPickup.Value) { IEnumerable enumerable; if (!((Object)(object)__instance.hotkeysTransform != (Object)null)) { enumerable = Enumerable.Empty(); } else { IEnumerable componentsInChildren = ((Component)__instance.hotkeysTransform).GetComponentsInChildren(true); enumerable = componentsInChildren; } IEnumerable first = enumerable; IEnumerable enumerable2; if (!((Object)(object)__instance.inventoryParent != (Object)null)) { enumerable2 = Enumerable.Empty(); } else { IEnumerable componentsInChildren = ((Component)__instance.inventoryParent).GetComponentsInChildren(true); enumerable2 = componentsInChildren; } IEnumerable second = enumerable2; ___cells = (from cell in first.Concat(second) where (Object)(object)cell != (Object)null select cell).Distinct().ToList(); } } } [HarmonyPatch(typeof(InventoryUI), "CooldownPickup")] internal static class BoundedPickupCooldownPatch { private static bool Prefix(InventoryUI __instance) { __instance.pickupCooldown = true; ((MonoBehaviour)__instance).CancelInvoke("ResetCooldown"); ((MonoBehaviour)__instance).Invoke("ResetCooldown", Mathf.Clamp((float)(NetStatus.GetPing() * 2) / 1000f, 0.05f, 0.35f)); return false; } } [HarmonyPatch(typeof(InventoryCell), "ShiftClick")] internal static class SafeChestShiftClickPatch { private static bool Prefix(InventoryCell __instance, ref bool __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)__instance.cellType != 2) { return true; } InventoryItem currentItem = __instance.currentItem; if ((Object)(object)currentItem == (Object)null || (Object)(object)InventoryUI.Instance == (Object)null || (Object)(object)OtherInput.Instance?.currentChest == (Object)null || !InventoryUI.Instance.CanPickup(currentItem)) { __result = false; return false; } int amount = currentItem.amount; int num = InventoryUI.Instance.AddItemToInventory(currentItem); if (num >= amount) { __result = false; return false; } if (num > 0) { currentItem.amount = num; __instance.UpdateCell(); } else { __instance.RemoveItem(); } int num2 = (((Object)(object)__instance.currentItem != (Object)null) ? __instance.currentItem.id : (-1)); int num3 = (((Object)(object)__instance.currentItem != (Object)null) ? __instance.currentItem.amount : 0); ClientSend.ChestUpdate(OtherInput.Instance.currentChest.id, __instance.cellId, num2, num3); __result = true; return false; } } [HarmonyPatch(typeof(GameManager), "RespawnPlayer")] internal static class SafeRespawnPatch { private static bool Prefix(GameManager __instance, int id, Vector3 zero) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (GameManager.players == null || !GameManager.players.TryGetValue(id, out var value) || (Object)(object)value == (Object)null) { return false; } Vector3 val = ((PacketSanitizer.ValidVector(zero) && zero != Vector3.zero) ? zero : ((Component)value).transform.position); int graveId = value.graveId; if (graveId >= 0 && ResourceManager.Instance?.list != null && ResourceManager.Instance.list.TryGetValue(graveId, out var value2) && (Object)(object)value2 != (Object)null) { val = value2.transform.position; value.RemoveGrave(); } else { value.graveId = -1; } if (!PacketSanitizer.ValidVector(val) || val.y < -100f) { val = Vector3.zero; } value.dead = false; if (Server.clients != null && Server.clients.TryGetValue(id, out var value3) && value3?.player != null) { value3.player.dead = false; } if ((Object)(object)LocalClient.instance != (Object)null && LocalClient.instance.myId == id && (Object)(object)PlayerMovement.Instance != (Object)null) { ((Component)PlayerMovement.Instance).transform.position = val + Vector3.up * 3f; ((Component)PlayerMovement.Instance).gameObject.SetActive(true); PlayerStatus instance = PlayerStatus.Instance; if (instance != null) { instance.Respawn(); } } else { ((Component)value).gameObject.SetActive(true); } return false; } } [HarmonyPatch(typeof(MoveCamera), "SpectateCamera")] internal static class EnhancedSpectateCameraPatch { private static bool Prefix(MoveCamera __instance, ref Transform ___target, ref Transform ___playerTarget, ref int ___spectatingId, ref Vector3 ___desiredSpectateRotation, ref float ___desiredX, ref float ___yRotation) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Settings.EnableEnhancedSpectator.Value) { return true; } if (Input.GetKeyDown((KeyCode)102)) { __instance.state = (CameraState)3; Vector3 eulerAngles = ((Component)__instance).transform.eulerAngles; ___desiredX = eulerAngles.y; ___yRotation = ((eulerAngles.x > 180f) ? (eulerAngles.x - 360f) : eulerAngles.x); ___target = null; ___playerTarget = null; SpectatorFix.SetTargetName(null); return false; } PlayerManager value; PlayerManager val = ((GameManager.players != null && GameManager.players.TryGetValue(___spectatingId, out value) && SpectatorFix.Valid(value)) ? value : SpectatorFix.Select(___spectatingId, 1)); if (Input.GetKeyDown(InputManager.rightClick)) { val = SpectatorFix.Select(val?.id ?? ___spectatingId, 1); } else if (Input.GetKeyDown(InputManager.leftClick)) { val = SpectatorFix.Select(val?.id ?? ___spectatingId, -1); } if ((Object)(object)val == (Object)null) { __instance.state = (CameraState)3; Vector3 eulerAngles2 = ((Component)__instance).transform.eulerAngles; ___desiredX = eulerAngles2.y; ___yRotation = ((eulerAngles2.x > 180f) ? (eulerAngles2.x - 360f) : eulerAngles2.x); SpectatorFix.SetTargetName(null); return false; } ___spectatingId = val.id; ___target = ((Component)val).transform; ___playerTarget = ((Component)val).transform; ((Component)__instance).transform.parent = null; SpectatorFix.SetTargetName(val); if (!SpectatorFix.RotationReady) { Vector3 eulerAngles3 = ((Component)__instance).transform.eulerAngles; ___desiredSpectateRotation = new Vector3((eulerAngles3.x > 180f) ? (eulerAngles3.x - 360f) : eulerAngles3.x, eulerAngles3.y, 0f); SpectatorFix.RotationReady = true; } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")); ___desiredSpectateRotation += new Vector3(0f - val2.y, val2.x, 0f) * 1.5f; ___desiredSpectateRotation.x = Mathf.Clamp(___desiredSpectateRotation.x, -80f, 80f); SpectatorFix.OrbitDistance -= Input.mouseScrollDelta.y; Vector3 val3 = (((Object)(object)val.spectateOrbit != (Object)null) ? val.spectateOrbit : ((Component)val).transform).position + Vector3.up * 1.2f; Quaternion val4 = Quaternion.Euler(___desiredSpectateRotation); Vector3 val5 = val3 - val4 * Vector3.forward * SpectatorFix.OrbitDistance; Vector3 val6 = val5 - val3; RaycastHit val7 = default(RaycastHit); if (Physics.Raycast(val3, ((Vector3)(ref val6)).normalized, ref val7, ((Vector3)(ref val6)).magnitude, LayerMask.op_Implicit(__instance.whatIsGround))) { val5 = ((RaycastHit)(ref val7)).point + ((RaycastHit)(ref val7)).normal * 0.35f; } ((Component)__instance).transform.position = Vector3.Lerp(((Component)__instance).transform.position, val5, Time.deltaTime * 12f); Vector3 val8 = val3 - ((Component)__instance).transform.position; if (((Vector3)(ref val8)).sqrMagnitude > 0.001f) { ((Component)__instance).transform.rotation = Quaternion.Lerp(((Component)__instance).transform.rotation, Quaternion.LookRotation(val8, Vector3.up), Time.deltaTime * 14f); } return false; } } [HarmonyPatch(typeof(MoveCamera), "FreeCam")] internal static class EnhancedFreeCameraPatch { private static bool Prefix(MoveCamera __instance, ref Transform ___target, ref Transform ___playerTarget, ref float ___desiredX, ref float ___yRotation, ref Vector3 ___cameraRot) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Settings.EnableEnhancedSpectator.Value) { return true; } SpectatorFix.SetTargetName(null); if (Input.GetKeyDown((KeyCode)102) && (Object)(object)SpectatorFix.Select(-1, 1) != (Object)null) { ___target = null; ___playerTarget = null; SpectatorFix.RotationReady = false; __instance.state = (CameraState)2; return false; } float num = (((Object)(object)__instance.playerInput != (Object)null) ? (__instance.playerInput.sensitivity * 0.02f * PlayerInput.sensMultiplier) : 1f); float num2 = Input.GetAxis("Mouse X") * num; float num3 = Input.GetAxis("Mouse Y") * num; if (CurrentSettings.invertedHor) { num2 = 0f - num2; } if (CurrentSettings.invertedVer) { num3 = 0f - num3; } ___desiredX += num2; ___yRotation = Mathf.Clamp(___yRotation - num3, -90f, 90f); ___cameraRot = new Vector3(___yRotation, ___desiredX, 0f); ((Component)__instance).transform.rotation = Quaternion.Euler(___cameraRot); Vector3 val = Vector3.zero; if (Input.GetKey(InputManager.forward)) { val += ((Component)__instance).transform.forward; } if (Input.GetKey(InputManager.backwards)) { val -= ((Component)__instance).transform.forward; } if (Input.GetKey(InputManager.right)) { val += ((Component)__instance).transform.right; } if (Input.GetKey(InputManager.left)) { val -= ((Component)__instance).transform.right; } if (Input.GetKey(InputManager.jump)) { val += Vector3.up; } if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)99)) { val -= Vector3.up; } float num4 = (Input.GetKey(InputManager.sprint) ? 60f : 15f); if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { Transform transform = ((Component)__instance).transform; transform.position += ((Vector3)(ref val)).normalized * num4 * Time.unscaledDeltaTime; } return false; } } internal static class NativeMenuIntegration { private const string PublicServersButtonName = "Muck Replayable Public Servers"; private const string PrivateServersButtonName = "Muck Replayable Private Servers"; private const string WorldsButtonName = "Muck Replayable Worlds"; private const string PausePublicButtonName = "Muck Replayable Open Public"; private const string PausePrivateButtonName = "Muck Replayable Open Private"; private static Button pausePublicButton; private static Button pausePrivateButton; private static TMP_Text pausePublicLabel; private static TMP_Text pausePrivateLabel; private static MenuUI appliedMainMenu; private static GameObject appliedPauseRoot; internal static void ResetSceneState() { appliedMainMenu = null; appliedPauseRoot = null; pausePublicButton = null; pausePrivateButton = null; pausePublicLabel = null; pausePrivateLabel = null; } internal static void Apply() { ApplyMainMenu(); ApplyPauseMenu(); } internal static void RefreshPauseButton() { if (!((Object)(object)pausePublicButton == (Object)null) && !((Object)(object)pausePrivateButton == (Object)null) && !((Object)(object)pausePublicLabel == (Object)null) && !((Object)(object)pausePrivateLabel == (Object)null)) { bool flag = LocalClient.serverOwner && (Object)(object)GameManager.instance != (Object)null; ((Component)pausePublicButton).gameObject.SetActive(flag); ((Component)pausePrivateButton).gameObject.SetActive(flag); if (flag) { pausePublicLabel.text = (LateJoinService.IsPublic ? "Close Public" : "Open Public"); pausePrivateLabel.text = (LateJoinService.IsPrivate ? "Close Private" : "Open Private"); ConfigureOneLine(pausePublicLabel); ConfigureOneLine(pausePrivateLabel); } } } private static void ApplyMainMenu() { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) MenuUI val = Object.FindObjectOfType(); if ((Object)(object)val?.mainUi == (Object)null || (Object)(object)ReforgedRuntime.Instance == (Object)null || (Object)(object)appliedMainMenu == (Object)(object)val) { return; } Transform[] componentsInChildren = val.mainUi.GetComponentsInChildren(true); Transform val2 = ((IEnumerable)componentsInChildren).FirstOrDefault((Func)((Transform value) => ((Object)value).name == "Buttons")); Transform? obj = ((IEnumerable)componentsInChildren).FirstOrDefault((Func)((Transform value) => ((Object)value).name == "MultiplayerButton")); Button val3 = ((obj != null) ? ((Component)obj).GetComponent