Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DanceHealingOnShip v2.8.0
DanceHealingOnShip.dll
Decompiled 8 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using DanceHealingOnShip.Patches; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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("DanceHealingOnShip")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Dance to heal yourself on the ship!")] [assembly: AssemblyFileVersion("2.8.0.0")] [assembly: AssemblyInformationalVersion("2.8.0")] [assembly: AssemblyProduct("DanceHealingOnShip")] [assembly: AssemblyTitle("DanceHealingOnShip")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.8.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DanceHealingOnShip { [BepInPlugin("DanceHealingOnShip", "DanceHealingOnShip", "2.8.0")] public class DanceHealingOnShip : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("DanceHealingOnShip"); public static DanceHealingOnShip Instance; internal static ManualLogSource Mls; public static Dictionary<string, float> ExecutedInstances; public static Dictionary<string, CancellationTokenSource> TokenSources; public static Dictionary<string, bool> HasShownMessage; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Mls = Logger.CreateLogSource("DanceHealingOnShip"); _harmony.PatchAll(typeof(DanceHealingOnShip)); _harmony.PatchAll(typeof(PlayerControllerBPatch)); _harmony.PatchAll(typeof(StartRoundPatch)); ExecutedInstances = new Dictionary<string, float>(); HasShownMessage = new Dictionary<string, bool>(); TokenSources = new Dictionary<string, CancellationTokenSource>(); Mls.LogInfo((object)"DanceHealingOnShip is loaded - version 2.8.0"); } } public static class PluginInfo { public const string PLUGIN_GUID = "DanceHealingOnShip"; public const string PLUGIN_NAME = "DanceHealingOnShip"; public const string PLUGIN_VERSION = "2.8.0"; } } namespace DanceHealingOnShip.Patches { internal class PlayerControllerBPatch { private const float HealingCooldownTime = 60f; [HarmonyPatch(typeof(PlayerControllerB), "StartPerformingEmoteClientRpc")] [HarmonyPostfix] public static async void OnDancingOnShip(PlayerControllerB __instance) { string playerUsername = __instance.playerUsername; float lastExecutionTime; bool isCooldownActive = DanceHealingOnShip.ExecutedInstances.TryGetValue(playerUsername, out lastExecutionTime) && Time.time - lastExecutionTime < 60f; if (__instance.performingEmote && __instance.health < 100 && __instance.isInHangarShipRoom && !isCooldownActive) { if (__instance.isPlayerDead) { DanceHealingOnShip.Mls.LogInfo((object)(playerUsername + " is dead and cannot heal.")); return; } if (DanceHealingOnShip.TokenSources.TryGetValue(playerUsername, out var existingCts)) { existingCts.Cancel(); DanceHealingOnShip.Mls.LogInfo((object)(playerUsername + " cancelled their previous healing task.")); } CancellationTokenSource cts = new CancellationTokenSource(); DanceHealingOnShip.TokenSources[playerUsername] = cts; try { while (__instance.health < 100 && __instance.performingEmote && !cts.Token.IsCancellationRequested) { await Task.Delay(1000, cts.Token); if (!__instance.performingEmote || cts.Token.IsCancellationRequested) { break; } __instance.health += 10; if (__instance.health > 100) { __instance.health = 100; } __instance.DamagePlayer(-10, false, true, (CauseOfDeath)0, 0, false, Vector3.zero); if (__instance.health >= 20) { __instance.criticallyInjured = false; } if ((Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController) { HUDManager.Instance.UpdateHealthUI(__instance.health, false); } } if (__instance.health >= 100) { DanceHealingOnShip.ExecutedInstances[playerUsername] = Time.time; DanceHealingOnShip.Mls.LogInfo((object)(playerUsername + " has been completed healed. Cooldown for 60s.")); if ((Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController) { HUDManager.Instance.DisplayTip("Full health by dancing!", "You are now at full health! Try to avoid damage for 60 seconds to heal again.", false, false, "LC_Tip1"); } } } catch (TaskCanceledException) { DanceHealingOnShip.Mls.LogInfo((object)(playerUsername + " healing was cancelled or is currently on progress.")); } finally { if ((Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController) { HUDManager.Instance.UpdateHealthUI(__instance.health, false); } DanceHealingOnShip.TokenSources.Remove(playerUsername); } } else { DanceHealingOnShip.Mls.LogInfo((object)(playerUsername + " is either not dancing, at full health, on cooldown, or not in the hangar room.")); } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartRoundPatch { [HarmonyPatch("StartGame")] [HarmonyPostfix] private static void StartGame() { Fullreset(); } [HarmonyPatch("EndOfGame")] [HarmonyPostfix] private static void EndOfGame() { Fullreset(); } [HarmonyPatch("EndOfGameClientRpc")] [HarmonyPostfix] private static void EndOfGameClientRpc() { Fullreset(); } private static void Fullreset() { DanceHealingOnShip.ExecutedInstances.Clear(); DanceHealingOnShip.TokenSources.Clear(); DanceHealingOnShip.Mls.LogInfo((object)"Diccionary reseted"); } } }