using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyTitle("Getting Yolked")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Getting Yolked")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("41234e88-2c24-4a63-8949-297cd0d3ef85")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace Getting_Yolked
{
internal enum EggKind
{
None,
Turkey,
Raven
}
[BepInPlugin("tony4twentys.Getting_Yolked", "Getting Yolked", "3.0.0")]
[BepInProcess("PEAK.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class GettingYolkedPlugin : BaseUnityPlugin
{
public const string PluginGuid = "tony4twentys.Getting_Yolked";
public const string PluginName = "Getting Yolked";
public const string PluginVersion = "3.0.0";
internal const byte EventCode = 158;
internal const int ProtocolVersion = 1;
internal const string EventMagic = "tony4twentys.Getting_Yolked";
internal const int ConfigPayloadLength = 29;
internal const ushort TurkeyEggItemId = 26;
internal const ushort RavenEggItemId = 177;
public static ConfigEntry<float> ExtraStaminaFromEgg;
public static ConfigEntry<bool> EnableExtraStamina;
public static ConfigEntry<bool> EnableFarting;
public static ConfigEntry<int> FartEggThreshold;
public static ConfigEntry<float> FartTimeWindow;
public static ConfigEntry<float> FartCheckInterval;
public static ConfigEntry<float> FartChance;
public static ConfigEntry<float> FartDuration;
public static ConfigEntry<bool> EnableClimbingSpeed;
public static ConfigEntry<float> CookedEggClimbingSpeedMultiplier;
public static ConfigEntry<float> CookedEggClimbingSpeedDuration;
public static ConfigEntry<bool> EnableJumpHeight;
public static ConfigEntry<float> CookedEggJumpHeightMultiplier;
public static ConfigEntry<float> CookedEggJumpHeightDuration;
public static ConfigEntry<bool> EnableSprintStaminaUsage;
public static ConfigEntry<float> RawEggSprintStaminaUsage;
public static ConfigEntry<float> RawEggSprintStaminaUsageDuration;
public static ConfigEntry<bool> EnableWeightReduction;
public static ConfigEntry<float> CookedEggWeightReductionMultiplier;
public static ConfigEntry<float> CookedEggWeightReductionDuration;
public static ConfigEntry<bool> EnableJumpStaminaUsage;
public static ConfigEntry<float> RawEggJumpStaminaUsage;
public static ConfigEntry<float> RawEggJumpStaminaUsageSprinting;
public static ConfigEntry<float> RawEggJumpStaminaUsageDuration;
public static ConfigEntry<bool> EnableRavenEggs;
public static ConfigEntry<float> RavenEggEffectMultiplier;
internal static ManualLogSource Log;
internal static GettingYolkedPlugin Instance;
internal static float syncedExtraStaminaFromEgg;
internal static bool syncedEnableExtraStamina;
internal static bool syncedEnableFarting;
internal static int syncedFartEggThreshold;
internal static float syncedFartTimeWindow;
internal static float syncedFartCheckInterval;
internal static float syncedFartChance;
internal static float syncedFartDuration;
internal static bool syncedEnableClimbingSpeed;
internal static float syncedCookedEggClimbingSpeedMultiplier;
internal static float syncedCookedEggClimbingSpeedDuration;
internal static bool syncedEnableJumpHeight;
internal static float syncedCookedEggJumpHeightMultiplier;
internal static float syncedCookedEggJumpHeightDuration;
internal static bool syncedEnableSprintStaminaUsage;
internal static float syncedRawEggSprintStaminaUsage;
internal static float syncedRawEggSprintStaminaUsageDuration;
internal static bool syncedEnableJumpStaminaUsage;
internal static float syncedRawEggJumpStaminaUsage;
internal static float syncedRawEggJumpStaminaUsageSprinting;
internal static float syncedRawEggJumpStaminaUsageDuration;
internal static bool syncedEnableWeightReduction;
internal static float syncedCookedEggWeightReductionMultiplier;
internal static float syncedCookedEggWeightReductionDuration;
internal static bool syncedEnableRavenEggs;
internal static float syncedRavenEggEffectMultiplier;
internal static bool isHandshakeValid = true;
internal static float climbingSpeedBonusEndTime;
internal static float weightReductionEndTime;
internal static float jumpHeightBonusEndTime;
private readonly List<float> recentEggConsumptionTimes = new List<float>();
private Coroutine activeFartingCoroutine;
private Harmony _harmony;
private static int _lastHandledEggId;
private static float _lastHandledEggTime = -999f;
private const float EggDedupeSeconds = 1.5f;
internal static bool IsGameplayEnabled
{
get
{
try
{
if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient)
{
return true;
}
}
catch
{
return isHandshakeValid;
}
return isHandshakeValid;
}
}
private void Awake()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
BindConfig();
ApplyLocalConfig();
if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient)
{
isHandshakeValid = true;
}
_harmony = new Harmony("tony4twentys.Getting_Yolked");
_harmony.PatchAll(typeof(GettingYolkedPlugin).Assembly);
YolkedNet.Ensure();
((BaseUnityPlugin)this).Config.SettingChanged += delegate
{
YolkedNet.OnLocalSettingChanged();
};
Log.LogInfo((object)string.Format("Getting Yolked v{0} loaded. Photon {1}.", "3.0.0", (byte)158));
}
private void Update()
{
if (recentEggConsumptionTimes.Count != 0)
{
float currentTime = Time.time;
recentEggConsumptionTimes.RemoveAll((float time) => currentTime - time > syncedFartTimeWindow);
}
}
private void OnDestroy()
{
if (activeFartingCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(activeFartingCoroutine);
activeFartingCoroutine = null;
}
}
private void BindConfig()
{
EnableExtraStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableExtraStamina", true, "Enable extra stamina boost when eating eggs (vanilla default is 0.1).");
ExtraStaminaFromEgg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ExtraStaminaFromEgg", 0.2f, "Amount of stamina to restore when eating an egg (vanilla default is 0.1).");
EnableRavenEggs = ((BaseUnityPlugin)this).Config.Bind<bool>("Raven Eggs", "EnableRavenEggs", true, "Apply Getting Yolked effects to raven / small Gloom eggs as well as Caldera turkey eggs.");
RavenEggEffectMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Raven Eggs", "RavenEggEffectMultiplier", 0.5f, "How strong raven / small eggs are compared to turkey eggs (0.5 = half effect, matching their smaller size).");
EnableFarting = ((BaseUnityPlugin)this).Config.Bind<bool>("Farting", "EnableFarting", true, "Enable farting when eating too many eggs.");
FartEggThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Farting", "FartEggThreshold", 2, "Number of eggs that must be eaten within the time window to trigger farting.");
FartTimeWindow = ((BaseUnityPlugin)this).Config.Bind<float>("Farting", "FartTimeWindow", 60f, "Time window in seconds for egg consumption tracking.");
FartCheckInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Farting", "FartCheckInterval", 30f, "Interval in seconds between fart chance checks.");
FartChance = ((BaseUnityPlugin)this).Config.Bind<float>("Farting", "FartChance", 0.3f, "Chance to fart on each check (0.3 = 30% chance).");
FartDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Farting", "FartDuration", 300f, "Duration in seconds that periodic farting continues after triggering.");
EnableClimbingSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("Cooked Eggs", "EnableClimbingSpeed", true, "Enable climbing speed bonus when eating cooked eggs.");
CookedEggClimbingSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Eggs", "ClimbingSpeedMultiplier", 2f, "Multiplier for climbing speed when consuming cooked eggs (2.0 = double speed).");
CookedEggClimbingSpeedDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Eggs", "ClimbingSpeedDuration", 30f, "Duration in seconds that the climbing speed bonus lasts after eating a cooked egg.");
EnableSprintStaminaUsage = ((BaseUnityPlugin)this).Config.Bind<bool>("Raw Eggs", "EnableSprintStaminaUsage", true, "Enable reduced sprint stamina usage when eating raw eggs.");
RawEggSprintStaminaUsage = ((BaseUnityPlugin)this).Config.Bind<float>("Raw Eggs", "SprintStaminaUsage", 0.01f, "Stamina usage per second while sprinting after eating raw eggs (vanilla is 0.025).");
RawEggSprintStaminaUsageDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Raw Eggs", "SprintStaminaUsageDuration", 30f, "Duration in seconds that the sprint stamina usage bonus lasts after eating a raw egg.");
EnableJumpStaminaUsage = ((BaseUnityPlugin)this).Config.Bind<bool>("Raw Eggs", "EnableJumpStaminaUsage", true, "Enable reduced jump stamina usage when eating raw eggs.");
RawEggJumpStaminaUsage = ((BaseUnityPlugin)this).Config.Bind<float>("Raw Eggs", "JumpStaminaUsage", 0.01f, "Jump stamina usage after eating raw eggs (vanilla is 0.05).");
RawEggJumpStaminaUsageSprinting = ((BaseUnityPlugin)this).Config.Bind<float>("Raw Eggs", "JumpStaminaUsageSprinting", 0.05f, "Jump stamina usage while sprinting after eating raw eggs (vanilla is 0.15).");
RawEggJumpStaminaUsageDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Raw Eggs", "JumpStaminaUsageDuration", 30f, "Duration in seconds that the jump stamina usage reduction lasts after eating a raw egg.");
EnableJumpHeight = ((BaseUnityPlugin)this).Config.Bind<bool>("Cooked Eggs", "EnableJumpHeight", true, "Enable jump height bonus when eating cooked eggs.");
CookedEggJumpHeightMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Eggs", "JumpHeightMultiplier", 5f, "Multiplier for jump height when consuming cooked eggs (5.0 = 5x jump height).");
CookedEggJumpHeightDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Eggs", "JumpHeightDuration", 30f, "Duration in seconds that the jump height bonus lasts after eating a cooked egg.");
EnableWeightReduction = ((BaseUnityPlugin)this).Config.Bind<bool>("Cooked Eggs", "EnableWeightReduction", true, "Enable weight reduction when eating cooked eggs (items feel lighter).");
CookedEggWeightReductionMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Eggs", "WeightReductionMultiplier", 0.5f, "Multiplier for item weight when consuming cooked eggs (0.5 = half weight).");
CookedEggWeightReductionDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Eggs", "WeightReductionDuration", 30f, "Duration in seconds that the weight reduction lasts after eating a cooked egg.");
}
internal static void ApplyLocalConfig()
{
syncedEnableExtraStamina = EnableExtraStamina.Value;
syncedExtraStaminaFromEgg = ExtraStaminaFromEgg.Value;
syncedEnableFarting = EnableFarting.Value;
syncedFartEggThreshold = FartEggThreshold.Value;
syncedFartTimeWindow = FartTimeWindow.Value;
syncedFartCheckInterval = FartCheckInterval.Value;
syncedFartChance = FartChance.Value;
syncedFartDuration = FartDuration.Value;
syncedEnableClimbingSpeed = EnableClimbingSpeed.Value;
syncedCookedEggClimbingSpeedMultiplier = CookedEggClimbingSpeedMultiplier.Value;
syncedCookedEggClimbingSpeedDuration = CookedEggClimbingSpeedDuration.Value;
syncedEnableJumpHeight = EnableJumpHeight.Value;
syncedCookedEggJumpHeightMultiplier = CookedEggJumpHeightMultiplier.Value;
syncedCookedEggJumpHeightDuration = CookedEggJumpHeightDuration.Value;
syncedEnableSprintStaminaUsage = EnableSprintStaminaUsage.Value;
syncedRawEggSprintStaminaUsage = RawEggSprintStaminaUsage.Value;
syncedRawEggSprintStaminaUsageDuration = RawEggSprintStaminaUsageDuration.Value;
syncedEnableJumpStaminaUsage = EnableJumpStaminaUsage.Value;
syncedRawEggJumpStaminaUsage = RawEggJumpStaminaUsage.Value;
syncedRawEggJumpStaminaUsageSprinting = RawEggJumpStaminaUsageSprinting.Value;
syncedRawEggJumpStaminaUsageDuration = RawEggJumpStaminaUsageDuration.Value;
syncedEnableWeightReduction = EnableWeightReduction.Value;
syncedCookedEggWeightReductionMultiplier = CookedEggWeightReductionMultiplier.Value;
syncedCookedEggWeightReductionDuration = CookedEggWeightReductionDuration.Value;
syncedEnableRavenEggs = EnableRavenEggs.Value;
syncedRavenEggEffectMultiplier = RavenEggEffectMultiplier.Value;
}
internal static object[] BuildConfigPayload(byte sub)
{
return new object[29]
{
"tony4twentys.Getting_Yolked", 1, sub, EnableExtraStamina.Value, ExtraStaminaFromEgg.Value, EnableFarting.Value, FartEggThreshold.Value, FartTimeWindow.Value, FartCheckInterval.Value, FartChance.Value,
FartDuration.Value, EnableClimbingSpeed.Value, CookedEggClimbingSpeedMultiplier.Value, CookedEggClimbingSpeedDuration.Value, EnableJumpHeight.Value, CookedEggJumpHeightMultiplier.Value, CookedEggJumpHeightDuration.Value, EnableSprintStaminaUsage.Value, RawEggSprintStaminaUsage.Value, RawEggSprintStaminaUsageDuration.Value,
EnableJumpStaminaUsage.Value, RawEggJumpStaminaUsage.Value, RawEggJumpStaminaUsageSprinting.Value, RawEggJumpStaminaUsageDuration.Value, EnableWeightReduction.Value, CookedEggWeightReductionMultiplier.Value, CookedEggWeightReductionDuration.Value, EnableRavenEggs.Value, RavenEggEffectMultiplier.Value
};
}
internal static void ApplyRemoteConfig(object[] arr)
{
if (arr == null || arr.Length < 29)
{
throw new InvalidOperationException("Getting Yolked config payload too short.");
}
syncedEnableExtraStamina = Convert.ToBoolean(arr[3]);
syncedExtraStaminaFromEgg = Convert.ToSingle(arr[4]);
syncedEnableFarting = Convert.ToBoolean(arr[5]);
syncedFartEggThreshold = Convert.ToInt32(arr[6]);
syncedFartTimeWindow = Convert.ToSingle(arr[7]);
syncedFartCheckInterval = Convert.ToSingle(arr[8]);
syncedFartChance = Convert.ToSingle(arr[9]);
syncedFartDuration = Convert.ToSingle(arr[10]);
syncedEnableClimbingSpeed = Convert.ToBoolean(arr[11]);
syncedCookedEggClimbingSpeedMultiplier = Convert.ToSingle(arr[12]);
syncedCookedEggClimbingSpeedDuration = Convert.ToSingle(arr[13]);
syncedEnableJumpHeight = Convert.ToBoolean(arr[14]);
syncedCookedEggJumpHeightMultiplier = Convert.ToSingle(arr[15]);
syncedCookedEggJumpHeightDuration = Convert.ToSingle(arr[16]);
syncedEnableSprintStaminaUsage = Convert.ToBoolean(arr[17]);
syncedRawEggSprintStaminaUsage = Convert.ToSingle(arr[18]);
syncedRawEggSprintStaminaUsageDuration = Convert.ToSingle(arr[19]);
syncedEnableJumpStaminaUsage = Convert.ToBoolean(arr[20]);
syncedRawEggJumpStaminaUsage = Convert.ToSingle(arr[21]);
syncedRawEggJumpStaminaUsageSprinting = Convert.ToSingle(arr[22]);
syncedRawEggJumpStaminaUsageDuration = Convert.ToSingle(arr[23]);
syncedEnableWeightReduction = Convert.ToBoolean(arr[24]);
syncedCookedEggWeightReductionMultiplier = Convert.ToSingle(arr[25]);
syncedCookedEggWeightReductionDuration = Convert.ToSingle(arr[26]);
syncedEnableRavenEggs = Convert.ToBoolean(arr[27]);
syncedRavenEggEffectMultiplier = Convert.ToSingle(arr[28]);
}
internal static void HandleEggItem(Item item, Character character)
{
if ((Object)(object)Instance == (Object)null || (Object)(object)item == (Object)null || (Object)(object)character == (Object)null || !IsGameplayEnabled || !character.IsLocal)
{
return;
}
EggKind eggKind = ClassifyEgg(item);
switch (eggKind)
{
case EggKind.None:
return;
case EggKind.Raven:
if (!syncedEnableRavenEggs)
{
return;
}
break;
}
if (!AlreadyHandled(item))
{
float num = ((eggKind == EggKind.Raven) ? Mathf.Clamp(syncedRavenEggEffectMultiplier, 0f, 4f) : 1f);
int num2 = ReadCookedAmount(item);
Log.LogInfo((object)string.Format("[Getting Yolked] Ate {0} egg '{1}' id={2} (cooked={3}, potency={4:0.00}).", (eggKind == EggKind.Raven) ? "raven/small" : "turkey", DescribeItem(item), item.itemID, num2, num));
if (syncedEnableFarting)
{
Instance.TrackEggForFarting(character);
}
switch (num2)
{
case 0:
ApplyRawEggBonuses(character, num);
break;
case 1:
ApplyCookedEggBonuses(character, num);
break;
}
}
}
private static bool AlreadyHandled(Item item)
{
int instanceID = ((Object)item).GetInstanceID();
float unscaledTime = Time.unscaledTime;
if (instanceID == _lastHandledEggId && unscaledTime - _lastHandledEggTime < 1.5f)
{
return true;
}
_lastHandledEggId = instanceID;
_lastHandledEggTime = unscaledTime;
return false;
}
internal static EggKind ClassifyEgg(Item item)
{
if ((Object)(object)item == (Object)null)
{
return EggKind.None;
}
try
{
if (item.itemID == 177)
{
return EggKind.Raven;
}
if (item.itemID == 26)
{
return EggKind.Turkey;
}
}
catch
{
}
if (IsSmashableShell(item))
{
return EggKind.None;
}
string text = Fold(((Object)item).name);
if ((Object)(object)((Component)item).gameObject != (Object)null)
{
text += Fold(((Object)((Component)item).gameObject).name);
}
try
{
if (item.UIData != null)
{
text += Fold(item.UIData.itemName);
text += Fold(item.GetName());
}
}
catch
{
}
if (text.IndexOf("egg", StringComparison.Ordinal) < 0)
{
return EggKind.None;
}
if (text.IndexOf("raven", StringComparison.Ordinal) >= 0 || text.IndexOf("smallegg", StringComparison.Ordinal) >= 0)
{
return EggKind.Raven;
}
return EggKind.Turkey;
}
private static bool IsSmashableShell(Item item)
{
if (HasHungerRestore(item))
{
return false;
}
if ((Object)(object)((Component)item).GetComponent<BreakableEgg>() != (Object)null)
{
return true;
}
Breakable component = ((Component)item).GetComponent<Breakable>();
return (Object)(object)component != (Object)null;
}
private static bool HasHungerRestore(Item item)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Invalid comparison between Unknown and I4
Action_RestoreHunger component = ((Component)item).GetComponent<Action_RestoreHunger>();
if ((Object)(object)component != (Object)null && component.restorationAmount > 0f)
{
return true;
}
Action_ModifyStatus[] components = ((Component)item).GetComponents<Action_ModifyStatus>();
if (components == null)
{
return false;
}
foreach (Action_ModifyStatus val in components)
{
if ((Object)(object)val != (Object)null && (int)val.statusType == 1 && val.changeAmount < 0f)
{
return true;
}
}
return false;
}
private static int ReadCookedAmount(Item item)
{
try
{
if ((Object)(object)item != (Object)null && item.HasData((DataEntryKey)1))
{
IntItemData data = item.GetData<IntItemData>((DataEntryKey)1);
if (data != null)
{
return data.Value;
}
}
}
catch (Exception ex)
{
Log.LogWarning((object)("[Getting Yolked] Failed to read cooked amount: " + ex.Message));
}
return 0;
}
private static string Fold(string value)
{
if (string.IsNullOrEmpty(value))
{
return string.Empty;
}
StringBuilder stringBuilder = new StringBuilder(value.Length);
foreach (char c in value)
{
if (char.IsLetterOrDigit(c))
{
stringBuilder.Append(char.ToLowerInvariant(c));
}
}
return stringBuilder.ToString();
}
private static string DescribeItem(Item item)
{
if ((Object)(object)item == (Object)null)
{
return "unknown";
}
string name = ((Object)item).name;
if (string.IsNullOrEmpty(name) && (Object)(object)((Component)item).gameObject != (Object)null)
{
name = ((Object)((Component)item).gameObject).name;
}
if (string.IsNullOrEmpty(name))
{
return "unknown";
}
return name.Replace("(Clone)", string.Empty).Trim();
}
private static void ApplyRawEggBonuses(Character character, float potency)
{
if (syncedEnableExtraStamina)
{
((MonoBehaviour)character).StartCoroutine(BoostStamina(character, syncedExtraStaminaFromEgg * potency));
}
if (character.refs != null && !((Object)(object)character.refs.movement == (Object)null))
{
if (syncedEnableSprintStaminaUsage)
{
SprintStaminaUsageBonusUpdater.ApplySprintStaminaUsageBonus(character.refs.movement, syncedRawEggSprintStaminaUsage, potency, MixDuration(syncedRawEggSprintStaminaUsageDuration, potency));
}
if (syncedEnableJumpStaminaUsage)
{
JumpStaminaUsageBonusUpdater.ApplyJumpStaminaUsageBonus(character.refs.movement, syncedRawEggJumpStaminaUsage, syncedRawEggJumpStaminaUsageSprinting, potency, MixDuration(syncedRawEggJumpStaminaUsageDuration, potency));
}
}
}
private static void ApplyCookedEggBonuses(Character character, float potency)
{
if (syncedEnableClimbingSpeed)
{
float num = MixDuration(syncedCookedEggClimbingSpeedDuration, potency);
climbingSpeedBonusEndTime = Time.time + num;
ClimbingSpeedBonusUpdater.ApplyClimbingSpeedBonus(character, MixMultiplier(syncedCookedEggClimbingSpeedMultiplier, potency), num);
}
if (syncedEnableJumpHeight && character.refs != null && (Object)(object)character.refs.movement != (Object)null)
{
float num2 = MixDuration(syncedCookedEggJumpHeightDuration, potency);
jumpHeightBonusEndTime = Time.time + num2;
JumpHeightBonusUpdater.ApplyJumpHeightBonus(character.refs.movement, MixMultiplier(syncedCookedEggJumpHeightMultiplier, potency), num2);
}
if (syncedEnableWeightReduction && character.refs != null && (Object)(object)character.refs.afflictions != (Object)null)
{
float duration = MixDuration(syncedCookedEggWeightReductionDuration, potency);
WeightReductionBonusUpdater.Apply(character, MixMultiplier(syncedCookedEggWeightReductionMultiplier, potency), duration);
}
}
internal static float MixMultiplier(float fullMultiplier, float potency)
{
return 1f + (fullMultiplier - 1f) * potency;
}
internal static float MixDuration(float duration, float potency)
{
return Mathf.Max(0.1f, duration * Mathf.Max(potency, 0.05f));
}
internal static float MixToward(float original, float bonus, float potency)
{
return original + (bonus - original) * potency;
}
private void TrackEggForFarting(Character character)
{
float currentTime = Time.time;
recentEggConsumptionTimes.Add(currentTime);
recentEggConsumptionTimes.RemoveAll((float time) => currentTime - time > syncedFartTimeWindow);
if (recentEggConsumptionTimes.Count >= syncedFartEggThreshold)
{
if (activeFartingCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(activeFartingCoroutine);
}
activeFartingCoroutine = ((MonoBehaviour)this).StartCoroutine(PeriodicFartingCoroutine(character));
recentEggConsumptionTimes.Clear();
}
}
private static IEnumerator BoostStamina(Character character, float boost)
{
yield return (object)new WaitForSeconds(0.25f);
if ((Object)(object)character != (Object)null)
{
character.AddExtraStamina(boost);
}
}
private IEnumerator PeriodicFartingCoroutine(Character character)
{
if ((Object)(object)character == (Object)null)
{
yield break;
}
float endTime = Time.time + syncedFartDuration;
while (Time.time < endTime && (Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null && !character.data.dead)
{
if (Random.value < syncedFartChance)
{
TryFart(character);
}
yield return (object)new WaitForSeconds(syncedFartCheckInterval);
}
activeFartingCoroutine = null;
}
private static void TryFart(Character character)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)character == (Object)null)
{
return;
}
Log.LogInfo((object)"[Getting Yolked] Fart triggered!");
try
{
GameUtils.instance.SpawnResourceAtPositionNetworked("VFX_SporeExploExploEdibleSpawn", character.Center, (RpcTarget)1);
GameUtils.instance.RPC_SpawnResourceAtPosition("VFX_SporeExploExploEdibleSpawn_NoKnockback", character.Center);
character.AddForceToBodyPart(character.GetBodypartRig((BodypartType)0), Vector3.zero, Vector3.up * 100f);
}
catch (Exception ex)
{
Log.LogWarning((object)("[Getting Yolked] Failed to trigger fart: " + ex.Message));
}
}
}
[HarmonyPatch(typeof(Item), "Consume")]
internal static class Patch_Item_Consume
{
private static bool _logged;
private static void Postfix(Item __instance, int consumerID)
{
try
{
if (!((Object)(object)__instance == (Object)null))
{
PhotonView photonView = PhotonNetwork.GetPhotonView(consumerID);
if (!((Object)(object)photonView == (Object)null))
{
Character component = ((Component)photonView).GetComponent<Character>();
GettingYolkedPlugin.HandleEggItem(__instance, component);
}
}
}
catch (Exception ex)
{
if (!_logged)
{
_logged = true;
GettingYolkedPlugin.Log.LogError((object)("[Getting Yolked] Consume patch failed: " + ex));
}
}
}
}
[HarmonyPatch(typeof(Action_RestoreHunger), "RunAction")]
internal static class Patch_Action_RestoreHunger_Egg
{
private static bool _logged;
private static void Postfix(Action_RestoreHunger __instance)
{
try
{
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((ItemActionBase)__instance).item == (Object)null) && !(__instance.restorationAmount <= 0f))
{
GettingYolkedPlugin.HandleEggItem(((ItemActionBase)__instance).item, ((ItemActionBase)__instance).character);
}
}
catch (Exception ex)
{
if (!_logged)
{
_logged = true;
GettingYolkedPlugin.Log.LogError((object)("[Getting Yolked] RestoreHunger patch failed: " + ex));
}
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "UpdateWeight")]
internal static class Patch_CharacterAfflictions_UpdateWeight
{
private static bool _logged;
private static void Postfix(CharacterAfflictions __instance)
{
try
{
if (!GettingYolkedPlugin.syncedEnableWeightReduction || Time.time >= GettingYolkedPlugin.weightReductionEndTime || (Object)(object)__instance == (Object)null)
{
return;
}
Character val = __instance.character;
if ((Object)(object)val == (Object)null)
{
val = ((Component)__instance).GetComponent<Character>();
}
if (!((Object)(object)val == (Object)null) && val.IsLocal)
{
float currentStatus = __instance.GetCurrentStatus((STATUSTYPE)7);
float num = currentStatus * WeightReductionBonusUpdater.ActiveMultiplier;
float num2 = num - currentStatus;
if (Mathf.Abs(num2) > 0.001f)
{
__instance.AdjustStatus((STATUSTYPE)7, num2, false);
}
}
}
catch (Exception ex)
{
if (!_logged)
{
_logged = true;
GettingYolkedPlugin.Log.LogError((object)("[Getting Yolked] UpdateWeight patch failed: " + ex));
}
}
}
}
internal static class WeightReductionBonusUpdater
{
internal static float ActiveMultiplier = 1f;
private static Coroutine _restore;
internal static void Apply(Character character, float multiplier, float duration)
{
GettingYolkedPlugin.weightReductionEndTime = Time.time + duration;
ActiveMultiplier = multiplier;
if (_restore != null)
{
((MonoBehaviour)GettingYolkedPlugin.Instance).StopCoroutine(_restore);
}
_restore = ((MonoBehaviour)GettingYolkedPlugin.Instance).StartCoroutine(RestoreAfterDelay(character, duration));
if ((Object)(object)character != (Object)null && character.refs != null && (Object)(object)character.refs.afflictions != (Object)null)
{
character.refs.afflictions.UpdateWeight();
}
}
private static IEnumerator RestoreAfterDelay(Character character, float delay)
{
yield return (object)new WaitForSeconds(delay);
ActiveMultiplier = 1f;
GettingYolkedPlugin.weightReductionEndTime = 0f;
if ((Object)(object)character != (Object)null && character.refs != null && (Object)(object)character.refs.afflictions != (Object)null)
{
character.refs.afflictions.UpdateWeight();
}
_restore = null;
}
}
internal static class ClimbingSpeedBonusUpdater
{
private const float DefaultClimbSpeedMod = 1f;
private static Coroutine _restore;
internal static void ApplyClimbingSpeedBonus(Character character, float multiplier, float duration)
{
if (!((Object)(object)character == (Object)null) && character.IsLocal && character.refs != null)
{
if (_restore != null)
{
((MonoBehaviour)GettingYolkedPlugin.Instance).StopCoroutine(_restore);
_restore = null;
}
SetClimbMods(character, 1f * multiplier);
_restore = ((MonoBehaviour)GettingYolkedPlugin.Instance).StartCoroutine(RestoreAfterDelay(character, duration));
}
}
private static IEnumerator RestoreAfterDelay(Character character, float delay)
{
yield return (object)new WaitForSeconds(delay);
SetClimbMods(character, 1f);
_restore = null;
}
private static void SetClimbMods(Character character, float value)
{
if (!((Object)(object)character == (Object)null) && character.refs != null)
{
if ((Object)(object)character.refs.climbing != (Object)null)
{
character.refs.climbing.climbSpeedMod = value;
}
if ((Object)(object)character.refs.ropeHandling != (Object)null)
{
character.refs.ropeHandling.climbSpeedMod = value;
}
if ((Object)(object)character.refs.vineClimbing != (Object)null)
{
character.refs.vineClimbing.climbSpeedMod = value;
}
}
}
}
internal static class JumpHeightBonusUpdater
{
private static readonly Dictionary<CharacterMovement, float> OriginalJumpImpulses = new Dictionary<CharacterMovement, float>();
private static Coroutine _restore;
internal static void ApplyJumpHeightBonus(CharacterMovement characterMovement, float multiplier, float duration)
{
if (!((Object)(object)characterMovement == (Object)null) && !((Object)(object)characterMovement.character == (Object)null) && characterMovement.character.IsLocal)
{
if (_restore != null)
{
((MonoBehaviour)GettingYolkedPlugin.Instance).StopCoroutine(_restore);
_restore = null;
}
if (!OriginalJumpImpulses.ContainsKey(characterMovement))
{
OriginalJumpImpulses[characterMovement] = characterMovement.jumpImpulse;
}
characterMovement.jumpImpulse = OriginalJumpImpulses[characterMovement] * multiplier;
_restore = ((MonoBehaviour)GettingYolkedPlugin.Instance).StartCoroutine(RestoreAfterDelay(characterMovement, duration));
}
}
private static IEnumerator RestoreAfterDelay(CharacterMovement characterMovement, float delay)
{
yield return (object)new WaitForSeconds(delay);
if ((Object)(object)characterMovement != (Object)null && OriginalJumpImpulses.ContainsKey(characterMovement))
{
characterMovement.jumpImpulse = OriginalJumpImpulses[characterMovement];
OriginalJumpImpulses.Remove(characterMovement);
}
_restore = null;
}
}
internal static class SprintStaminaUsageBonusUpdater
{
private static readonly Dictionary<CharacterMovement, float> OriginalSprintStaminaUsages = new Dictionary<CharacterMovement, float>();
private static Coroutine _restore;
internal static void ApplySprintStaminaUsageBonus(CharacterMovement characterMovement, float sprintStaminaUsage, float potency, float duration)
{
if (!((Object)(object)characterMovement == (Object)null) && !((Object)(object)characterMovement.character == (Object)null) && characterMovement.character.IsLocal)
{
if (_restore != null)
{
((MonoBehaviour)GettingYolkedPlugin.Instance).StopCoroutine(_restore);
_restore = null;
}
if (!OriginalSprintStaminaUsages.ContainsKey(characterMovement))
{
OriginalSprintStaminaUsages[characterMovement] = characterMovement.sprintStaminaUsage;
}
float original = OriginalSprintStaminaUsages[characterMovement];
characterMovement.sprintStaminaUsage = GettingYolkedPlugin.MixToward(original, sprintStaminaUsage, potency);
_restore = ((MonoBehaviour)GettingYolkedPlugin.Instance).StartCoroutine(RestoreAfterDelay(characterMovement, duration));
}
}
private static IEnumerator RestoreAfterDelay(CharacterMovement characterMovement, float delay)
{
yield return (object)new WaitForSeconds(delay);
if ((Object)(object)characterMovement != (Object)null && OriginalSprintStaminaUsages.ContainsKey(characterMovement))
{
characterMovement.sprintStaminaUsage = OriginalSprintStaminaUsages[characterMovement];
OriginalSprintStaminaUsages.Remove(characterMovement);
}
_restore = null;
}
}
internal static class JumpStaminaUsageBonusUpdater
{
private static readonly Dictionary<CharacterMovement, float> OriginalJumpStaminaUsages = new Dictionary<CharacterMovement, float>();
private static readonly Dictionary<CharacterMovement, float> OriginalJumpStaminaUsageSprintings = new Dictionary<CharacterMovement, float>();
private static Coroutine _restore;
internal static void ApplyJumpStaminaUsageBonus(CharacterMovement characterMovement, float jumpStaminaUsage, float jumpStaminaUsageSprinting, float potency, float duration)
{
if (!((Object)(object)characterMovement == (Object)null) && !((Object)(object)characterMovement.character == (Object)null) && characterMovement.character.IsLocal)
{
if (_restore != null)
{
((MonoBehaviour)GettingYolkedPlugin.Instance).StopCoroutine(_restore);
_restore = null;
}
if (!OriginalJumpStaminaUsages.ContainsKey(characterMovement))
{
OriginalJumpStaminaUsages[characterMovement] = characterMovement.jumpStaminaUsage;
}
if (!OriginalJumpStaminaUsageSprintings.ContainsKey(characterMovement))
{
OriginalJumpStaminaUsageSprintings[characterMovement] = characterMovement.jumpStaminaUsageSprinting;
}
float original = OriginalJumpStaminaUsages[characterMovement];
float original2 = OriginalJumpStaminaUsageSprintings[characterMovement];
characterMovement.jumpStaminaUsage = GettingYolkedPlugin.MixToward(original, jumpStaminaUsage, potency);
characterMovement.jumpStaminaUsageSprinting = GettingYolkedPlugin.MixToward(original2, jumpStaminaUsageSprinting, potency);
_restore = ((MonoBehaviour)GettingYolkedPlugin.Instance).StartCoroutine(RestoreAfterDelay(characterMovement, duration));
}
}
private static IEnumerator RestoreAfterDelay(CharacterMovement characterMovement, float delay)
{
yield return (object)new WaitForSeconds(delay);
if ((Object)(object)characterMovement != (Object)null)
{
if (OriginalJumpStaminaUsages.ContainsKey(characterMovement))
{
characterMovement.jumpStaminaUsage = OriginalJumpStaminaUsages[characterMovement];
OriginalJumpStaminaUsages.Remove(characterMovement);
}
if (OriginalJumpStaminaUsageSprintings.ContainsKey(characterMovement))
{
characterMovement.jumpStaminaUsageSprinting = OriginalJumpStaminaUsageSprintings[characterMovement];
OriginalJumpStaminaUsageSprintings.Remove(characterMovement);
}
}
_restore = null;
}
}
internal sealed class YolkedNet : MonoBehaviourPunCallbacks, IOnEventCallback
{
private const byte SubConfig = 1;
private const byte SubConfigRequest = 2;
private const float HostSyncTimeoutSeconds = 12f;
private const float HostSyncRetrySeconds = 2f;
internal static bool HostModConfirmed;
private Coroutine _debounce;
private Coroutine _hostSyncWatch;
private bool _syncingFromNet;
internal static YolkedNet Instance { get; private set; }
internal static bool HostControlsConfig
{
get
{
try
{
return PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient && HostModConfirmed;
}
catch
{
return false;
}
}
}
internal static void Ensure()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if ((Object)(object)Instance != (Object)null)
{
return;
}
GameObject val = new GameObject("GettingYolked_Net");
Object.DontDestroyOnLoad((Object)(object)val);
Instance = val.AddComponent<YolkedNet>();
try
{
if (PhotonNetwork.InRoom)
{
Instance.HandleJoinedRoom();
}
}
catch
{
}
}
private void Awake()
{
Instance = this;
}
public override void OnEnable()
{
((MonoBehaviourPunCallbacks)this).OnEnable();
PhotonNetwork.AddCallbackTarget((object)this);
}
public override void OnDisable()
{
PhotonNetwork.RemoveCallbackTarget((object)this);
((MonoBehaviourPunCallbacks)this).OnDisable();
}
public override void OnJoinedRoom()
{
HandleJoinedRoom();
}
public override void OnLeftRoom()
{
StopHostSyncWatch();
HostModConfirmed = false;
GettingYolkedPlugin.isHandshakeValid = true;
GettingYolkedPlugin.ApplyLocalConfig();
}
public override void OnMasterClientSwitched(Player newMasterClient)
{
if (PhotonNetwork.IsMasterClient)
{
HostModConfirmed = true;
GettingYolkedPlugin.isHandshakeValid = true;
GettingYolkedPlugin.ApplyLocalConfig();
BroadcastNow();
StopHostSyncWatch();
}
else
{
HostModConfirmed = false;
GettingYolkedPlugin.isHandshakeValid = false;
RequestHostSync();
RestartHostSyncWatch();
}
}
public override void OnPlayerEnteredRoom(Player newPlayer)
{
if (PhotonNetwork.IsMasterClient)
{
((MonoBehaviour)this).StartCoroutine(BroadcastAfterDelay(0.5f));
}
}
public void OnEvent(EventData photonEvent)
{
if (photonEvent == null || photonEvent.Code != 158 || !(photonEvent.CustomData is object[] array) || array.Length < 3 || !(array[0] is string text) || text != "tony4twentys.Getting_Yolked" || ToInt(array[1]) != 1)
{
return;
}
byte b = ToByte(array[2]);
if (b == 2 && PhotonNetwork.IsMasterClient)
{
BroadcastNow();
}
else
{
if (b != 1 || PhotonNetwork.IsMasterClient)
{
return;
}
try
{
_syncingFromNet = true;
StopHostSyncWatch();
HostModConfirmed = true;
GettingYolkedPlugin.isHandshakeValid = true;
GettingYolkedPlugin.ApplyRemoteConfig(array);
GettingYolkedPlugin.Log.LogInfo((object)"[Getting Yolked] Host config sync applied.");
}
catch (Exception ex)
{
GettingYolkedPlugin.Log.LogError((object)("[Getting Yolked] Config sync failed: " + ex.Message));
}
finally
{
_syncingFromNet = false;
}
}
}
internal static void OnLocalSettingChanged()
{
if (!((Object)(object)Instance != (Object)null) || !Instance._syncingFromNet)
{
if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient)
{
GettingYolkedPlugin.ApplyLocalConfig();
}
ScheduleBroadcast();
}
}
internal static void ScheduleBroadcast()
{
if (!((Object)(object)Instance == (Object)null) && PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
{
if (Instance._debounce != null)
{
((MonoBehaviour)Instance).StopCoroutine(Instance._debounce);
}
Instance._debounce = ((MonoBehaviour)Instance).StartCoroutine(Instance.DebounceBroadcast());
}
}
private void HandleJoinedRoom()
{
if (PhotonNetwork.IsMasterClient)
{
HostModConfirmed = true;
GettingYolkedPlugin.isHandshakeValid = true;
GettingYolkedPlugin.ApplyLocalConfig();
BroadcastNow();
StopHostSyncWatch();
}
else
{
HostModConfirmed = false;
GettingYolkedPlugin.isHandshakeValid = false;
RequestHostSync();
RestartHostSyncWatch();
}
}
private static void RequestHostSync()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient)
{
PhotonNetwork.RaiseEvent((byte)158, (object)new object[3]
{
"tony4twentys.Getting_Yolked",
1,
(byte)2
}, new RaiseEventOptions
{
Receivers = (ReceiverGroup)2
}, SendOptions.SendReliable);
}
}
private void RestartHostSyncWatch()
{
StopHostSyncWatch();
if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient)
{
_hostSyncWatch = ((MonoBehaviour)this).StartCoroutine(WatchForHostSync());
}
}
private void StopHostSyncWatch()
{
if (_hostSyncWatch != null)
{
((MonoBehaviour)this).StopCoroutine(_hostSyncWatch);
_hostSyncWatch = null;
}
}
private IEnumerator WatchForHostSync()
{
float elapsed = 0f;
float nextRetry = 2f;
while (elapsed < 12f)
{
if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient || HostModConfirmed)
{
yield break;
}
elapsed += Time.unscaledDeltaTime;
if (elapsed >= nextRetry)
{
RequestHostSync();
nextRetry += 2f;
}
yield return null;
}
if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient && !HostModConfirmed)
{
GettingYolkedPlugin.isHandshakeValid = false;
GettingYolkedPlugin.Log.LogWarning((object)"[Getting Yolked] Host does not appear to have Getting Yolked — effects disabled.");
}
_hostSyncWatch = null;
}
private IEnumerator DebounceBroadcast()
{
yield return (object)new WaitForSeconds(0.25f);
BroadcastNow();
_debounce = null;
}
private IEnumerator BroadcastAfterDelay(float seconds)
{
yield return (object)new WaitForSeconds(seconds);
BroadcastNow();
}
private static void BroadcastNow()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
{
PhotonNetwork.RaiseEvent((byte)158, (object)GettingYolkedPlugin.BuildConfigPayload(1), new RaiseEventOptions
{
Receivers = (ReceiverGroup)0
}, SendOptions.SendReliable);
}
}
private static int ToInt(object value)
{
return Convert.ToInt32(value);
}
private static byte ToByte(object value)
{
return Convert.ToByte(value);
}
}
}