using 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; 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("FeedingFrenzy")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+79a7584893ecdf26256e75b2a3192d3a2048d25b")] [assembly: AssemblyProduct("FeedingFrenzy")] [assembly: AssemblyTitle("FeedingFrenzy")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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 FeedingFrenzy { [HarmonyPatch(typeof(Character), "AddExtraStamina")] internal static class AddExtraStamina_Multiplier_Patch { private static Dictionary feedTimes = new Dictionary(); private const float FED_WINDOW = 3f; public static void MarkAsFed(int characterID) { feedTimes[characterID] = Time.time; if (FeedingFrenzyPlugin.debugMode.Value) { FeedingFrenzyPlugin.Log.LogInfo((object)$"[FeedingFrenzy] Marked character {characterID} as fed"); } } [HarmonyPrefix] private static void Prefix(Character __instance, ref float add) { if (add <= 0f) { return; } int ownerActorNr = ((MonoBehaviourPun)__instance).photonView.OwnerActorNr; if (feedTimes.TryGetValue(ownerActorNr, out var value)) { if (Time.time - value <= 3f) { float num = add; add = num * FeedingFrenzyPlugin.extraStaminaMultiplier.Value; feedTimes.Remove(ownerActorNr); FeedingFrenzyPlugin.Log.LogInfo((object)("[FeedingFrenzy] " + __instance.characterName + " fed! " + $"Extra stamina: {num:F2} → {add:F2}")); } else { feedTimes.Remove(ownerActorNr); } } } } [BepInPlugin("jill920.FeedingFrenzy", "Feeding Frenzy", "1.0.1")] public class FeedingFrenzyPlugin : BaseUnityPlugin { public const string MOD_GUID = "jill920.FeedingFrenzy"; public const string MOD_NAME = "Feeding Frenzy"; public const string MOD_VERSION = "1.0.1"; public static ConfigEntry extraStaminaMultiplier; public static ConfigEntry debugMode; public static ManualLogSource Log { get; private set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; extraStaminaMultiplier = ((BaseUnityPlugin)this).Config.Bind("General", "ExtraStaminaMultiplier", 1.5f, "Multiplier applied to extra stamina when feeding another player."); debugMode = ((BaseUnityPlugin)this).Config.Bind("Debug", "EnableDebugLogs", false, "Enable debug logging"); Harmony.CreateAndPatchAll(typeof(GameUtils_StartFeed_Patch), "jill920.FeedingFrenzy"); Harmony.CreateAndPatchAll(typeof(AddExtraStamina_Multiplier_Patch), "jill920.FeedingFrenzy"); Log.LogInfo((object)"[Feeding Frenzy 1.0.1] Loaded successfully!"); } } [HarmonyPatch(typeof(GameUtils), "StartFeed")] internal static class GameUtils_StartFeed_Patch { [HarmonyPrefix] private static void Prefix(int giverID, int receiverID, ushort itemID, float totalItemTime) { Character val = default(Character); Character val2 = default(Character); if (Character.GetCharacterWithPhotonID(giverID, ref val) && Character.GetCharacterWithPhotonID(receiverID, ref val2)) { AddExtraStamina_Multiplier_Patch.MarkAsFed(((MonoBehaviourPun)val2).photonView.OwnerActorNr); FeedingFrenzyPlugin.Log.LogInfo((object)$"[FeedingFrenzy] Native feed detected: {val.characterName} -> {val2.characterName} (Item ID: {itemID})"); } } } }