using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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: AssemblyTitle("JellyJamLocationSwapPEAKMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JellyJamLocationSwapPEAKMod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d300a51b-4145-4301-b462-e7e308614952")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public class RandomDamageTeleport : MonoBehaviour
{
private CharacterAfflictions _afflictions;
private static float lastSwapTime = 0f;
private static float swapCooldown = 1f;
private void Awake()
{
_afflictions = ((Component)this).GetComponent<CharacterAfflictions>();
if ((Object)(object)_afflictions != (Object)null)
{
CharacterAfflictions afflictions = _afflictions;
afflictions.OnAddedStatus = (Action<STATUSTYPE, float>)Delegate.Combine(afflictions.OnAddedStatus, new Action<STATUSTYPE, float>(OnStatusAdded));
}
}
private void OnStatusAdded(STATUSTYPE status, float value)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
if ((int)status == 7 || (int)status == 1 || Time.time - lastSwapTime < swapCooldown)
{
return;
}
lastSwapTime = Time.time;
if (PhotonNetwork.IsMasterClient)
{
Character selfChar = ((Component)this).GetComponent<Character>();
Character[] array = (from c in Character.AllCharacters
where (Object)(object)c != (Object)null
where (Object)(object)c != (Object)(object)selfChar
where (Object)(object)c.data != (Object)null
where !c.data.dead
select c).ToArray();
if (array.Length != 0)
{
Character target = array[Random.Range(0, array.Length)];
SwapWith(target);
}
}
}
private void SwapWith(Character target)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
Character component = ((Component)this).GetComponent<Character>();
if (!((Object)(object)component == (Object)null) && !((Object)(object)target == (Object)null) && !component.data.dead && !target.data.dead)
{
Vector3 center = component.Center;
Vector3 center2 = target.Center;
((MonoBehaviourPun)component).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { center2, false });
((MonoBehaviourPun)target).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { center, false });
Debug.Log((object)("[RandomDamageTeleport] Swapped " + ((Object)component).name + " with " + ((Object)target).name));
}
}
}
namespace JellyJamTinyPeakMod.Patches
{
[HarmonyPatch(typeof(Character))]
public class AfflictionPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void AwakePostfix(Character __instance)
{
if (!((Object)(object)__instance == (Object)null) && (Object)(object)((Component)__instance).GetComponent<RandomDamageTeleport>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<RandomDamageTeleport>();
}
}
}
}
namespace JellyJamLocationSwapPEAKMod
{
[BepInPlugin("JellyJam.LocationSwapMod", "JellyJamLocationSwapMod", "1.0.0.0")]
public class ModBase : BaseUnityPlugin
{
private const string modGUID = "JellyJam.LocationSwapMod";
private const string modName = "JellyJamLocationSwapMod";
private const string modVersion = "1.0.0.0";
private readonly Harmony harmony = new Harmony("JellyJam.LocationSwapMod");
private static ModBase Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("JellyJam.LocationSwapMod");
mls.LogInfo((object)"The JellyJamLocationSwapMod has started");
harmony.PatchAll();
}
}
}