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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Peak.Afflictions;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PeakClassMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PeakClassMod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("68e93fcd-af72-447e-8fcc-2e7429a66921")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PeakClassMod;
[BepInPlugin("com.peakmod.classmod", "PEAK Class Mod", "2.9.4")]
public class PeakClassModPlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <>c__DisplayClass22_0
{
public int actor;
public Func<Character, bool> <>9__0;
internal bool <HostGiveItemsToPlayerWhenReady>b__0(Character c)
{
return (Object)(object)c != (Object)null && !c.isBot && (Object)(object)((MonoBehaviourPun)c).photonView != (Object)null && ((MonoBehaviourPun)c).photonView.Owner != null && ((MonoBehaviourPun)c).photonView.Owner.ActorNumber == actor;
}
}
[CompilerGenerated]
private sealed class <GiveItemLocalRoutine>d__20 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Character ch;
public ushort id;
public PeakClassModPlugin <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GiveItemLocalRoutine>d__20(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if ((Object)(object)ch == (Object)null)
{
return false;
}
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((Object)(object)ch.player != (Object)null && ch.player.HasEmptySlot(id))
{
ItemSlot val = default(ItemSlot);
ch.player.AddItem(id, (ItemInstanceData)null, ref val);
}
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 <HostGiveItemsToPlayerWhenReady>d__22 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Player newPlayer;
private <>c__DisplayClass22_0 <>8__1;
private float <start>5__2;
private Character <ch>5__3;
private string <hatName>5__4;
private List<string> <itemsToGive>5__5;
private ClassModNetwork <netComp>5__6;
private List<string>.Enumerator <>s__7;
private string <itemName>5__8;
private Item <item>5__9;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <HostGiveItemsToPlayerWhenReady>d__22(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<ch>5__3 = null;
<hatName>5__4 = null;
<itemsToGive>5__5 = null;
<netComp>5__6 = null;
<>s__7 = default(List<string>.Enumerator);
<itemName>5__8 = null;
<item>5__9 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Expected O, but got Unknown
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass22_0();
if (newPlayer == null)
{
return false;
}
<start>5__2 = Time.time;
<>8__1.actor = newPlayer.ActorNumber;
break;
case 1:
<>1__state = -1;
break;
case 2:
<>1__state = -1;
<ch>5__3 = null;
break;
}
if (Time.time - <start>5__2 < 120f)
{
if (!PhotonNetwork.IsMasterClient || !IsMultiplayerActive)
{
return false;
}
<ch>5__3 = ((IEnumerable<Character>)Character.AllCharacters).FirstOrDefault((Func<Character, bool>)((Character c) => (Object)(object)c != (Object)null && !c.isBot && (Object)(object)((MonoBehaviourPun)c).photonView != (Object)null && ((MonoBehaviourPun)c).photonView.Owner != null && ((MonoBehaviourPun)c).photonView.Owner.ActorNumber == <>8__1.actor));
if ((Object)(object)<ch>5__3 != (Object)null)
{
if ((Object)(object)((Component)<ch>5__3).gameObject.GetComponent<ClassModNetwork>() == (Object)null)
{
((Component)<ch>5__3).gameObject.AddComponent<ClassModNetwork>();
}
if ((Object)(object)((Component)<ch>5__3).gameObject.GetComponent<AstronautStatHandler>() == (Object)null)
{
((Component)<ch>5__3).gameObject.AddComponent<AstronautStatHandler>();
}
if ((Object)(object)((Component)<ch>5__3).gameObject.GetComponent<MedicStatHandler>() == (Object)null)
{
((Component)<ch>5__3).gameObject.AddComponent<MedicStatHandler>();
}
if (!HatUtils.TryGetHatName(<ch>5__3, out <hatName>5__4))
{
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
if (GivenActorsThisScene.Contains(<>8__1.actor))
{
return false;
}
<itemsToGive>5__5 = BuildStartItems(<ch>5__3);
if (<itemsToGive>5__5.Count > 0)
{
<netComp>5__6 = ((Component)<ch>5__3).gameObject.GetComponent<ClassModNetwork>();
if ((Object)(object)<netComp>5__6 != (Object)null)
{
<>s__7 = <itemsToGive>5__5.GetEnumerator();
try
{
while (<>s__7.MoveNext())
{
<itemName>5__8 = <>s__7.Current;
<item>5__9 = ItemCache.Get(<itemName>5__8);
if ((Object)(object)<item>5__9 != (Object)null)
{
((MonoBehaviourPun)<netComp>5__6).photonView.RPC("ClassMod_GiveItem", newPlayer, new object[1] { <item>5__9.itemID });
}
<item>5__9 = null;
<itemName>5__8 = null;
}
}
finally
{
((IDisposable)<>s__7).Dispose();
}
<>s__7 = default(List<string>.Enumerator);
}
<netComp>5__6 = null;
}
GivenActorsThisScene.Add(<>8__1.actor);
return false;
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 2;
return true;
}
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 <SmartGiveItemsRoutine>d__16 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public PeakClassModPlugin <>4__this;
private int <maxRetries>5__1;
private int <currentTry>5__2;
private bool <allPlayersReady>5__3;
private List<Character>.Enumerator <>s__4;
private Character <character>5__5;
private List<Character>.Enumerator <>s__6;
private Character <character>5__7;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SmartGiveItemsRoutine>d__16(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>s__4 = default(List<Character>.Enumerator);
<character>5__5 = null;
<>s__6 = default(List<Character>.Enumerator);
<character>5__7 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Expected O, but got Unknown
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)"[ClassMod] Run Started. Waiting for players...");
}
<>2__current = (object)new WaitForSeconds(3f);
<>1__state = 1;
return true;
}
case 1:
<>1__state = -1;
<maxRetries>5__1 = 30;
<currentTry>5__2 = 0;
break;
case 2:
<>1__state = -1;
break;
case 3:
<>1__state = -1;
break;
case 4:
<>1__state = -1;
break;
case 5:
<>1__state = -1;
break;
}
if (<currentTry>5__2 < <maxRetries>5__1)
{
<currentTry>5__2++;
if (PhotonNetwork.IsConnected && !PhotonNetwork.IsConnectedAndReady)
{
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 2;
return true;
}
if (Character.AllCharacters.Count == 0)
{
if (<currentTry>5__2 % 5 == 0)
{
ManualLogSource log2 = Log;
if (log2 != null)
{
log2.LogInfo((object)"Waiting for characters...");
}
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 3;
return true;
}
ItemCache.Refresh();
if ((Object)(object)ItemCache.Get("Shroomberry_Red") == (Object)null)
{
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 4;
return true;
}
<allPlayersReady>5__3 = true;
<>s__4 = Character.AllCharacters.GetEnumerator();
try
{
while (<>s__4.MoveNext())
{
<character>5__5 = <>s__4.Current;
if (!((Object)(object)<character>5__5 == (Object)null) && !<character>5__5.isBot)
{
if ((Object)(object)<character>5__5.player == (Object)null)
{
<allPlayersReady>5__3 = false;
break;
}
<character>5__5 = null;
}
}
}
finally
{
((IDisposable)<>s__4).Dispose();
}
<>s__4 = default(List<Character>.Enumerator);
if (!<allPlayersReady>5__3)
{
if (<currentTry>5__2 % 5 == 0)
{
ManualLogSource log3 = Log;
if (log3 != null)
{
log3.LogInfo((object)"Waiting for Player scripts...");
}
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 5;
return true;
}
<>s__6 = Character.AllCharacters.GetEnumerator();
try
{
while (<>s__6.MoveNext())
{
<character>5__7 = <>s__6.Current;
if ((Object)(object)<character>5__7 != (Object)null)
{
if ((Object)(object)((Component)<character>5__7).gameObject.GetComponent<ClassModNetwork>() == (Object)null)
{
((Component)<character>5__7).gameObject.AddComponent<ClassModNetwork>();
}
if ((Object)(object)((Component)<character>5__7).gameObject.GetComponent<AstronautStatHandler>() == (Object)null)
{
((Component)<character>5__7).gameObject.AddComponent<AstronautStatHandler>();
}
if ((Object)(object)((Component)<character>5__7).gameObject.GetComponent<MedicStatHandler>() == (Object)null)
{
((Component)<character>5__7).gameObject.AddComponent<MedicStatHandler>();
}
}
<character>5__7 = null;
}
}
finally
{
((IDisposable)<>s__6).Dispose();
}
<>s__6 = default(List<Character>.Enumerator);
ManualLogSource log4 = Log;
if (log4 != null)
{
log4.LogInfo((object)"[ClassMod] All Players Ready. Distributing Items.");
}
<>4__this.DistributeItems();
return false;
}
ManualLogSource log5 = Log;
if (log5 != null)
{
log5.LogError((object)"[ClassMod] Timed out waiting for players.");
}
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 PeakClassModPlugin Instance;
private static Harmony harmony;
internal static ManualLogSource Log;
internal static readonly HashSet<int> GivenActorsThisScene = new HashSet<int>();
public static bool scoutActive = false;
public static bool medicActive = false;
public static bool techPriestActive = false;
public static bool mushroomancerActive = false;
public static bool greatEpeeActive = false;
public static bool rogueActive = false;
public static bool billActive = false;
public static bool astronautActive = false;
public static string currentClass = "None";
private GameObject _callbacksGO;
private static readonly string[] StartBerries = new string[5] { "Shroomberry_Red", "Shroomberry_Yellow", "Shroomberry_Purple", "Shroomberry_Blue", "Shroomberry_Green" };
private static bool IsMultiplayerActive => PhotonNetwork.IsConnectedAndReady && PhotonNetwork.CurrentRoom != null && PhotonNetwork.CurrentRoom.PlayerCount > 1;
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
harmony = new Harmony("com.peakmod.classmod");
harmony.PatchAll();
_callbacksGO = new GameObject("PeakClassModCallbacks");
Object.DontDestroyOnLoad((Object)(object)_callbacksGO);
_callbacksGO.AddComponent<PeakClassModCallbacks>();
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)"[ClassMod] Ready. Version 2.9.4 loaded.");
}
}
private void OnDestroy()
{
try
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
catch
{
}
if ((Object)(object)_callbacksGO != (Object)null)
{
Object.Destroy((Object)(object)_callbacksGO);
}
}
[IteratorStateMachine(typeof(<SmartGiveItemsRoutine>d__16))]
public IEnumerator SmartGiveItemsRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SmartGiveItemsRoutine>d__16(0)
{
<>4__this = this
};
}
private void DistributeItems()
{
bool flag = PhotonNetwork.IsConnectedAndReady && PhotonNetwork.IsMasterClient && IsMultiplayerActive;
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter == (Object)null || allCharacter.isBot || (Object)(object)allCharacter.player == (Object)null)
{
continue;
}
int num = (((Object)(object)((MonoBehaviourPun)allCharacter).photonView != (Object)null && ((MonoBehaviourPun)allCharacter).photonView.Owner != null) ? ((MonoBehaviourPun)allCharacter).photonView.Owner.ActorNumber : (-1));
if ((num > 0 && GivenActorsThisScene.Contains(num)) || !HatUtils.TryGetHatName(allCharacter, out var _))
{
continue;
}
List<string> list = BuildStartItems(allCharacter);
if (list.Count == 0)
{
if (num > 0)
{
GivenActorsThisScene.Add(num);
}
continue;
}
string characterName = allCharacter.characterName;
if (flag)
{
foreach (string item in list)
{
Item val = ItemCache.Get(item);
if (!((Object)(object)val == (Object)null))
{
ClassModNetwork component = ((Component)allCharacter).gameObject.GetComponent<ClassModNetwork>();
if ((Object)(object)component != (Object)null)
{
((MonoBehaviourPun)component).photonView.RPC("ClassMod_GiveItem", ((MonoBehaviourPun)allCharacter).photonView.Owner, new object[1] { val.itemID });
}
}
}
if (num > 0)
{
GivenActorsThisScene.Add(num);
}
}
else
{
if (IsMultiplayerActive)
{
continue;
}
foreach (string item2 in list)
{
Item val2 = ItemCache.Get(item2);
if (!((Object)(object)val2 == (Object)null))
{
((MonoBehaviour)this).StartCoroutine(GiveItemLocalRoutine(allCharacter, val2.itemID));
}
}
if (num > 0)
{
GivenActorsThisScene.Add(num);
}
}
}
}
[IteratorStateMachine(typeof(<GiveItemLocalRoutine>d__20))]
private IEnumerator GiveItemLocalRoutine(Character ch, ushort id)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GiveItemLocalRoutine>d__20(0)
{
<>4__this = this,
ch = ch,
id = id
};
}
private static List<string> BuildStartItems(Character character)
{
List<string> list = new List<string>();
if ((Object)(object)character == (Object)null)
{
return list;
}
if (ClassCheckUtil.IsMushroom(character))
{
for (int i = 0; i < 3; i++)
{
list.Add(StartBerries[Random.Range(0, StartBerries.Length)]);
}
}
else if (ClassCheckUtil.IsMedicHat(character))
{
list.Add("FirstAidKit");
list.Add("Cure-All");
}
else if (ClassCheckUtil.IsTechPriest(character))
{
list.Add("ChainShooter");
list.Add("ChainShooter");
}
else if (ClassCheckUtil.IsRogueHat(character))
{
list.Add("RopeSpool");
list.Add("RopeSpool");
}
else if (ClassCheckUtil.IsAstronaut(character))
{
list.Add("BalloonBunch");
}
return list;
}
[IteratorStateMachine(typeof(<HostGiveItemsToPlayerWhenReady>d__22))]
internal static IEnumerator HostGiveItemsToPlayerWhenReady(Player newPlayer)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <HostGiveItemsToPlayerWhenReady>d__22(0)
{
newPlayer = newPlayer
};
}
}
public class AstronautStatHandler : MonoBehaviour
{
[CompilerGenerated]
private sealed class <ApplyWindWalkDelayed>d__9 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public AstronautStatHandler <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ApplyWindWalkDelayed>d__9(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
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (ClassManager.IsAstronautActive() && (Object)(object)<>4__this._character != (Object)null)
{
<>4__this.TriggerWindWalk();
}
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 Character _character;
private CharacterMovement _movement;
private Traverse _travMove;
private float _defJump = 400f;
private float _defSprintMult = 2f;
private bool _defaultsCaptured = false;
private bool _isModified = false;
private void Start()
{
_character = ((Component)this).GetComponent<Character>();
_movement = ((Component)this).GetComponent<CharacterMovement>();
}
private void Update()
{
if (!((Object)(object)_character == (Object)null) && _character.IsLocal && ClassManager.IsAstronautActive() && Input.GetKeyDown((KeyCode)32) && _character.data.isGrounded)
{
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(ApplyWindWalkDelayed());
}
}
[IteratorStateMachine(typeof(<ApplyWindWalkDelayed>d__9))]
private IEnumerator ApplyWindWalkDelayed()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ApplyWindWalkDelayed>d__9(0)
{
<>4__this = this
};
}
private void TriggerWindWalk()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
try
{
Affliction_LowGravity val = new Affliction_LowGravity(3, 3f);
_character.refs.afflictions.AddAffliction((Affliction)(object)val, true);
ManualLogSource log = PeakClassModPlugin.Log;
if (log != null)
{
log.LogInfo((object)"[Astronaut] WindWalk Activated (Delayed 2s)");
}
}
catch (Exception ex)
{
ManualLogSource log2 = PeakClassModPlugin.Log;
if (log2 != null)
{
log2.LogError((object)("[Astronaut] Error applying WindWalk: " + ex.Message));
}
}
}
private void FixedUpdate()
{
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_character == (Object)null || !_character.IsLocal || (Object)(object)_movement == (Object)null)
{
return;
}
if (_travMove == null)
{
_travMove = Traverse.Create((object)_movement);
}
if (ClassManager.IsAstronautActive())
{
if (!_defaultsCaptured && !_isModified)
{
float? num = _travMove.Field("jumpImpulse").GetValue<float>();
if (num.HasValue && num.Value > 0f)
{
_defJump = num.Value;
}
float? num2 = _travMove.Field("sprintMultiplier").GetValue<float>();
if (num2.HasValue)
{
_defSprintMult = num2.Value;
}
_defaultsCaptured = true;
}
_travMove.Field("jumpImpulse").SetValue((object)1200f);
_travMove.Field("sprintMultiplier").SetValue((object)1.7f);
if (_character.data.isGrounded)
{
List<Affliction> afflictionList = _character.refs.afflictions.afflictionList;
for (int num3 = afflictionList.Count - 1; num3 >= 0; num3--)
{
if (afflictionList[num3] is Affliction_LowGravity)
{
_character.refs.afflictions.RemoveAffliction(afflictionList[num3], false, true);
}
}
}
if (!_character.data.isSprinting)
{
Traverse val = _travMove.Field("velocity");
if (val.FieldExists())
{
Vector3 value = val.GetValue<Vector3>();
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(value.x, 0f, value.z);
if (((Vector3)(ref val2)).magnitude > 1.6f)
{
Vector3 val3 = ((Vector3)(ref val2)).normalized * 1.6f;
Vector3 val4 = default(Vector3);
((Vector3)(ref val4))..ctor(val3.x, value.y, val3.z);
val.SetValue((object)val4);
}
}
}
_isModified = true;
}
else if (_isModified)
{
_travMove.Field("jumpImpulse").SetValue((object)_defJump);
_travMove.Field("sprintMultiplier").SetValue((object)_defSprintMult);
_isModified = false;
_defaultsCaptured = false;
}
}
}
public class MedicStatHandler : MonoBehaviour
{
private Character _character;
private ClassModNetwork _network;
private int _healsRemaining = 10;
private float _lastHealTime = 0f;
private void Start()
{
_character = ((Component)this).GetComponent<Character>();
_network = ((Component)this).GetComponent<ClassModNetwork>();
_healsRemaining = 10;
}
private void Update()
{
if ((Object)(object)_character == (Object)null || !_character.IsLocal)
{
return;
}
if (ClassManager.IsMedicActive())
{
if (Input.GetKeyDown((KeyCode)104) && Time.time - _lastHealTime > 1f)
{
TrySelfHeal();
}
}
else if (_healsRemaining < 10)
{
_healsRemaining = 10;
}
}
private void TrySelfHeal()
{
if (_healsRemaining <= 0)
{
return;
}
CharacterAfflictions afflictions = _character.refs.afflictions;
if (afflictions.GetCurrentStatus((STATUSTYPE)0) > 0f)
{
_healsRemaining--;
_lastHealTime = Time.time;
afflictions.SubtractStatus((STATUSTYPE)0, 0.1f, false, false);
if ((Object)(object)_network != (Object)null)
{
((MonoBehaviourPun)_network).photonView.RPC("ShowMedicHealEffectRPC", (RpcTarget)0, new object[1] { _healsRemaining });
}
}
}
}
public class PeakClassModCallbacks : MonoBehaviourPunCallbacks
{
public override void OnPlayerEnteredRoom(Player newPlayer)
{
if (PhotonNetwork.IsMasterClient)
{
((MonoBehaviour)PeakClassModPlugin.Instance).StartCoroutine(PeakClassModPlugin.HostGiveItemsToPlayerWhenReady(newPlayer));
}
}
public override void OnPlayerLeftRoom(Player otherPlayer)
{
if (otherPlayer != null)
{
PeakClassModPlugin.GivenActorsThisScene.Remove(otherPlayer.ActorNumber);
}
}
}
internal static class HatUtils
{
private static string _lastLocalHatName;
internal static void SetLastLocalHatName(string hatName)
{
if (!string.IsNullOrEmpty(hatName))
{
_lastLocalHatName = hatName;
}
}
public static bool TryGetHatName(Character ch, out string hatName)
{
hatName = null;
if ((Object)(object)ch == (Object)null)
{
return false;
}
CustomizationOption[] array = Singleton<Customization>.Instance?.hats;
if (array == null)
{
return false;
}
PersistentPlayerDataService service = GameHandler.GetService<PersistentPlayerDataService>();
PersistentPlayerData val = null;
if ((Object)(object)((MonoBehaviourPun)ch).photonView != (Object)null && ((MonoBehaviourPun)ch).photonView.Owner != null)
{
val = ((service != null) ? service.GetPlayerData(((MonoBehaviourPun)ch).photonView.Owner) : null);
}
if (val == null && ch.IsLocal && PhotonNetwork.LocalPlayer != null)
{
val = ((service != null) ? service.GetPlayerData(PhotonNetwork.LocalPlayer) : null);
}
if (val != null)
{
int currentHat = val.customizationData.currentHat;
if (currentHat >= 0 && currentHat < array.Length && (Object)(object)array[currentHat] != (Object)null)
{
hatName = ((Object)array[currentHat]).name;
return !string.IsNullOrEmpty(hatName);
}
}
if (ch.IsLocal && !string.IsNullOrEmpty(_lastLocalHatName))
{
hatName = _lastLocalHatName;
return true;
}
return false;
}
public static bool HasHat(Character ch, string expected)
{
string hatName;
return TryGetHatName(ch, out hatName) && string.Equals(hatName, expected, StringComparison.Ordinal);
}
public static bool HasAnyHat(Character ch, params string[] names)
{
if (!TryGetHatName(ch, out var hatName))
{
return false;
}
return names.Contains(hatName);
}
}
internal static class ClassCheckUtil
{
public static bool IsBill(Character ch)
{
return HatUtils.HasHat(ch, "Hat_Bandana");
}
public static bool IsTechPriest(Character ch)
{
return HatUtils.HasHat(ch, "Hat_Crab");
}
public static bool IsMedicHat(Character ch)
{
return HatUtils.HasAnyHat(ch, "Hat_Medic", "MedicHelmet");
}
public static bool IsMushroom(Character ch)
{
return HatUtils.HasHat(ch, "Hat_Mushroom");
}
public static bool IsRogueHat(Character ch)
{
return HatUtils.HasHat(ch, "Hat_NinjaHeadband");
}
public static bool IsGreatEpeeHat(Character ch)
{
return HatUtils.HasHat(ch, "Hat_Propeller");
}
public static bool IsAstronaut(Character ch)
{
return HatUtils.HasHat(ch, "Hat_Astronaut");
}
}
internal static class ItemCache
{
private static Dictionary<string, Item> _byName;
public static void Refresh()
{
_byName = null;
EnsureCache();
}
private static void EnsureCache()
{
if (_byName != null)
{
return;
}
_byName = new Dictionary<string, Item>(StringComparer.OrdinalIgnoreCase);
Item[] array = Resources.FindObjectsOfTypeAll<Item>();
foreach (Item val in array)
{
if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(((Object)val).name) && !_byName.ContainsKey(((Object)val).name))
{
_byName[((Object)val).name] = val;
}
}
}
public static Item Get(string name)
{
EnsureCache();
_byName.TryGetValue(name, out var value);
return value;
}
}
public class ClassModNetwork : MonoBehaviourPun
{
[CompilerGenerated]
private sealed class <WaitAndAdd>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Character ch;
public ushort itemID;
public ClassModNetwork <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitAndAdd>d__1(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
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((Object)(object)ch.player != (Object)null && ch.player.HasEmptySlot(itemID))
{
ItemSlot val = default(ItemSlot);
ch.player.AddItem(itemID, (ItemInstanceData)null, ref val);
}
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();
}
}
[PunRPC]
public void ClassMod_GiveItem(ushort itemID, PhotonMessageInfo info)
{
Character component = ((Component)this).GetComponent<Character>();
if (!((Object)(object)component == (Object)null))
{
((MonoBehaviour)this).StartCoroutine(WaitAndAdd(component, itemID));
}
}
[IteratorStateMachine(typeof(<WaitAndAdd>d__1))]
private IEnumerator WaitAndAdd(Character ch, ushort itemID)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitAndAdd>d__1(0)
{
<>4__this = this,
ch = ch,
itemID = itemID
};
}
[PunRPC]
public void ShowMedicHealEffectRPC(int remainingHeals)
{
ManualLogSource log = PeakClassModPlugin.Log;
if (log != null)
{
log.LogInfo((object)$"[ClassMod] Medic heal used! Remaining: {remainingHeals}");
}
}
}
[HarmonyPatch(typeof(Character), "Start")]
public class Character_Start_AddNetComp_Patch
{
private static void Postfix(Character __instance)
{
if ((Object)(object)__instance != (Object)null)
{
if ((Object)(object)((Component)__instance).gameObject.GetComponent<ClassModNetwork>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<ClassModNetwork>();
}
if ((Object)(object)((Component)__instance).gameObject.GetComponent<AstronautStatHandler>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<AstronautStatHandler>();
}
if ((Object)(object)((Component)__instance).gameObject.GetComponent<MedicStatHandler>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<MedicStatHandler>();
}
}
}
}
public static class ClassManager
{
[CompilerGenerated]
private sealed class <GreatEpeePermanentEffects>d__22 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Character character;
private bool <hasFaster>5__1;
private List<Affliction>.Enumerator <>s__2;
private Affliction <a>5__3;
private Affliction_FasterBoi <fb>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GreatEpeePermanentEffects>d__22(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>s__2 = default(List<Affliction>.Enumerator);
<a>5__3 = null;
<fb>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (PeakClassModPlugin.greatEpeeActive && (Object)(object)character != (Object)null && character.IsLocal)
{
<hasFaster>5__1 = false;
<>s__2 = character.refs.afflictions.afflictionList.GetEnumerator();
try
{
while (<>s__2.MoveNext())
{
<a>5__3 = <>s__2.Current;
if (((object)<a>5__3).GetType().Name.Contains("FasterBoi"))
{
<hasFaster>5__1 = true;
}
<a>5__3 = null;
}
}
finally
{
((IDisposable)<>s__2).Dispose();
}
<>s__2 = default(List<Affliction>.Enumerator);
if (!<hasFaster>5__1)
{
<fb>5__4 = new Affliction_FasterBoi
{
totalTime = 99999f
};
character.refs.afflictions.AddAffliction((Affliction)(object)<fb>5__4, false);
<fb>5__4 = null;
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
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 <GreatEpeeStaminaRoutine>d__23 : IEnumerator<object>, IDisposable, IEnumerator
{
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 <GreatEpeeStaminaRoutine>d__23(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
character.refs.afflictions.AddStatus((STATUSTYPE)6, 1f, false, true);
break;
}
if (PeakClassModPlugin.greatEpeeActive && (Object)(object)character != (Object)null && character.IsLocal)
{
<>2__current = (object)new WaitForSeconds(Random.Range(45f, 150f));
<>1__state = 1;
return true;
}
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 <MushroomancerLocalStaminaWatch>d__20 : IEnumerator<object>, IDisposable, IEnumerator
{
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 <MushroomancerLocalStaminaWatch>d__20(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if ((Object)(object)character != (Object)null && PeakClassModPlugin.mushroomancerActive && character.IsLocal && character.data.currentStamina <= 0.001f && !character.data.fullyPassedOut)
{
TryActivateStaminaZeroMechanic(character);
}
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
}
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 static readonly Dictionary<int, float> lastStaminaZeroTime = new Dictionary<int, float>();
private static readonly string[] ZeroStaminaFungi = new string[3] { "ShelfShroom", "BounceShroom", "CloudFungus" };
public static void ResetAllFlags()
{
PeakClassModPlugin.scoutActive = false;
PeakClassModPlugin.medicActive = false;
PeakClassModPlugin.techPriestActive = false;
PeakClassModPlugin.mushroomancerActive = false;
PeakClassModPlugin.greatEpeeActive = false;
PeakClassModPlugin.rogueActive = false;
PeakClassModPlugin.billActive = false;
PeakClassModPlugin.astronautActive = false;
PeakClassModPlugin.currentClass = "None";
}
public static void ActivateScoutClass()
{
ResetAllFlags();
PeakClassModPlugin.scoutActive = true;
PeakClassModPlugin.currentClass = "Scout";
}
public static void ActivateMedicClass()
{
ResetAllFlags();
PeakClassModPlugin.medicActive = true;
PeakClassModPlugin.currentClass = "Medic";
}
public static void ActivateTechPriestClass()
{
ResetAllFlags();
PeakClassModPlugin.techPriestActive = true;
PeakClassModPlugin.currentClass = "Tech-Priest";
}
public static void ActivateMushroomancerClass()
{
ResetAllFlags();
PeakClassModPlugin.mushroomancerActive = true;
PeakClassModPlugin.currentClass = "Mushroomancer";
}
public static void ActivateGreatEpeeClass()
{
ResetAllFlags();
PeakClassModPlugin.greatEpeeActive = true;
PeakClassModPlugin.currentClass = "GreatEpee";
}
public static void ActivateRogueClass()
{
ResetAllFlags();
PeakClassModPlugin.rogueActive = true;
PeakClassModPlugin.currentClass = "Rogue";
if ((Object)(object)Character.localCharacter != (Object)null)
{
Character.localCharacter.data.jumpsRemaining = 2;
}
}
public static void ActivateBillClass()
{
ResetAllFlags();
PeakClassModPlugin.billActive = true;
PeakClassModPlugin.currentClass = "Bill";
}
public static void ActivateAstronautClass()
{
ResetAllFlags();
PeakClassModPlugin.astronautActive = true;
PeakClassModPlugin.currentClass = "Astronaut";
}
public static void DeactivateAllClasses()
{
ResetAllFlags();
if ((Object)(object)Character.localCharacter != (Object)null)
{
Character.localCharacter.data.jumpsRemaining = 1;
}
}
public static bool IsScoutActive()
{
return PeakClassModPlugin.scoutActive;
}
public static bool IsMedicActive()
{
return PeakClassModPlugin.medicActive;
}
public static bool IsTechPriestActive()
{
return PeakClassModPlugin.techPriestActive;
}
public static bool IsMushroomancerActive()
{
return PeakClassModPlugin.mushroomancerActive;
}
public static bool IsGreatEpeeActive()
{
return PeakClassModPlugin.greatEpeeActive;
}
public static bool IsRogueActive()
{
return PeakClassModPlugin.rogueActive;
}
public static bool IsBillActive()
{
return PeakClassModPlugin.billActive;
}
public static bool IsAstronautActive()
{
return PeakClassModPlugin.astronautActive;
}
[IteratorStateMachine(typeof(<MushroomancerLocalStaminaWatch>d__20))]
public static IEnumerator MushroomancerLocalStaminaWatch(Character character)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <MushroomancerLocalStaminaWatch>d__20(0)
{
character = character
};
}
public static void TryActivateStaminaZeroMechanic(Character character)
{
if ((Object)(object)character == (Object)null)
{
return;
}
PhotonView photonView = ((MonoBehaviourPun)character).photonView;
if (((photonView != null) ? photonView.Owner : null) == null)
{
return;
}
int actorNumber = ((MonoBehaviourPun)character).photonView.Owner.ActorNumber;
if (lastStaminaZeroTime.TryGetValue(actorNumber, out var value) && Time.time - value < 2f)
{
return;
}
string name = ZeroStaminaFungi[Random.Range(0, ZeroStaminaFungi.Length)];
Item val = ItemCache.Get(name);
if ((Object)(object)val == (Object)null)
{
return;
}
ushort itemID = val.itemID;
if ((Object)(object)character.player != (Object)null && character.player.HasEmptySlot(itemID))
{
lastStaminaZeroTime[actorNumber] = Time.time;
CharacterRefs refs = character.refs;
if (refs != null)
{
CharacterAfflictions afflictions = refs.afflictions;
if (afflictions != null)
{
afflictions.AddStatus((STATUSTYPE)5, 0.02f, false, true);
}
}
ItemSlot val2 = default(ItemSlot);
character.player.AddItem(itemID, (ItemInstanceData)null, ref val2);
}
else
{
lastStaminaZeroTime[actorNumber] = Time.time;
}
}
[IteratorStateMachine(typeof(<GreatEpeePermanentEffects>d__22))]
public static IEnumerator GreatEpeePermanentEffects(Character character)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GreatEpeePermanentEffects>d__22(0)
{
character = character
};
}
[IteratorStateMachine(typeof(<GreatEpeeStaminaRoutine>d__23))]
public static IEnumerator GreatEpeeStaminaRoutine(Character character)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GreatEpeeStaminaRoutine>d__23(0)
{
character = character
};
}
}
[HarmonyPatch(typeof(CharacterCustomization), "SetCharacterHat")]
public class SetHat_Patch
{
private static void Postfix(int index)
{
CustomizationOption[] array = Singleton<Customization>.Instance?.hats;
object obj;
if (array == null || index < 0 || index >= array.Length)
{
obj = "Unknown";
}
else
{
CustomizationOption obj2 = array[index];
obj = ((obj2 != null) ? ((Object)obj2).name : null);
}
string text = (string)obj;
HatUtils.SetLastLocalHatName(text);
if (index == 12)
{
ClassManager.ActivateScoutClass();
}
else if (text == "Hat_Medic" || text == "MedicHelmet")
{
ClassManager.ActivateMedicClass();
}
else
{
switch (text)
{
case "Hat_Crab":
ClassManager.ActivateTechPriestClass();
break;
case "Hat_Mushroom":
ClassManager.ActivateMushroomancerClass();
break;
case "Hat_Propeller":
ClassManager.ActivateGreatEpeeClass();
break;
case "Hat_NinjaHeadband":
ClassManager.ActivateRogueClass();
break;
case "Hat_Bandana":
ClassManager.ActivateBillClass();
break;
case "Hat_Astronaut":
ClassManager.ActivateAstronautClass();
break;
default:
ClassManager.DeactivateAllClasses();
break;
}
}
if ((Object)(object)Character.localCharacter != (Object)null && (Object)(object)GUIManager.instance?.bar != (Object)null)
{
GUIManager.instance.bar.ChangeBar();
}
}
}
[HarmonyPatch(typeof(RunManager), "StartRun")]
public class RunManager_StartRun_Patch
{
[CompilerGenerated]
private sealed class <AddEffectsDelayed>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
private Character <lc>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <AddEffectsDelayed>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<lc>5__1 = null;
<>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
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(8f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<lc>5__1 = Character.localCharacter;
if ((Object)(object)<lc>5__1 == (Object)null)
{
return false;
}
if (ClassCheckUtil.IsMushroom(<lc>5__1))
{
ClassManager.ActivateMushroomancerClass();
((MonoBehaviour)<lc>5__1).StartCoroutine(ClassManager.MushroomancerLocalStaminaWatch(<lc>5__1));
}
else if (ClassCheckUtil.IsBill(<lc>5__1))
{
ClassManager.ActivateBillClass();
CharacterRefs refs = <lc>5__1.refs;
if (refs != null)
{
CharacterAfflictions afflictions = refs.afflictions;
if (afflictions != null)
{
afflictions.SetStatus((STATUSTYPE)5, 0.35f, true);
}
}
}
else if (ClassCheckUtil.IsGreatEpeeHat(<lc>5__1))
{
ClassManager.ActivateGreatEpeeClass();
((MonoBehaviour)<lc>5__1).StartCoroutine(ClassManager.GreatEpeePermanentEffects(<lc>5__1));
((MonoBehaviour)<lc>5__1).StartCoroutine(ClassManager.GreatEpeeStaminaRoutine(<lc>5__1));
}
else if (ClassCheckUtil.IsMedicHat(<lc>5__1))
{
ClassManager.ActivateMedicClass();
CharacterRefs refs2 = <lc>5__1.refs;
if (refs2 != null)
{
CharacterAfflictions afflictions2 = refs2.afflictions;
if (afflictions2 != null)
{
afflictions2.SetStatus((STATUSTYPE)5, 0.15f, true);
}
}
}
else if (ClassCheckUtil.IsAstronaut(<lc>5__1))
{
ClassManager.ActivateAstronautClass();
}
else if (ClassCheckUtil.IsTechPriest(<lc>5__1))
{
ClassManager.ActivateTechPriestClass();
}
else if (ClassCheckUtil.IsRogueHat(<lc>5__1))
{
ClassManager.ActivateRogueClass();
}
else if (HatUtils.HasHat(<lc>5__1, "Hat_Scout"))
{
ClassManager.ActivateScoutClass();
}
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 static void Postfix()
{
PeakClassModPlugin.GivenActorsThisScene.Clear();
((MonoBehaviour)PeakClassModPlugin.Instance).StartCoroutine(PeakClassModPlugin.Instance.SmartGiveItemsRoutine());
((MonoBehaviour)PeakClassModPlugin.Instance).StartCoroutine(AddEffectsDelayed());
}
[IteratorStateMachine(typeof(<AddEffectsDelayed>d__1))]
public static IEnumerator AddEffectsDelayed()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <AddEffectsDelayed>d__1(0);
}
}
[HarmonyPatch(typeof(Character), "UseStamina")]
public class Character_UseStamina_Patch
{
private static void Prefix(Character __instance, ref float usage)
{
if (ClassManager.IsScoutActive())
{
usage *= 0.8f;
}
if (ClassManager.IsRogueActive())
{
usage *= 2f;
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")]
public class General_AddStatus_Patch
{
private static bool Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref float amount)
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Invalid comparison between Unknown and I4
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Invalid comparison between Unknown and I4
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Invalid comparison between Unknown and I4
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Invalid comparison between Unknown and I4
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Invalid comparison between Unknown and I4
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Invalid comparison between Unknown and I4
Character character = __instance.character;
if ((Object)(object)character == (Object)null)
{
return true;
}
if (character.IsLocal)
{
if (ClassManager.IsAstronautActive() && (int)statusType == 1)
{
amount *= 1.3f;
}
if (ClassManager.IsScoutActive() && (int)statusType == 1)
{
amount *= 1.7f;
}
if (ClassManager.IsBillActive() && (int)statusType == 1)
{
amount *= 2f;
if (amount > 0f)
{
ManualLogSource log = PeakClassModPlugin.Log;
if (log != null)
{
log.LogInfo((object)$"[Bill] Hunger added x2: {amount}");
}
}
}
}
if ((int)statusType == 1 && ClassCheckUtil.IsTechPriest(character) && ClassManager.IsTechPriestActive())
{
amount = 0f;
}
if ((int)statusType == 7 && ClassCheckUtil.IsTechPriest(character) && ClassManager.IsTechPriestActive())
{
amount = 0f;
}
if ((int)statusType == 3 && ClassCheckUtil.IsMushroom(character))
{
amount = 0f;
}
return true;
}
}
[HarmonyPatch(typeof(BarAffliction), "ChangeAffliction")]
public class BarAffliction_Patch
{
private static void Postfix(BarAffliction __instance)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
if (!((Object)(object)Character.localCharacter == (Object)null) && (int)__instance.afflictionType == 7)
{
if (ClassManager.IsScoutActive())
{
__instance.size *= 0.5f;
}
if (ClassManager.IsBillActive())
{
__instance.size *= 2f;
}
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "get_statusSum")]
public class StatusSum_Patch
{
private static void Postfix(CharacterAfflictions __instance, ref float __result)
{
if (!((Object)(object)__instance.character == (Object)null) && __instance.character.IsLocal)
{
float currentStatus = __instance.GetCurrentStatus((STATUSTYPE)7);
if (ClassManager.IsScoutActive())
{
__result = __result - currentStatus + currentStatus * 0.5f;
}
if (ClassManager.IsBillActive())
{
__result = __result - currentStatus + currentStatus * 2f;
}
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "SetStatus")]
public class SetStatus_Medic_Patch
{
private static void Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref float amount)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)statusType == 5 && amount == 0f && ClassCheckUtil.IsMedicHat(__instance.character))
{
amount = __instance.GetCurrentStatus((STATUSTYPE)5);
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "SubtractStatus")]
public class SubtractStatus_Medic_Patch
{
private static void Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref bool __state)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Invalid comparison between Unknown and I4
__state = (int)statusType == 5 && ClassCheckUtil.IsMedicHat(__instance.character);
}
private static void Postfix(CharacterAfflictions __instance, STATUSTYPE statusType, bool __state)
{
if (__state)
{
__instance.currentStatuses[5] = 0.15f;
}
}
}
[HarmonyPatch(typeof(Affliction_ClearAllStatus), "OnApplied")]
public class ClearAllStatus_Patch
{
private static void Prefix(Affliction_ClearAllStatus __instance)
{
if (ClassCheckUtil.IsMedicHat(((Affliction)__instance).character))
{
__instance.excludeCurse = true;
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "ClearAllStatus")]
public class ClearAllStatus_Method_Patch
{
private static void Prefix(CharacterAfflictions __instance, ref bool excludeCurse)
{
if (ClassCheckUtil.IsMedicHat(__instance.character))
{
excludeCurse = true;
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions), "UpdateNormalStatuses")]
public class UpdateStatus_TechPriest_Patch
{
private static void Prefix(CharacterAfflictions __instance)
{
if (ClassCheckUtil.IsTechPriest(__instance.character) && ClassManager.IsTechPriestActive())
{
__instance.currentStatuses[1] = 0f;
__instance.currentStatuses[7] = 0f;
}
}
}
internal static class TechPriestBlocker
{
public static bool ShouldBlockItem(Item item)
{
if ((Object)(object)item == (Object)null)
{
return false;
}
if ((Object)(object)((Component)item).GetComponent<Action_RestoreHunger>() != (Object)null || (Object)(object)((Component)item).GetComponent<Action_GiveExtraStamina>() != (Object)null)
{
return true;
}
string text = ((Object)item).name.Replace("(Clone)", "").Trim().ToLower();
if (text.Contains("bandage") || text.Contains("firstaid") || text.Contains("medkit") || text.Contains("cure") || text.Contains("marshmallow"))
{
ManualLogSource log = PeakClassModPlugin.Log;
if (log != null)
{
log.LogInfo((object)("[TechPriest] Blocked item usage by Name: " + text));
}
return true;
}
MonoBehaviour[] components = ((Component)item).GetComponents<MonoBehaviour>();
foreach (MonoBehaviour val in components)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
string text2 = ((object)val).GetType().Name.ToLower();
if (text2.Contains("heal") || text2.Contains("cure") || text2.Contains("medicine") || text2.Contains("restorehealth"))
{
ManualLogSource log2 = PeakClassModPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)("[TechPriest] Blocked item usage by Component: " + text2));
}
return true;
}
}
return false;
}
}
[HarmonyPatch(typeof(Item), "StartUsePrimary")]
public class TechPriestConsumablePatch1
{
private static bool Prefix(Item __instance)
{
if (ClassCheckUtil.IsTechPriest((__instance != null) ? __instance.holderCharacter : null))
{
if (TechPriestBlocker.ShouldBlockItem(__instance))
{
return false;
}
Action_ApplyAffliction component = ((Component)__instance).GetComponent<Action_ApplyAffliction>();
if ((Object)(object)component != (Object)null && component.affliction != null && ((object)component.affliction).GetType().Name.Contains("FasterBoi"))
{
return false;
}
}
return true;
}
}
[HarmonyPatch(typeof(Item), "StartUseSecondary")]
public class TechPriestConsumablePatch2
{
private static bool Prefix(Item __instance)
{
if (ClassCheckUtil.IsTechPriest((__instance != null) ? __instance.holderCharacter : null))
{
if (TechPriestBlocker.ShouldBlockItem(__instance))
{
return false;
}
Action_ApplyAffliction component = ((Component)__instance).GetComponent<Action_ApplyAffliction>();
if ((Object)(object)component != (Object)null && component.affliction != null && ((object)component.affliction).GetType().Name.Contains("FasterBoi"))
{
return false;
}
}
return true;
}
}
[HarmonyPatch(typeof(Affliction_FasterBoi), "OnApplied")]
public class TechPriestFasterBoiBlock
{
private static bool Prefix(Affliction_FasterBoi __instance)
{
return !ClassCheckUtil.IsTechPriest(((Affliction)__instance).character);
}
}
[HarmonyPatch(typeof(Character), "AddExtraStamina")]
public class TechPriestStaminaPatch1
{
private static bool Prefix(Character __instance)
{
return !ClassCheckUtil.IsTechPriest(__instance);
}
}
[HarmonyPatch(typeof(Affliction_InfiniteStamina), "OnApplied")]
public class TechPriestStaminaPatch2
{
private static bool Prefix(Affliction_InfiniteStamina __instance)
{
return !ClassCheckUtil.IsTechPriest(((Affliction)__instance).character);
}
}
[HarmonyPatch(typeof(Affliction_InfiniteStamina), "UpdateEffect")]
public class TechPriestStaminaPatch2_Update
{
private static bool Prefix(Affliction_InfiniteStamina __instance)
{
return !ClassCheckUtil.IsTechPriest(((Affliction)__instance).character);
}
}
[HarmonyPatch(typeof(Affliction_PoisonOverTime), "OnApplied")]
public class PoisonPatch
{
private static bool Prefix(Affliction_PoisonOverTime __instance)
{
return !ClassCheckUtil.IsMushroom(((Affliction)__instance).character);
}
}
[HarmonyPatch(typeof(CharacterMovement), "EvaluateGroundChecks")]
public class RogueJumpPatch
{
private static void Postfix(CharacterMovement __instance)
{
Character component = ((Component)__instance).GetComponent<Character>();
if ((Object)(object)component != (Object)null && component.IsLocal && PeakClassModPlugin.rogueActive)
{
component.data.jumpsRemaining = 2;
}
}
}
[HarmonyPatch(typeof(CharacterMovement), "TryToJump")]
public class RogueJumpRPCPatch
{
private static bool Prefix(CharacterMovement __instance)
{
Character component = ((Component)__instance).GetComponent<Character>();
if ((Object)(object)component != (Object)null && component.IsLocal && PeakClassModPlugin.rogueActive && component.data.jumpsRemaining > 0 && component.data.currentStamina > 0.005f)
{
CharacterData data = component.data;
data.jumpsRemaining--;
component.data.chargingJump = true;
component.refs.view.RPC("JumpRpc", (RpcTarget)0, new object[1] { false });
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Character), "ShowMedicHealEffectRPC")]
public class MedicRPC_Patch
{
private static void Postfix()
{
}
}