using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dawn.Internal; using Dusk; using GameNetcodeStuff; using HarmonyLib; using LCBetterSaves; using LethalThings; using Lethal_Nuke; using Microsoft.CodeAnalysis; using NicheTweaks.ExternalTweaks.BetterSaves; using NicheTweaks.ExternalTweaks.DawnLib; using NicheTweaks.ExternalTweaks.EladsHUD; using NicheTweaks.ExternalTweaks.EladsHUD.AutoHide; using NicheTweaks.ExternalTweaks.EladsHUD.HUDReorder; using NicheTweaks.ExternalTweaks.EladsHUD.Misc; using NicheTweaks.ExternalTweaks.EnhancedMonsters; using NicheTweaks.ExternalTweaks.GeneralImprovements; using NicheTweaks.ExternalTweaks.ImmersiveVisor; using NicheTweaks.ExternalTweaks.InputUtils; using NicheTweaks.ExternalTweaks.LethalConfig; using NicheTweaks.ExternalTweaks.LethalNuke; using NicheTweaks.ExternalTweaks.LethalThings; using NicheTweaks.ExternalTweaks.LobbyControl; using NicheTweaks.ExternalTweaks.LobbyImprovements; using NicheTweaks.ExternalTweaks.MagicShippingCrate; using NicheTweaks.ExternalTweaks.MirrorDecor; using NicheTweaks.ExternalTweaks.MoreBlood; using NicheTweaks.ExternalTweaks.MoreCompany; using NicheTweaks.ExternalTweaks.ShipWindows; using NicheTweaks.NetcodePatcher; using NicheTweaks.Patches; using NicheTweaks.Tweaks.Audio; using NicheTweaks.Tweaks.Decals; using NicheTweaks.Tweaks.Gameplay; using NicheTweaks.Tweaks.HUD; using NicheTweaks.Tweaks.QoL; using NicheTweaks.Tweaks.Ship; using NicheTweaks.Tweaks.Visuals; using NicheTweaks.Tweaks.Visuals.PlayerSelfShadow; using NicheTweaks.Utils; using ShipWindows; using ShipWindows.Api.events; using ShipWindows.ShutterSwitch; using ShipWindows.WindowDefinition; using Steamworks.Data; using TMPro; using TooManyEmotes.Patches; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.VFX; using Woecust.ImmersiveVisor; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NicheTweaks")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.4.5.0")] [assembly: AssemblyInformationalVersion("0.4.5")] [assembly: AssemblyProduct("NicheTweaks")] [assembly: AssemblyTitle("NicheTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.5.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NicheTweaks { internal static class ConfigManager { internal const string Audio = "Audio"; internal const string Decals = "Decals"; internal const string Gameplay = "Gameplay"; internal const string UI = "UI"; internal const string Visuals = "Visuals"; internal const string Ship = "Ship"; internal const string QoL = "QoL"; internal const string OtherMods = "zOther mods"; internal const string EladsHUD = "zzEladsHUD"; internal static ConfigEntry SilenceRingingEarsAudio { get; private set; } internal static ConfigEntry SilenceLightningStatic { get; private set; } internal static ConfigEntry MuteFearAudio { get; private set; } internal static ConfigEntry EnableDecalDrawDistanceOverride { get; private set; } internal static ConfigEntry EnableFootprintPoolOverride { get; private set; } internal static ConfigEntry FootprintPoolSize { get; private set; } internal static ConfigEntry EnablePlayerBlood { get; private set; } internal static ConfigEntry MinimumDamageForBlood { get; private set; } internal static ConfigEntry BloodAmount { get; private set; } internal static ConfigEntry BloodDecalSize { get; private set; } internal static ConfigEntry FixHoarderBugManEaterTarget { get; private set; } internal static ConfigEntry GrabbableToEnemiesItemBlacklistToggle { get; private set; } internal static ConfigEntry GrabbableToEnemiesItemBlacklist { get; private set; } internal static ConfigEntry RadmechLargerHitCollider { get; private set; } internal static ConfigEntry ButlerTallerHitCollider { get; private set; } internal static ConfigEntry JesterTallerHitCollider { get; private set; } internal static ConfigEntry ButlerCollisionAdjustment { get; private set; } internal static ConfigEntry DisableUtilitySlot { get; private set; } internal static ConfigEntry PreventCheckDeadPlayersCheese { get; private set; } internal static ConfigEntry TriggerDeadlineEjectionAtZeroDays { get; private set; } internal static ConfigEntry DisableInspectItem { get; private set; } internal static ConfigEntry FixZeroScaleItems { get; private set; } internal static ConfigEntry DisableClock { get; private set; } internal static ConfigEntry AddClockToDeathScreen { get; private set; } internal static ConfigEntry DisableChat { get; private set; } internal static ConfigEntry FixChatColon { get; private set; } internal static ConfigEntry DisableCompass { get; private set; } internal static ConfigEntry DisableWeight { get; private set; } internal static ConfigEntry HandsFullTextPresetSelection { get; private set; } internal static ConfigEntry ItemLightningBorder { get; private set; } internal static ConfigEntry RemoveItemSlotFade { get; private set; } internal static ConfigEntry HideHUDAtTerminal { get; private set; } internal static ConfigEntry EnableFloodedCondensation { get; private set; } internal static ConfigEntry FixQuitGameMenuHighlightColours { get; private set; } internal static ConfigEntry QuitGameColourConsistency { get; private set; } internal static ConfigEntry HideJoinButton { get; private set; } internal static ConfigEntry HideInviteFriendsButton { get; private set; } internal static ConfigEntry HideCreditsButton { get; private set; } internal static ConfigEntry ChangeFriendsOnlyTextToPrivate { get; private set; } internal static ConfigEntry DisableControlTips { get; private set; } internal static ConfigEntry FixUtilitySlotItemIconSize { get; private set; } internal static ConfigEntry EnableTooltipRename { get; private set; } internal static ConfigEntry TooltipItemsToRename { get; private set; } internal static ConfigEntry AllItemNamesList { get; private set; } internal static ConfigEntry ScanNodeOverridesToggle { get; private set; } internal static ConfigEntry ScanNodeOverrides { get; private set; } internal static ConfigEntry HideWarningDisplayTipToggle { get; private set; } internal static ConfigEntry DisableFilmGrain { get; private set; } internal static ConfigEntry BlockCustomMoonVFX { get; private set; } internal static ConfigEntry BlockCustomMoonVFXMoonFilter { get; private set; } internal static ConfigEntry DisableLocalPlayerSelfShadow { get; private set; } internal static ConfigEntry HidePlayerArms { get; private set; } internal static ConfigEntry ToyCubeTextureFix { get; private set; } internal static ConfigEntry EnableLODOverride { get; private set; } internal static ConfigEntry LODBias { get; private set; } internal static ConfigEntry DisableChargeStationScanNode { get; private set; } internal static ConfigEntry CloseShipDoorOnLeverPull { get; private set; } internal static ConfigEntry PlanetVideoReelDisable { get; private set; } internal static ConfigEntry EnableGlobalVolumeMeter { get; private set; } internal static ConfigEntry SavePlayerVolume { get; private set; } internal static ConfigEntry EnableDropshipPickupDelay { get; private set; } internal static ConfigEntry DropshipPickupDelayTime { get; private set; } internal static ConfigEntry EnableShipTeleporterBlock { get; private set; } internal static ConfigEntry EnableLandmineFix { get; private set; } internal static ConfigEntry JesterWarmup { get; private set; } internal static ConfigEntry AmbientMusicWarmup { get; private set; } internal static ConfigEntry NormaliseHelmetLightBrightness { get; private set; } internal static ConfigEntry UncapFPS { get; private set; } internal static ConfigEntry PreventErrorFromSteamImage { get; private set; } internal static ConfigEntry DisableAchievementPopups { get; private set; } internal static ConfigEntry ReplaceDawnLibHotloadingPlayerImages { get; private set; } internal static ConfigEntry FixMoreBloodFootprints { get; private set; } internal static ConfigEntry HideMoreCompanyMenuButton { get; private set; } internal static ConfigEntry HideMoreCompanyCrewCount { get; private set; } internal static ConfigEntry MoreCompanyOrangeCosmeticButton { get; private set; } internal static ConfigEntry LobbyImprovementsTextEdit { get; private set; } internal static ConfigEntry BetterSavesTextEdit { get; private set; } internal static ConfigEntry BetterSavesAutoRename { get; private set; } internal static ConfigEntry BetterSavesStartCreditsFix { get; private set; } internal static ConfigEntry HideKeybindsLegacyButton { get; private set; } internal static ConfigEntry HideLethalConfigMenu { get; private set; } internal static ConfigEntry AddSpaceToLethalConfig { get; private set; } internal static ConfigEntry EnableLIUtilBeltAlign { get; private set; } internal static ConfigEntry MZCoMagicShippingNeverRespawns { get; private set; } internal static ConfigEntry ImmersiveVisorWorksWithHurricane { get; private set; } internal static ConfigEntry ShipWindowsOpenClose { get; private set; } internal static ConfigEntry LethalNukeFix { get; private set; } internal static ConfigEntry MirrorDecorFPSCapToggle { get; private set; } internal static ConfigEntry MirrorDecorFPSCap { get; private set; } internal static ConfigEntry RemoveEnhancedMonstersVersionNumber { get; private set; } internal static ConfigEntry RemoveLobbyCommand { get; private set; } internal static ConfigEntry PlayerScanNodeRed { get; private set; } internal static ConfigEntry V80Compat { get; private set; } internal static ConfigEntry EnableEladsHUDReorder { get; private set; } internal static ConfigEntry FixStaminaTenPercent { get; private set; } internal static ConfigEntry DisableEladsHUDStaminaNotch { get; private set; } internal static ConfigEntry HideEladsHUDWeight { get; private set; } internal static ConfigEntry EladsHUDTriggerHealthShowOnHeal { get; private set; } internal static ConfigEntry EladsHUDHideStaminaPercentage { get; private set; } internal static ConfigEntry EladsHUDAutoHideStamina { get; private set; } internal static ConfigEntry EladsHUDStaminaAutoHideDelay { get; private set; } internal static ConfigEntry EladsHUDStaminaAutoHideStartPercent { get; private set; } internal static ConfigEntry EladsHUDWeightTriggersStamina { get; private set; } internal static ConfigEntry EladsHUDHideOxygenPercentage { get; private set; } internal static ConfigEntry EladsHUDAutoHideOxygen { get; private set; } internal static ConfigEntry EladsHUDAutoHideOxygenDelay { get; private set; } internal static ConfigEntry EladsHUDAutoHideOxygenValue { get; private set; } internal static ConfigEntry EladsHUDHidePercentDividers { get; private set; } internal static ConfigEntry EladsHUDHideInsanityPercentage { get; private set; } internal static ConfigEntry EladsHUDAutoHideInsanity { get; private set; } internal static ConfigEntry EladsHUDAutoHideInsanityDelay { get; private set; } private static ConfigEntry Bind(ConfigFile config, string section, string key, T defaultValue, string description) { return config.Bind(section, key, defaultValue, description); } internal static void CfgInit(ConfigFile config) { SilenceRingingEarsAudio = Bind(config, "Audio", "Silence ear ringing audio", defaultValue: false, "If true, silences the ear ringing audio from shotgun blasts."); SilenceLightningStatic = Bind(config, "Audio", "Silence lightning static audio", defaultValue: false, "If true, silences live lightning static that plays from a conductive item being targeted when entering the facility."); MuteFearAudio = Bind(config, "Audio", "Mute fear audio", defaultValue: false, "If true, stops the fear ambience and heartbeat audio driven by the local player's fear level."); EnableDecalDrawDistanceOverride = Bind(config, "Decals", "Enable decal draw distance override", defaultValue: false, "If true, breaks the decal draw distance and causes decals to always be rendered. Will impact performance, not recommended without LethalSponge."); EnableFootprintPoolOverride = Bind(config, "Decals", "Enable footprint pool override", defaultValue: false, "If true, overrides the number of footprint decals allowed to exist."); FootprintPoolSize = Bind(config, "Decals", "Footprint pool size", 250, "Number of footprints that are allowed to be present before the oldest footprints start culling visually. Increasing this will impact performance."); EnablePlayerBlood = Bind(config, "Decals", "Enable player blood effects", defaultValue: false, "Enable blood effects when players take damage."); MinimumDamageForBlood = Bind(config, "Decals", "Minimum damage for blood", 5, "Minimum damage before blood splatter appears."); BloodAmount = Bind(config, "Decals", "Blood amount", 3, "Number of blood splatters a player takes damage."); BloodDecalSize = Bind(config, "Decals", "BloodDecalSize", 3f, "Size of blood splats created by players taking damage."); FixHoarderBugManEaterTarget = Bind(config, "Gameplay", "Fix hoarder bug trying to grab man eater", defaultValue: false, "If true, prevents hoarder bugs from trying to pick up man eaters"); GrabbableToEnemiesItemBlacklistToggle = Bind(config, "Gameplay", "Enable grabbable to enemies item blacklist", defaultValue: false, "If true, enables grabbable to enemies item blacklist"); GrabbableToEnemiesItemBlacklist = Bind(config, "Gameplay", "Grabbable to enemies item blacklist", "", "Uses itemProperties name, separated by commas. E.g. 'Big bolt,Large axle,Bowl of Apples'"); RadmechLargerHitCollider = Bind(config, "Gameplay", "Give Radmechs a larger hit collider", defaultValue: false, "If true, gives the Radmech/Old Bird enemies a larger hitbox, mainly for use with mods where they are no longer immortal. However, as an unavoidable consequence, they can now grab you far easier, making them more difficult. Can be used to increase their lethality as well."); ButlerTallerHitCollider = Bind(config, "Gameplay", "Give Butlers a taller player hit collider", defaultValue: false, "If true, increases the height of Butlers player hit collider to allow them to have more vertical reach. This is to stop players sitting on the Mansion doorframe to avoid danger, amongst other high areas."); JesterTallerHitCollider = Bind(config, "Gameplay", "Give Jesters a taller player hit collider", defaultValue: false, "If true, increases the height of Jesters player hit collider to allow them to have more vertical reach. This is to stop players sitting on the Mansion doorframe to avoid danger, amongst other high areas."); ButlerCollisionAdjustment = Bind(config, "Gameplay", "Lower size of Butler obstacle avoidance", defaultValue: false, "If true, resizes Butler's NavMeshAgent obstacle avoidance radius from 1.6 to 1.4 to help them fit through tighter spaces and open doors properly."); DisableUtilitySlot = Bind(config, "Gameplay", "Disable utility slot", defaultValue: false, "If true, disables the utility slot on the HUD and prevents items from using the utility slot."); PreventCheckDeadPlayersCheese = Bind(config, "Gameplay", "Prevent check dead players cheese", defaultValue: false, "If true, displays the 'No one can hear you' popup when sending a chat message when everyone is dead."); TriggerDeadlineEjectionAtZeroDays = Bind(config, "Gameplay", "Eject at zero days without ship loot", defaultValue: false, "If true, triggers the deadline firing sequence as soon as the crew reaches 0 days left when no ship scrap value is found."); DisableInspectItem = Bind(config, "Gameplay", "Disable item inspection", defaultValue: false, "If true, disables the ability to inspect items."); FixZeroScaleItems = Bind(config, "Gameplay", "Fix zero scale items", defaultValue: false, "EXPERIMENTAL | If true, attempts to fix NaN errors. Not sure if this works."); DisableClock = Bind(config, "UI", "Hide clock from HUD", defaultValue: false, "If true, hides the clock from the HUD."); AddClockToDeathScreen = Bind(config, "UI", "Add clock to death screen", defaultValue: false, "If true, adds clock to death screen."); DisableChat = Bind(config, "UI", "Hide chat from HUD", defaultValue: false, "If true, hides the chat from the HUD. Warning: It remains hidden even if you type in it."); FixChatColon = Bind(config, "UI", "Set chat colon colour to blue", defaultValue: false, "If true, sets the colon in the chat to blue and prevents the colon from changing colours when using html attributes in chat messages."); DisableCompass = Bind(config, "UI", "Hide compass from HUD", defaultValue: false, "If true, hides the compass from the HUD."); DisableWeight = Bind(config, "UI", "Hide weight from HUD", defaultValue: false, "If true, hides the weight from the HUD."); HandsFullTextPresetSelection = Bind(config, "UI", "Hands full text preset", HandsFullTextPreset.DefaultNoChange, "Preset for HandsFullText position/rotation/scale/opacity. DefaultNoChange does not modify the HUD."); ItemLightningBorder = Bind(config, "UI", "Item Lightning Warning", defaultValue: false, "If true, warns the player which item is about to be struck by lightning with a visual indicator."); RemoveItemSlotFade = Bind(config, "UI", "Remove Item Slot Fade", defaultValue: false, "If true, removes the fade popout of the item slot frame when swapping item slots."); HideHUDAtTerminal = Bind(config, "UI", "Hide HUD at terminal", defaultValue: false, "If true, hides the HUD whilst at the terminal."); EnableFloodedCondensation = Bind(config, "UI", "Enable condensation on visor during flooded", defaultValue: false, "If true, shows helmet condensation during Flooded weather."); FixQuitGameMenuHighlightColours = Bind(config, "UI", "Fix quit game highlight colours", defaultValue: false, "If true, changes the green highlights and corners of the in-game quit menu to be highlighted orange like the rest of the game."); QuitGameColourConsistency = Bind(config, "UI", "Change quit game confirmation text to orange", defaultValue: false, "If true, changes the light blue 'Would you like to leave the game?' text to be orange."); HideJoinButton = Bind(config, "UI", "Hide join button", defaultValue: false, "If true, hides the join crew button in the main menu."); HideInviteFriendsButton = Bind(config, "UI", "Hide invite friends button", defaultValue: false, "If true, hides the invite friends button in the quick menu."); HideCreditsButton = Bind(config, "UI", "Hide credits button", defaultValue: false, "If true, hides the Credits button in the main menu."); ChangeFriendsOnlyTextToPrivate = Bind(config, "UI", "Change friends only text to private", defaultValue: false, "If true, changes the 'Friends only' lobby option in lobby creation menu to say 'Private'."); DisableControlTips = Bind(config, "UI", "Hide control tips from HUD", defaultValue: false, "If true, hides the control tip labels (top right of HUD)."); FixUtilitySlotItemIconSize = Bind(config, "UI", "Fix utility slot item icon size", defaultValue: false, "If true, fits the item icon to the utility slot."); EnableTooltipRename = Bind(config, "UI", "Customise control tip item name", defaultValue: false, "If true, enables the replacement of item control tip texts with their scan node text."); TooltipItemsToRename = Bind(config, "UI", "Items to change the control tip text of", "Brush = Hair brush,clipboard = Training manual,Bell = Brass bell,Gift = Gift box,Gold bar = Gold Bar,Hive = Bee hive,Ring = Wedding ring,Toy robot = Robot Toy,Metal sheet = Tattered metal sheet,Mug = Coffee mug,Rubber Ducky = Rubber ducky,Tea kettle = Tea Kettle,Ammo = Shotgun shell,Cookie pan = Cookie mold pan", "Items that will have their control tip text altered. E.g. 'ExampleItem1 = '"); AllItemNamesList = Bind(config, "UI", "Autogenerated item and scan node default text list", "Generates after loading a lobby", "Auto generated list of all item names and their respective default scan node text. Needs control tip renaming to be set to true"); ScanNodeOverridesToggle = Bind(config, "UI", "Scan node overrides toggle", defaultValue: false, "If true, enables the ability to override the type of any scan node"); ScanNodeOverrides = Bind(config, "UI", "Scan node overrides", "SnailCatRe:1, Fake SnailCatRe:1, Bandages:0, Defibrillator:0, Handlamp:0, MedicalKit:0, ProductivityAutoinjector:0, ShiftController:0, Toolbox:0, SeedCarrot:0, SeedGrape1:0, SeedGrape0:0, SeedPotato:0, SeedWheat:0, Fertilizer0:0", "Uses GameObject name and ScanNodeType, separated by colons and commas. E.g. 'SnailCatRe:1,Fake SnailCatRe:1,Bandages:0'. Searches the target GameObject and its hierarchy for ScanNodeProperties. 0 = Blue, 1 = Red, 2 = Green. A GameObject's name may not be the same as an item or enemies name!"); HideWarningDisplayTipToggle = Bind(config, "UI", "Hide warning display tips", defaultValue: false, "If true, hides all warning display tips (yellow display tips)"); DisableFilmGrain = Bind(config, "Visuals", "Disable film grain effect globally", defaultValue: false, "If true, globally disables film grain where it may be present."); BlockCustomMoonVFX = Bind(config, "Visuals", "Disable custom VFX on moons", defaultValue: false, "If true, disables all visual effects on moons, primarily for use with custom moons. WARNING: Will cause issues with some modded weathers that have custom visuals, compatibility is planned."); BlockCustomMoonVFXMoonFilter = Bind(config, "Visuals", "Disable custom VFX moon filter", "", "Moons to enable custom VFX disabling on. Separated by commas, example: Experimentation,Abaddon,Embrion. Empty = all moons."); DisableLocalPlayerSelfShadow = Bind(config, "Visuals", "Disable local player shadow", defaultValue: false, "If true, disables shadow casting for the local player only. Very useful for modded flashlights with very high intensities."); HidePlayerArms = Bind(config, "Visuals", "Hide player arms", defaultValue: false, "If true, hides the player arms."); ToyCubeTextureFix = Bind(config, "Visuals", "Enable texture fix for Toy cube", defaultValue: false, "If true, changes the texture of Toy cube (rubix cube) scrap to a texture of a rubix cube that is actually solvable."); EnableLODOverride = Bind(config, "Visuals", "Enable LOD bias override", defaultValue: false, "If true, enables custom LOD distance."); LODBias = Bind(config, "Visuals", "LOD bias", 1f, "LOD bias value. Increasing this will impact performance."); DisableChargeStationScanNode = Bind(config, "Ship", "Disable leftover charge station scan node", defaultValue: false, "If true, hides the scan node of the charge station inside the ship. This only affects the leftover scan node after moving the charge station with build mode."); CloseShipDoorOnLeverPull = Bind(config, "Ship", "Close ship doors when lever is pulled", defaultValue: false, "If true, closes the ship doors when the lever is pulled."); PlanetVideoReelDisable = Bind(config, "Ship", "Disable planet reel video on ship monitors", defaultValue: false, "If true, disables the planet reel video on the ship monitor."); EnableGlobalVolumeMeter = Bind(config, "QoL", "Enable global voice volume slider", defaultValue: false, "If true, enables the global voice volume slider in the player list."); SavePlayerVolume = Bind(config, "QoL", "Enable player volume saving", defaultValue: false, "If true, enables player volume saving. Works with global volume slider."); EnableDropshipPickupDelay = Bind(config, "QoL", "Enable dropship item pickup delay", defaultValue: false, "If true, adds a short delay to items dropped by the dropship before they can be grabbed."); DropshipPickupDelayTime = Bind(config, "QoL", "Dropship item pickup delay time", 1f, "Time in seconds before dropped items can be picked up."); EnableShipTeleporterBlock = Bind(config, "QoL", "Enable teleporter item pickup block", defaultValue: false, "If true, block item pickup whilst you are being teleported."); EnableLandmineFix = Bind(config, "QoL", "Remove landmine invisible bump", defaultValue: false, "Removes the invisible bump left by landmines after exploding."); JesterWarmup = Bind(config, "QoL", "Jester Warmup", defaultValue: false, "If true, silently plays and stops the Jester's audio clips so they are decompressed before first real playback to prevent an in-game lag spike"); AmbientMusicWarmup = Bind(config, "QoL", "Ambient music warmup", defaultValue: false, "If true, silently plays and stops ambient music audio so they are decompressed before first real playback to prevent an in-game lag spike"); NormaliseHelmetLightBrightness = Bind(config, "QoL", "Normalise helmet light brightness", defaultValue: false, "If true, matches the helmet light intensity to the flashlight's held light intensity when a flashlight is pocketed."); UncapFPS = Bind(config, "QoL", "Uncap FPS", defaultValue: false, "If true, removes the 250 fps cap."); PreventErrorFromSteamImage = Bind(config, "QoL", "Prevent a harmless error on player join", defaultValue: false, "If true, fixes a vanilla bug that causes harmless errors to be thrown when players join a lobby."); DisableAchievementPopups = Bind(config, "zOther mods", "Hide and mute DawnLib achievement popups", defaultValue: false, "If true, hides DawnLib's achievement popup and sound."); ReplaceDawnLibHotloadingPlayerImages = Bind(config, "zOther mods", "Replace DawnLib hotloadUI images", defaultValue: false, "If true, replaces DawnLib hotloadUI player Steam images with a vanilla image."); FixMoreBloodFootprints = Bind(config, "zOther mods", "Fix MoreBlood footprint smearing", defaultValue: false, "If true, enable fix for MoreBlood footprint smearing."); HideMoreCompanyMenuButton = Bind(config, "zOther mods", "Hide MoreCompany main menu button", defaultValue: false, "If true, hides the MoreCompany cosmetics button in the main menu. Requires MoreCompany to be installed."); HideMoreCompanyCrewCount = Bind(config, "zOther mods", "Hide MoreCompany crew count in create lobby menu", defaultValue: false, "If true, hides the MoreCompany crew count in the create lobby menu. Requires MoreCompany to be installed."); MoreCompanyOrangeCosmeticButton = Bind(config, "zOther mods", "Change MoreCompany cosmetic button icon to orange", defaultValue: false, "If true, changes the cosmetic button in the main menu and the pause menu from green to orange. Requires MoreCompany to be installed."); LobbyImprovementsTextEdit = Bind(config, "zOther mods", "Change LobbyImprovements text", defaultValue: false, "If true, changes text on the create a lobby screen from 'ImprovedLobby' -> 'Lobby'. Requires LobbyImprovements to be installed."); BetterSavesTextEdit = Bind(config, "zOther mods", "Change BetterSaves text", defaultValue: false, "If true, changes text on the create a lobby screen from 'BetterSaves' -> 'Save Files'. Requires LCBetterSaves to be installed."); BetterSavesAutoRename = Bind(config, "zOther mods", "BetterSaves auto rename", defaultValue: false, "If true, automatically renames new saves to the lobby name. Requires LCBetterSaves to be installed."); BetterSavesStartCreditsFix = Bind(config, "zOther mods", "BetterSaves start credits fix", defaultValue: false, "If true, sets BetterSaves starting credits to 60 rather than 30. Requires LCBetterSaves to be installed."); HideKeybindsLegacyButton = Bind(config, "zOther mods", "Hide legacy control button inside control settings", defaultValue: false, "If true, hide legacy control button inside control settings. Requires LethalCompany InputUtils to be installed."); HideLethalConfigMenu = Bind(config, "zOther mods", "Hide LethalConfig main menu button", defaultValue: false, "If true, hides LethalConfig button in the main menu."); AddSpaceToLethalConfig = Bind(config, "zOther mods", "Add space to LethalConfig", defaultValue: false, "If true, renames 'LethalConfig' to 'Lethal Config' in the main menu and in the pause menu in-game."); EnableLIUtilBeltAlign = Bind(config, "zOther mods", "Enable Utility Belt UI alignment fix", defaultValue: false, "If true, aligns Utility Belt item slots to the middle for consistency purposes. Requires LethalThings to be installed."); MZCoMagicShippingNeverRespawns = Bind(config, "zOther mods", "MZCoMagicShipping crate never respawns", defaultValue: false, "If true, the magic crate does not respawn and is single use only. Requires MZCoMagicShipping to be installed."); ImmersiveVisorWorksWithHurricane = Bind(config, "zOther mods", "ImmersiveVisor works with Hurricane", defaultValue: false, "If true, Immersive Visor shows rain drops on the visor during hurricane weather. Requires ImmersiveVisor and Wesleys Weathers to be installed."); ShipWindowsOpenClose = Bind(config, "zOther mods", "Ship window shutters close on departure", defaultValue: false, "If true, ship window shutters close when the ship doors close on departure. Requires ShipWindows to be installed."); LethalNukeFix = Bind(config, "zOther mods", "Lethal Nuke Fix", defaultValue: false, "If true, prevents lethal nuke's particle effect from looping. Requires Lethal Nuke to be installed."); MirrorDecorFPSCapToggle = Bind(config, "zOther mods", "MirrorDecor FPS cap toggle", defaultValue: false, "If true, enables FPS cap for MirrorDecor and prevents camera from rendering when not on the ship. Requires MirrorDecor to be installed."); MirrorDecorFPSCap = Bind(config, "zOther mods", "MirrorDecor FPS cap", 30, "Sets the FPS for MirrorDecor."); RemoveEnhancedMonstersVersionNumber = Bind(config, "zOther mods", "Remove EnhancedMonsters version number", defaultValue: false, "If true, removes EnhancesMonsters' version number from Lethal Company's version number text in the main menu. Requires EnhancedMonsters to be installed."); RemoveLobbyCommand = Bind(config, "zOther mods", "Remove LobbyControl command", defaultValue: false, "If true, removes the lobby command from help/other screen on the terminal. Does not disable the lobby command, only hides. Requires LobbyControl to be installed."); PlayerScanNodeRed = Bind(config, "zOther mods", "Player Scan node red", defaultValue: false, "If true, sets the player scan node to be red for GI's 'Scan players'. Requires GeneralImprovements to be installed."); V80Compat = Bind(config, "zzEladsHUD", "v80 utility slot compatibility", defaultValue: false, "If true, allows the utility slot to be seen when using EladsHUD in Lethal Company V80. Requires EladsHUD to be installed."); EnableEladsHUDReorder = Bind(config, "zzEladsHUD", "Reorganise EladsHUD", defaultValue: false, "If true, moves InsanityDisplay's percentage down to be in line with Stamina and Oxygen. Requires InsanityDisplay and Oxygen to be installed and configured accordingly."); FixStaminaTenPercent = Bind(config, "zzEladsHUD", "Fix stamina bar 10% cap", defaultValue: false, "If true, fixes stamina bar being unable to deplete to 0% properly."); DisableEladsHUDStaminaNotch = Bind(config, "zzEladsHUD", "Hide stamina notch", defaultValue: false, "If true, hides the notch on the stamina bar that's present during stamina drain."); HideEladsHUDWeight = Bind(config, "zzEladsHUD", "Hide weight", defaultValue: false, "If true, hides weight UI."); EladsHUDTriggerHealthShowOnHeal = Bind(config, "zzEladsHUD", "Trigger health bar popup on heal", defaultValue: false, "If true, will show health bar when health increases as well rather than when only decreasing."); EladsHUDHideStaminaPercentage = Bind(config, "zzEladsHUD", "Hide stamina number and percentage", defaultValue: false, "If true, hides number and percentage for stamina."); EladsHUDAutoHideStamina = Bind(config, "zzEladsHUD", "Autohide stamina bar", defaultValue: false, "If true, automatically hides stamina bar when at configured value for a period of time."); EladsHUDStaminaAutoHideDelay = Bind(config, "zzEladsHUD", "Stamina bar auto hide delay time", 3f, "Seconds to wait before hiding the stamina bar."); EladsHUDStaminaAutoHideStartPercent = Bind(config, "zzEladsHUD", "Autohide stamina start percent", 1f, "Percentage (0.0–1.0) at which stamina autohide begins. Example: 0.75 = 75%."); EladsHUDWeightTriggersStamina = Bind(config, "zzEladsHUD", "Weight affects stamina bar fading", defaultValue: false, "If true, stamina bar and percentage will reappear when weight updates."); EladsHUDHideOxygenPercentage = Bind(config, "zzEladsHUD", "Hide oxygen number and percentage", defaultValue: false, "If true, hides number and percentage for oxygen. Requires Oxygen to be installed."); EladsHUDAutoHideOxygen = Bind(config, "zzEladsHUD", "Autohide oxygen bar", defaultValue: false, "If true, automatically hides oxygen bar when at 100% for a period of time. Requires Oxygen to be installed."); EladsHUDAutoHideOxygenDelay = Bind(config, "zzEladsHUD", "Oxygen bar auto hide delay time", 3f, "Seconds to wait at 100% stamina before hiding the stamina bar. Requires Oxygen to be installed."); EladsHUDAutoHideOxygenValue = Bind(config, "zzEladsHUD", "AutoHideOxygenValue", 0.75f, "Oxygen HUD disappears if oxygen value > this setting."); EladsHUDHidePercentDividers = Bind(config, "zzEladsHUD", "Hide percentage dividers", defaultValue: false, "If true, hides the percentage divider UI elements. These are the small dots between each percent number. Requires Oxygen to be installed."); EladsHUDHideInsanityPercentage = Bind(config, "zzEladsHUD", "Hide insanity number and percentage", defaultValue: false, "If true, hides number and percentage for insanity. Requires InsanityDisplay to be installed."); EladsHUDAutoHideInsanity = Bind(config, "zzEladsHUD", "Autohide insanity bar", defaultValue: false, "If true, automatically hides insanity bar when at 100% for a period of time. Requires InsanityDisplay to be installed."); EladsHUDAutoHideInsanityDelay = Bind(config, "zzEladsHUD", "Insanity bar auto hide delay time", 3f, "Seconds to wait at 100% insanity before hiding the stamina bar. Requires InsanityDisplay to be installed."); } } [BepInPlugin("MrHat.NicheTweaks", "NicheTweaks", "0.4.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { internal const string modGUID = "MrHat.NicheTweaks"; internal const string modName = "NicheTweaks"; internal const string modVersion = "0.4.5"; internal static Harmony _harmony; internal static ManualLogSource mls; internal static Plugin? Instance; private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Instance = this; mls = Logger.CreateLogSource("MrHat.NicheTweaks"); _harmony = new Harmony("MrHat.NicheTweaks"); ConfigManager.CfgInit(((BaseUnityPlugin)this).Config); Keys.Init(); Log.Info("NicheTweaks initialised"); Patch(typeof(StartOfRoundPatches)); Patch(ConfigManager.SilenceRingingEarsAudio, typeof(RingingEarsAudioSilencerTweak)); Patch(ConfigManager.SilenceLightningStatic, typeof(LightningStaticAudioTweak)); Patch(ConfigManager.MuteFearAudio, typeof(FearAudioMuteTweak)); Patch(ConfigManager.EnableDecalDrawDistanceOverride, typeof(DecalDrawDistanceTweak)); Patch(ConfigManager.EnableFootprintPoolOverride, typeof(FootprintPoolOverrideTweak)); Patch(ConfigManager.EnablePlayerBlood, typeof(PlayerBloodTweak), typeof(PlayerBloodDamageTweak)); Patch(ConfigManager.FixHoarderBugManEaterTarget, typeof(HoarderBugManEaterTargetFixTweak)); Patch(ConfigManager.GrabbableToEnemiesItemBlacklistToggle, typeof(GrabbableToEnemiesBlacklistTweak)); Patch(ConfigManager.RadmechLargerHitCollider, typeof(RadmechHitColliderTweak)); Patch(ConfigManager.ButlerTallerHitCollider, typeof(ButlerTallerDamageCollider)); Patch(ConfigManager.JesterTallerHitCollider, typeof(JesterTallerDamageCollider)); Patch(ConfigManager.ButlerCollisionAdjustment, typeof(ButlerCollisionAdjustmentTweak)); Patch(ConfigManager.DisableUtilitySlot, typeof(UtilitySlotDisableTweak), typeof(UtilitySlotHUDHideTweak)); Patch(ConfigManager.PreventCheckDeadPlayersCheese, typeof(DeadPlayerCheckCheesePreventionTweak), typeof(DeadPlayerCheckCheeseTextCacheTweak)); Patch(ConfigManager.TriggerDeadlineEjectionAtZeroDays, typeof(DeadlineEjectionTweak)); Patch(ConfigManager.DisableInspectItem, typeof(ItemInspectionDisableTweak)); Patch(ConfigManager.FixZeroScaleItems, typeof(ZeroScaleItemFixTweak)); Patch(ConfigManager.DisableClock, typeof(ClockHUDHideTweak)); Patch(ConfigManager.AddClockToDeathScreen, typeof(DeathScreenClockSetupTweak), typeof(DeathScreenClockTweak)); Patch(ConfigManager.DisableChat, typeof(ChatHUDHideTweak)); Patch(ConfigManager.FixChatColon, typeof(ChatColonColorTweak)); Patch(ConfigManager.DisableCompass, typeof(CompassHUDHideTweak)); Patch(ConfigManager.DisableWeight, typeof(WeightHUDHideTweak)); if (ConfigManager.HandsFullTextPresetSelection.Value != 0) { Log.Info(((ConfigEntryBase)ConfigManager.HandsFullTextPresetSelection).Definition.Key + " enabled"); Patch(typeof(HandsFullTextPositionTweak)); } Patch(ConfigManager.ItemLightningBorder, typeof(ItemLightningBorderSetupTweak), typeof(ItemLightningBorderTweak)); Patch(ConfigManager.RemoveItemSlotFade, typeof(RemoveItemSlotFadeTweak)); Patch(ConfigManager.HideHUDAtTerminal, typeof(TerminalHUDHideTweak), typeof(TerminalHUDRestoreTweak)); Patch(ConfigManager.EnableFloodedCondensation, typeof(FloodedCondensationTweak)); Patch(ConfigManager.FixQuitGameMenuHighlightColours, typeof(QuitGameHighlightColourTweak)); Patch(ConfigManager.QuitGameColourConsistency, typeof(QuitGameTextColourTweak)); Patch(ConfigManager.HideJoinButton, typeof(JoinButtonHideTweak)); Patch(ConfigManager.HideInviteFriendsButton, typeof(InviteFriendsButtonHideTweak)); Patch(ConfigManager.HideCreditsButton, typeof(CreditsButtonHideTweak)); Patch(ConfigManager.ChangeFriendsOnlyTextToPrivate, typeof(FriendsOnlyTextToPrivateTweak)); Patch(ConfigManager.DisableControlTips, typeof(ControlTipsHideTweak)); Patch(ConfigManager.FixUtilitySlotItemIconSize, typeof(UtilitySlotIconSizeTweak)); Patch(ConfigManager.EnableTooltipRename, typeof(ControlTipItemNameTweak), typeof(ControlTipItemNameListTweak)); Patch(ConfigManager.ScanNodeOverridesToggle, typeof(ScanNodeOverrideTweak)); Patch(ConfigManager.HideWarningDisplayTipToggle, typeof(HideWarningDisplayTip)); Patch(ConfigManager.DisableFilmGrain, typeof(FilmGrainDisableTweak)); Patch(ConfigManager.BlockCustomMoonVFX, typeof(CustomMoonVFXDisableTweak), typeof(CustomMoonVFXCleanupTweak)); Patch(ConfigManager.DisableLocalPlayerSelfShadow, typeof(LocalPlayerShadowDisableTweak), typeof(HeldItemShadowDisableTweak)); if (ConfigManager.DisableLocalPlayerSelfShadow.Value && Keys.hasTooManyEmotes) { Patch(typeof(TooManyEmotesSelfShadowCompat)); } if (ConfigManager.DisableLocalPlayerSelfShadow.Value && Keys.hasLocalFlashlight) { Patch(typeof(LocalFlashlightSelfShadowCompat)); } Patch(ConfigManager.HidePlayerArms, typeof(PlayerArmsHideTweak)); Patch(ConfigManager.ToyCubeTextureFix, typeof(ToyCubeTextureFixTweak)); Patch(ConfigManager.EnableLODOverride, typeof(LODBiasOverrideSetupTweak)); Patch(ConfigManager.DisableChargeStationScanNode, typeof(ChargeStationScanNodeDisableTweak)); Patch(ConfigManager.CloseShipDoorOnLeverPull, typeof(ShipDoorCloseTweak)); Patch(ConfigManager.PlanetVideoReelDisable, typeof(PlanetVideoReelDisableTweak)); Patch(ConfigManager.EnableGlobalVolumeMeter, typeof(GlobalVoiceVolumeSliderTweak), typeof(GlobalVoiceVolumeOverlay)); Patch(ConfigManager.SavePlayerVolume, typeof(PlayerVolumeSavingTweak)); if (ConfigManager.SavePlayerVolume.Value) { SavePlayerVolumeRuntime.SaveFileSetup(); } Patch(ConfigManager.EnableDropshipPickupDelay, typeof(DropshipPickupDelayTweak)); Patch(ConfigManager.EnableShipTeleporterBlock, typeof(TeleporterItemPickupBlockTrackingTweak), typeof(TeleporterItemPickupBlockTweak), typeof(TeleporterItemPickupBlockResetTweak)); Patch(ConfigManager.EnableLandmineFix, typeof(LandmineInvisibleBumpTweak)); Patch(ConfigManager.JesterWarmup, typeof(JesterWarmupTweak)); Patch(ConfigManager.AmbientMusicWarmup, typeof(AmbientMusicPrewarmTweak)); Patch(ConfigManager.NormaliseHelmetLightBrightness, typeof(HelmetLightBrightnessTweak)); Patch(ConfigManager.UncapFPS, typeof(FpsUncapTweak)); Patch(ConfigManager.PreventErrorFromSteamImage, typeof(SteamImageErrorPreventionTweak)); if (Keys.hasDawnLib && ConfigManager.ReplaceDawnLibHotloadingPlayerImages.Value) { DawnLibHotloadingPlayerImageTweak.Load(); } PatchIf(Keys.hasDawnLib, ConfigManager.DisableAchievementPopups, typeof(DawnLibAchievementPopupTweak)); PatchIf(Keys.hasDawnLib, ConfigManager.ReplaceDawnLibHotloadingPlayerImages, typeof(DawnLibHotloadingPlayerImageTweak)); PatchIf(Keys.hasMoreBlood, ConfigManager.FixMoreBloodFootprints, typeof(MoreBloodFootprintFixTweak)); if (Keys.hasMoreCompany && (ConfigManager.HideMoreCompanyMenuButton.Value || ConfigManager.HideMoreCompanyCrewCount.Value || ConfigManager.MoreCompanyOrangeCosmeticButton.Value)) { Patch(typeof(MoreCompanyMenuTweak)); } PatchIf(Keys.hasMoreCompany, ConfigManager.HideMoreCompanyMenuButton); PatchIf(Keys.hasMoreCompany, ConfigManager.HideMoreCompanyCrewCount); PatchIf(Keys.hasMoreCompany, ConfigManager.MoreCompanyOrangeCosmeticButton); PatchIf(Keys.hasLobbyImprovements, ConfigManager.LobbyImprovementsTextEdit, typeof(LobbyImprovementsTextTweak)); PatchIf(Keys.hasLCBetterSaves, ConfigManager.BetterSavesTextEdit, typeof(BetterSavesTextTweak)); PatchIf(Keys.hasLCBetterSaves, ConfigManager.BetterSavesAutoRename, typeof(BetterSavesAutoRename)); PatchIf(Keys.hasLCBetterSaves, ConfigManager.BetterSavesStartCreditsFix, typeof(BetterSavesStartCreditsFix)); PatchIf(Keys.hasInputUtils, ConfigManager.HideKeybindsLegacyButton, typeof(InputUtilsLegacyButtonHideTweak)); PatchIf(Keys.hasLethalConfig, ConfigManager.HideLethalConfigMenu, typeof(LethalConfigMenuButtonTweak)); PatchIf(Keys.hasLethalConfig, ConfigManager.AddSpaceToLethalConfig, typeof(LethalConfigSpacingTweak)); PatchIf(Keys.hasLethalThings, ConfigManager.EnableLIUtilBeltAlign, typeof(LethalThingsUtilityBeltTweak)); PatchIf(Keys.hasMZCoMagicShipping, ConfigManager.MZCoMagicShippingNeverRespawns, typeof(MagicShippingCrateRespawnTweak), typeof(MagicShippingCrateStartCleanupTweak)); PatchIf(Keys.hasImmersiveVisor, ConfigManager.ImmersiveVisorWorksWithHurricane, typeof(ImmersiveVisorHurricaneTweak)); PatchIf(Keys.hasShipWindows, ConfigManager.ShipWindowsOpenClose, typeof(ShipWindowsOpenCloseTweak)); PatchIf(Keys.hasLethalNuke, ConfigManager.LethalNukeFix, typeof(LethalNukeFixTweak)); PatchIf(Keys.hasMirrorDecor, ConfigManager.MirrorDecorFPSCapToggle, typeof(MirrorDecorFpsCapTweak)); PatchIf(Keys.hasEnhancedMonsters, ConfigManager.RemoveEnhancedMonstersVersionNumber, typeof(EnhancedMonstersVersionNumberRemovalTweak)); PatchIf(Keys.hasLobbyControl, ConfigManager.RemoveLobbyCommand, typeof(LobbyControlCommandRemovalTweak)); PatchIf(Keys.hasGeneralImprovements, ConfigManager.PlayerScanNodeRed, typeof(GeneralImprovementsPlayerScanNodeTweak)); if (Keys.hasEladsHUD) { Patch(ConfigManager.V80Compat, typeof(EladsHUDV80Compat)); Patch(ConfigManager.FixStaminaTenPercent, typeof(EladsHUDStaminaTenPercentTweak)); Patch(ConfigManager.EladsHUDTriggerHealthShowOnHeal, typeof(EladsHUDHealthPopupTweak)); PatchIf(Keys.hasInsanityDisplay && Keys.hasOxygen, ConfigManager.EnableEladsHUDReorder, typeof(EladsHUDStaminaReorderTweak), typeof(EladsHUDInsanityReorderTweak), typeof(EladsHUDInsanityPercentageReorderTweak), typeof(EladsHUDOxygenReorderTweak)); Patch(typeof(EladsHUDTweak)); Patch(ConfigManager.DisableEladsHUDStaminaNotch); Patch(ConfigManager.HideEladsHUDWeight); Patch(ConfigManager.EladsHUDAutoHideStamina); Patch(ConfigManager.EladsHUDWeightTriggersStamina); } PatchIf(Keys.hasEladsHUD, ConfigManager.EladsHUDHideStaminaPercentage); PatchIf(Keys.hasEladsHUD && Keys.hasOxygen, ConfigManager.EladsHUDHideOxygenPercentage); PatchIf(Keys.hasEladsHUD && Keys.hasOxygen, ConfigManager.EladsHUDAutoHideOxygen); PatchIf(Keys.hasEladsHUD && Keys.hasOxygen, ConfigManager.EladsHUDHidePercentDividers); PatchIf(Keys.hasEladsHUD && Keys.hasInsanityDisplay, ConfigManager.EladsHUDHideInsanityPercentage); PatchIf(Keys.hasEladsHUD && Keys.hasInsanityDisplay, ConfigManager.EladsHUDAutoHideInsanity); if ((Keys.hasEladsHUD && ConfigManager.EladsHUDHideStaminaPercentage.Value) || (Keys.hasEladsHUD && Keys.hasInsanityDisplay && ConfigManager.EladsHUDHideInsanityPercentage.Value)) { GameObject val = CreateRunner("MrHat.NicheTweaks.PercentageHideRunner"); if (Keys.hasEladsHUD && ConfigManager.EladsHUDHideStaminaPercentage.Value) { val.AddComponent(); } if (Keys.hasEladsHUD && Keys.hasInsanityDisplay && ConfigManager.EladsHUDHideInsanityPercentage.Value) { val.AddComponent(); } } } private static void Patch(params Type[] patchTypes) { for (int i = 0; i < patchTypes.Length; i++) { _harmony.PatchAll(patchTypes[i]); } } private static void Patch(ConfigEntry configEntry, params Type[] patchTypes) { PatchIf(condition: true, configEntry, patchTypes); } private static void PatchIf(bool condition, ConfigEntry configEntry, params Type[] patchTypes) { if (condition && configEntry.Value) { Log.Info(((ConfigEntryBase)configEntry).Definition.Key + " enabled"); Patch(patchTypes); } } private static GameObject CreateRunner(string name) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown GameObject val = new GameObject(name); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)61; return val; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "NicheTweaks"; public const string PLUGIN_NAME = "NicheTweaks"; public const string PLUGIN_VERSION = "0.4.5"; } } namespace NicheTweaks.Utils { internal enum HandsFullTextPreset { DefaultNoChange, BelowInventory, AboveInventory, TopOfScreen, AboveVanillaStaminaHealthUI, BelowChat, AboveTooltips } internal static class Keys { internal static bool hasLCBetterSaves { get; private set; } internal static bool hasLethalNuke { get; private set; } internal static bool hasImmersiveVisor { get; private set; } internal static bool hasLobbyImprovements { get; private set; } internal static bool hasInsanityDisplay { get; private set; } internal static bool hasEladsHUD { get; private set; } internal static bool hasOxygen { get; private set; } internal static bool hasHotbarPlus { get; private set; } internal static bool hasGeneralImprovements { get; private set; } internal static bool hasDawnLib { get; private set; } internal static bool hasLethalConfig { get; private set; } internal static bool hasMoreBlood { get; private set; } internal static bool hasMoreCompany { get; private set; } internal static bool hasLethalThings { get; private set; } internal static bool hasMZCoMagicShipping { get; private set; } internal static bool hasDiversity { get; private set; } internal static bool hasInputUtils { get; private set; } internal static bool hasTooManyEmotes { get; private set; } internal static bool hasLocalFlashlight { get; private set; } internal static bool hasShipWindows { get; private set; } internal static bool hasMisideItems { get; private set; } internal static bool hasMirrorDecor { get; private set; } internal static bool hasKeepUnlocks { get; private set; } internal static bool hasEnhancedMonsters { get; private set; } internal static bool hasLobbyControl { get; private set; } internal static void Init() { hasLCBetterSaves = Chainloader.PluginInfos.ContainsKey("LCBetterSaves"); hasLethalNuke = Chainloader.PluginInfos.ContainsKey("Lethal_Nuke"); hasImmersiveVisor = Chainloader.PluginInfos.ContainsKey("ImmersiveVisor"); hasLobbyImprovements = Chainloader.PluginInfos.ContainsKey("uk.1a3.lobbyimprovements"); hasInsanityDisplay = Chainloader.PluginInfos.ContainsKey("InsanityDisplay.Confusified.com.GitHub"); hasEladsHUD = Chainloader.PluginInfos.ContainsKey("me.eladnlg.customhud"); hasOxygen = Chainloader.PluginInfos.ContainsKey("consequential.Oxygen"); hasHotbarPlus = Chainloader.PluginInfos.ContainsKey("FlipMods.HotbarPlus"); hasGeneralImprovements = Chainloader.PluginInfos.ContainsKey("ShaosilGaming.GeneralImprovements"); hasDawnLib = Chainloader.PluginInfos.ContainsKey("com.github.teamxiaolan.dawnlib"); hasLethalConfig = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); hasMoreBlood = Chainloader.PluginInfos.ContainsKey("FlipMods.MoreBlood"); hasMoreCompany = Chainloader.PluginInfos.ContainsKey("me.swipez.melonloader.morecompany"); hasLethalThings = Chainloader.PluginInfos.ContainsKey("evaisa.lethalthings"); hasMZCoMagicShipping = Chainloader.PluginInfos.ContainsKey("com.github.xuuxiaolan.mzcomagicshipping"); hasDiversity = Chainloader.PluginInfos.ContainsKey("Chaos.Diversity"); hasInputUtils = Chainloader.PluginInfos.ContainsKey("com.rune580.LethalCompanyInputUtils"); hasTooManyEmotes = Chainloader.PluginInfos.ContainsKey("FlipMods.TooManyEmotes"); hasLocalFlashlight = Chainloader.PluginInfos.ContainsKey("command.localFlashlight"); hasShipWindows = Chainloader.PluginInfos.ContainsKey("TestAccount666.ShipWindows"); hasMisideItems = Chainloader.PluginInfos.ContainsKey("MrHat.MisideItems.Internals"); hasMirrorDecor = Chainloader.PluginInfos.ContainsKey("quackandcheese.mirrordecor"); hasKeepUnlocks = Chainloader.PluginInfos.ContainsKey("butterystancakes.lethalcompany.keepunlocks"); hasEnhancedMonsters = Chainloader.PluginInfos.ContainsKey("com.velddev.enhancedmonsters"); hasLobbyControl = Chainloader.PluginInfos.ContainsKey("mattymatty.LobbyControl"); } } internal static class Log { internal static void Debug(string message) { Write((LogLevel)32, message); } internal static void Info(string message) { Write((LogLevel)16, message); } internal static void Warn(string message) { Write((LogLevel)4, message); } internal static void Error(string message) { Write((LogLevel)2, message); } internal static void Fatal(string message) { Write((LogLevel)1, message); } private static void Write(LogLevel logLevel, string message) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Plugin.mls != null) { Plugin.mls.Log(logLevel, (object)message); } } } internal static class SceneObjectUtils { private static readonly Dictionary cachedObjects = new Dictionary(); internal static void CacheObject(string path) { GameObject val = Find(path); if ((Object)(object)val == (Object)null) { cachedObjects.Remove(path); } else { cachedObjects[path] = val; } } internal static GameObject? GetCachedObject(string path) { GameObject value; return cachedObjects.TryGetValue(path, out value) ? value : null; } internal static void Clear() { cachedObjects.Clear(); } internal static GameObject? Find(string path) { GameObject val = GameObject.Find(path); return val ?? null; } internal static Transform? FindChild(string path, string childPath) { GameObject? obj = Find(path); return (obj != null) ? obj.transform.Find(childPath) : null; } internal static void SetActive(string path, bool active) { GameObject val = Find(path); if (val != null) { val.SetActive(active); } } internal static void SetLocalPosition(string path, Vector3 localPosition) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) GameObject val = Find(path); if (val != null) { val.transform.localPosition = localPosition; } } internal static void SetText(string path, string textValue) { string textValue2 = textValue; WithComponent(path, (Action)delegate(TextMeshProUGUI text) { ((TMP_Text)text).text = textValue2; }); } internal static void SetTextColor(string path, Color color) { //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) WithComponent(path, (Action)delegate(TextMeshProUGUI text) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ((Graphic)text).color = color; }); } internal static void SetImageColor(string path, Color color) { //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) WithComponent(path, (Action)delegate(Image image) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ((Graphic)image).color = color; }); } internal static void HideCanvasGroup(string path) { GameObject val = Find(path); if (!((Object)(object)val == (Object)null)) { CanvasGroupUtils.Hide(val); } } internal static void SetDirectChildObjectsActive(string path, bool active) { GameObject val = Find(path); if (!((Object)(object)val == (Object)null)) { Transform transform = val.transform; for (int i = 0; i < transform.childCount; i++) { ((Component)transform.GetChild(i)).gameObject.SetActive(active); } } } internal static void SetObjectsNamedActive(string objectName, bool active) { string objectName2 = objectName; IEnumerable enumerable = from transform in Object.FindObjectsOfType(true) where ((Object)transform).name == objectName2 select transform; foreach (Transform item in enumerable) { ((Component)item).gameObject.SetActive(active); } } private static void WithComponent(string path, Action action) where T : Component { T component = GetComponent(path); if ((Object)(object)component != (Object)null) { action(component); } } private static T? GetComponent(string path) where T : Component { GameObject val = Find(path); return (val != null) ? val.GetComponent() : default(T); } } internal static class ResourceUtils { internal static T[] FindAll() where T : Object { return Resources.FindObjectsOfTypeAll(); } internal static T FindFirst() where T : Object { return FindAll()[0]; } internal static GameObject? FindGameObject(Func predicate) { GameObject[] array = ResourceUtils.FindAll(); foreach (GameObject val in array) { if (predicate(val)) { return val; } } return null; } } internal static class CoroutineUtils { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float seconds; public Action action; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(seconds); <>1__state = 1; return true; case 1: <>1__state = -1; action(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Action action; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; action(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] internal static IEnumerator DelayThen(float seconds, Action action) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0) { seconds = seconds, action = action }; } [IteratorStateMachine(typeof(d__1))] internal static IEnumerator NextFrameThen(Action action) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { action = action }; } } internal static class AudioPrewarmUtils { internal static int Prewarm(AudioSource audioSource, IEnumerable clips, HashSet prewarmedClipIds) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 AudioClip clip = audioSource.clip; float volume = audioSource.volume; float time = audioSource.time; bool isPlaying = audioSource.isPlaying; int num = 0; foreach (AudioClip clip2 in clips) { if (!((Object)(object)clip2 == (Object)null) && (int)clip2.loadType != 2 && prewarmedClipIds.Add(((Object)clip2).GetInstanceID())) { audioSource.clip = clip2; audioSource.volume = 0f; audioSource.Play(); audioSource.Pause(); audioSource.Stop(); audioSource.time = 0f; num++; } } audioSource.clip = clip; audioSource.volume = volume; if (isPlaying && (Object)(object)clip != (Object)null) { audioSource.time = Mathf.Min(time, clip.length); audioSource.Play(); } else { audioSource.Stop(); } return num; } } internal static class ConfigStringUtils { internal static List SplitCommaSeparated(string raw) { List list = new List(); if (string.IsNullOrWhiteSpace(raw)) { return list; } string[] array = raw.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { list.Add(text); } } return list; } internal static Dictionary ParseAssignments(string raw, char separator) { Dictionary dictionary = new Dictionary(); if (string.IsNullOrWhiteSpace(raw)) { return dictionary; } foreach (string item in SplitCommaSeparated(raw)) { int num = item.IndexOf(separator); if (num > 0 && num < item.Length - 1) { string text = item.Substring(0, num).Trim(); string text2 = item.Substring(num + 1).Trim(); if (text.Length != 0 && text2.Length != 0) { dictionary[text] = text2; } } } return dictionary; } internal static Dictionary ParseIntAssignments(string raw, char separator, int minValue, int maxValue) { Dictionary dictionary = new Dictionary(); if (string.IsNullOrWhiteSpace(raw)) { return dictionary; } foreach (string item in SplitCommaSeparated(raw)) { int num = item.LastIndexOf(separator); if (num > 0 && num < item.Length - 1) { string text = item.Substring(0, num).Trim(); string s = item.Substring(num + 1).Trim(); if (text.Length != 0 && int.TryParse(s, out var result) && result >= minValue && result <= maxValue) { dictionary[text] = result; } } } return dictionary; } } internal static class CanvasGroupUtils { internal static CanvasGroup GetOrAdd(GameObject gameObject) { CanvasGroup component = gameObject.GetComponent(); return Object.op_Implicit((Object)(object)component) ? component : gameObject.AddComponent(); } internal static CanvasGroup GetOrAdd(Transform transform) { return GetOrAdd(((Component)transform).gameObject); } internal static float GetAlpha(Transform transform) { CanvasGroup component = ((Component)transform).GetComponent(); return Object.op_Implicit((Object)(object)component) ? component.alpha : 1f; } internal static void SetAlpha(Transform transform, float alpha) { GetOrAdd(((Component)transform).gameObject).alpha = alpha; } internal static void SetAlpha(float alpha, CanvasGroup? first, CanvasGroup? second, CanvasGroup? third, CanvasGroup? fourth) { if (first != null) { first.alpha = alpha; } if (second != null) { second.alpha = alpha; } if (third != null) { third.alpha = alpha; } if (fourth != null) { fourth.alpha = alpha; } } internal static void Hide(GameObject gameObject) { CanvasGroup orAdd = GetOrAdd(gameObject); orAdd.alpha = 0f; orAdd.interactable = false; orAdd.blocksRaycasts = false; } } internal static class AssetBundleUtils { internal static bool TryLoadAsset(string bundleFileName, string assetPath, out T? asset, out string bundlePath) where T : Object { string path = Path.GetDirectoryName(typeof(Plugin).Assembly.Location) ?? string.Empty; bundlePath = Path.Combine(path, bundleFileName); AssetBundle val = AssetBundle.LoadFromFile(bundlePath); if ((Object)(object)val == (Object)null) { asset = default(T); return false; } asset = val.LoadAsset(assetPath); val.Unload(false); return (Object)(object)asset != (Object)null; } } } namespace NicheTweaks.Tweaks.Visuals { internal static class MoonVFXBlock { private static readonly HashSet moonFilterKeys = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly Regex levelSuffixRegex = new Regex("Level$", RegexOptions.IgnoreCase | RegexOptions.Compiled); private static bool enabled; private static bool hooksInstalled; private static string? lastRawFilter; internal static void Start() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) enabled = true; SceneHooks(); SetMoonFilter(ConfigManager.BlockCustomMoonVFXMoonFilter.Value); ApplyIfLoadedSceneIsCurrentLevel(SceneManager.GetActiveScene()); } internal static void Clear() { enabled = false; moonFilterKeys.Clear(); lastRawFilter = null; } private static void SceneHooks() { if (!hooksInstalled) { hooksInstalled = true; SceneManager.sceneLoaded += OnSceneLoaded; } } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (enabled) { ApplyIfLoadedSceneIsCurrentLevel(scene); } } private static void SetMoonFilter(string commaSeparatedMoonNames) { if (string.Equals(lastRawFilter, commaSeparatedMoonNames, StringComparison.Ordinal)) { return; } lastRawFilter = commaSeparatedMoonNames; moonFilterKeys.Clear(); if (string.IsNullOrWhiteSpace(commaSeparatedMoonNames)) { return; } foreach (string item in ConfigStringUtils.SplitCommaSeparated(commaSeparatedMoonNames)) { string text = NormaliseMoonKey(item); if (!string.IsNullOrWhiteSpace(text)) { moonFilterKeys.Add(text); } } } private static string NormaliseMoonKey(string raw) { if (string.IsNullOrWhiteSpace(raw)) { return string.Empty; } string input = raw.Trim(); return levelSuffixRegex.Replace(input, string.Empty).Trim(); } private static bool LevelMatchesFilter(SelectableLevel level) { if (moonFilterKeys.Count == 0) { return true; } string text = NormaliseMoonKey(((Object)level).name); return !string.IsNullOrWhiteSpace(text) && moonFilterKeys.Contains(text); } private static void ApplyIfLoadedSceneIsCurrentLevel(Scene loadedScene) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!((Scene)(ref loadedScene)).IsValid() || !((Scene)(ref loadedScene)).isLoaded || string.Equals(((Scene)(ref loadedScene)).name, "SampleSceneRelay", StringComparison.OrdinalIgnoreCase)) { return; } SelectableLevel val = StartOfRound.Instance?.currentLevel; if (!((Object)(object)val == (Object)null) && LevelMatchesFilter(val)) { string sceneName = val.sceneName; if (!string.IsNullOrWhiteSpace(sceneName) && string.Equals(((Scene)(ref loadedScene)).name, sceneName, StringComparison.Ordinal)) { DisableVFXInScene(loadedScene, out var vfxFound, out var vfxDisabled, out var volumesFound, out var volumesDisabled); Log.Debug($"moon scene vfx disabled in {((Scene)(ref loadedScene)).name} with {vfxDisabled} of {vfxFound} effects and {volumesDisabled} of {volumesFound} volumes"); } } } private static void DisableVFXInScene(Scene scene, out int vfxFound, out int vfxDisabled, out int volumesFound, out int volumesDisabled) { vfxFound = 0; vfxDisabled = 0; volumesFound = 0; volumesDisabled = 0; GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if ((Object)(object)val == (Object)null) { continue; } VisualEffect[] componentsInChildren = val.GetComponentsInChildren(true); foreach (VisualEffect val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { vfxFound++; if (((Behaviour)val2).enabled) { ((Behaviour)val2).enabled = false; vfxDisabled++; } } } Volume[] componentsInChildren2 = val.GetComponentsInChildren(true); foreach (Volume val3 in componentsInChildren2) { if (!((Object)(object)val3 == (Object)null)) { volumesFound++; bool flag = false; if (((Behaviour)val3).enabled) { ((Behaviour)val3).enabled = false; flag = true; } if (val3.weight > 0f) { val3.weight = 0f; flag = true; } if (flag) { volumesDisabled++; } } } } } } [HarmonyPatch(typeof(RoundManager), "Start")] internal static class CustomMoonVFXDisableTweak { [HarmonyPostfix] private static void Postfix() { MoonVFXBlock.Start(); } } [HarmonyPatch(typeof(StartOfRound), "OnDestroy")] internal static class CustomMoonVFXCleanupTweak { [HarmonyPostfix] private static void Postfix() { MoonVFXBlock.Clear(); } } [HarmonyPatch(typeof(FilmGrain))] internal static class FilmGrainDisableTweak { [HarmonyPatch("IsActive")] [HarmonyPrefix] private static bool Prefix(ref bool __result) { __result = false; return false; } } [HarmonyPatch(typeof(PlayerControllerB), "Start")] internal static class LODBiasOverrideSetupTweak { [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance) { HDAdditionalCameraData cam = default(HDAdditionalCameraData); if (((Component)__instance.gameplayCamera).TryGetComponent(ref cam)) { LODBiasOverride.Apply(cam); } } } internal static class LODBiasOverride { internal static void Apply(HDAdditionalCameraData cam) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) cam.customRenderingSettings = true; ((BitArray128)(ref cam.renderingPathCustomFrameSettingsOverrideMask.mask))[60u] = true; ((BitArray128)(ref cam.renderingPathCustomFrameSettingsOverrideMask.mask))[61u] = true; ((FrameSettings)(ref cam.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)60, true); ((FrameSettings)(ref cam.renderingPathCustomFrameSettings)).SetEnabled((FrameSettingsField)61, true); cam.renderingPathCustomFrameSettings.lodBiasMode = (LODBiasMode)2; cam.renderingPathCustomFrameSettings.lodBias = ConfigManager.LODBias.Value; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] internal static class PlayerArmsHideTweak { [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance) { ((Renderer)__instance.thisPlayerModelArms).enabled = false; } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] internal static class ToyCubeTextureFixTweak { private const string BundleFileName = "toycubefixassets"; private const string MaterialAssetPath = "Assets/LethalCompany/Mods/plugins/NicheTweaks/ToyCubeMaterialFix/ToyCubeFixed.mat"; private static Material? fixedToyCubeMaterial; [HarmonyPostfix] private static void OnGameNetworkManagerStart() { if ((Object)(object)fixedToyCubeMaterial == (Object)null && !AssetBundleUtils.TryLoadAsset("toycubefixassets", "Assets/LethalCompany/Mods/plugins/NicheTweaks/ToyCubeMaterialFix/ToyCubeFixed.mat", out fixedToyCubeMaterial, out string bundlePath)) { Log.Error("toy cube material missing from asset bundle at " + bundlePath); return; } GameObject[] array = ResourceUtils.FindAll(); GrabbableObject val2 = default(GrabbableObject); foreach (GameObject val in array) { if (!val.TryGetComponent(ref val2)) { continue; } Item itemProperties = val2.itemProperties; if (!((Object)(object)itemProperties == (Object)null) && IsToyCubeName(itemProperties.itemName)) { MeshRenderer componentInChildren = val.GetComponentInChildren(true); if (!((Object)(object)componentInChildren == (Object)null)) { ((Renderer)componentInChildren).sharedMaterial = fixedToyCubeMaterial; break; } } } } private static bool IsToyCubeName(string itemName) { if (string.IsNullOrWhiteSpace(itemName)) { return false; } string text = itemName.Replace(" ", ""); return text.Equals("ToyCube", StringComparison.OrdinalIgnoreCase); } } } namespace NicheTweaks.Tweaks.Visuals.PlayerSelfShadow { internal static class HeldItemShadowDisableTweak { [HarmonyPatch(typeof(GrabbableObject), "GrabItem")] [HarmonyPostfix] private static void GrabItemPostfix(GrabbableObject __instance) { Refresh(__instance); } [HarmonyPatch(typeof(GrabbableObject), "EquipItem")] [HarmonyPostfix] private static void EquipItemPostfix(GrabbableObject __instance) { Refresh(__instance); } [HarmonyPatch(typeof(GrabbableObject), "DiscardItem")] [HarmonyPostfix] private static void DiscardItemPostfix(GrabbableObject __instance) { if (__instance.hasHitGround) { HeldItemShadowCache.RestoreIfGrounded(__instance); } } [HarmonyPatch(typeof(GrabbableObject), "OnHitGround")] [HarmonyPostfix] private static void OnHitGroundPostfix(GrabbableObject __instance) { HeldItemShadowCache.RestoreIfGrounded(__instance); } internal static void RefreshHeldItems(PlayerControllerB player) { if ((Object)(object)player == (Object)null || player.ItemSlots == null) { return; } for (int i = 0; i < player.ItemSlots.Length; i++) { GrabbableObject val = player.ItemSlots[i]; if (!((Object)(object)val == (Object)null)) { Refresh(val); } } } private static void Refresh(GrabbableObject item) { if ((Object)(object)item == (Object)null) { return; } if (!item.isHeld) { if (item.hasHitGround) { HeldItemShadowCache.RestoreIfGrounded(item); } return; } PlayerControllerB playerHeldBy = item.playerHeldBy; if (playerHeldBy != null && ((NetworkBehaviour)playerHeldBy).IsOwner) { HeldItemShadowCache.Cache(item); if (LocalPlayerShadowDisableTweak.ShouldHideHeldItemShadows(playerHeldBy)) { HeldItemShadowCache.ApplyHeld(item); } else { HeldItemShadowCache.Restore(item); } } } } internal static class HeldItemShadowCache { private class CachedItemShadowState { public readonly CachedRendererShadowState[] Renderers; public readonly bool HasAnyShadowEnabled; public bool ShadowsHidden; public CachedItemShadowState(CachedRendererShadowState[] renderers, bool hasAnyShadowEnabled) { Renderers = renderers; HasAnyShadowEnabled = hasAnyShadowEnabled; base..ctor(); } } private readonly struct CachedRendererShadowState { public readonly Renderer Renderer; public readonly ShadowCastingMode ShadowCastingMode; public CachedRendererShadowState(Renderer renderer) { //IL_0009: 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) Renderer = renderer; ShadowCastingMode = renderer.shadowCastingMode; } } private static readonly Dictionary cachedItems = new Dictionary(); internal static void Cache(GrabbableObject item) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 if ((Object)(object)item == (Object)null || cachedItems.ContainsKey(item)) { return; } Renderer[] componentsInChildren = ((Component)item).GetComponentsInChildren(true); List list = new List(componentsInChildren.Length); bool hasAnyShadowEnabled = false; foreach (Renderer val in componentsInChildren) { if (val is MeshRenderer || val is SkinnedMeshRenderer) { list.Add(new CachedRendererShadowState(val)); if ((int)val.shadowCastingMode > 0) { hasAnyShadowEnabled = true; } } } if (list.Count != 0) { cachedItems[item] = new CachedItemShadowState(list.ToArray(), hasAnyShadowEnabled); } } internal static void ApplyHeld(GrabbableObject item) { if (item == null || !item.isHeld || !cachedItems.TryGetValue(item, out CachedItemShadowState value) || !value.HasAnyShadowEnabled || value.ShadowsHidden) { return; } for (int i = 0; i < value.Renderers.Length; i++) { Renderer renderer = value.Renderers[i].Renderer; if (!((Object)(object)renderer == (Object)null)) { renderer.shadowCastingMode = (ShadowCastingMode)0; } } value.ShadowsHidden = true; } internal static void Restore(GrabbableObject item) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null || !cachedItems.TryGetValue(item, out CachedItemShadowState value) || !value.HasAnyShadowEnabled || !value.ShadowsHidden) { return; } for (int i = 0; i < value.Renderers.Length; i++) { CachedRendererShadowState cachedRendererShadowState = value.Renderers[i]; if (!((Object)(object)cachedRendererShadowState.Renderer == (Object)null)) { cachedRendererShadowState.Renderer.shadowCastingMode = cachedRendererShadowState.ShadowCastingMode; } } value.ShadowsHidden = false; } internal static void RestoreIfGrounded(GrabbableObject item) { if (item != null && item.hasHitGround) { Restore(item); } } internal static void Clear() { cachedItems.Clear(); } } [HarmonyPatch] internal static class LocalFlashlightSelfShadowCompat { private static FieldInfo? cachedPublicFlashStateField; [HarmonyTargetMethod] private static MethodBase TargetMethod() { return AccessTools.Method("LocalFlashlight.LightScript:Toggle", (Type[])null, (Type[])null); } [HarmonyPostfix] private static void Postfix() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { LocalPlayerShadowDisableTweak.Refresh(val); } } private static bool GetPublicFlashState() { if (cachedPublicFlashStateField == null) { Type type = Type.GetType("LocalFlashlight.LightScript, LocalFlashlight"); if (type == null) { return false; } cachedPublicFlashStateField = type.GetField("publicFlashState", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (cachedPublicFlashStateField == null) { return false; } } return (bool)cachedPublicFlashStateField.GetValue(null); } internal static bool IsLocalFlashlightOn() { return GetPublicFlashState(); } } [HarmonyPatch] internal static class LocalPlayerShadowDisableTweak { [CompilerGenerated] private sealed class d__25 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; Refresh(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly HashSet cachedFlashlights = new HashSet(); private static PlayerControllerB? cachedPlayer; private static SkinnedMeshRenderer? cachedLod1Renderer; private static SkinnedMeshRenderer? cachedLod2Renderer; private static bool CacheRenderers(PlayerControllerB player) { if ((Object)(object)player == (Object)null) { return false; } if (!((NetworkBehaviour)player).IsOwner) { return false; } if ((Object)(object)cachedPlayer == (Object)(object)player && ((Object)(object)cachedLod1Renderer != (Object)null || (Object)(object)cachedLod2Renderer != (Object)null)) { return true; } cachedPlayer = player; Transform val = ((Component)player).transform.Find("ScavengerModel"); if ((Object)(object)val == (Object)null) { return false; } Transform val2 = val.Find("LOD1"); Transform val3 = val.Find("LOD2"); cachedLod1Renderer = ((val2 != null) ? ((Component)val2).GetComponent() : null); cachedLod2Renderer = ((val3 != null) ? ((Component)val3).GetComponent() : null); return (Object)(object)cachedLod1Renderer != (Object)null || (Object)(object)cachedLod2Renderer != (Object)null; } private static void SetLODRenderers(PlayerControllerB player, bool enabled) { if (CacheRenderers(player)) { SkinnedMeshRenderer? obj = cachedLod1Renderer; if (obj != null) { ((Renderer)obj).enabled = enabled; } SkinnedMeshRenderer? obj2 = cachedLod2Renderer; if (obj2 != null) { ((Renderer)obj2).enabled = enabled; } } } internal static void RegisterFlashlight(FlashlightItem flashlight) { if (!((Object)(object)flashlight == (Object)null)) { cachedFlashlights.Add(flashlight); } } internal static void UnregisterFlashlight(FlashlightItem flashlight) { if (!((Object)(object)flashlight == (Object)null)) { cachedFlashlights.Remove(flashlight); } } internal static void ClearCache() { cachedFlashlights.Clear(); cachedPlayer = null; cachedLod1Renderer = null; cachedLod2Renderer = null; } private static void Refresh(PlayerControllerB player, bool hide) { SetLODRenderers(player, !hide); } private static bool ShouldHidePlayerSelfShadow(PlayerControllerB player) { if (player == null || !((NetworkBehaviour)player).IsOwner) { return false; } if (Keys.hasLocalFlashlight && LocalFlashlightSelfShadowCompat.IsLocalFlashlightOn()) { return true; } bool flag = IsAnyFlashlightOn(player); Light helmetLight = player.helmetLight; bool flag2 = helmetLight != null && ((Behaviour)helmetLight).enabled; return flag || flag2; } internal static bool ShouldHideHeldItemShadows(PlayerControllerB player) { if (player == null || !((NetworkBehaviour)player).IsOwner) { return false; } return !TooManyEmotesSelfShadowCompat.IsLocalPlayerEmoting() && ((Keys.hasLocalFlashlight && LocalFlashlightSelfShadowCompat.IsLocalFlashlightOn()) || IsAnyFlashlightOn(player)); } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "OnDestroy")] private static void Postfix_StartOfRound() { ClearCache(); } [HarmonyPostfix] [HarmonyPatch(typeof(FlashlightItem), "Start")] private static void Postfix_FlashlightStart(FlashlightItem __instance) { RegisterFlashlight(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ChangeHelmetLight")] private static void Postfix_ChangeHelmetLight(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner) { Refresh(__instance); } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "Start")] private static void Postfix_PlayerStart(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner) { Refresh(__instance); } } [HarmonyPostfix] [HarmonyPatch(typeof(FlashlightItem), "SwitchFlashlight")] private static void Postfix_SwitchFlashlight(FlashlightItem __instance) { PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy; if (!((Object)(object)playerHeldBy == (Object)null) && ((NetworkBehaviour)playerHeldBy).IsOwner) { Refresh(playerHeldBy); } } [HarmonyPostfix] [HarmonyPatch(typeof(FlashlightItem), "DiscardItem")] private static void Postfix_DropFlashlight() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null) && ((NetworkBehaviour)val).IsOwner) { Refresh(val); } } [HarmonyPostfix] [HarmonyPatch(typeof(FlashlightItem), "EquipItem")] private static void Postfix_EquipFlashlight(FlashlightItem __instance) { PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy; if (!((Object)(object)playerHeldBy == (Object)null) && ((NetworkBehaviour)playerHeldBy).IsOwner) { Refresh(playerHeldBy); } } internal static void Refresh(PlayerControllerB player) { if (!((Object)(object)player == (Object)null)) { bool hide = !TooManyEmotesSelfShadowCompat.IsLocalPlayerEmoting() && ShouldHidePlayerSelfShadow(player); Refresh(player, hide); HeldItemShadowDisableTweak.RefreshHeldItems(player); } } private static void Refresh() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { Refresh(val); } } internal static void ApplyHideFromEmote(PlayerControllerB player) { Refresh(player, hide: true); HeldItemShadowDisableTweak.RefreshHeldItems(player); } internal static void ApplyShowFromEmote(PlayerControllerB player) { Refresh(player, hide: false); HeldItemShadowDisableTweak.RefreshHeldItems(player); } private static bool IsAnyFlashlightOn(PlayerControllerB player) { if (cachedFlashlights.Count == 0) { return false; } List list = null; bool result = false; foreach (FlashlightItem cachedFlashlight in cachedFlashlights) { if ((Object)(object)cachedFlashlight == (Object)null) { if (list == null) { list = new List(); } list.Add(cachedFlashlight); } else if (!((Object)(object)((GrabbableObject)cachedFlashlight).playerHeldBy != (Object)(object)player) && ((GrabbableObject)cachedFlashlight).isBeingUsed) { result = true; break; } } if (list != null) { for (int i = 0; i < list.Count; i++) { cachedFlashlights.Remove(list[i]); } } return result; } internal static void RefreshLocalPlayerNextFrame() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { ((MonoBehaviour)val).StartCoroutine(DelayedRefresh()); } } [IteratorStateMachine(typeof(d__25))] private static IEnumerator DelayedRefresh() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__25(0); } } [HarmonyPatch] internal static class TooManyEmotesSelfShadowCompat { private static bool localPlayerIsEmoting; internal static bool IsLocalPlayerEmoting() { return localPlayerIsEmoting; } [HarmonyPatch(typeof(ThirdPersonEmoteController), "OnStartCustomEmoteLocal")] [HarmonyPostfix] private static void OnStartEmote() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { localPlayerIsEmoting = true; LocalPlayerShadowDisableTweak.ApplyShowFromEmote(val); } } [HarmonyPatch(typeof(ThirdPersonEmoteController), "OnStopCustomEmoteLocal")] [HarmonyPostfix] private static void OnStopEmote() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { localPlayerIsEmoting = false; LocalPlayerShadowDisableTweak.Refresh(val); LocalPlayerShadowDisableTweak.RefreshLocalPlayerNextFrame(); } } } } namespace NicheTweaks.Tweaks.Ship { [HarmonyPatch(typeof(StartOfRound), "Start")] internal static class ChargeStationScanNodeDisableTweak { [HarmonyPostfix] private static void OnStart() { SceneObjectUtils.SetActive("Environment/HangarShip/ShipModels2b/ChargeStation/ScanNode (1)", active: false); } } [HarmonyPatch] internal static class PlanetVideoReelDisableTweak { internal class StayDisabledForever : MonoBehaviour { private void Awake() { if (((Component)this).gameObject.activeSelf) { ((Component)this).gameObject.SetActive(false); } } private void OnEnable() { ((Component)this).gameObject.SetActive(false); } } private static GameObject? planetVideoReel; [HarmonyPatch(typeof(StartOfRound), "ResetPlayersLoadedValueClientRpc")] [HarmonyPatch(typeof(StartOfRound), "PlayerLoadedClientRpc")] [HarmonyPatch(typeof(StartOfRound), "PlayerLoadedServerRpc")] [HarmonyPostfix] private static void Postfix() { if ((Object)(object)planetVideoReel == (Object)null) { planetVideoReel = SceneObjectUtils.Find("MapScreenUI/PlanetVideoReel"); } if (!((Object)(object)planetVideoReel == (Object)null) && (Object)(object)planetVideoReel.GetComponent() == (Object)null) { planetVideoReel.AddComponent(); } } } [HarmonyPatch] internal static class ShipDoorCloseTweak { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnRequest; public static HandleNamedMessageDelegate <1>__OnApply; } private const string Request = "MrHat.NicheTweaks.ShipDoorClose.Request"; private const string Apply = "MrHat.NicheTweaks.ShipDoorClose.Apply"; [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void StartOfRoundStartPostfix() { Wired(); } [HarmonyPatch(typeof(StartMatchLever), "StartGame")] [HarmonyPostfix] private static void StartMatchLeverStartGamePostfix() { Wired(); SendRequest(); } private static void Wired() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //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_006e: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; customMessagingManager.UnregisterNamedMessageHandler("MrHat.NicheTweaks.ShipDoorClose.Request"); customMessagingManager.UnregisterNamedMessageHandler("MrHat.NicheTweaks.ShipDoorClose.Apply"); object obj = <>O.<0>__OnRequest; if (obj == null) { HandleNamedMessageDelegate val = OnRequest; <>O.<0>__OnRequest = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("MrHat.NicheTweaks.ShipDoorClose.Request", (HandleNamedMessageDelegate)obj); object obj2 = <>O.<1>__OnApply; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnApply; <>O.<1>__OnApply = val2; obj2 = (object)val2; } customMessagingManager.RegisterNamedMessageHandler("MrHat.NicheTweaks.ShipDoorClose.Apply", (HandleNamedMessageDelegate)obj2); } private static void SendRequest() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { return; } CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(1, (Allocator)2, -1); try { customMessagingManager.SendNamedMessage("MrHat.NicheTweaks.ShipDoorClose.Request", 0uL, val, (NetworkDelivery)2); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } private static void OnRequest(ulong sender, FastBufferReader reader) { if (NetworkManager.Singleton.IsServer) { Broadcast(); ApplyLocal(); } } private static void OnApply(ulong sender, FastBufferReader reader) { ApplyLocal(); } private static void Broadcast() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(1, (Allocator)2, -1); try { customMessagingManager.SendNamedMessageToAll("MrHat.NicheTweaks.ShipDoorClose.Apply", val, (NetworkDelivery)2); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } private static void ApplyLocal() { StartOfRound instance = StartOfRound.Instance; HangarShipDoor val = Object.FindObjectOfType(); instance.SetShipDoorsClosed(true); val.PlayDoorAnimation(true); val.SetDoorButtonsEnabled(false); } } } namespace NicheTweaks.Tweaks.QoL { internal static class AmbientMusicPrewarmTweak { [CompilerGenerated] private sealed class d__2 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private AudioClip? <>2__current; private int <>l__initialThreadId; private SoundManager soundManager; public SoundManager <>3__soundManager; private AudioClip[] <>s__1; private int <>s__2; private AudioClip 5__3; private AudioClip[] <>s__4; private int <>s__5; private AudioClip 5__6; AudioClip IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = null; 5__3 = null; <>s__4 = null; 5__6 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>s__1 = soundManager.DaytimeMusic; <>s__2 = 0; goto IL_008d; case 1: <>1__state = -1; 5__3 = null; <>s__2++; goto IL_008d; case 2: { <>1__state = -1; 5__6 = null; <>s__5++; break; } IL_008d: if (<>s__2 < <>s__1.Length) { 5__3 = <>s__1[<>s__2]; <>2__current = 5__3; <>1__state = 1; return true; } <>s__1 = null; <>s__4 = soundManager.EveningMusic; <>s__5 = 0; break; } if (<>s__5 < <>s__4.Length) { 5__6 = <>s__4[<>s__5]; <>2__current = 5__6; <>1__state = 2; return true; } <>s__4 = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__2 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__2(0); } d__.soundManager = <>3__soundManager; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly HashSet prewarmedClipIds = new HashSet(); [HarmonyPatch(typeof(SoundManager), "Start")] [HarmonyPostfix] private static void Postfix(SoundManager __instance) { AudioSource musicSource = __instance.musicSource; if ((Object)(object)musicSource == (Object)null) { Log.Debug("ambient music warmup skipped because music source was not ready"); return; } Stopwatch stopwatch = Stopwatch.StartNew(); int num = AudioPrewarmUtils.Prewarm(musicSource, GetAmbientMusicClips(__instance), prewarmedClipIds); stopwatch.Stop(); Log.Debug($"ambient music warmup completed in {stopwatch.Elapsed.TotalMilliseconds:F2} ms with {num} clips prewarmed"); } [IteratorStateMachine(typeof(d__2))] private static IEnumerable GetAmbientMusicClips(SoundManager soundManager) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(-2) { <>3__soundManager = soundManager }; } } internal static class DropshipPickupDelayTweak { private static float blockUntilTime; private static bool blockActive; internal static void StartCooldown(float seconds) { blockUntilTime = Time.time + seconds; blockActive = true; } [HarmonyPatch(typeof(PlayerControllerB), "Interact_performed")] [HarmonyPrefix] private static bool Prefix() { if (!blockActive) { return true; } if (Time.time >= blockUntilTime) { blockActive = false; return true; } return false; } [HarmonyPatch(typeof(InteractTrigger), "Interact")] [HarmonyPostfix] private static void Postfix(InteractTrigger __instance) { ItemDropship componentInParent = ((Component)__instance).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { StartCooldown(ConfigManager.DropshipPickupDelayTime.Value); } } } internal static class FpsUncapTweak { [HarmonyPatch(typeof(IngamePlayerSettings))] [HarmonyPatch("UpdateGameToMatchSettings")] [HarmonyPatch("SetFramerateCap")] [HarmonyPostfix] private static void Postfix() { Application.targetFrameRate = -1; } } [HarmonyPatch(typeof(QuickMenuManager))] internal static class GlobalVoiceVolumeSliderTweak { [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPostfix(QuickMenuManager __instance) { GlobalVoiceVolumeOverlay.AddGlobalSlider(__instance); } [HarmonyPatch("AddUserToPlayerList")] [HarmonyPostfix] private static void AddUserToPlayerListPostfix(QuickMenuManager __instance) { QuickMenuManager __instance2 = __instance; if (!((Object)(object)GlobalVoiceVolumeOverlay.GlobalSlider == (Object)null)) { ((MonoBehaviour)__instance2).StartCoroutine(CoroutineUtils.NextFrameThen(delegate { GlobalVoiceVolumeOverlay.ApplyGlobalVolumeToAllSlots(__instance2, GlobalVoiceVolumeOverlay.GlobalSlider.value); })); } } } internal class GlobalVoiceVolumeOverlay : MonoBehaviour { internal static Slider? GlobalSlider; internal static void AddGlobalSlider(QuickMenuManager qm) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) QuickMenuManager qm2 = qm; if ((Object)(object)GlobalSlider != (Object)null) { return; } PlayerListSlot[] playerListSlots = qm2.playerListSlots; Slider val = ((playerListSlots == null) ? null : playerListSlots[0]?.volumeSlider); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = SceneObjectUtils.Find("Systems/UI/Canvas/QuickMenu/PlayerList/Image"); if (!((Object)(object)val2 == (Object)null)) { GameObject val3 = new GameObject("MrHat.NicheTweaks.GlobalVoiceHolder", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(val2.transform, false); RectTransform component = val3.GetComponent(); component.anchorMin = new Vector2(1f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 1f); component.anchoredPosition = new Vector2(2f, -13f); component.sizeDelta = new Vector2(125f, 20f); GlobalSlider = Object.Instantiate(val, val3.transform); ((Object)GlobalSlider).name = "MrHat.NicheTweaks.GlobalVoiceVolume"; RectTransform component2 = ((Component)GlobalSlider).GetComponent(); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); component2.pivot = val4; Vector2 anchorMin = (component2.anchorMax = val4); component2.anchorMin = anchorMin; component2.anchoredPosition = Vector2.zero; component2.sizeDelta = ((Component)val).GetComponent().sizeDelta; Image[] componentsInChildren = ((Component)GlobalSlider).GetComponentsInChildren(); foreach (Image val6 in componentsInChildren) { ((Graphic)val6).color = new Color(((Graphic)val6).color.r, ((Graphic)val6).color.g, ((Graphic)val6).color.b, 1f); } ((Selectable)GlobalSlider).interactable = true; GlobalSlider.value = val.value; ((UnityEvent)(object)GlobalSlider.onValueChanged).AddListener((UnityAction)delegate(float value) { ApplyGlobalVolumeToAllSlots(qm2, value); }); } } internal static void ApplyGlobalVolumeToAllSlots(QuickMenuManager quickMenuManager, float value) { PlayerListSlot[] playerListSlots = quickMenuManager.playerListSlots; foreach (PlayerListSlot val in playerListSlots) { if (!((Object)(object)val?.volumeSlider == (Object)null)) { val.volumeSlider.value = value; } } } } [HarmonyPatch(typeof(FlashlightItem))] internal static class HelmetLightBrightnessTweak { [HarmonyPatch("PocketItem")] [HarmonyPatch("PocketFlashlightClientRpc")] [HarmonyPatch("SwitchFlashlight")] [HarmonyPostfix] private static void Postfix_FlashlightItem(FlashlightItem __instance) { HelmetLightBrightness.Apply(__instance); } [HarmonyPatch(typeof(PlayerControllerB), "ChangeHelmetLight")] [HarmonyPostfix] private static void Postfix_ChangeHelmetLight(PlayerControllerB __instance) { GrabbableObject pocketedFlashlight = __instance.pocketedFlashlight; HelmetLightBrightness.Apply((FlashlightItem?)(object)((pocketedFlashlight is FlashlightItem) ? pocketedFlashlight : null)); } } internal static class HelmetLightBrightness { internal static void Apply(FlashlightItem? flashlight) { if (flashlight == null || !flashlight.usingPlayerHelmetLight || (Object)(object)flashlight.flashlightBulb == (Object)null) { return; } PlayerControllerB val = ((GrabbableObject)flashlight).playerHeldBy ?? flashlight.previousPlayerHeldBy; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.helmetLight == (Object)null)) { float intensity = flashlight.flashlightBulb.intensity; if (!Mathf.Approximately(val.helmetLight.intensity, intensity)) { val.helmetLight.intensity = intensity; } } } } internal static class JesterWarmupTweak { [CompilerGenerated] private sealed class d__2 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private AudioClip? <>2__current; private int <>l__initialThreadId; private JesterAI jester; public JesterAI <>3__jester; AudioClip IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = jester.popGoesTheWeaselTheme; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = jester.popUpSFX; <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = jester.screamingSFX; <>1__state = 3; return true; case 3: <>1__state = -1; <>2__current = jester.killPlayerSFX; <>1__state = 4; return true; case 4: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__2 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__2(0); } d__.jester = <>3__jester; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly HashSet prewarmedClipIds = new HashSet(); [HarmonyPatch(typeof(SoundManager), "Start")] [HarmonyPostfix] private static void Postfix(SoundManager __instance) { JesterAI[] array = ResourceUtils.FindAll(); if (array.Length == 0) { Log.Debug("jester audio warmup skipped because no jester prefab was found"); return; } JesterAI jester = array[0]; AudioSource tempAudio = __instance.tempAudio1; if ((Object)(object)tempAudio == (Object)null) { Log.Debug("jester audio warmup skipped because temp audio was not ready"); return; } Stopwatch stopwatch = Stopwatch.StartNew(); int num = AudioPrewarmUtils.Prewarm(tempAudio, GetJesterClips(jester), prewarmedClipIds); stopwatch.Stop(); Log.Debug($"jester audio warmup completed in {stopwatch.Elapsed.TotalMilliseconds:F2} ms with {num} clips prewarmed"); } [IteratorStateMachine(typeof(d__2))] private static IEnumerable GetJesterClips(JesterAI jester) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(-2) { <>3__jester = jester }; } } [HarmonyPatch(typeof(Landmine), "ExplodeMineClientRpc")] internal static class LandmineInvisibleBumpTweak { [HarmonyPostfix] private static void Postfix(Landmine __instance) { Transform val = ((Component)__instance).transform.Find("Landmine/GameObject") ?? ((Component)__instance).transform.Find("GameObject"); if (val != null) { ((Component)val).gameObject.SetActive(false); } } } internal static class PlayerVolumeSavingTweak { [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPostfix] private static void RoundManagerStartPostfix() { SavePlayerVolume.Create(); SavePlayerVolume.RefreshControllerState(); } [HarmonyPatch(typeof(QuickMenuManager), "Start")] [HarmonyPostfix] private static void QuickMenuStartPostfix(QuickMenuManager __instance) { SavePlayerVolumeRuntime.RegisterQuickMenu(__instance); SavePlayerVolumeRuntime.LoadFromFile(); SavePlayerVolume.RefreshControllerState(); } [HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")] [HarmonyPostfix] private static void CloseQuickMenuPostfix() { SavePlayerVolumeRuntime.SaveCurrentVolumes(); SavePlayerVolume.RefreshControllerState(); } [HarmonyPatch(typeof(StartOfRound), "OnDestroy")] [HarmonyPostfix] private static void StartOfRoundDestroyPostfix() { SavePlayerVolumeRuntime.ClearQuickMenu(); SavePlayerVolume.RefreshControllerState(); } [HarmonyPatch(typeof(StartOfRound), "ResetPlayersLoadedValueClientRpc")] [HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")] [HarmonyPostfix] private static void Postfix() { SavePlayerVolume.RefreshControllerState(); } } internal static class SavePlayerVolume { private static GameObject? controllerObject; private static SavePlayerVolumeController? controller; internal static void Create() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!((Object)(object)controllerObject != (Object)null)) { controllerObject = new GameObject("MrHat.NicheTweaks.SavePlayerVolume.Controller"); Object.DontDestroyOnLoad((Object)(object)controllerObject); controller = controllerObject.AddComponent(); controller.RefreshFromShipPhase(); } } internal static void RefreshControllerState() { if (!((Object)(object)controller == (Object)null)) { controller.RefreshFromShipPhase(); } } } internal class SavePlayerVolumeController : MonoBehaviour { private GameObject? workerObject; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown workerObject = new GameObject("MrHat.NicheTweaks.SavePlayerVolume.Worker"); workerObject.transform.SetParent(((Component)this).transform, false); workerObject.AddComponent(); } internal void RefreshFromShipPhase() { bool flag = StartOfRound.Instance?.inShipPhase ?? false; GameObject? obj = workerObject; if (obj == null || obj.activeSelf != flag) { GameObject? obj2 = workerObject; if (obj2 != null) { obj2.SetActive(flag); } } } } internal class SavePlayerVolumeToggle : MonoBehaviour { private void Awake() { ((Component)this).gameObject.SetActive(false); } private void OnEnable() { ((MonoBehaviour)this).InvokeRepeating("ApplySavedVolumes", 0f, 0.1f); } private void OnDisable() { ((MonoBehaviour)this).CancelInvoke("ApplySavedVolumes"); } private void ApplySavedVolumes() { SavePlayerVolumeRuntime.ApplySavedVolumes(); } } internal static class SavePlayerVolumeRuntime { private static readonly Dictionary savedVolumes = new Dictionary(StringComparer.OrdinalIgnoreCase); private static QuickMenuManager? quickMenuManager; private static string? savePath; private static float? savedGlobalVolume; private static bool pendingGlobalRestore; internal static void SaveFileSetup() { savePath = Path.Combine(Application.persistentDataPath, "NicheTweaksPlayerVolumes.txt"); try { if (!File.Exists(savePath)) { File.WriteAllText(savePath, string.Empty); } Log.Info("player volume save file ready"); } catch (Exception ex) when (((ex is IOException || ex is UnauthorizedAccessException) ? 1 : 0) != 0) { Log.Error("player volume save file setup failed because " + ex.Message); } } internal static void RegisterQuickMenu(QuickMenuManager instance) { quickMenuManager = instance; } internal static void ClearQuickMenu() { quickMenuManager = null; } internal static void LoadFromFile() { savedVolumes.Clear(); savedGlobalVolume = null; pendingGlobalRestore = false; if (!File.Exists(savePath)) { return; } string[] array; try { array = File.ReadAllLines(savePath); } catch (Exception ex) when (((ex is IOException || ex is UnauthorizedAccessException) ? 1 : 0) != 0) { Log.Error("player volume save file could not be read because " + ex.Message); return; } foreach (string text in array) { if (string.IsNullOrWhiteSpace(text)) { continue; } string[] array2 = text.Split(';'); if (array2.Length == 2) { ulong result2; float result3; if (array2[0].Equals("global", StringComparison.OrdinalIgnoreCase)) { if (float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { savedGlobalVolume = result; } } else if (ulong.TryParse(array2[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out result2) && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out result3)) { savedVolumes["steam:" + result2.ToString(CultureInfo.InvariantCulture)] = result3; } continue; } int num = text.IndexOf(';'); if (num < 0) { continue; } int num2 = text.IndexOf(';', num + 1); if (num2 < 0) { continue; } string text2 = text.Substring(0, num); string text3 = text.Substring(num + 1, num2 - num - 1); string s = text.Substring(num2 + 1); if (!float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result4)) { continue; } if (text2.Equals("steam", StringComparison.OrdinalIgnoreCase)) { if (ulong.TryParse(text3, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result5)) { savedVolumes["steam:" + result5.ToString(CultureInfo.InvariantCulture)] = result4; } } else if (text2.Equals("name", StringComparison.OrdinalIgnoreCase)) { string text4 = DecodePlayerName(text3); if (!string.IsNullOrWhiteSpace(text4)) { savedVolumes["name:" + text4.Trim()] = result4; } } } pendingGlobalRestore = savedGlobalVolume.HasValue && ConfigManager.EnableGlobalVolumeMeter.Value; } internal static void ApplySavedVolumes() { if ((Object)(object)quickMenuManager == (Object)null || quickMenuManager.playerListSlots == null) { return; } PlayerListSlot[] playerListSlots = quickMenuManager.playerListSlots; foreach (PlayerListSlot val in playerListSlots) { if (val.isConnected && !((Object)(object)val.volumeSlider == (Object)null) && val.volumeSlider.value == 0f && TryGetPlayerKey(val, out string playerKey) && savedVolumes.TryGetValue(playerKey, out var value)) { val.volumeSlider.value = value; } } TryRestoreGlobalSlider(); } internal static void SaveCurrentVolumes() { if ((Object)(object)quickMenuManager == (Object)null || quickMenuManager.playerListSlots == null) { return; } PlayerListSlot[] playerListSlots = quickMenuManager.playerListSlots; foreach (PlayerListSlot val in playerListSlots) { if (val.isConnected && !((Object)(object)val.volumeSlider == (Object)null)) { float value = val.volumeSlider.value; if (value != 0f && TryGetPlayerKey(val, out string playerKey)) { savedVolumes[playerKey] = value; } } } savedGlobalVolume = ((ConfigManager.EnableGlobalVolumeMeter.Value && (Object)(object)GlobalVoiceVolumeOverlay.GlobalSlider != (Object)null) ? new float?(GlobalVoiceVolumeOverlay.GlobalSlider.value) : null); SaveToFile(); Log.Debug($"player volume settings saved with {savedVolumes.Count} entries"); } private static bool TryGetPlayerKey(PlayerListSlot playerListSlot, out string? playerKey) { if (playerListSlot.playerSteamId != 0) { playerKey = "steam:" + playerListSlot.playerSteamId.ToString(CultureInfo.InvariantCulture); return true; } string text = ((TMP_Text)playerListSlot.usernameHeader).text.Trim(); if (text.Length != 0) { playerKey = "name:" + text; return true; } playerKey = null; return false; } private static void TryRestoreGlobalSlider() { if (pendingGlobalRestore && savedGlobalVolume.HasValue) { Slider globalSlider = GlobalVoiceVolumeOverlay.GlobalSlider; if (!((Object)(object)globalSlider == (Object)null)) { globalSlider.SetValueWithoutNotify(savedGlobalVolume.Value); pendingGlobalRestore = false; } } } private static void SaveToFile() { List list = new List(savedVolumes.Count + (savedGlobalVolume.HasValue ? 1 : 0)); if (savedGlobalVolume.HasValue) { list.Add("global;" + savedGlobalVolume.Value.ToString(CultureInfo.InvariantCulture)); } foreach (KeyValuePair savedVolume in savedVolumes) { string text = savedVolume.Value.ToString(CultureInfo.InvariantCulture); if (savedVolume.Key.StartsWith("steam:", StringComparison.Ordinal)) { list.Add("steam;" + savedVolume.Key.Substring(6) + ";" + text); } else if (savedVolume.Key.StartsWith("name:", StringComparison.Ordinal)) { list.Add("name;" + EncodePlayerName(savedVolume.Key.Substring(5)) + ";" + text); } } try { File.WriteAllLines(savePath, list); } catch (Exception ex) when (((ex is IOException || ex is UnauthorizedAccessException) ? 1 : 0) != 0) { Log.Error("player volume save file could not be written because " + ex.Message); } } private static string EncodePlayerName(string playerName) { return Convert.ToBase64String(Encoding.UTF8.GetBytes(playerName)); } private static string DecodePlayerName(string encodedPlayerName) { try { return Encoding.UTF8.GetString(Convert.FromBase64String(encodedPlayerName)); } catch (FormatException ex) { Log.Warn("saved player volume name could not be decoded because " + ex.Message); return string.Empty; } } } internal static class ShipTeleporterInteractBlock { private static bool localPlayerBeaming; internal static bool IsLocalPlayerBeaming() { return localPlayerBeaming; } internal static void SetLocalPlayerBeaming(PlayerControllerB player, int teleporterId) { if ((Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController) { localPlayerBeaming = teleporterId != -1; } } internal static void Reset() { if (localPlayerBeaming) { Log.Warn("teleporter interact block reset"); localPlayerBeaming = false; } } } [HarmonyPatch(typeof(ShipTeleporter), "SetPlayerTeleporterId")] internal static class TeleporterItemPickupBlockTrackingTweak { [HarmonyPostfix] private static void Postfix(PlayerControllerB playerScript, int teleporterId) { ShipTeleporterInteractBlock.SetLocalPlayerBeaming(playerScript, teleporterId); } } [HarmonyPatch(typeof(PlayerControllerB), "Interact_performed")] internal static class TeleporterItemPickupBlockTweak { [HarmonyPrefix] private static bool Prefix(PlayerControllerB __instance) { if ((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController) { return true; } return !ShipTeleporterInteractBlock.IsLocalPlayerBeaming(); } } [HarmonyPatch(typeof(StartOfRound), "Awake")] internal static class TeleporterItemPickupBlockResetTweak { [HarmonyPostfix] private static void Postfix() { ShipTeleporterInteractBlock.Reset(); } } [HarmonyPatch(typeof(HUDManager), "GetTextureFromImage")] internal static class SteamImageErrorPreventionTweak { private static bool loggedNullImage; [HarmonyPrefix] private static bool Prefix(Image? image, ref Texture2D? __result) { if (image.HasValue) { return true; } if (!loggedNullImage) { Log.Warn("steam image error prevented because image was null"); loggedNullImage = true; } __result = null; return false; } } } namespace NicheTweaks.Tweaks.HUD { [HarmonyPatch(typeof(HUDManager), "AddChatMessage", new Type[] { typeof(string), typeof(string), typeof(int), typeof(bool) })] internal static class ChatColonColorTweak { [HarmonyPrefix] private static bool Prefix(HUDManager __instance, string chatMessage, string nameOfUserWhoTyped, int playerWhoSent, bool dontRepeat) { if ((dontRepeat && __instance.lastChatMessage == chatMessage) || (int)GameNetworkManager.Instance.localPlayerController.playerClientId == playerWhoSent) { return false; } __instance.lastChatMessage = chatMessage; __instance.PingHUDElement(__instance.Chat, 4f, 1f, 0.2f); if (__instance.ChatMessageHistory.Count >= 4) { __instance.ChatMessageHistory.RemoveAt(0); } string text = ResolvePlayerTokens(chatMessage); text = NormaliseColorTags(text); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("" + nameOfUserWhoTyped + ": " + text + "") : ("" + text + "")); __instance.ChatMessageHistory.Add(item); ((TMP_Text)__instance.chatText).text = ""; for (int i = 0; i < __instance.ChatMessageHistory.Count; i++) { ((TMP_Text)__instance.chatText).text = ((TMP_Text)__instance.chatText).text + "\n" + __instance.ChatMessageHistory[i]; } return false; } private static string ResolvePlayerTokens(string chatMessage) { StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("[playerNum0]", StartOfRound.Instance.allPlayerScripts[0].playerUsername); stringBuilder.Replace("[playerNum1]", StartOfRound.Instance.allPlayerScripts[1].playerUsername); stringBuilder.Replace("[playerNum2]", StartOfRound.Instance.allPlayerScripts[2].playerUsername); stringBuilder.Replace("[playerNum3]", StartOfRound.Instance.allPlayerScripts[3].playerUsername); return stringBuilder.ToString(); } private static string NormaliseColorTags(string text) { int num = 0; StringBuilder stringBuilder = new StringBuilder(text.Length); int num2 = 0; while (num2 < text.Length) { if (text[num2] == '<') { if (StartsWithIgnoreCase(text, num2, "")) { if (num > 0) { num--; stringBuilder.Append(""); } num2 += 8; continue; } if (StartsWithIgnoreCase(text, num2, "', num2); if (num3 != -1) { num++; stringBuilder.Append(text, num2, num3 - num2 + 1); num2 = num3 + 1; continue; } } } stringBuilder.Append(text[num2]); num2++; } for (int i = 0; i < num; i++) { stringBuilder.Append(""); } return stringBuilder.ToString(); } private static bool StartsWithIgnoreCase(string text, int startIndex, string value) { return startIndex + value.Length <= text.Length && text.IndexOf(value, startIndex, value.Length, StringComparison.OrdinalIgnoreCase) == startIndex; } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class ChatHUDHideTweak { [HarmonyPostfix] private static void Postfix() { SceneObjectUtils.SetDirectChildObjectsActive("Systems/UI/Canvas/IngamePlayerHUD/BottomLeftCorner", active: false); } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class ClockHUDHideTweak { [HarmonyPostfix] private static void Postfix() { Transform val = SceneObjectUtils.FindChild("Systems/UI/Canvas/IngamePlayerHUD/ProfitQuota", "Container"); if ((Object)(object)val != (Object)null) { for (int i = 0; i < val.childCount; i++) { Transform child = val.GetChild(i); if ((Object)(object)child.Find("TimeNumber") != (Object)null && (Object)(object)child.Find("Image") != (Object)null) { ((Component)child).gameObject.SetActive(false); break; } } } SceneObjectUtils.SetActive("Systems/UI/Canvas/IngamePlayerHUD/ProfitQuota/ShipLeavingIcon", active: false); } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class CompassHUDHideTweak { [HarmonyPostfix] private static void Postfix() { SceneObjectUtils.SetObjectsNamedActive("CompassImage", active: false); } } [HarmonyPatch(typeof(HUDManager), "ChangeControlTipMultiple")] internal static class ControlTipItemNameTweak { private static readonly Dictionary renameMap = new Dictionary(StringComparer.OrdinalIgnoreCase); internal static void Rebuild() { renameMap.Clear(); UpdateGeneratedItemList(); string value = ConfigManager.TooltipItemsToRename.Value; if (string.IsNullOrWhiteSpace(value)) { return; } foreach (KeyValuePair item in ConfigStringUtils.ParseAssignments(value, '=')) { renameMap[item.Key] = item.Value; } } private static void UpdateGeneratedItemList() { List itemsList = StartOfRound.Instance.allItemsList.itemsList; if (itemsList == null) { return; } List list = new List(); foreach (Item item in itemsList) { if (!((Object)(object)item == (Object)null)) { string itemName = item.itemName; ScanNodeProperties val = (Object.op_Implicit((Object)(object)item.spawnPrefab) ? item.spawnPrefab.GetComponentInChildren() : null); string text = (((Object)(object)val != (Object)null) ? (val.headerText ?? "") : itemName); list.Add(itemName + " = " + text); } } ConfigManager.AllItemNamesList.Value = string.Join(",", list); } [HarmonyPostfix] private static void Postfix(bool holdingItem, Item itemProperties, HUDManager __instance) { if (holdingItem && !((Object)(object)itemProperties == (Object)null) && renameMap.TryGetValue(itemProperties.itemName, out string value)) { TextMeshProUGUI val = __instance.controlTipLines[0]; if (!((Object)(object)val == (Object)null) && !string.IsNullOrEmpty(((TMP_Text)val).text)) { ((TMP_Text)val).text = ((TMP_Text)val).text.Replace(itemProperties.itemName, value); } } } [HarmonyPostfix] private static void ThrowablesControlTips_Postfix(bool holdingItem, Item itemProperties, HUDManager __instance) { if (!holdingItem || (Object)(object)itemProperties == (Object)null) { return; } TextMeshProUGUI[] controlTipLines = __instance.controlTipLines; if (controlTipLines == null || controlTipLines.Length < 2) { return; } TextMeshProUGUI val = controlTipLines[1]; if (!((Object)(object)val == (Object)null)) { string value; if (itemProperties.itemName.Equals("Stun grenade", StringComparison.OrdinalIgnoreCase)) { ((TMP_Text)val).text = "Use Stun grenade : [LMB]"; } else if (itemProperties.itemName.Equals("Homemade flashbang", StringComparison.OrdinalIgnoreCase)) { ((TMP_Text)val).text = "Use Homemade flashbang : [LMB]"; } else if (renameMap.TryGetValue(itemProperties.itemName, out value) && ((TMP_Text)val).text.Contains(itemProperties.itemName, StringComparison.OrdinalIgnoreCase)) { ((TMP_Text)val).text = ((TMP_Text)val).text.Replace(itemProperties.itemName, value); } } } } [HarmonyPatch(typeof(StartOfRound), "Start")] internal static class ControlTipItemNameListTweak { [HarmonyPostfix] private static void OnStart() { ControlTipItemNameTweak.Rebuild(); } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class ControlTipsHideTweak { [HarmonyPostfix] private static void Postfix() { SceneObjectUtils.HideCanvasGroup("Systems/UI/Canvas/IngamePlayerHUD/TopRightCorner/ControlTip1"); SceneObjectUtils.HideCanvasGroup("Systems/UI/Canvas/IngamePlayerHUD/TopRightCorner/ControlTip2"); SceneObjectUtils.HideCanvasGroup("Systems/UI/Canvas/IngamePlayerHUD/TopRightCorner/ControlTip3"); SceneObjectUtils.HideCanvasGroup("Systems/UI/Canvas/IngamePlayerHUD/TopRightCorner/ControlTip4"); } } [HarmonyPatch(typeof(MenuManager), "Start")] internal static class CreditsButtonHideTweak { [HarmonyPostfix] private static void Postfix() { MainMenuButtonLayout.SetActive("Credits", active: false); MainMenuButtonLayout.Compact(); } } internal static class DeathScreenClockRuntime { internal static TextMeshProUGUI? Clock; } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class DeathScreenClockSetupTweak { [HarmonyPostfix] private static void Postfix() { //IL_0070: 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) GameObject val = SceneObjectUtils.Find("Systems/UI/Canvas/IngamePlayerHUD/ProfitQuota/Container/Box/TimeNumber"); if (!((Object)(object)val == (Object)null)) { GameObject val2 = SceneObjectUtils.Find("Systems/UI/Canvas/DeathScreen/SpectateUI"); if (!((Object)(object)val2 == (Object)null)) { GameObject val3 = Object.Instantiate(val, val2.transform); ((Object)val3).name = "MrHat.NicheTweaks.DeathScreenClock"; val3.SetActive(true); RectTransform component = val3.GetComponent(); ((Transform)component).localScale = new Vector3(0.8f, 0.8f, 0.8f); ((Transform)component).localPosition = new Vector3(-369.5971f, 217.0461f, 0f); DeathScreenClockRuntime.Clock = val3.GetComponentInChildren(); } } } } [HarmonyPatch(typeof(HUDManager), "SetClock")] internal static class DeathScreenClockTweak { [HarmonyPostfix] private static void Postfix(HUDManager __instance) { TextMeshProUGUI clock = DeathScreenClockRuntime.Clock; if (!((Object)(object)clock == (Object)null)) { ((TMP_Text)clock).text = ((TMP_Text)__instance.clockNumber).text.Replace("\n", " "); } } } [HarmonyPatch(typeof(HUDManager), "HelmetCondensationDrops")] internal static class FloodedCondensationTweak { [HarmonyPrefix] internal static bool Prefix(HUDManager __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0083: 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) SelectableLevel val = StartOfRound.Instance?.currentLevel; if ((Object)(object)val == (Object)null || (int)val.currentWeather != 4) { return true; } TimeOfDay instance = TimeOfDay.Instance; if (instance == null || instance.insideLighting) { return true; } Camera val2 = GameNetworkManager.Instance.localPlayerController?.gameplayCamera; if ((Object)(object)val2 == (Object)null) { return true; } if (Vector3.Angle(((Component)val2).transform.forward, Vector3.up) < 45f) { __instance.increaseHelmetCondensation = true; } return true; } } [HarmonyPatch(typeof(MenuManager), "ClickHostButton")] internal static class FriendsOnlyTextToPrivateTweak { [HarmonyPostfix] private static void Postfix() { SceneObjectUtils.SetText("Canvas/MenuContainer/LobbyHostSettings/HostSettingsContainer/LobbyHostOptions/OptionsNormal/Private/Text (TMP)", "Private"); } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class HandsFullTextPositionTweak { [HarmonyPostfix] private static void Postfix() { //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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_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_0129: 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_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) Transform val = SceneObjectUtils.FindChild("UI/Canvas/IngamePlayerHUD", "HandsFullText"); if (!((Object)(object)val == (Object)null)) { Vector3 val2 = default(Vector3); Vector3 zero = default(Vector3); Vector3 localScale = default(Vector3); float num; switch (ConfigManager.HandsFullTextPresetSelection.Value) { default: return; case HandsFullTextPreset.BelowInventory: ((Vector3)(ref val2))..ctor(0f, -262.6901f, 24.8253f); zero = Vector3.zero; ((Vector3)(ref localScale))..ctor(1.7248f, 1.7248f, 1.7248f); num = 1f; break; case HandsFullTextPreset.AboveInventory: ((Vector3)(ref val2))..ctor(0f, -153.6261f, 24.8253f); zero = Vector3.zero; ((Vector3)(ref localScale))..ctor(1.7248f, 1.7248f, 1.7248f); num = 1f; break; case HandsFullTextPreset.TopOfScreen: ((Vector3)(ref val2))..ctor(0f, 230.464f, 24.8253f); zero = Vector3.zero; ((Vector3)(ref localScale))..ctor(1.7248f, 1.7248f, 1.7248f); num = 1f; break; case HandsFullTextPreset.AboveVanillaStaminaHealthUI: ((Vector3)(ref val2))..ctor(-327.2649f, 216.0129f, 24.8253f); zero = Vector3.zero; ((Vector3)(ref localScale))..ctor(1.4248f, 1.4248f, 1.7248f); num = 1f; break; case HandsFullTextPreset.BelowChat: ((Vector3)(ref val2))..ctor(-343.9384f, -248.2916f, 24.8253f); ((Vector3)(ref zero))..ctor(0f, 0f, 4.3f); ((Vector3)(ref localScale))..ctor(1.7248f, 1.7248f, 1.7248f); num = 0.366f; break; case HandsFullTextPreset.AboveTooltips: ((Vector3)(ref val2))..ctor(377.8974f, 205.0974f, 24.8253f); ((Vector3)(ref zero))..ctor(0f, 16.8352f, 0f); ((Vector3)(ref localScale))..ctor(1.2f, 1.2f, 1.7248f); num = 1f; break; } val.SetLocalPositionAndRotation(val2, Quaternion.Euler(zero)); val.localScale = localScale; TextMeshProUGUI val3 = default(TextMeshProUGUI); if (((Component)val).TryGetComponent(ref val3)) { Color color = ((Graphic)val3).color; color.a = Mathf.Clamp01(num); ((Graphic)val3).color = color; } } } } internal static class HideWarningDisplayTip { [HarmonyPatch(typeof(HUDManager), "DisplayTip")] private static bool Prefix(bool isWarning) { return isWarning; } } [HarmonyPatch(typeof(QuickMenuManager), "Start")] internal static class InviteFriendsButtonHideTweak { [HarmonyPostfix] private static void Postfix(QuickMenuManager __instance) { if ((Object)(object)__instance.inviteFriendsTextAlpha != (Object)null) { ((Component)__instance.inviteFriendsTextAlpha).gameObject.SetActive(false); } SceneObjectUtils.SetObjectsNamedActive("InvitePlayers", active: false); } } [HarmonyPatch] public static class ItemLightningBorderTweak { [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPatch(typeof(RoundManager), "Start")] [HarmonyPostfix] private static void HUDManager_Postfix() { RefreshLightningBorders(); } [HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayer")] [HarmonyPostfix] private static void EntranceTeleport_Postfix() { RefreshLightningBorders(); LightningBorderMethods.DestroyDuplicateLightningBorders(); LightningBorderMethods.RefreshLocation(); } [HarmonyPatch(typeof(StormyWeather), "SetStaticElectricityWarning")] [HarmonyPostfix] private static void StormyWeatherSetStaticElectricityWarning_Postfix(NetworkObject warningObject) { LightningBorderMethods.RefreshStaticElectricityWarning(warningObject); } [HarmonyPatch(typeof(StormyWeather), "LightningStrike")] [HarmonyPrefix] private static void StormyWeatherLightningStrike_Prefix(bool useTargetedObject) { if (useTargetedObject) { LightningBorderMethods.ClearStaticElectricityWarning(); } } [HarmonyPatch(typeof(StormyWeather), "Update")] [HarmonyPostfix] private static void StormyWeatherUpdate_Postfix(StormyWeather __instance) { if (!((Object)(object)LightningBorderMethods.StaticElectricityTarget == (Object)null) && !__instance.staticElectricityParticle.isPlaying) { LightningBorderMethods.ClearStaticElectricityWarning(); } } [HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")] [HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")] [HarmonyPostfix] private static void PlayerControllerBSwitchToItemSlot_Postfix() { if (!((Object)(object)LightningBorderMethods.StaticElectricityTarget == (Object)null)) { LightningBorderMethods.RefreshStaticElectricitySlot(); } } private static void RefreshLightningBorders() { LightningBorderMethods.RefreshItemSlotCount(); LightningBorderMethods.Refresh(); LightningBorderMethods.RefreshItemSlotSize(); } } internal static class LightningBorderAssets { private const string BundleFileName = "lightningborderassets"; private const string PrefabAssetPath = "Assets/LethalCompany/Mods/plugins/NicheTweaks/LightningBorder/LightningBorder.prefab"; private static bool attemptedLoad; public static GameObject? Prefab { get; private set; } public static void LoadOnce() { if (!attemptedLoad) { attemptedLoad = true; if (!AssetBundleUtils.TryLoadAsset("lightningborderassets", "Assets/LethalCompany/Mods/plugins/NicheTweaks/LightningBorder/LightningBorder.prefab", out GameObject asset, out string bundlePath)) { Log.Error("lightning border prefab missing from asset bundle at " + bundlePath); } else { Prefab = asset; } } } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class ItemLightningBorderSetupTweak { private static bool loaded; [HarmonyPostfix] private static void Postfix() { //IL_003a: 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) if (!loaded) { LightningBorderAssets.LoadOnce(); RectTransform val = default(RectTransform); if (!((Object)(object)LightningBorderAssets.Prefab == (Object)null) && LightningBorderAssets.Prefab.TryGetComponent(ref val)) { RectTransform obj = val; ((Transform)obj).localScale = ((Transform)obj).localScale * 1.2f; loaded = true; } } } } internal static class LightningBorderMethods { public static readonly List Instances = new List(); private static Image[]? itemSlotIconFrames; private static bool suppressStaticElectricityWarning; private static GameObject? prefab; private static string? prefabName; private static string? prefabCloneName; private static int staticElectricitySlot = -1; internal static GrabbableObject? StaticElectricityTarget; public static int ItemSlotCount { get; private set; } public static bool IsInsideFactory { get; private set; } public static void RefreshItemSlotCount() { HUDManager instance = HUDManager.Instance; if (!((Object)(object)instance == (Object)null)) { itemSlotIconFrames = instance.itemSlotIconFrames; if (itemSlotIconFrames != null) { ItemSlotCount = itemSlotIconFrames.Length; } } } public static void Refresh() { //IL_01a1: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) if (itemSlotIconFrames == null || ItemSlotCount == 0 || !CachePrefab()) { return; } GameObject val = prefab; if (val == null || (Object)(object)HUDManager.Instance == (Object)null) { return; } int num = Mathf.Min(ItemSlotCount, itemSlotIconFrames.Length); _ = Instances.Count; while (Instances.Count > num) { int index = Instances.Count - 1; GameObject val2 = Instances[index]; Instances.RemoveAt(index); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } } while (Instances.Count < num) { Instances.Add(CreateInstance(val)); } RectTransform val5 = default(RectTransform); for (int i = 0; i < num; i++) { Image val3 = itemSlotIconFrames[i]; if (!((Object)(object)val3 == (Object)null)) { GameObject val4 = Instances[i]; if ((Object)(object)val4 == (Object)null) { val4 = CreateInstance(val); Instances[i] = val4; } if ((Object)(object)val4.transform.parent != (Object)(object)((Component)val3).transform) { val4.transform.SetParent(((Component)val3).transform, false); } if (val4.activeSelf) { val4.SetActive(false); } if (val4.TryGetComponent(ref val5)) { val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.anchoredPosition = Vector2.zero; val5.offsetMin = Vector2.zero; val5.offsetMax = Vector2.zero; ((Transform)val5).localRotation = Quaternion.identity; } } } ApplyStaticElectricityVisuals(); } public static void RefreshItemSlotSize() { //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_00a9: Unknown result type (might be due to invalid IL or missing references) if (itemSlotIconFrames == null || ItemSlotCount == 0 || !CachePrefab()) { return; } GameObject val = prefab; RectTransform val2 = default(RectTransform); if (val == null || !val.TryGetComponent(ref val2)) { return; } Vector3 localScale = ((Transform)val2).localScale; int num = Mathf.Min(Instances.Count, ItemSlotCount); RectTransform val4 = default(RectTransform); for (int i = 0; i < num; i++) { GameObject val3 = Instances[i]; if (!((Object)(object)val3 == (Object)null) && val3.TryGetComponent(ref val4)) { ((Transform)val4).localScale = localScale; } } } public static void RefreshLocation() { PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { return; } bool isInsideFactory = localPlayerController.isInsideFactory; if (isInsideFactory != IsInsideFactory) { IsInsideFactory = isInsideFactory; if (IsInsideFactory) { suppressStaticElectricityWarning = true; StaticElectricityTarget = null; staticElectricitySlot = -1; ApplyStaticElectricityVisuals(); return; } suppressStaticElectricityWarning = false; } ApplyStaticElectricityVisuals(); } public static void RefreshStaticElectricityWarning(NetworkObject warningObject) { if (!suppressStaticElectricityWarning || !IsInsideFactory) { if (suppressStaticElectricityWarning && !IsInsideFactory) { suppressStaticElectricityWarning = false; } StaticElectricityTarget = ((warningObject != null) ? ((Component)warningObject).GetComponent() : null); RefreshStaticElectricitySlot(); } } public static void RefreshStaticElectricitySlot() { if (suppressStaticElectricityWarning && IsInsideFactory) { ApplyStaticElectricityVisuals(); return; } int num = -1; if ((Object)(object)StaticElectricityTarget != (Object)null) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController != (Object)null) { GrabbableObject[] itemSlots = localPlayerController.ItemSlots; for (int i = 0; i < itemSlots.Length; i++) { if ((Object)(object)itemSlots[i] == (Object)(object)StaticElectricityTarget) { num = i; break; } } } } if (num != staticElectricitySlot) { staticElectricitySlot = num; } ApplyStaticElectricityVisuals(); } public static void ClearStaticElectricityWarning() { StaticElectricityTarget = null; staticElectricitySlot = -1; if (!IsInsideFactory) { suppressStaticElectricityWarning = false; } ApplyStaticElectricityVisuals(); } public static void DestroyDuplicateLightningBorders() { if (itemSlotIconFrames == null || ItemSlotCount == 0 || !CachePrefab()) { return; } int num = Mathf.Min(ItemSlotCount, itemSlotIconFrames.Length); int num2 = 0; for (int i = 0; i < num; i++) { Image val = itemSlotIconFrames[i]; if ((Object)(object)val == (Object)null) { continue; } Transform transform = ((Component)val).transform; GameObject val2 = ((i < Instances.Count) ? Instances[i] : null); for (int num3 = transform.childCount - 1; num3 >= 0; num3--) { GameObject gameObject = ((Component)transform.GetChild(num3)).gameObject; if ((!(((Object)gameObject).name != prefabName) || !(((Object)gameObject).name != prefabCloneName)) && (!((Object)(object)val2 != (Object)null) || !((Object)(object)gameObject == (Object)(object)val2))) { if ((Object)(object)val2 == (Object)null) { val2 = gameObject; if (i < Instances.Count) { Instances[i] = val2; } else if (i == Instances.Count) { Instances.Add(val2); } } else { Object.Destroy((Object)(object)gameObject); num2++; } } } } } private static void ApplyStaticElectricityVisuals() { if (itemSlotIconFrames == null || ItemSlotCount == 0) { return; } int num = Mathf.Min(Mathf.Min(Instances.Count, ItemSlotCount), itemSlotIconFrames.Length); bool flag = !IsInsideFactory && (Object)(object)StaticElectricityTarget != (Object)null && staticElectricitySlot >= 0; for (int i = 0; i < num; i++) { bool flag2 = flag && i == staticElectricitySlot; GameObject val = Instances[i]; if ((Object)(object)val != (Object)null) { bool activeSelf = val.activeSelf; if (activeSelf != flag2) { val.SetActive(flag2); } } Image val2 = itemSlotIconFrames[i]; if ((Object)(object)val2 != (Object)null) { bool flag3 = !flag2; bool enabled = ((Behaviour)val2).enabled; if (enabled != flag3) { ((Behaviour)val2).enabled = flag3; } } } } private static bool CachePrefab() { if ((Object)(object)prefab != (Object)null) { return true; } prefab = LightningBorderAssets.Prefab; if ((Object)(object)prefab == (Object)null) { return false; } prefabName = ((Object)prefab).name; prefabCloneName = prefabName + "(Clone)"; return true; } private static GameObject CreateInstance(GameObject prefabObject) { GameObject val = Object.Instantiate(prefabObject); if (val.activeSelf) { val.SetActive(false); } return val; } } [HarmonyPatch(typeof(MenuManager), "Start")] internal static class JoinButtonHideTweak { [HarmonyPostfix] private static void Postfix() { MainMenuButtonLayout.SetActive("StartLAN", active: false); MainMenuButtonLayout.SetActive("JoinACrew", active: false); MainMenuButtonLayout.Compact(); } } internal static class MainMenuButtonLayout { private const string MainButtonsPath = "Canvas/MenuContainer/MainButtons"; private static readonly string[] ButtonOrder = new string[6] { "HostButton", "JoinACrew", "StartLAN", "SettingsButton", "Credits", "QuitButton" }; private static readonly string[] SlotSources = new string[5] { "HostButton", "JoinACrew", "SettingsButton", "Credits", "QuitButton" }; private static readonly List SlotPositions = new List(); internal static void SetActive(string childName, bool active) { Transform val = FindButton(childName); if (val != null) { ((Component)val).gameObject.SetActive(active); } } internal static void Compact() { //IL_0096: 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_00c2: Unknown result type (might be due to invalid IL or missing references) GameObject? obj = SceneObjectUtils.Find("Canvas/MenuContainer/MainButtons"); Transform val = ((obj != null) ? obj.transform : null); if ((Object)(object)val == (Object)null) { return; } CacheSlotPositions(val); if (SlotPositions.Count == 0) { return; } int num = 0; for (int i = 0; i < ButtonOrder.Length; i++) { Transform val2 = val.Find(ButtonOrder[i]); if (val2 != null && ((Component)val2).gameObject.activeSelf) { RectTransform val3 = (RectTransform)(object)((val2 is RectTransform) ? val2 : null); if (val3 != null) { Vector2 anchoredPosition = val3.anchoredPosition; anchoredPosition.y = SlotPositions[Mathf.Min(num, SlotPositions.Count - 1)]; val3.anchoredPosition = anchoredPosition; num++; } } } } private static Transform? FindButton(string childName) { GameObject? obj = SceneObjectUtils.Find("Canvas/MenuContainer/MainButtons"); Transform val = ((obj != null) ? obj.transform : null); return (val != null) ? val.Find(childName) : null; } private static void CacheSlotPositions(Transform root) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (SlotPositions.Count > 0) { return; } for (int i = 0; i < SlotSources.Length; i++) { Transform val = root.Find(SlotSources[i]); RectTransform val2 = (RectTransform)(object)((val is RectTransform) ? val : null); if (val2 != null) { SlotPositions.Add(val2.anchoredPosition.y); } } } } [HarmonyPatch(typeof(QuickMenuManager), "Start")] internal static class QuitGameHighlightColourTweak { [HarmonyPostfix] private static void Postfix() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(1f, 0.431f, 0f, 0.49f); SceneObjectUtils.SetImageColor("UI/Canvas/QuickMenu/ConfirmLeaveGame", color); SceneObjectUtils.SetImageColor("UI/Canvas/QuickMenu/ConfirmLeaveGame/Quit (1)/SelectionHighlight", color); SceneObjectUtils.SetImageColor("UI/Canvas/QuickMenu/ConfirmLeaveGame/Quit (2)/SelectionHighlight", color); } } [HarmonyPatch(typeof(QuickMenuManager), "Start")] internal static class QuitGameTextColourTweak { [HarmonyPostfix] private static void Postfix() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) SceneObjectUtils.SetTextColor("Systems/UI/Canvas/QuickMenu/ConfirmLeaveGame/Text (TMP) (1)", new Color(1f, 0.5647f, 0f, 1f)); } } internal static class RemoveItemSlotFadeTweak { [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPostfix] private static void Postfix() { GameObject val = SceneObjectUtils.Find("IngamePlayerHUD/Inventory"); if ((Object)(object)val == (Object)null) { return; } Transform[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (((Object)componentsInChildren[i]).name == "fadeIcon") { ((Component)componentsInChildren[i]).gameObject.SetActive(false); } } } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] internal static class ScanNodeOverrideTweak { [HarmonyPostfix] private static void OnGameNetworkManagerStart() { string value = ConfigManager.ScanNodeOverrides.Value; if (string.IsNullOrWhiteSpace(value)) { return; } Dictionary dictionary = ConfigStringUtils.ParseIntAssignments(value, ':', 0, 2); if (dictionary.Count == 0) { return; } GameObject[] allGameObjects = ResourceUtils.FindAll(); foreach (KeyValuePair item in dictionary) { ApplyOverride(allGameObjects, item.Key, item.Value); } } private static void ApplyOverride(GameObject[] allGameObjects, string gameObjectName, int nodeType) { foreach (GameObject val in allGameObjects) { if (((Object)val).name != gameObjectName) { continue; } ScanNodeProperties[] componentsInChildren = val.GetComponentsInChildren(true); if (componentsInChildren.Length != 0) { for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].nodeType = nodeType; } Log.Debug("scan node color set to " + GetScanNodeColorName(nodeType) + " for " + ((Object)val).name); } } } private static string GetScanNodeColorName(int nodeType) { if (1 == 0) { } string result = nodeType switch { 0 => "Blue", 1 => "Red", 2 => "Green", _ => "Unknown", }; if (1 == 0) { } return result; } } internal static class TerminalHUDState { public static bool hidPlayerInfo; public static bool hidCompass; public static bool hidChatImage; public static bool hidChatText; public static bool hidChatInput; public static bool hidInventory; } [HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")] internal static class TerminalHUDHideTweak { [HarmonyPostfix] private static void Postfix() { DisableIfActive("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)", ref TerminalHUDState.hidPlayerInfo); DisableIfActive("Systems/UI/Canvas/IngamePlayerHUD/CompassImage (1)", ref TerminalHUDState.hidCompass); DisableIfActive("Systems/UI/Canvas/IngamePlayerHUD/BottomLeftCorner/Image", ref TerminalHUDState.hidChatImage); DisableIfActive("Systems/UI/Canvas/IngamePlayerHUD/BottomLeftCorner/ChatText", ref TerminalHUDState.hidChatText); DisableIfActive("Systems/UI/Canvas/IngamePlayerHUD/BottomLeftCorner/InputField (TMP)", ref TerminalHUDState.hidChatInput); DisableIfActive("Systems/UI/Canvas/IngamePlayerHUD/Inventory", ref TerminalHUDState.hidInventory); } internal static void DisableIfActive(string path, ref bool flag) { GameObject val = SceneObjectUtils.Find(path); if (!((Object)(object)val == (Object)null) && val.activeSelf) { flag = true; val.SetActive(false); } } } [HarmonyPatch(typeof(Terminal), "QuitTerminal")] internal static class TerminalHUDRestoreTweak { [HarmonyPostfix] internal static void Postfix() { Restore("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)", TerminalHUDState.hidPlayerInfo); Restore("Systems/UI/Canvas/IngamePlayerHUD/CompassImage (1)", TerminalHUDState.hidCompass); Restore("Systems/UI/Canvas/IngamePlayerHUD/BottomLeftCorner/Image", TerminalHUDState.hidChatImage); Restore("Systems/UI/Canvas/IngamePlayerHUD/BottomLeftCorner/ChatText", TerminalHUDState.hidChatText); Restore("Systems/UI/Canvas/IngamePlayerHUD/BottomLeftCorner/InputField (TMP)", TerminalHUDState.hidChatInput); Restore("Systems/UI/Canvas/IngamePlayerHUD/Inventory", TerminalHUDState.hidInventory); TerminalHUDState.hidPlayerInfo = false; TerminalHUDState.hidCompass = false; TerminalHUDState.hidChatImage = false; TerminalHUDState.hidChatText = false; TerminalHUDState.hidChatInput = false; TerminalHUDState.hidInventory = false; } internal static void Restore(string path, bool shouldRestore) { if (shouldRestore) { SceneObjectUtils.SetActive(path, active: true); } } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class UtilitySlotHUDHideTweak { [HarmonyPostfix] private static void Postfix() { SceneObjectUtils.SetActive("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner/UtilitySlot", active: false); } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class UtilitySlotIconSizeTweak { [HarmonyPostfix] private static void Postfix(HUDManager __instance) { //IL_003d: 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_0050: 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_006b: 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) if (!((Object)(object)__instance.itemOnlySlotIcon == (Object)null) && !((Object)(object)__instance.itemOnlySlotIconFrame == (Object)null)) { RectTransform rectTransform = ((Graphic)__instance.itemOnlySlotIconFrame).rectTransform; RectTransform rectTransform2 = ((Graphic)__instance.itemOnlySlotIcon).rectTransform; if (!(rectTransform2.sizeDelta == rectTransform.sizeDelta) || !(((Transform)rectTransform2).localScale == ((Transform)rectTransform).localScale)) { rectTransform2.sizeDelta = rectTransform.sizeDelta; ((Transform)rectTransform2).localScale = ((Transform)rectTransform).localScale; } } } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class WeightHUDHideTweak { [HarmonyPostfix] private static void Postfix() { SceneObjectUtils.SetActive("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner/WeightUI", active: false); } } } namespace NicheTweaks.Tweaks.Gameplay { [HarmonyPatch(typeof(GameNetworkManager), "Start")] internal static class ButlerCollisionAdjustmentTweak { [HarmonyPostfix] private static void OnGameNetworkManagerStart() { ButlerEnemyAI val = ResourceUtils.FindFirst(); ((Component)val).GetComponent().radius = 1.4f; } } internal static class ButlerTallerDamageCollider { [HarmonyPatch(typeof(ButlerEnemyAI), "Start")] [HarmonyPostfix] private static void Postfix(ButlerEnemyAI __instance) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)((Component)__instance).GetComponentInChildren(true)).transform; transform.localScale = new Vector3(transform.localScale.x, 3.1021f, transform.localScale.z); } } internal static class DeadlineEjectionTweak { [HarmonyPatch(typeof(StartOfRound), "PassTimeToNextDay")] [HarmonyPostfix] private static void Postfix(StartOfRound __instance) { if (!((NetworkBehaviour)__instance).IsServer || __instance.isChallengeFile) { return; } TimeOfDay instance = TimeOfDay.Instance; if (!((Object)(object)instance == (Object)null) && instance.profitQuota > instance.quotaFulfilled && instance.daysUntilDeadline == 0 && !(instance.timeUntilDeadline <= 0f)) { int valueOfAllScrap = __instance.GetValueOfAllScrap(true, false); if (valueOfAllScrap > 0) { Log.Debug("deadline ejection waited because ship loot was found"); return; } instance.timeUntilDeadline = 0f; instance.UpdateProfitQuotaCurrentTime(); Log.Debug("deadline ejection armed at zero days"); } } } [HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")] internal static class DeadPlayerCheckCheesePreventionTweak { private static readonly int PingHash = Animator.StringToHash("ping"); [HarmonyPostfix] private static void Postfix() { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!localPlayerController.isPlayerDead && StartOfRound.Instance.livingPlayers == 1 && StartOfRound.Instance.connectedPlayersAmount > 0 && !localPlayerController.inTerminalMenu) { GameObject cachedObject = SceneObjectUtils.GetCachedObject("PlayersTooFarText"); Animator val = default(Animator); if ((Object)(object)cachedObject != (Object)null && cachedObject.TryGetComponent(ref val)) { val.SetTrigger(PingHash); } } } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class DeadPlayerCheckCheeseTextCacheTweak { [HarmonyPostfix] private static void Postfix() { SceneObjectUtils.CacheObject("PlayersTooFarText"); } } [HarmonyPatch(typeof(GrabbableObject), "Start")] internal static class GrabbableToEnemiesBlacklistTweak { private static readonly HashSet BlacklistedItemNames = new HashSet(StringComparer.OrdinalIgnoreCase); private static string cachedBlacklist = string.Empty; private static void RefreshBlacklist() { string text = ConfigManager.GrabbableToEnemiesItemBlacklist.Value ?? string.Empty; if (cachedBlacklist == text) { return; } cachedBlacklist = text; BlacklistedItemNames.Clear(); foreach (string item in ConfigStringUtils.SplitCommaSeparated(text)) { BlacklistedItemNames.Add(item); } Log.Debug($"grabbable enemy blacklist loaded with {BlacklistedItemNames.Count} entries"); } private static bool IsBlacklisted(GrabbableObject item) { RefreshBlacklist(); return (Object)(object)item.itemProperties != (Object)null && !string.IsNullOrWhiteSpace(item.itemProperties.itemName) && BlacklistedItemNames.Contains(item.itemProperties.itemName); } [HarmonyPostfix] private static void Postfix(GrabbableObject __instance) { if (IsBlacklisted(__instance)) { __instance.grabbableToEnemies = false; HoarderBugAI.grabbableObjectsInMap.Remove(((Component)__instance).gameObject); Log.Debug("hoarder bug item blacklist applied to " + __instance.itemProperties.itemName); } } } [HarmonyPatch(typeof(HoarderBugAI), "SetGoTowardsTargetObject")] internal static class HoarderBugManEaterTargetFixTweak { [HarmonyPrefix] private static bool Prefix(HoarderBugAI __instance, GameObject foundObject) { if ((Object)(object)foundObject == (Object)null) { return true; } GrabbableObject component = foundObject.GetComponent(); if (component == null || component.grabbableToEnemies) { return true; } Log.Debug("hoarder bug target blocked for " + ((Object)foundObject).name); __instance.targetItem = null; return false; } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] internal static class ItemInspectionDisableTweak { [HarmonyPostfix] private static void OnGameNetworkManagerStart() { Item[] array = ResourceUtils.FindAll(); int num = 0; foreach (Item val in array) { if (val.canBeInspected) { val.canBeInspected = false; num++; } } Log.Info($"item inspection disabled for {num} item resources"); } } internal static class JesterTallerDamageCollider { private static BoxCollider Collider; private static float OriginalCenterY; private static float OriginalSizeY; [HarmonyPatch(typeof(JesterAI), "Start")] [HarmonyPostfix] private static void StartPostfix(JesterAI __instance) { //IL_0017: 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) Collider = ((Component)((Component)__instance).GetComponentInChildren(true)).GetComponent(); OriginalCenterY = Collider.center.y; OriginalSizeY = Collider.size.y; } [HarmonyPatch(typeof(JesterAI), "Update")] [HarmonyPostfix] private static void UpdatePostfix(JesterAI __instance) { //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_0011: 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_005c: 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) Vector3 center = Collider.center; Vector3 size = Collider.size; center.y = (__instance.mainCollider.isTrigger ? 3.052277f : OriginalCenterY); size.y = (__instance.mainCollider.isTrigger ? 5.883789f : OriginalSizeY); Collider.center = center; Collider.size = size; } } internal static class RadmechHitColliderTweak { [HarmonyPatch(typeof(RadMechAI), "Start")] [HarmonyPostfix] private static void Postfix(RadMechAI __instance) { EnemyAICollisionDetect val = ((Component)__instance).gameObject.AddComponent(); val.mainScript = (EnemyAI)(object)__instance; } } internal static class UtilitySlotDisableTweak { [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPostfix] private static void OnGameNetworkManagerStart() { Item[] array = ResourceUtils.FindAll(); int num = 0; foreach (Item val in array) { if (!val.disallowUtilitySlot) { val.disallowUtilitySlot = true; num++; } } Log.Debug($"utility slot disabled for {num} item resources"); } [HarmonyPatch(typeof(PlayerControllerB), "UseUtilitySlot_performed")] [HarmonyPrefix] private static bool Prefix() { return false; } } [HarmonyPatch(typeof(GrabbableObject), "Start")] internal static class ZeroScaleItemFixTweak { [HarmonyPostfix] private static void Postfix(GrabbableObject __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) if (__instance.originalScale != Vector3.zero) { return; } Item itemProperties = __instance.itemProperties; if ((Object)(object)itemProperties == (Object)null) { Log.Warn("zero scale grabbable repair skipped because item properties were missing"); return; } GameObject spawnPrefab = itemProperties.spawnPrefab; if ((Object)(object)spawnPrefab == (Object)null) { Log.Warn("zero scale grabbable repair skipped because spawn prefab was missing"); return; } string text = (string.IsNullOrWhiteSpace(itemProperties.itemName) ? ((Object)__instance).name : itemProperties.itemName); Vector3 localScale = spawnPrefab.transform.localScale; ((Component)__instance).transform.localScale = localScale; __instance.originalScale = localScale; int num = RemoveZeroInertiaRigidbodies(__instance); Log.Debug((num > 0) ? $"zero scale grabbable repaired for {text} and {num} rigidbodies removed" : ("zero scale grabbable repaired for " + text)); } private static int RemoveZeroInertiaRigidbodies(GrabbableObject grabbableObject) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Rigidbody[] componentsInChildren = ((Component)grabbableObject).GetComponentsInChildren(false); int num = 0; foreach (Rigidbody val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !(val.inertiaTensor != Vector3.zero)) { Object.Destroy((Object)(object)val); num++; } } return num; } } } namespace NicheTweaks.Tweaks.Decals { [HarmonyPatch(typeof(DecalProjector), "Awake")] internal static class DecalDrawDistanceTweak { private const float DecalDistance = 1001f; private const BindingFlags InstancePrivate = BindingFlags.Instance | BindingFlags.NonPublic; private static readonly FieldInfo? drawDistanceField = typeof(DecalProjector).GetField("m_DrawDistance", BindingFlags.Instance | BindingFlags.NonPublic); private static bool loggedMissingDrawDistanceField; [HarmonyPostfix] private static void Postfix(DecalProjector __instance) { if (drawDistanceField == null) { if (!loggedMissingDrawDistanceField) { loggedMissingDrawDistanceField = true; Log.Error("decal projector draw distance field was not found"); } } else { drawDistanceField.SetValue(__instance, 1001f); } } } [HarmonyPatch(typeof(StartOfRound), "InstantiateFootprintsPooledObjects")] internal static class FootprintPoolOverrideTweak { private static readonly HashSet InitialisedRounds = new HashSet(); [HarmonyPrefix] private static bool Prefix(StartOfRound? __instance) { if ((Object)(object)__instance == (Object)null) { return true; } if (InitialisedRounds.Contains(__instance)) { return false; } InitialisedRounds.Add(__instance); int num = Mathf.Max(0, ConfigManager.FootprintPoolSize.Value); Transform bloodObjectsContainer = __instance.bloodObjectsContainer; if ((Object)(object)bloodObjectsContainer != (Object)null) { for (int num2 = bloodObjectsContainer.childCount - 1; num2 >= 0; num2--) { Transform child = bloodObjectsContainer.GetChild(num2); if (child != null && ((Object)child).name.Contains("FootprintDecal")) { Object.DestroyImmediate((Object)(object)((Component)child).gameObject); } } } __instance.snowFootprintsPooledObjects.Clear(); for (int i = 0; i < num; i++) { GameObject val = Object.Instantiate(__instance.footprintDecal, bloodObjectsContainer); __instance.snowFootprintsPooledObjects.Add(val.GetComponent()); } return false; } } internal static class PlayerBloodTweak { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnRequest; public static HandleNamedMessageDelegate <1>__OnSpawn; } private const string Request = "MrHat.NicheTweaks.PlayerBlood.Request"; private const string Spawn = "MrHat.NicheTweaks.PlayerBlood.Spawn"; private static bool wired; [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPostfix] private static void StartOfRoundStartPostfix() { Wired(); } internal static void Wired() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0056: 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_0061: Expected O, but got Unknown if (!wired) { NetworkManager singleton = NetworkManager.Singleton; CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; object obj = <>O.<0>__OnRequest; if (obj == null) { HandleNamedMessageDelegate val = OnRequest; <>O.<0>__OnRequest = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("MrHat.NicheTweaks.PlayerBlood.Request", (HandleNamedMessageDelegate)obj); object obj2 = <>O.<1>__OnSpawn; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnSpawn; <>O.<1>__OnSpawn = val2; obj2 = (object)val2; } customMessagingManager.RegisterNamedMessageHandler("MrHat.NicheTweaks.PlayerBlood.Spawn", (HandleNamedMessageDelegate)obj2); wired = true; } } private static void OnRequest(ulong sender, FastBufferReader reader) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //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) if (NetworkManager.Singleton.IsServer) { Vector3 pos = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref pos); Quaternion rot = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref rot); float size = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref size, default(ForPrimitives)); Broadcast(pos, rot, size); SpawnLocal(pos, rot, size); } } private static void OnSpawn(ulong sender, FastBufferReader reader) { //IL_001b: 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_0056: 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_004b: 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) Vector3 pos = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref pos); Quaternion rot = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref rot); float size = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref size, default(ForPrimitives)); if (NetworkManager.Singleton.IsServer && sender == NetworkManager.Singleton.LocalClientId) { SpawnLocal(pos, rot, size); } else { SpawnLocal(pos, rot, size); } } private static void Broadcast(Vector3 pos, Quaternion rot, float size) { //IL_0040: 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_0054: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { return; } CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(ref pos); ((FastBufferWriter)(ref val)).WriteValueSafe(ref rot); ((FastBufferWriter)(ref val)).WriteValueSafe(ref size, default(ForPrimitives)); customMessagingManager.SendNamedMessageToAll("MrHat.NicheTweaks.PlayerBlood.Spawn", val, (NetworkDelivery)2); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } internal static void SendRequest(Vector3 pos, Quaternion rot, float size) { //IL_0040: 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_0056: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { return; } CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(64, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(ref pos); ((FastBufferWriter)(ref val)).WriteValueSafe(ref rot); ((FastBufferWriter)(ref val)).WriteValueSafe(ref size, default(ForPrimitives)); customMessagingManager.SendNamedMessage("MrHat.NicheTweaks.PlayerBlood.Request", 0uL, val, (NetworkDelivery)2); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } private static void SpawnLocal(Vector3 pos, Quaternion rot, float size) { //IL_0034: 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_0050: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } GameObject playerBloodPrefab = instance.playerBloodPrefab; Transform bloodObjectsContainer = instance.bloodObjectsContainer; Transform val = ((bloodObjectsContainer != null) ? ((Component)bloodObjectsContainer).transform : null); GameObject val2 = Object.Instantiate(playerBloodPrefab, pos, rot, val); DecalProjector componentInChildren = val2.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.size = new Vector3(size, size, size); } val2.SetActive(true); PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if (!val3.playerBloodPooledObjects.Contains(val2)) { val3.playerBloodPooledObjects.Add(val2); } } } } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] internal static class PlayerBloodDamageTweak { [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance, int damageNumber) { //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_00b5: 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_00e2: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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_01d8: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) PlayerBloodTweak.Wired(); if ((Object)(object)__instance == (Object)null) { return; } NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null) { return; } bool isOwner = ((NetworkBehaviour)__instance).IsOwner; bool isServer = singleton.IsServer; if ((!isOwner && !isServer) || damageNumber < ConfigManager.MinimumDamageForBlood.Value) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } int num = Mathf.Max(1, ConfigManager.BloodAmount.Value); Vector3 val = ((Component)__instance).transform.position + Vector3.up * 0.25f; Transform bloodObjectsContainer = instance.bloodObjectsContainer; Transform val2 = ((bloodObjectsContainer != null) ? ((Component)bloodObjectsContainer).transform : null); float value = ConfigManager.BloodDecalSize.Value; RaycastHit val4 = default(RaycastHit); for (int i = 0; i < num; i++) { Vector3 val3 = val + Vector3.right * Random.Range(-1.5f, 1.5f) + Vector3.forward * Random.Range(-1.5f, 1.5f) + Vector3.up * 0.75f; if (Physics.Raycast(val3, Vector3.down, ref val4, 6f, instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { Vector3 val5 = ((RaycastHit)(ref val4)).point + new Vector3(Random.Range(-0.75f, 0.75f), 0f, Random.Range(-0.75f, 0.75f)) - ((RaycastHit)(ref val4)).normal * 0.01f; Quaternion val6 = Quaternion.LookRotation(Vector3.down, ((RaycastHit)(ref val4)).normal); Quaternion val7 = Quaternion.AngleAxis(Random.Range(0f, 360f), ((RaycastHit)(ref val4)).normal); Quaternion val8 = val7 * val6; GameObject val9 = Object.Instantiate(instance.playerBloodPrefab, val5, val8, val2); DecalProjector componentInChildren = val9.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.size = new Vector3(value, value, value); } val9.SetActive(true); if (!__instance.playerBloodPooledObjects.Contains(val9)) { __instance.playerBloodPooledObjects.Add(val9); } PlayerBloodTweak.SendRequest(val5, val8, value); } } } } } namespace NicheTweaks.Tweaks.Audio { internal static class FearAudioMuteTweak { [HarmonyPatch(typeof(SoundManager), "SetFearAudio")] [HarmonyPrefix] private static bool Prefix(SoundManager __instance) { Stop(__instance.highAction1); Stop(__instance.highAction2); Stop(__instance.heartbeatSFX); Stop(__instance.lowAction); return false; } private static void Stop(AudioSource? audioSource) { if (!((Object)(object)audioSource == (Object)null)) { audioSource.volume = 0f; audioSource.Stop(); } } } internal static class LightningStaticAudioTweak { [HarmonyPatch(typeof(EntranceTeleport), "TeleportPlayer")] [HarmonyPostfix] private static void Postfix() { StormyWeather[] array = Object.FindObjectsOfType(); foreach (StormyWeather val in array) { if (!((Object)(object)val.staticElectricityParticle == (Object)null)) { AudioSource component = ((Component)val.staticElectricityParticle).GetComponent(); if (component != null && component.isPlaying) { component.Stop(); } } } } } [HarmonyPatch(typeof(SoundManager), "SetEarsRinging")] internal static class RingingEarsAudioSilencerTweak { [HarmonyPrefix] private static bool Prefix() { return false; } } } namespace NicheTweaks.Patches { [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRoundPatches { [HarmonyPatch("OnDestroy")] [HarmonyPostfix] private static void CleanupOnDestroy() { SceneObjectUtils.Clear(); if (ConfigManager.DisableLocalPlayerSelfShadow.Value) { HeldItemShadowCache.Clear(); } } } } namespace NicheTweaks.ExternalTweaks.ShipWindows { internal static class ShipWindowsOpenCloseTweak { [HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")] [HarmonyPostfix] private static void ShipHasLeft_Postfix() { SetShuttersLocal(closed: true, locked: false); } [HarmonyPatch(typeof(StartOfRound), "EndOfGameClientRpc")] [HarmonyPostfix] private static void EndOfGameClientRpc_Postfix() { SetShuttersLocal(closed: false, locked: false); } [HarmonyPatch(typeof(EventAPI), "AfterWindowSpawn")] [HarmonyPostfix] private static void AfterWindowSpawn_Postfix(GameObject windowObject) { AbstractWindow componentInChildren = windowObject.GetComponentInChildren(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ShutterSwitchBehavior instance = ShutterSwitchBehavior.Instance; if (Object.op_Implicit((Object)(object)instance)) { bool @bool = instance.animator.GetBool(ShutterSwitchBehavior.EnabledAnimatorHash); bool flag = !instance.interactTrigger.interactable; componentInChildren.ToggleWindowShutter(@bool, flag); } } } private static void SetShuttersLocal(bool closed, bool locked) { foreach (AbstractWindow spawnedWindow in ShipWindows.windowManager.spawnedWindows) { spawnedWindow.ToggleWindowShutter(closed, locked); } } } } namespace NicheTweaks.ExternalTweaks.MoreCompany { internal static class MoreCompanyMenuTweak { private const string QuickMenuCosmeticsButtonPath = "Systems/UI/Canvas/GlobalScale/ActivateButton"; private const string MainMenuCosmeticsButtonPath = "TestOverlay(Clone)/Canvas/GlobalScale/ActivateButton"; private const string CrewCountPath = "MC_CrewCount"; private static readonly Color MoreCompanyOrange = new Color(1f, 0.5647f, 0f, 1f); [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPostfix] private static void OnHudManagerStart() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Keys.hasMoreCompany && ConfigManager.MoreCompanyOrangeCosmeticButton.Value) { SceneObjectUtils.SetImageColor("Systems/UI/Canvas/GlobalScale/ActivateButton", MoreCompanyOrange); } } [HarmonyPatch(typeof(MenuManager), "Start")] [HarmonyPostfix] private static void OnMenuManagerStart() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Keys.hasMoreCompany && ConfigManager.MoreCompanyOrangeCosmeticButton.Value) { SceneObjectUtils.SetImageColor("TestOverlay(Clone)/Canvas/GlobalScale/ActivateButton", MoreCompanyOrange); } if (Keys.hasMoreCompany && ConfigManager.HideMoreCompanyMenuButton.Value) { SceneObjectUtils.SetActive("TestOverlay(Clone)/Canvas/GlobalScale/ActivateButton", active: false); } } [HarmonyPatch(typeof(MenuManager))] [HarmonyPatch("ClickHostButton")] [HarmonyPatch("LAN_HostSetLocal")] [HarmonyPostfix] private static void OnClickHostButton() { if (Keys.hasMoreCompany && ConfigManager.HideMoreCompanyCrewCount.Value) { SceneObjectUtils.SetActive("MC_CrewCount", active: false); } } } } namespace NicheTweaks.ExternalTweaks.MoreBlood { [HarmonyPatch] internal static class MoreBloodFootprintFixTweak { private static readonly MethodBase Target = AccessTools.Method("MoreBlood.Patches.MoreBloodPatcher:MoreBlood", (Type[])null, (Type[])null); [HarmonyPrepare] private static bool Prepare() { return Target != null; } [HarmonyTargetMethod] private static MethodBase TargetMethod() { return Target; } [HarmonyPrefix] private static bool Prefix(bool leaveFootprint) { return !leaveFootprint; } } } namespace NicheTweaks.ExternalTweaks.MirrorDecor { internal static class MirrorDecorFpsCapTweak { private static void SetMirrorCameraFramerate() { GameObject val = FindRootObject("Mirror"); Transform val2 = ((val != null) ? val.transform.Find("MirrorFrame/MirrorMesh/Camera") : null); if (!((Object)(object)val2 == (Object)null)) { ((Component)val2).gameObject.AddComponent(); } } private static GameObject? FindRootObject(string name) { string name2 = name; return ResourceUtils.FindGameObject((GameObject x) => ((Object)x).name == name2 && (Object)(object)x.transform.parent == (Object)null && (Object)(object)x.transform.Find("MirrorFrame/MirrorMesh/Camera") != (Object)null); } [HarmonyPatch(typeof(TimeOfDay), "Start")] [HarmonyPostfix] private static void Postfix(TimeOfDay __instance) { ((MonoBehaviour)__instance).StartCoroutine(CoroutineUtils.DelayThen(3f, SetMirrorCameraFramerate)); } } internal class MirrorCameraFramerateController : MonoBehaviour { [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MirrorCameraFramerateController <>4__this; private WaitForSeconds 5__1; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = new WaitForSeconds(0.25f); break; case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; } if (!<>4__this.localPlayerController.isInHangarShipRoom) { <>2__current = 5__1; <>1__state = 1; return true; } <>4__this.mirrorCamera.Render(); 5__2 = Mathf.Max(1, ConfigManager.MirrorDecorFPSCap.Value); <>2__current = (object)new WaitForSeconds(1f / (float)5__2); <>1__state = 2; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Camera mirrorCamera = null; private PlayerControllerB localPlayerController = null; private Coroutine? renderCoroutine; private bool initialised; private void Start() { mirrorCamera = ((Component)this).GetComponent(); localPlayerController = StartOfRound.Instance.localPlayerController; ((Behaviour)mirrorCamera).enabled = false; initialised = true; StartRenderCoroutine(); } private void OnEnable() { StartRenderCoroutine(); } private void OnDisable() { if (renderCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(renderCoroutine); renderCoroutine = null; } } private void StartRenderCoroutine() { if (initialised && renderCoroutine == null) { renderCoroutine = ((MonoBehaviour)this).StartCoroutine(RenderCamera()); } } [IteratorStateMachine(typeof(d__8))] private IEnumerator RenderCamera() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { <>4__this = this }; } } } namespace NicheTweaks.ExternalTweaks.MagicShippingCrate { [HarmonyPatch] internal static class MagicShippingCrateRespawnTweak { private const string MagicShippingCrateTypeName = "MZCoMagicShipping.Content.MagicShippingCrate"; [HarmonyPrepare] private static bool Prepare() { return AccessTools.TypeByName("MZCoMagicShipping.Content.MagicShippingCrate") != null; } [HarmonyTargetMethod] private static MethodBase? TargetMethod() { return AccessTools.Method(AccessTools.TypeByName("MZCoMagicShipping.Content.MagicShippingCrate"), "OpenCrateServerRpc", (Type[])null, (Type[])null); } [HarmonyPostfix] private static void Postfix(MonoBehaviour __instance) { GameObject crateObject = ((Component)__instance).gameObject; __instance.StartCoroutine(CoroutineUtils.DelayThen(12f, delegate { Object.Destroy((Object)(object)crateObject); })); } } [HarmonyPatch(typeof(StartOfRound), "Start")] internal static class MagicShippingCrateStartCleanupTweak { [HarmonyPostfix] private static void Postfix() { GameObject val = SceneObjectUtils.Find("MithzanCrate(Clone)"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } } namespace NicheTweaks.ExternalTweaks.LobbyImprovements { internal static class LobbyImprovementsTextTweak { [HarmonyPatch(typeof(SaveFileUISlot), "OnEnable")] [HarmonyPostfix] private static void Postfix() { SceneObjectUtils.SetText("Canvas/MenuContainer/LobbyHostSettings/LIPanel_Host/EnterAName", "Lobby"); } } } namespace NicheTweaks.ExternalTweaks.LobbyControl { [HarmonyPatch(typeof(Terminal), "Start")] internal static class LobbyControlCommandRemovalTweak { private const string LobbyControlTerminalText = "\n\n>LOBBY [command] (lobby name)\ntype lobby help for more info.\n\n"; [HarmonyPostfix] private static void RemoveLobbyControlTerminalText(ref TerminalNodesList ___terminalNodes) { TerminalNode val = null; TerminalKeyword[] allKeywords = ___terminalNodes.allKeywords; foreach (TerminalKeyword val2 in allKeywords) { if (val2.word == "other") { val = val2.specialKeywordResult; break; } } if (!((Object)(object)val == (Object)null)) { val.displayText = val.displayText.Replace("\n\n>LOBBY [command] (lobby name)\ntype lobby help for more info.\n\n", "").TrimEnd() + "\n\n"; } } } } namespace NicheTweaks.ExternalTweaks.LethalThings { [HarmonyPatch(typeof(PouchyBelt), "UpdateHUD")] internal static class LethalThingsUtilityBeltTweak { [HarmonyPostfix] private static void Postfix(PouchyBelt __instance, bool add) { //IL_002c: 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_00a0: Unknown result type (might be due to invalid IL or missing references) if (add) { Image[] itemSlotIconFrames = HUDManager.Instance.itemSlotIconFrames; int beltCapacity = __instance.beltCapacity; Image val = itemSlotIconFrames[0]; float x = ((Graphic)val).rectTransform.sizeDelta.x; float num = (float)beltCapacity * x + (float)(beltCapacity - 1) * 15f; float num2 = 0f - num * 0.5f + x * 0.5f; for (int i = 0; i < beltCapacity; i++) { int num3 = __instance.slotIndexes[i]; Image val2 = itemSlotIconFrames[num3]; float num4 = num2 + (float)i * (x + 15f); ((Graphic)val2).rectTransform.anchoredPosition = new Vector2(num4, ((Graphic)val2).rectTransform.anchoredPosition.y); } } } } } namespace NicheTweaks.ExternalTweaks.LethalNuke { [HarmonyPatch(typeof(NuclearBomb), "boomasync")] internal static class LethalNukeFixTweak { private static void Prefix(NuclearBomb __instance) { //IL_0007: 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_0025: 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_0032: Unknown result type (might be due to invalid IL or missing references) MainModule main = __instance.nuclearParticles.main; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0; EmissionModule emission = __instance.nuclearParticles.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); } } } namespace NicheTweaks.ExternalTweaks.LethalConfig { [HarmonyPatch] internal static class LethalConfigMenuButtonTweak { private static readonly MethodBase? Target = Type.GetType("LethalConfig.Patches.MenuManagerPatches, LethalConfig")?.GetMethod("InjectToMainMenu", BindingFlags.Static | BindingFlags.NonPublic); private static bool Prepare() { return Target != null; } private static MethodBase? TargetMethod() { return Target; } [HarmonyPrefix] private static bool Prefix() { return false; } } [HarmonyPatch] internal static class LethalConfigSpacingTweak { private static readonly MethodBase? Target = Type.GetType("LethalConfig.Utils.MenusUtils, LethalConfig")?.GetMethod("InjectMenu", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); private static bool Prepare() { return Target != null; } private static MethodBase? TargetMethod() { return Target; } [HarmonyPostfix] private static void Postfix(Transform mainButtonsTransform) { TextMeshProUGUI[] componentsInChildren = ((Component)mainButtonsTransform).GetComponentsInChildren(true); foreach (TextMeshProUGUI val in componentsInChildren) { if (((TMP_Text)val).text == "> LethalConfig") { ((TMP_Text)val).text = "> Lethal Config"; } } } } } namespace NicheTweaks.ExternalTweaks.InputUtils { [HarmonyPatch(typeof(KepRemapPanel))] internal static class InputUtilsLegacyButtonHideTweak { [HarmonyPatch("OnEnable")] [HarmonyPostfix] private static void Postfix() { SceneObjectUtils.SetActive("KeybindsPanel/Back(Clone)", active: false); } } } namespace NicheTweaks.ExternalTweaks.ImmersiveVisor { [HarmonyPatch(typeof(Visor), "RaindropUpdate")] internal static class ImmersiveVisorHurricaneTweak { private const string ExtraWeatherName = "Hurricane"; private static bool IsExtraRainWeather() { return ((object)(LevelWeatherType)(ref TimeOfDay.Instance.currentLevelWeather)).ToString() == "Hurricane"; } [HarmonyTranspiler] private static IEnumerable Transpiler(IEnumerable instructions) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown List list = instructions.ToList(); MethodInfo methodInfo = AccessTools.Method(typeof(ImmersiveVisorHurricaneTweak), "IsExtraRainWeather", (Type[])null, (Type[])null); CodeMatcher val = new CodeMatcher((IEnumerable)list, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((Func)((CodeInstruction ci) => ci.opcode == OpCodes.Ldloc_3 || ci.opcode == OpCodes.Ldloc_S), (string)null), new CodeMatch((Func)((CodeInstruction ci) => ci.opcode == OpCodes.Brtrue || ci.opcode == OpCodes.Brtrue_S), (string)null) }); if (!val.IsValid) { return list; } CodeInstruction val2 = val.InstructionAt(1); if (!(val2.operand is Label label) || 1 == 0) { return list; } val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Call, (object)methodInfo), new CodeInstruction(OpCodes.Brtrue, (object)label) }); return val.InstructionEnumeration(); } } } namespace NicheTweaks.ExternalTweaks.GeneralImprovements { internal static class GeneralImprovementsPlayerScanNodeTweak { [HarmonyPatch(typeof(HUDManager), "AssignNodeToUIElement")] [HarmonyAfter(new string[] { "ShaosilGaming.GeneralImprovements" })] [HarmonyPriority(0)] [HarmonyPostfix] private static void Postfix(ScanNodeProperties node) { Transform parent = ((Component)node).transform.parent; PlayerControllerB val = default(PlayerControllerB); if (!((Object)(object)parent == (Object)null) && ((Component)parent).TryGetComponent(ref val) && !((Object)(object)val == (Object)(object)StartOfRound.Instance.localPlayerController)) { node.nodeType = 1; } } } } namespace NicheTweaks.ExternalTweaks.EnhancedMonsters { [HarmonyPatch(typeof(MenuManager), "Start")] internal static class EnhancedMonstersVersionNumberRemovalTweak { private static readonly Regex EnhancedMonstersVersionLine = new Regex("\\r?\\nEnhanced Monsters v[^<]+", RegexOptions.CultureInvariant); [HarmonyPostfix] private static void OnStart(MenuManager __instance) { TextMeshProUGUI versionNumberText = __instance.versionNumberText; if (!((Object)(object)versionNumberText == (Object)null) && !string.IsNullOrEmpty(((TMP_Text)versionNumberText).text)) { string text = ((TMP_Text)versionNumberText).text; string text2 = EnhancedMonstersVersionLine.Replace(text, string.Empty); if (!(text2 == text)) { ((TMP_Text)versionNumberText).text = text2; } } } } } namespace NicheTweaks.ExternalTweaks.EladsHUD { internal static class EladsHUDHelper { internal const string PlayerInfoName = "PlayerInfo(Clone)"; internal const string PlayerInfo = "Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)"; internal const string StaminaInfo = "Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/Stamina/StaminaInfo"; internal const string CarryInfo = "Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/Stamina/CarryInfo"; internal const string OxygenInfo = "Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/OxygenMeter/StaminaInfo"; internal const string OxygenDivider = "Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/OxygenMeter/StaminaDivider"; internal const string OxygenDividerClone = "Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/OxygenMeter/StaminaDivider(Clone)"; internal const string InsanityInfo = "Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/InsanityMeter/InsanityInfo"; internal const string OxygenDividerChild = "OxygenMeter/StaminaDivider"; internal const string CustomHUDMono = "CustomHUD_Mono, EladsHUD"; internal const string CustomHUDMonoUnqualified = "CustomHUD_Mono"; internal const string CustomHUDPlugin = "CustomHUD.Plugin, EladsHUD"; internal const string InsanityEladsCompatibility = "LC_InsanityDisplay.Plugin.ModCompatibility.EladsHUDCompatibility, InsanityDisplay"; internal const string OxygenInit = "Oxygen.General.OxygenInit, Oxygen"; internal static Type? FindType(string typeName) { return AccessTools.TypeByName(typeName); } internal static MethodBase? FindMethod(string typeName, string methodName) { Type type = FindType(typeName); return (type == null) ? null : AccessTools.Method(type, methodName, (Type[])null, (Type[])null); } internal static void SetActive(string path, bool active) { SceneObjectUtils.SetActive(path, active); } internal static void SetCachedActive(ref GameObject? gameObject, string path, bool active) { if ((Object)(object)gameObject == (Object)null) { gameObject = SceneObjectUtils.Find(path); } GameObject? obj = gameObject; if (obj != null) { obj.SetActive(active); } } internal static Transform? FindPlayerInfoChild(string childPath) { return SceneObjectUtils.FindChild("PlayerInfo(Clone)", childPath); } internal static void SetLocalPosition(string path, Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SceneObjectUtils.SetLocalPosition(path, position); } } [HarmonyPatch(typeof(HUDManager), "Start")] internal static class EladsHUDTweak { [HarmonyPostfix] private static void OnStart(HUDManager __instance) { if (Keys.hasEladsHUD && Keys.hasOxygen && ConfigManager.EladsHUDHidePercentDividers.Value) { EladsHUDVisibility.HideOxygenDividers(); } if (Keys.hasEladsHUD && Keys.hasOxygen && ConfigManager.EladsHUDHideOxygenPercentage.Value) { EladsHUDVisibility.HideOxygenPercentage(); } if (Keys.hasEladsHUD && ConfigManager.HideEladsHUDWeight.Value) { EladsHUDVisibility.HideWeight(); } if (ConfigManager.EladsHUDAutoHideStamina.Value) { EladsHUDVisibility.HideDetailedStaminaForOxygenCompat(); } if (Keys.hasEladsHUD && ConfigManager.EladsHUDAutoHideStamina.Value) { ((Component)__instance).gameObject.AddComponent(); } if (Keys.hasEladsHUD && Keys.hasInsanityDisplay && ConfigManager.EladsHUDAutoHideInsanity.Value) { ((Component)__instance).gameObject.AddComponent(); } if (Keys.hasEladsHUD && Keys.hasOxygen && ConfigManager.EladsHUDAutoHideOxygen.Value) { ((Component)__instance).gameObject.AddComponent(); } } } internal static class EladsHUDV80Compat { private static readonly Type? CustomHUDMonoType = EladsHUDHelper.FindType("CustomHUD_Mono"); private static readonly FieldInfo? CustomHUDMonoInstanceField = ((CustomHUDMonoType == null) ? null : AccessTools.Field(CustomHUDMonoType, "instance")); private static RectTransform? UtilitySlot; private static Transform? VisibleParent; internal static void Clear() { UtilitySlot = null; VisibleParent = null; } private static void EladsHUDCompat() { if ((Object)(object)UtilitySlot == (Object)null) { GameObject val = SceneObjectUtils.Find("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner/UtilitySlot"); if ((Object)(object)val == (Object)null) { return; } UtilitySlot = val.GetComponent(); } RectTransform utilitySlot = UtilitySlot; if ((Object)(object)utilitySlot == (Object)null) { return; } if ((Object)(object)VisibleParent == (Object)null) { object? obj = CustomHUDMonoInstanceField?.GetValue(null); Component val2 = (Component)((obj is Component) ? obj : null); if (val2 == null) { return; } VisibleParent = val2.transform.parent; } Transform visibleParent = VisibleParent; if (!((Object)(object)visibleParent == (Object)null) && (Object)(object)((Transform)utilitySlot).parent != (Object)(object)visibleParent) { ((Transform)utilitySlot).SetParent(visibleParent, false); } } [HarmonyPatch(typeof(HUDManager), "Awake")] [HarmonyPostfix] private static void Postfix() { EladsHUDCompat(); } [HarmonyPatch(typeof(HUDManager), "Start")] [HarmonyPostfix] private static void PostfixStart() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)UtilitySlot == (Object)null)) { ((Transform)UtilitySlot).localPosition = new Vector3(270.5923f, -150.4603f, 0f); if (ConfigManager.DisableUtilitySlot.Value) { ((Component)UtilitySlot).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(StartOfRound), "OnDestroy")] [HarmonyPostfix] private static void PostfixCacheClear() { Clear(); } } } namespace NicheTweaks.ExternalTweaks.EladsHUD.Misc { internal static class EladsHUDVisibility { internal static void HideOxygenDividers() { EladsHUDHelper.SetActive("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/OxygenMeter/StaminaDivider", active: false); EladsHUDHelper.SetActive("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/OxygenMeter/StaminaDivider(Clone)", active: false); } internal static void HideWeight() { EladsHUDHelper.SetActive("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/Stamina/CarryInfo", active: false); } internal static void HideOxygenPercentage() { EladsHUDHelper.SetActive("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/OxygenMeter/StaminaInfo", active: false); } internal static void HideStaminaPercentage(ref GameObject? staminaInfo) { EladsHUDHelper.SetCachedActive(ref staminaInfo, "Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/Stamina/StaminaInfo", active: false); } internal static void HideInsanityPercentage(ref GameObject? insanityInfo) { EladsHUDHelper.SetCachedActive(ref insanityInfo, "Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/InsanityMeter/InsanityInfo", active: false); } internal static void HideDetailedStaminaForOxygenCompat() { Type type = EladsHUDHelper.FindType("CustomHUD.Plugin, EladsHUD"); object obj = ((type == null) ? null : AccessTools.Field(type, "detailedStamina")?.GetValue(null)); if (obj != null) { object obj2 = AccessTools.Property(obj.GetType(), "Value")?.GetValue(obj); if (obj2 != null) { EladsHUDHelper.SetActive("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/Stamina/StaminaInfo", active: false); } } } } [HarmonyPatch] internal static class EladsHUDHealthPopupTweak { private static readonly MethodBase? Target = EladsHUDHelper.FindMethod("CustomHUD_Mono, EladsHUD", "UpdateFromPlayer"); private static FieldInfo? lastHealthField; private static FieldInfo? lastHealthChangeField; [HarmonyPrepare] private static bool Prepare() { return ConfigManager.EladsHUDTriggerHealthShowOnHeal.Value && Target != null; } [HarmonyTargetMethod] private static MethodBase? TargetMethod() { return Target; } [HarmonyPrefix] private static void Prefix(MonoBehaviour __instance, PlayerControllerB player) { if ((object)lastHealthField == null) { lastHealthField = AccessTools.Field(((object)__instance).GetType(), "lastHealth"); } if ((object)lastHealthChangeField == null) { lastHealthChangeField = AccessTools.Field(((object)__instance).GetType(), "lastHealthChange"); } if (lastHealthField == null || lastHealthChangeField == null) { return; } object value = lastHealthField.GetValue(__instance); if (value is int) { int num = (int)value; if (true && player.health > num) { lastHealthChangeField.SetValue(__instance, 0f); } } } } internal class HideStaminaPercentageRunner : MonoBehaviour { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public HideStaminaPercentageRunner <>4__this; private WaitForSeconds 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = new WaitForSeconds(0.25f); break; case 1: <>1__state = -1; break; } EladsHUDVisibility.HideStaminaPercentage(ref <>4__this.staminaInfo); <>2__current = 5__1; <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private GameObject? staminaInfo; [IteratorStateMachine(typeof(d__1))] private IEnumerator Start() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { <>4__this = this }; } } internal class HideInsanityPercentageRunner : MonoBehaviour { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public HideInsanityPercentageRunner <>4__this; private WaitForSeconds 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__1 = new WaitForSeconds(0.25f); break; case 1: <>1__state = -1; break; } EladsHUDVisibility.HideInsanityPercentage(ref <>4__this.insanityInfo); <>2__current = 5__1; <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private GameObject? insanityInfo; [IteratorStateMachine(typeof(d__1))] private IEnumerator Start() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { <>4__this = this }; } } [HarmonyPatch] internal static class EladsHUDStaminaTenPercentTweak { private static readonly MethodBase? Target = EladsHUDHelper.FindMethod("CustomHUD_Mono, EladsHUD", "UpdateFromPlayer"); private static FieldInfo? staminaTextField; private static FieldInfo? staminaBarField; private static FieldInfo? staminaBarChangeFGField; private static float lastSprint = 1f; [HarmonyTargetMethod] private static MethodBase? TargetMethod() { return Target; } [HarmonyPostfix] private static void Apply(object __instance, PlayerControllerB player) { if ((Object)(object)player == (Object)null) { return; } float num = Mathf.InverseLerp(0.1f, 1f, player.sprintMeter); num = Mathf.Clamp01(num); int num2 = Mathf.RoundToInt(num * 100f); if ((object)staminaTextField == null) { staminaTextField = AccessTools.Field(__instance.GetType(), "staminaText"); } object? obj = staminaTextField?.GetValue(__instance); TextMeshProUGUI val = (TextMeshProUGUI)((obj is TextMeshProUGUI) ? obj : null); if (val != null) { string text = ((TMP_Text)val).text ?? string.Empty; int num3 = text.IndexOf("%", StringComparison.Ordinal); string text2 = ((num3 >= 0) ? text.Substring(num3) : "%"); ((TMP_Text)val).text = num2 + text2; } if ((object)staminaBarField == null) { staminaBarField = AccessTools.Field(__instance.GetType(), "staminaBar"); } if ((object)staminaBarChangeFGField == null) { staminaBarChangeFGField = AccessTools.Field(__instance.GetType(), "staminaBarChangeFG"); } if (!(staminaBarField == null) && !(staminaBarChangeFGField == null)) { object? value = staminaBarField.GetValue(__instance); Image val2 = (Image)((value is Image) ? value : null); object? value2 = staminaBarChangeFGField.GetValue(__instance); Image val3 = (Image)((value2 is Image) ? value2 : null); if (val3 != null) { ((Component)val3).gameObject.SetActive(!ConfigManager.DisableEladsHUDStaminaNotch.Value); } if (!((Object)(object)val2 == (Object)null)) { float num5 = (val2.fillAmount = Mathf.Lerp(lastSprint, num, Time.deltaTime * 10f)); lastSprint = num5; } } } } } namespace NicheTweaks.ExternalTweaks.EladsHUD.HUDReorder { [HarmonyPatch] internal static class EladsHUDStaminaReorderTweak { private static MethodBase? target; [HarmonyPrepare] private static bool Prepare() { target = EladsHUDHelper.FindMethod("CustomHUD_Mono, EladsHUD", "Start"); return target != null; } [HarmonyTargetMethod] private static MethodBase? TargetMethod() { return target; } [HarmonyPostfix] private static void Postfix() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) EladsHUDHelper.SetLocalPosition("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/Stamina/StaminaInfo", new Vector3(44.7863f, -15.4f, 0f)); } } [HarmonyPatch] internal static class EladsHUDInsanityReorderTweak { private static MethodBase? target; [HarmonyPrepare] private static bool Prepare() { target = EladsHUDHelper.FindMethod("LC_InsanityDisplay.Plugin.ModCompatibility.EladsHUDCompatibility, InsanityDisplay", "Start"); return target != null; } [HarmonyTargetMethod] private static MethodBase? TargetMethod() { return target; } [HarmonyPostfix] private static void Postfix() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) EladsHUDHelper.SetLocalPosition("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/InsanityMeter/InsanityInfo", new Vector3(-234.9753f, -23.3653f, 0f)); } } [HarmonyPatch] internal static class EladsHUDInsanityPercentageReorderTweak { private static MethodBase? target; private static PropertyInfo? percentageTextProperty; [HarmonyPrepare] private static bool Prepare() { Type type = EladsHUDHelper.FindType("LC_InsanityDisplay.Plugin.ModCompatibility.EladsHUDCompatibility, InsanityDisplay"); target = ((type == null) ? null : AccessTools.Method(type, "UpdatePercentageText", (Type[])null, (Type[])null)); percentageTextProperty = ((type == null) ? null : AccessTools.Property(type, "InsanityPercentageText")); return target != null; } [HarmonyTargetMethod] private static MethodBase? TargetMethod() { return target; } [HarmonyPostfix] private static void Postfix() { object? obj = percentageTextProperty?.GetValue(null, null); TextMeshProUGUI val = (TextMeshProUGUI)((obj is TextMeshProUGUI) ? obj : null); if (val == null) { return; } string text = ((TMP_Text)val).text ?? string.Empty; if (!string.IsNullOrWhiteSpace(text)) { string s = new string(new ReadOnlySpan(text.Where(char.IsDigit).ToArray())); if (int.TryParse(s, out var result)) { ((TMP_Text)val).text = $"{result}%"; } } } } [HarmonyPatch] internal static class EladsHUDOxygenReorderTweak { private static MethodBase? target; [HarmonyPrepare] private static bool Prepare() { target = EladsHUDHelper.FindMethod("Oxygen.General.OxygenInit, Oxygen", "Init_EladsHUD"); return target != null; } [HarmonyTargetMethod] private static MethodBase? TargetMethod() { return target; } [HarmonyPostfix] private static void Postfix() { //IL_0040: 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) Transform val = EladsHUDHelper.FindPlayerInfoChild("OxygenMeter/StaminaDivider"); if (!((Object)(object)val == (Object)null)) { GameObject val2 = Object.Instantiate(((Component)val).gameObject, val.parent); val2.transform.localPosition = new Vector3(82.1844f, -6.4f, 2.8f); EladsHUDHelper.SetLocalPosition("Systems/UI/Canvas/IngamePlayerHUD/PlayerInfo(Clone)/OxygenMeter/StaminaInfo", new Vector3(86.4336f, -7.2726f, 2.7698f)); } } } } namespace NicheTweaks.ExternalTweaks.EladsHUD.AutoHide { internal class InsanityAutoHide : MonoBehaviour { private float hideDelayTimer; private CanvasGroup? cachedGroup; private TMP_Text? cachedText; private string? lastText; private void Start() { Transform val = EladsHUDHelper.FindPlayerInfoChild("InsanityMeter"); if ((Object)(object)val == (Object)null) { cachedGroup = null; cachedText = null; return; } cachedGroup = CanvasGroupUtils.GetOrAdd(val); Transform val2 = val.Find("InsanityInfo"); cachedText = ((val2 != null) ? ((Component)val2).GetComponent() : null); hideDelayTimer = 0f; lastText = null; } private void LateUpdate() { if ((Object)(object)cachedGroup == (Object)null || (Object)(object)cachedText == (Object)null) { return; } string text = cachedText.text; bool flag = text != lastText; lastText = text; float deltaTime = Time.deltaTime; float value = ConfigManager.EladsHUDAutoHideInsanityDelay.Value; if (flag) { hideDelayTimer = 0f; cachedGroup.alpha = 1f; return; } hideDelayTimer += deltaTime; if (hideDelayTimer < value) { cachedGroup.alpha = 1f; } else { cachedGroup.alpha = Mathf.MoveTowards(cachedGroup.alpha, 0f, deltaTime * 3f); } } } internal class OxygenAutoHide : MonoBehaviour { private float hideDelayTimer; private CanvasGroup? cachedGroup; private TMP_Text? cachedText; private void Start() { Transform val = EladsHUDHelper.FindPlayerInfoChild("OxygenMeter"); if ((Object)(object)val == (Object)null) { cachedGroup = null; cachedText = null; return; } cachedGroup = CanvasGroupUtils.GetOrAdd(val); Transform val2 = val.Find("StaminaInfo"); cachedText = ((val2 != null) ? ((Component)val2).GetComponent() : null); hideDelayTimer = 0f; } private void LateUpdate() { if (!ConfigManager.EladsHUDAutoHideOxygen.Value || (Object)(object)cachedGroup == (Object)null || (Object)(object)cachedText == (Object)null) { return; } float deltaTime = Time.deltaTime; float value = ConfigManager.EladsHUDAutoHideOxygenDelay.Value; string text = cachedText.text; int num = text.IndexOf('<'); string text2 = ((num > 0) ? text.Substring(0, num) : text); text2 = text2.Trim(); float.TryParse(text2, out var result); float num2 = ConfigManager.EladsHUDAutoHideOxygenValue.Value * 100f; if (result > num2) { hideDelayTimer += deltaTime; if (hideDelayTimer >= value) { cachedGroup.alpha = Mathf.MoveTowards(cachedGroup.alpha, 0f, deltaTime * 3f); } else { cachedGroup.alpha = Mathf.MoveTowards(cachedGroup.alpha, 1f, deltaTime * 3f); } } else { hideDelayTimer = 0f; cachedGroup.alpha = Mathf.MoveTowards(cachedGroup.alpha, 1f, deltaTime * 3f); } } } internal class StaminaAutoHide : MonoBehaviour { private float hideDelayTimer; private float lastWeight = -1f; private float lastStaminaFill = 1f; private CanvasGroup? staminaBG; private CanvasGroup? staminaInfo; private CanvasGroup? bar; private CanvasGroup? carryInfo; private void Start() { GameObject val = SceneObjectUtils.Find("PlayerInfo(Clone)"); if ((Object)(object)val == (Object)null) { return; } Transform val2 = EladsHUDHelper.FindPlayerInfoChild("Stamina"); if (!((Object)(object)val2 == (Object)null)) { Transform val3 = val2.Find("Stamina BG"); Transform val4 = val2.Find("StaminaInfo"); Transform val5 = val2.Find("Bar"); Transform val6 = val2.Find("CarryInfo"); if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val4 == (Object)null) && !((Object)(object)val5 == (Object)null) && !((Object)(object)val6 == (Object)null)) { staminaBG = CanvasGroupUtils.GetOrAdd(val3); staminaInfo = CanvasGroupUtils.GetOrAdd(val4); bar = CanvasGroupUtils.GetOrAdd(val5); carryInfo = CanvasGroupUtils.GetOrAdd(val6); hideDelayTimer = 0f; lastWeight = -1f; lastStaminaFill = 1f; } } } private void LateUpdate() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val == (Object)null || (Object)(object)staminaBG == (Object)null || (Object)(object)staminaInfo == (Object)null || (Object)(object)bar == (Object)null || (Object)(object)carryInfo == (Object)null) { return; } float deltaTime = Time.deltaTime; float sprintMeter = val.sprintMeter; float value = ConfigManager.EladsHUDStaminaAutoHideStartPercent.Value; bool flag = val.isSprinting || sprintMeter < lastStaminaFill - 0.001f; bool flag2 = sprintMeter >= value - 0.001f; lastStaminaFill = sprintMeter; bool flag3 = false; if (ConfigManager.EladsHUDWeightTriggersStamina.Value) { float carryWeight = val.carryWeight; if (!Mathf.Approximately(carryWeight, lastWeight)) { lastWeight = carryWeight; flag3 = true; } } float num; if (flag || flag3) { hideDelayTimer = 0f; num = 1f; } else if (flag2) { hideDelayTimer += deltaTime; float value2 = ConfigManager.EladsHUDStaminaAutoHideDelay.Value; num = ((hideDelayTimer >= value2) ? 0f : 1f); } else { hideDelayTimer = 0f; num = 1f; } float alpha = Mathf.MoveTowards(staminaBG.alpha, num, deltaTime * 3f); CanvasGroupUtils.SetAlpha(alpha, staminaBG, staminaInfo, bar, carryInfo); } } } namespace NicheTweaks.ExternalTweaks.DawnLib { [HarmonyPatch] internal static class DawnLibAchievementPopupTweak { [HarmonyPostfix] [HarmonyPatch(typeof(AchievementUIGetCanvas), "QueuePopup")] private static void Postfix(object __instance) { Component val = (Component)((__instance is Component) ? __instance : null); if (val == null) { return; } Transform[] componentsInChildren = val.GetComponentsInChildren(true); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name.Contains("Achievement") || ((Object)val2).name.Contains("Popup")) { ((Component)val2).gameObject.SetActive(false); } } AudioSource[] componentsInChildren2 = val.GetComponentsInChildren(true); foreach (AudioSource val3 in componentsInChildren2) { val3.mute = true; } } } internal static class DawnLibHotloadingPlayerImageTweak { private const string AssetBundleFileName = "dawnlibuiassets"; private const string PlayerImageAssetPath = "Assets/LethalCompany/Mods/plugins/NicheTweaks/DawnLibAssetReplacement/PlayerStaringAtScreen.png"; private static Texture2D? replacementTexture; private static bool loadAttempted; private static bool loggedMissingAsset; private static bool loggedMissingImage; private static bool loggedApplied; internal static void Load() { if (!loadAttempted) { loadAttempted = true; if (!AssetBundleUtils.TryLoadAsset("dawnlibuiassets", "Assets/LethalCompany/Mods/plugins/NicheTweaks/DawnLibAssetReplacement/PlayerStaringAtScreen.png", out replacementTexture, out string bundlePath)) { Log.Error("DawnLib hotloadUI image asset missing at " + bundlePath); loggedMissingAsset = true; } else { Log.Info("DawnLib hotloadUI image loaded"); } } } internal static void Apply(GameObject playerEntry, string username) { SetUsername(playerEntry, username); if ((Object)(object)replacementTexture == (Object)null) { if (!loggedMissingAsset) { Log.Error("DawnLib hotloadUI image asset was not loaded"); loggedMissingAsset = true; } return; } RawImage val = FindRawImage(playerEntry); if ((Object)(object)val == (Object)null) { if (!loggedMissingImage) { Log.Error("DawnLib hotloadUI image target was not found"); loggedMissingImage = true; } return; } val.texture = (Texture)(object)replacementTexture; if (!loggedApplied) { Log.Debug("DawnLib hotloadUI image replaced"); loggedApplied = true; } } private static RawImage? FindRawImage(GameObject playerEntry) { RawImage[] componentsInChildren = playerEntry.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (((Object)componentsInChildren[i]).name == "PlayerSpectateBox") { return componentsInChildren[i]; } } return null; } private static void SetUsername(GameObject playerEntry, string username) { TMP_Text[] componentsInChildren = playerEntry.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (((Object)componentsInChildren[i]).name == "PlayerBeingMonitored") { componentsInChildren[i].text = username; break; } } } [HarmonyPatch(typeof(PlayerNameplateUI), "Setup")] [HarmonyPrefix] private static bool Prefix(PlayerNameplateUI __instance, PlayerControllerB player) { Apply(((Component)__instance).gameObject, player.playerUsername); return false; } } } namespace NicheTweaks.ExternalTweaks.BetterSaves { [HarmonyPatch(typeof(MenuManager))] internal static class BetterSavesAutoRename { [HarmonyPrefix] [HarmonyPatch("StartHosting")] private static void Prefix(out bool __state) { string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName; __state = currentSaveFileName == "LCSaveFile" + Plugin.newSaveFileNum && !ES3.FileExists(currentSaveFileName); } [HarmonyPostfix] [HarmonyPatch("StartHosting")] private static void Postfix(bool __state) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown if (!__state) { return; } GameObject val = GameObject.Find("Canvas/MenuContainer/LobbyHostSettings/HostSettingsContainer/LobbyHostOptions/OptionsNormal/ServerNameField/Text Area/Text"); if ((Object)val == (Object)null) { return; } TMP_Text component = val.GetComponent(); if (!((Object)component == (Object)null)) { string text = component.text.Trim(); if (!string.IsNullOrWhiteSpace(text)) { ES3.Save("Alias_BetterSaves", text, GameNetworkManager.Instance.currentSaveFileName); Plugin.RefreshNameFields(); } } } } internal static class BetterSavesStartCreditsFix { [HarmonyPatch(typeof(SaveFileUISlot_BetterSaves), "UpdateStats")] [HarmonyPrefix] private static bool Prefix(SaveFileUISlot_BetterSaves __instance) { if (ES3.FileExists(__instance.fileString)) { int num = ES3.Load("GroupCredits", __instance.fileString, 60); int num2 = ES3.Load("Stats_DaysSpent", __instance.fileString, 0); ((TMP_Text)__instance.fileStatsText).text = $"${num}\nDays: {num2}"; } else { ((TMP_Text)__instance.fileStatsText).text = ""; } return false; } } internal static class BetterSavesTextTweak { [HarmonyPatch(typeof(SaveFileUISlot), "OnEnable")] [HarmonyPostfix] private static void SaveFileUISlotPostfix() { BetterSaves(); } [HarmonyPatch(typeof(DeleteFileButton_BetterSaves))] [HarmonyPatch("UpdateFileToDelete")] [HarmonyPatch("DeleteFile")] [HarmonyPostfix] private static void DeleteFileButtonPostfix() { BetterSaves(); } [HarmonyPatch(typeof(Plugin), "InitializeBetterSaves")] [HarmonyPostfix] private static void PluginPostfix() { BetterSaves(); } private static void BetterSaves() { SceneObjectUtils.SetText("Canvas/MenuContainer/LobbyHostSettings/FilesPanel/EnterAName", "Save Files"); } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace NicheTweaks.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }