using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("my.pahsiv.MyBananaDontHurtMe")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.4.0")]
[assembly: AssemblyInformationalVersion("0.1.4")]
[assembly: AssemblyProduct("my.pahsiv.MyBananaDontHurtMe")]
[assembly: AssemblyTitle("MyBananaDontHurtMe")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.4.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.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace MyBananaDontHurtMe
{
internal class Explosion
{
[HarmonyPatch(typeof(ExplosionEffect), "GetPoints")]
private static class ReduceDynamiteCloudInstanceCount
{
public static void Postfix(ExplosionEffect __instance)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
__instance.explosionPoints = (ExplosionOrb[])(object)new ExplosionOrb[1] { __instance.explosionPoints[0] };
}
}
}
public class Magnitude : MonoBehaviour
{
[CompilerGenerated]
private sealed class <CheckAllPlayers>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Magnitude <>4__this;
private List<Character>.Enumerator <>7__wrap1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CheckAllPlayers>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 1u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>7__wrap1 = default(List<Character>.Enumerator);
<>1__state = -2;
}
private bool MoveNext()
{
try
{
int num = <>1__state;
Magnitude magnitude = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
if (Character.AllCharacters == null)
{
return false;
}
<>7__wrap1 = Character.AllCharacters.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
break;
case 2:
<>1__state = -3;
break;
}
if (<>7__wrap1.MoveNext())
{
Character current = <>7__wrap1.Current;
if ((Object)(object)current == (Object)null || (Object)(object)current == (Object)(object)Character.localCharacter)
{
<>2__current = null;
<>1__state = 1;
return true;
}
if (magnitude.CheckMagnitude(current))
{
string text = Plugin.RemoveTags(((Object)current.player).name);
Plugin.Log.LogMessage((object)(text + " High Magnitude Detected!"));
Plugin.Notification(((Object)current.player).name + " High Magnitude Detected!");
magnitude.ResetRagdollPhysics(current);
}
<>2__current = null;
<>1__state = 2;
return true;
}
<>m__Finally1();
<>7__wrap1 = default(List<Character>.Enumerator);
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
((IDisposable)<>7__wrap1).Dispose();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <PeriodicCheck>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Magnitude <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PeriodicCheck>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>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
int num = <>1__state;
Magnitude magnitude = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
if (Plugin.PeriodicCheck)
{
((MonoBehaviour)magnitude).StartCoroutine(magnitude.CheckAllPlayers());
}
break;
}
if (Plugin.PeriodicCheck)
{
<>2__current = (object)new WaitForSeconds(20f);
<>1__state = 1;
return true;
}
magnitude.periodicCheckCoroutine = 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();
}
}
[CompilerGenerated]
private sealed class <ReEnablePhysics>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Character character;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ReEnablePhysics>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_00c0: 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)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForFixedUpdate();
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((Object)(object)character == (Object)null || character.refs == null || (Object)(object)character.refs.ragdoll == (Object)null || character.refs.ragdoll.partList == null)
{
return false;
}
foreach (Bodypart part in character.refs.ragdoll.partList)
{
if (!((Object)(object)part == (Object)null) && !((Object)(object)part.rig == (Object)null))
{
part.rig.linearVelocity = Vector3.zero;
part.rig.angularVelocity = Vector3.zero;
part.rig.isKinematic = false;
}
}
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 Coroutine periodicCheckCoroutine;
public void StartPeriodicCheck()
{
if (periodicCheckCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(periodicCheckCoroutine);
periodicCheckCoroutine = null;
}
periodicCheckCoroutine = ((MonoBehaviour)this).StartCoroutine(PeriodicCheck());
}
public void StopPeriodicCheck()
{
if (periodicCheckCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(periodicCheckCoroutine);
periodicCheckCoroutine = null;
}
}
[IteratorStateMachine(typeof(<PeriodicCheck>d__3))]
private IEnumerator PeriodicCheck()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PeriodicCheck>d__3(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<CheckAllPlayers>d__4))]
private IEnumerator CheckAllPlayers()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CheckAllPlayers>d__4(0)
{
<>4__this = this
};
}
private void ResetRagdollPhysics(Character character)
{
if ((Object)(object)character == (Object)null || character.refs == null || (Object)(object)character.refs.ragdoll == (Object)null || character.refs.ragdoll.partList == null)
{
return;
}
foreach (Bodypart part in character.refs.ragdoll.partList)
{
if (!((Object)(object)part == (Object)null) && !((Object)(object)part.rig == (Object)null))
{
part.rig.isKinematic = true;
}
}
((MonoBehaviour)this).StartCoroutine(ReEnablePhysics(character));
}
[IteratorStateMachine(typeof(<ReEnablePhysics>d__6))]
private IEnumerator ReEnablePhysics(Character character)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ReEnablePhysics>d__6(0)
{
character = character
};
}
public bool CheckMagnitude(Character selectCharacter)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
if (selectCharacter?.refs?.ragdoll?.partList == null)
{
return false;
}
foreach (Bodypart part in selectCharacter.refs.ragdoll.partList)
{
if (!((Object)(object)part?.rig == (Object)null))
{
Vector3 linearVelocity = part.rig.linearVelocity;
float magnitude = ((Vector3)(ref linearVelocity)).magnitude;
if (magnitude > Plugin.HighMagnitudeThreshold.Value)
{
return true;
}
}
}
return false;
}
}
internal class MobPatch
{
[HarmonyPatch(typeof(MushroomZombie), "Update")]
private class MushroomZombieUpdatePatch
{
private static bool Prefix(MushroomZombie __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_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)__instance).transform.position;
float num = Vector3.Distance(position, ((Component)Camera.main).transform.position);
if (num > 2500f)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Mob), "Update")]
private class MobUpdatePatch
{
private static bool Prefix(Mob __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_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)__instance).transform.position;
float num = Vector3.Distance(position, ((Component)Camera.main).transform.position);
if (num > 2500f)
{
return false;
}
return true;
}
}
}
public static class Network
{
[HarmonyPatch(typeof(Campfire), "Light_Rpc")]
public class Light_Rpc_Patch
{
private static bool Prefix(Campfire __instance)
{
if (!Plugin.gracePeriod)
{
Plugin.gracePeriod = true;
((MonoBehaviour)Plugin.Instance).StartCoroutine(Plugin.Instance.EndGracePeriod());
}
return true;
}
}
[HarmonyPatch(typeof(ItemPhysicsSyncer), "FixedUpdate")]
public class ItemPhysicsSyncerPatch
{
public static ConditionalWeakTable<ItemPhysicsSyncer, StrongBox<float>> groundTime = new ConditionalWeakTable<ItemPhysicsSyncer, StrongBox<float>>();
public static ConditionalWeakTable<ItemPhysicsSyncer, StrongBox<bool>> colorChanged = new ConditionalWeakTable<ItemPhysicsSyncer, StrongBox<bool>>();
private static bool Prefix(ItemPhysicsSyncer __instance)
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.BananaStabilize.Value)
{
return true;
}
Rigidbody val = __instance.m_item?.rig;
if ((Object)(object)val == (Object)null || __instance.m_photonView.IsMine)
{
return true;
}
PhotonView photonView = __instance.m_photonView;
object obj;
if (photonView == null)
{
obj = null;
}
else
{
GameObject gameObject = ((Component)photonView).gameObject;
obj = ((gameObject != null) ? ((Object)gameObject).name : null);
}
string text = (string)obj;
if (text == null || !text.ToLower().Contains("berrynana peel"))
{
return true;
}
StrongBox<bool> orCreateValue = colorChanged.GetOrCreateValue(__instance);
if (!val.IsSleeping() && orCreateValue.Value)
{
RestoreOriginalColor(__instance);
orCreateValue.Value = false;
}
if ((int)__instance.m_item.itemState != 0)
{
StrongBox<float> orCreateValue2 = groundTime.GetOrCreateValue(__instance);
orCreateValue2.Value = 0f;
if (val.IsSleeping())
{
val.WakeUp();
}
return true;
}
StrongBox<float> orCreateValue3 = groundTime.GetOrCreateValue(__instance);
orCreateValue3.Value += Time.fixedDeltaTime;
if (orCreateValue3.Value < 1f)
{
return true;
}
if (!((PhotonBinaryStreamSerializer<ItemPhysicsSyncData>)(object)__instance).RemoteValue.IsSome)
{
return true;
}
if (((Vector3)(ref __instance.lastRecievedLinearVelocity)).magnitude > Plugin.BananaThreshold.Value || ((Vector3)(ref __instance.lastRecievedAngularVelocity)).magnitude > Plugin.BananaThreshold.Value)
{
orCreateValue3.Value = 0f;
if (val.IsSleeping())
{
val.WakeUp();
}
return true;
}
if (!val.IsSleeping())
{
val.linearVelocity = Vector3.zero;
val.angularVelocity = Vector3.zero;
val.Sleep();
}
if (!orCreateValue.Value)
{
SetSleepingColor(__instance);
orCreateValue.Value = true;
}
if (Plugin.ShowDebugInfo.Value)
{
skipCounter++;
}
return false;
}
private static void SetSleepingColor(ItemPhysicsSyncer syncer)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.ShowDebugInfo.Value)
{
Renderer[] componentsInChildren = ((Component)syncer).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
val.material.SetColor("_Tint", Color.magenta);
}
}
}
private static void SetSleepingColor(BananaPeel input)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.ShowDebugInfo.Value)
{
return;
}
Renderer[] componentsInChildren = ((Component)input).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
Material material = val.material;
if (material.HasProperty("_Tint"))
{
material.SetColor("_Tint", Color.blue);
}
}
}
public static void RestoreOriginalColor(ItemPhysicsSyncer syncer)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.ShowDebugInfo.Value)
{
Renderer[] componentsInChildren = ((Component)syncer).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
val.material.SetColor("_Tint", Color.blue);
}
}
}
}
[HarmonyPatch(typeof(BananaPeel), "Start")]
public class BananaPeelStartPatch
{
private static void Postfix(BananaPeel __instance)
{
Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
val.shadowCastingMode = (ShadowCastingMode)0;
val.receiveShadows = false;
val.reflectionProbeUsage = (ReflectionProbeUsage)0;
val.lightProbeUsage = (LightProbeUsage)0;
val.motionVectorGenerationMode = (MotionVectorGenerationMode)2;
}
MeshFilter component = ((Component)__instance).GetComponent<MeshFilter>();
if ((Object)(object)component != (Object)null && (Object)(object)component.mesh != (Object)null)
{
component.mesh.Optimize();
}
}
}
[HarmonyPatch(typeof(Dynamite), "Start")]
public class DynamiteStartPatch
{
private static void Postfix(Dynamite __instance)
{
Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
val.shadowCastingMode = (ShadowCastingMode)0;
val.receiveShadows = false;
val.reflectionProbeUsage = (ReflectionProbeUsage)0;
val.lightProbeUsage = (LightProbeUsage)0;
val.motionVectorGenerationMode = (MotionVectorGenerationMode)2;
}
MeshFilter component = ((Component)__instance).GetComponent<MeshFilter>();
if ((Object)(object)component != (Object)null && (Object)(object)component.mesh != (Object)null)
{
component.mesh.Optimize();
}
}
}
[HarmonyPatch(typeof(Item), "Update")]
public class Item_Update_Patch
{
private static Dictionary<Item, float> myDestroyTicks = new Dictionary<Item, float>();
private static bool Prefix(Item __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
float num = Vector3.Distance(((Component)__instance).transform.position, ((Component)Camera.main).transform.position);
if (((Component)__instance).transform.position.y < -2000f || ((Component)__instance).transform.position.y > 4000f || num > 10000f)
{
if (!myDestroyTicks.ContainsKey(__instance))
{
myDestroyTicks[__instance] = 0f;
}
myDestroyTicks[__instance] += Time.deltaTime;
if (myDestroyTicks[__instance] > 2f)
{
Plugin.Log.LogMessage((object)$"Hiding {((Object)__instance).name} at {((Component)__instance).transform.position} | Distance: {num:F0}");
myDestroyTicks.Remove(__instance);
((Component)__instance).gameObject.SetActive(false);
return false;
}
}
else
{
myDestroyTicks.Remove(__instance);
}
return true;
}
}
public static int skipCounter;
public static void ResetSkipCounter()
{
skipCounter = 0;
}
public static bool PreNetworkInstantiate(InstantiateParameters parameters, bool roomObject, bool instantiateEvent)
{
//IL_0005: 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_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: 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_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
if (!instantiateEvent)
{
return true;
}
string prefabName = parameters.prefabName;
Vector3 position = parameters.position;
Player creator = parameters.creator;
string text = prefabName.ToLower();
if (text.Contains("healingpuffshroom"))
{
if (Plugin.gracePeriod)
{
Plugin.Log.LogMessage((object)$"GracePeriod Spawn | {prefabName} at {position}!");
return true;
}
float num = Vector3.Distance(position, ((Component)Camera.main).transform.position);
if (num > 50f)
{
return false;
}
}
else if (text.Contains("berrynana peel"))
{
float num2 = Mathf.Sqrt(Mathf.Pow(position.x - ((Component)Camera.main).transform.position.x, 2f) + Mathf.Pow(position.z - ((Component)Camera.main).transform.position.z, 2f));
if (num2 > 50f)
{
return false;
}
}
if (creator != null && creator != PhotonNetwork.MasterClient)
{
float num3 = Vector3.Distance(position, ((Component)Camera.main).transform.position);
if (prefabName.ToLower().Contains("mushroomzombie"))
{
Plugin.Notification($"{creator} spawn a Zombie at {position} ! Distance : {num3}");
Plugin.Log.LogWarning((object)$"{creator} spawn a Zombie at {position} ! Distance : {num3}");
return false;
}
if (prefabName.ToLower().Contains("scorpion") && num3 > 2500f)
{
Plugin.Notification($"{creator} spawn a Scorpion at {position} ! Distance : {num3}");
Plugin.Log.LogWarning((object)$"{creator} spawn a Scorpion at {position} ! Distance : {num3}");
return false;
}
}
if (prefabName.ToLower().Contains("mushroomzombie") || prefabName.ToLower().Contains("scorpion"))
{
float num4 = Vector3.Distance(position, ((Component)Camera.main).transform.position);
if (num4 > 2500f)
{
return false;
}
}
if (prefabName.ToLower().Contains("beetle"))
{
float num5 = Vector3.Distance(position, ((Component)Camera.main).transform.position);
Plugin.Notification($"{creator} spawn a Beetle at {position} ! Distance : {num5}");
}
return true;
}
public static bool PreOnEvent(EventData photonEvent)
{
return true;
}
private static void LogShaderProperties(BananaPeel input)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
Renderer[] componentsInChildren = ((Component)input).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
Material material = val.material;
Shader shader = material.shader;
Plugin.Log.LogMessage((object)("Shader name: " + ((Object)shader).name));
int propertyCount = shader.GetPropertyCount();
for (int j = 0; j < propertyCount; j++)
{
string propertyName = shader.GetPropertyName(j);
ShaderPropertyType propertyType = shader.GetPropertyType(j);
if ((int)propertyType == 0)
{
Color color = material.GetColor(propertyName);
Plugin.Log.LogMessage((object)$" Color property: {propertyName} = {color}");
}
}
}
}
}
internal class NullReferencePatch
{
[HarmonyPatch(typeof(RopeSyncer), "ShouldSendData")]
private class RopeSyncerShouldSendDataPatch
{
private static bool Prefix(RopeSyncer __instance, ref bool __result)
{
//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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
try
{
List<Transform> ropeSegments = __instance.rope.GetRopeSegments();
if (__instance.rope.isClimbable && __instance.startSyncTime.IsNone)
{
__instance.startSyncTime = Optionable<float>.Some(Time.realtimeSinceStartup);
}
if (ropeSegments.Count == 0)
{
__result = false;
return false;
}
Vector3 pos = ropeSegments.First().position;
List<Character> allPlayerCharacters = PlayerHandler.GetAllPlayerCharacters();
if (allPlayerCharacters.Count == 0)
{
__result = false;
return false;
}
List<Character> list = allPlayerCharacters.Where((Character c) => (Object)(object)c != (Object)null && (Object)(object)((Component)c).gameObject != (Object)null && (Object)(object)((Component)c).transform != (Object)null).ToList();
if (list.Count == 0)
{
__result = false;
return false;
}
float num = list.Select((Character character) => Vector3.Distance(character.Center, pos)).Min();
if (num > 100f)
{
__result = false;
return false;
}
if (__instance.startSyncTime.IsSome && Time.realtimeSinceStartup - __instance.startSyncTime.Value > 60f)
{
__instance.updateVisualizerManually = true;
__instance.syncIndex++;
if (__instance.syncIndex < 600)
{
__result = false;
return false;
}
__instance.syncIndex = 0;
}
__result = !__instance.rope.creatorLeft;
return false;
}
catch (Exception ex)
{
Plugin.Log.LogMessage((object)("Error in RopeSyncer.ShouldSendData: " + ex.Message));
__result = false;
return false;
}
}
}
[HarmonyPatch(typeof(PlayerGhost), "Update")]
private class PlayerGhostUpdatePatch
{
private static bool Prefix(PlayerGhost __instance)
{
if ((Object)(object)__instance.m_target == (Object)null || (Object)(object)((Component)__instance.m_target).gameObject == (Object)null || (Object)(object)((Component)__instance.m_target).transform == (Object)null)
{
return false;
}
if ((Object)(object)__instance.m_owner == (Object)null || (Object)(object)((Component)__instance.m_owner).gameObject == (Object)null)
{
return false;
}
return true;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private class MonoBehaviourPunPhotonViewPatch
{
private static bool Prefix(MonoBehaviourPun __instance, ref PhotonView __result)
{
if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).gameObject == (Object)null || (Object)(object)((Component)__instance).transform == (Object)null)
{
__result = null;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Character), "EndGame")]
private class CharacterEndGamePatch
{
private static bool Prefix(Character __instance)
{
if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).gameObject == (Object)null || (Object)(object)((Component)__instance).transform == (Object)null)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Character), "CheckEndGame")]
private class CharacterCheckEndGamePatch
{
private static bool Prefix(Character __instance)
{
if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).gameObject == (Object)null || (Object)(object)((Component)__instance).transform == (Object)null)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "SetStatus")]
public class SetStatusPatch
{
public static bool Prefix(CharacterAfflictions __instance)
{
if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null)
{
return false;
}
return true;
}
}
}
[BepInPlugin("my.pahsiv.MyBananaDontHurtMe", "MyBananaDontHurtMe", "0.1.4")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <EndGracePeriod>d__20 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <EndGracePeriod>d__20(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(30f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
gracePeriod = false;
Log.LogMessage((object)" Remedy Fungus Grace Period Ended");
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 <SkippingInfo>d__21 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SkippingInfo>d__21(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (Network.skipCounter > 0)
{
Log.LogMessage((object)$"[ {Network.skipCounter} ] Banana Update Skipped!");
Network.ResetSkipCounter();
}
<>2__current = (object)new WaitForSeconds(10f);
<>1__state = 1;
return true;
case 1:
<>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();
}
}
public static bool gracePeriod;
public static bool PeriodicCheck;
public static Magnitude? MagnitudeCheck;
public static ConfigEntry<float> BananaThreshold;
public static ConfigEntry<float> HighMagnitudeThreshold;
public static ConfigEntry<bool> ShowDebugInfo;
public static ConfigEntry<bool> BananaStabilize;
public static ConfigEntry<float> RagdollClose;
public static ConfigEntry<float> RagdollFar;
public static ConfigEntry<float> RagdollVeryFar;
public const string Id = "my.pahsiv.MyBananaDontHurtMe";
public static ManualLogSource Log { get; private set; }
public static Plugin Instance { get; private set; }
public static string Name => "MyBananaDontHurtMe";
public static string Version => "0.1.4";
private void Awake()
{
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Expected O, but got Unknown
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Expected O, but got Unknown
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Expected O, but got Unknown
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Instance = this;
HighMagnitudeThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "High Magnitude Threshold", 70f, "");
BananaThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Banana Threshold", 0.3f, "");
BananaStabilize = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Banana Stabilizer", false, "");
ShowDebugInfo = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Debug Info", false, "");
RagdollClose = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Ragdoll Update Distance (Close)", 30f, new ConfigDescription("Distance for ragdoll update in full speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2500f), Array.Empty<object>()));
RagdollFar = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Ragdoll Update Distance (Far)", 100f, new ConfigDescription("Distance for ragdoll update in half speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2500f), Array.Empty<object>()));
RagdollFar = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Ragdoll Update Distance (Very Far)", 1000f, new ConfigDescription("Distance for ragdoll update in very slow speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2500f), Array.Empty<object>()));
Harmony val = new Harmony("my.pahsiv.MyBananaDontHurtMe");
val.PatchAll();
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
MethodInfo method = typeof(PhotonNetwork).GetMethod("NetworkInstantiate", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[3]
{
typeof(InstantiateParameters),
typeof(bool),
typeof(bool)
}, null);
if (method == null)
{
Log.LogError((object)" Failed to find NetworkInstantiate method!");
}
else
{
MethodInfo method2 = typeof(Network).GetMethod("PreNetworkInstantiate", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
val.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
if (ShowDebugInfo.Value)
{
IEnumerable<MethodBase> patchedMethods = val.GetPatchedMethods();
Log.LogMessage((object)$" Total patched methods: {patchedMethods.Count()}");
foreach (MethodBase item in patchedMethods)
{
Log.LogMessage((object)(" Patched: " + item.DeclaringType?.Name + "." + item.Name));
}
}
GameObject val2 = new GameObject("MagnitudeCheck");
MagnitudeCheck = val2.AddComponent<Magnitude>();
Object.DontDestroyOnLoad((Object)(object)val2);
Log.LogMessage((object)(" Plugin " + Name + " " + Version + " is loaded!"));
}
private void SceneManager_sceneLoaded(Scene scene, LoadSceneMode mode)
{
if (((Scene)(ref scene)).name.Contains("Level_"))
{
PeriodicCheck = true;
Log.LogMessage((object)" Magnitude Check Started!");
MagnitudeCheck?.StartPeriodicCheck();
gracePeriod = true;
Log.LogMessage((object)" Remedy Fungus Grace Period Started");
((MonoBehaviour)this).StartCoroutine(EndGracePeriod());
if (ShowDebugInfo.Value)
{
((MonoBehaviour)this).StartCoroutine(SkippingInfo());
}
}
else
{
PeriodicCheck = false;
Log.LogMessage((object)" Magnitude Check Stopped!");
MagnitudeCheck?.StopPeriodicCheck();
}
}
[IteratorStateMachine(typeof(<EndGracePeriod>d__20))]
public IEnumerator EndGracePeriod()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <EndGracePeriod>d__20(0);
}
[IteratorStateMachine(typeof(<SkippingInfo>d__21))]
public IEnumerator SkippingInfo()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SkippingInfo>d__21(0);
}
public static void Notification(string message, string color = "FFFFFF", bool sound = false)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
PlayerConnectionLog val = Object.FindFirstObjectByType<PlayerConnectionLog>();
if ((Object)(object)val == (Object)null)
{
return;
}
string text = "<color=#" + color + ">" + message + "</color>";
MethodInfo method = typeof(PlayerConnectionLog).GetMethod("AddMessage", BindingFlags.Instance | BindingFlags.NonPublic);
if (method != null)
{
method.Invoke(val, new object[1] { text });
if ((Object)(object)val.sfxJoin != (Object)null && sound)
{
val.sfxJoin.Play(default(Vector3));
}
}
else
{
Debug.LogWarning((object)"AddMessage method not found.");
}
}
public static string RemoveTags(string input)
{
return Regex.Replace(input, "<[^>]*>", "");
}
}
internal class Ragdoll
{
[HarmonyPatch(typeof(CharacterRagdoll), "FixedUpdate")]
private class RagdollPatch
{
private static Dictionary<CharacterRagdoll, float> update_time = new Dictionary<CharacterRagdoll, float>();
private static float medium_update_time = 0.5f;
private static float far_update_time = 5f;
private static bool Prefix(CharacterRagdoll __instance)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if (__instance.character.IsLocal)
{
return true;
}
float num = Vector3.Distance(__instance.character.Center, ((Component)Camera.main).transform.position);
if (num < Plugin.RagdollClose.Value)
{
return true;
}
float num2;
if (num < Plugin.RagdollFar.Value)
{
num2 = medium_update_time;
}
else
{
if (!(num < Plugin.RagdollVeryFar.Value))
{
return false;
}
num2 = far_update_time;
}
if (!update_time.ContainsKey(__instance))
{
update_time[__instance] = 0f;
}
update_time[__instance] += Time.fixedDeltaTime;
if (update_time[__instance] >= num2)
{
update_time[__instance] -= num2;
__instance.SetPhysicsMats();
if (__instance.firstFrame)
{
__instance.firstFrame = false;
}
else
{
UpdateRagdoll(__instance);
}
}
return false;
}
private static void UpdateRagdoll(CharacterRagdoll ragdoll)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ragdoll.character.data.currentItem != (Object)null)
{
ragdoll.character.refs.animations.PrepIK();
}
ragdoll.RotateCharacter();
ragdoll.character.refs.ikRigBuilder.SyncLayers();
ragdoll.character.refs.ikRigBuilder.Evaluate(Time.fixedDeltaTime);
PlayableGraph playableGraph = ragdoll.character.refs.animator.playableGraph;
((PlayableGraph)(ref playableGraph)).Evaluate(Time.fixedDeltaTime);
ragdoll.character.refs.animations.ConfigureIK();
foreach (Bodypart part in ragdoll.partList)
{
part.SaveAnimationData();
ragdoll.DrawLines(part.jointParent, part);
}
ragdoll.SaveAdditionalTransformPositions();
ragdoll.ResetRotation();
foreach (Bodypart part2 in ragdoll.partList)
{
part2.ResetTransform();
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}