using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HatBuffs.Config;
using Microsoft.CodeAnalysis;
using PEAKLib.Core;
using PEAKLib.Items.UnityEditor;
using Peak.Afflictions;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core.Serizalization;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HatBuffs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+da4c4727f3693ebec58777aefc323637570d4731")]
[assembly: AssemblyProduct("HatBuffs")]
[assembly: AssemblyTitle("HatBuffs")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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;
}
}
}
namespace HatBuffs
{
[Serializable]
public class Affliction_Aggro : Affliction
{
public float moveSpeedMod = 0.35f;
public float climbSpeedMod = 0.35f;
public float injury;
public float climbDelay;
public override AfflictionType GetAfflictionType()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return (AfflictionType)2;
}
public override void Stack(Affliction incomingAffliction)
{
base.totalTime = Mathf.Max(base.totalTime, incomingAffliction.totalTime);
}
protected override void UpdateEffect()
{
if (base.character.data.isClimbing)
{
climbDelay = 0f;
base.bonusTime = 0f;
}
if (base.character.refs.afflictions.currentStatuses[0] > 0.05f)
{
float num = base.character.refs.afflictions.currentStatuses[0] - injury;
base.character.refs.afflictions.currentStatuses[0] = injury;
injury += num;
}
}
public override void OnApplied()
{
((Affliction)this).OnApplied();
CharacterMovement movement = base.character.refs.movement;
movement.movementModifier += moveSpeedMod;
CharacterClimbing climbing = base.character.refs.climbing;
climbing.climbSpeedMod += climbSpeedMod;
CharacterRopeHandling ropeHandling = base.character.refs.ropeHandling;
ropeHandling.climbSpeedMod += climbSpeedMod;
CharacterVineClimbing vineClimbing = base.character.refs.vineClimbing;
vineClimbing.climbSpeedMod += climbSpeedMod;
if (base.character.IsLocal)
{
GUIManager.instance.StartHeat();
}
injury = base.character.refs.afflictions.GetCurrentStatus((STATUSTYPE)0);
base.character.refs.afflictions.SetStatus((STATUSTYPE)0, Math.Min(injury, 0.05f), true);
base.bonusTime = climbDelay;
}
public override void OnRemoved()
{
((Affliction)this).OnRemoved();
CharacterMovement movement = base.character.refs.movement;
movement.movementModifier -= moveSpeedMod;
CharacterClimbing climbing = base.character.refs.climbing;
climbing.climbSpeedMod -= climbSpeedMod;
CharacterRopeHandling ropeHandling = base.character.refs.ropeHandling;
ropeHandling.climbSpeedMod -= climbSpeedMod;
CharacterVineClimbing vineClimbing = base.character.refs.vineClimbing;
vineClimbing.climbSpeedMod -= climbSpeedMod;
base.character.refs.afflictions.AddStatus((STATUSTYPE)0, Math.Max(injury - 0.05f, 0.05f), false, true, true, false);
if (base.character.IsLocal)
{
GUIManager.instance.EndHeat();
}
}
public override void Serialize(BinarySerializer serializer)
{
serializer.WriteFloat(base.totalTime);
serializer.WriteFloat(moveSpeedMod);
serializer.WriteFloat(climbSpeedMod);
serializer.WriteFloat(climbDelay);
}
public override void Deserialize(BinaryDeserializer serializer)
{
base.totalTime = serializer.ReadFloat();
moveSpeedMod = serializer.ReadFloat();
climbSpeedMod = serializer.ReadFloat();
climbDelay = serializer.ReadFloat();
base.bonusTime = climbDelay;
}
}
[BepInPlugin("hatbuffs.stykbug.peak", "Hat Buffs", "0.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource? logger;
private static readonly Harmony harmony = new Harmony("com.stykbug.hatbuffs");
public static GameObject? hat;
private bool done = false;
public static GameObject? magicBeanPrefab;
public static GameObject[] bigPotionPrefabs = (GameObject[])(object)new GameObject[3];
public static GameObject[] lilPotionPrefabs = (GameObject[])(object)new GameObject[6];
public static GameObject? vialPrefab;
public static SFX_Instance[]? audClips;
public void Awake()
{
logger = ((BaseUnityPlugin)this).Logger;
PluginConfig.RegisterConfigs(((BaseUnityPlugin)this).Config);
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "hatmagicbean.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("HatMagicBean");
magicBeanPrefab = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "smallpotion1.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("SPotion1");
lilPotionPrefabs[0] = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "smallpotion2.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("SPotion2");
lilPotionPrefabs[1] = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "smallpotion3.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("SPotion3");
lilPotionPrefabs[2] = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "smallpotion4.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("SPotion4");
lilPotionPrefabs[3] = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "smallpotion5.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("SPotion5");
lilPotionPrefabs[4] = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "smallpotion6.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("SPotion6");
lilPotionPrefabs[5] = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "largepotion1.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("LPotion1");
bigPotionPrefabs[0] = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "largepotion2.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("LPotion2");
bigPotionPrefabs[1] = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "largepotion3.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("LPotion3");
bigPotionPrefabs[2] = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "stamina_vial.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("Stamina Vial");
vialPrefab = val.ItemPrefab;
peakBundle.Mod.RegisterContent();
});
BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "audio.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle)
{
UnityItemContent val = peakBundle.LoadAsset<UnityItemContent>("AUDIO");
audClips = val.ItemPrefab.GetComponent<ItemUseFeedback>().equip;
peakBundle.Mod.RegisterContent();
});
}
public void Update()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_08f5: Unknown result type (might be due to invalid IL or missing references)
//IL_08fc: Expected O, but got Unknown
//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0808: Expected O, but got Unknown
//IL_0a81: Unknown result type (might be due to invalid IL or missing references)
//IL_0a88: Expected O, but got Unknown
//IL_0c06: Unknown result type (might be due to invalid IL or missing references)
//IL_0c0d: Expected O, but got Unknown
//IL_0c52: Unknown result type (might be due to invalid IL or missing references)
//IL_0c59: Expected O, but got Unknown
//IL_0dfe: Unknown result type (might be due to invalid IL or missing references)
//IL_0e05: Expected O, but got Unknown
//IL_0b5e: Unknown result type (might be due to invalid IL or missing references)
//IL_0b65: Expected O, but got Unknown
//IL_0fdf: Unknown result type (might be due to invalid IL or missing references)
//IL_0fe6: Expected O, but got Unknown
//IL_0afb: Unknown result type (might be due to invalid IL or missing references)
//IL_0b02: Expected O, but got Unknown
//IL_099e: Unknown result type (might be due to invalid IL or missing references)
//IL_09a5: Expected O, but got Unknown
//IL_0893: Unknown result type (might be due to invalid IL or missing references)
//IL_08a0: Expected O, but got Unknown
//IL_0e78: Unknown result type (might be due to invalid IL or missing references)
//IL_0e7f: Expected O, but got Unknown
//IL_0ec4: Unknown result type (might be due to invalid IL or missing references)
//IL_0ecb: Expected O, but got Unknown
//IL_0ccc: Unknown result type (might be due to invalid IL or missing references)
//IL_0cd3: Expected O, but got Unknown
//IL_0f3e: Unknown result type (might be due to invalid IL or missing references)
//IL_0f45: Expected O, but got Unknown
//IL_0f8a: Unknown result type (might be due to invalid IL or missing references)
//IL_0f91: Expected O, but got Unknown
Scene activeScene = SceneManager.GetActiveScene();
string name = ((Scene)(ref activeScene)).name;
if (name.StartsWith("Level_"))
{
if (!done)
{
hat = GetHat(((Component)Character.localCharacter).gameObject);
switch (((Object)hat).name)
{
case "Fedora":
hat.AddComponent<FedoraHat>();
done = true;
break;
case "Hat.001":
hat.AddComponent<PropellerHat>();
done = true;
break;
case "StrawHat":
hat.AddComponent<SunHat>();
done = true;
break;
case "AviatorHat":
{
hat.AddComponent<AviatorHat>();
MethodInfo method31 = typeof(CharacterAfflictions).GetMethod("AddStatus", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method32 = typeof(AviatorHat).GetMethod("ColdPatch", BindingFlags.Static | BindingFlags.NonPublic);
harmony.Patch((MethodBase)method31, new HarmonyMethod(method32), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "SailorHat":
hat.AddComponent<SailorHat>();
done = true;
break;
case "MedicHelmet":
hat.AddComponent<MedicHat>();
done = true;
break;
case "Midsummer":
{
hat.AddComponent<FloraRingHat>();
hat.AddComponent<MushroomExpert>();
MethodInfo method29 = typeof(InventoryItemUI).GetMethod("UpdateNameText", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method30 = typeof(MushroomExpert).GetMethod("NamePatch", BindingFlags.Static | BindingFlags.NonPublic);
harmony.Patch((MethodBase)method29, (HarmonyMethod)null, new HarmonyMethod(method30), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "MushroomHat":
{
hat.AddComponent<MushroomHat>();
hat.AddComponent<MushroomExpert>();
MethodInfo method27 = typeof(InventoryItemUI).GetMethod("UpdateNameText", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method28 = typeof(MushroomExpert).GetMethod("NamePatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val14 = new HarmonyMethod(method28);
harmony.Patch((MethodBase)method27, (HarmonyMethod)null, val14, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "CrabHat":
done = true;
break;
case "CourierHat":
hat.AddComponent<SpeedrunHat>();
done = true;
break;
case "ScoutmasterHat":
hat.AddComponent<ScoutmasterHat>();
done = true;
break;
case "Bandana":
done = true;
break;
case "NinjaHeadband":
{
hat.AddComponent<NarutoHat>();
MethodInfo method25 = typeof(CharacterMovement).GetMethod("AcceptableAngle", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method26 = typeof(NarutoHat).GetMethod("AnglePatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val13 = new HarmonyMethod(method26);
harmony.Patch((MethodBase)method25, val13, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "ChefHat":
hat.AddComponent<ChefHat>();
done = true;
break;
case "WizardHat":
hat.AddComponent<WitchHat>();
done = true;
break;
case "WolfEars":
hat.AddComponent<WolfHat>();
done = true;
break;
case "Crown":
hat.AddComponent<CrownHat>();
done = true;
break;
case "Goat":
hat.AddComponent<GoatHat>();
done = true;
break;
case "DesertHat":
case "StrawSunHat":
{
SunHat sunHat = hat.AddComponent<SunHat>();
sunHat.cap = 0.8f;
MethodInfo method23 = typeof(CharacterAfflictions).GetMethod("AddStatus", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method24 = typeof(SunHat).GetMethod("HeatPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val12 = new HarmonyMethod(method24);
harmony.Patch((MethodBase)method23, val12, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "SunVisorHat":
hat.AddComponent<VisorHat>();
done = true;
break;
case "CowboyHat":
{
hat.AddComponent<CowboyHat>();
MethodInfo method21 = typeof(Item).GetMethod("Interact", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method22 = typeof(CowboyHat).GetMethod("LauncherPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val11 = new HarmonyMethod(method22);
harmony.Patch((MethodBase)method21, (HarmonyMethod)null, val11, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "Ice Hood Blue":
case "Ice Hood Pink":
{
hat.AddComponent<IceClimbHat>();
MethodInfo method19 = typeof(CharacterAfflictions).GetMethod("AddStatus", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method20 = typeof(IceClimbHat).GetMethod("HeatPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val10 = new HarmonyMethod(method20);
harmony.Patch((MethodBase)method19, val10, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "BBHat":
hat.AddComponent<BingBongHat>();
done = true;
break;
case "Racing Helmet":
hat.AddComponent<RacingHat>();
done = true;
break;
case "SpaceHelmet White":
hat.AddComponent<AstronautHat>();
done = true;
break;
case "PumpkinHead":
{
hat.AddComponent<PumpkinHat>();
MethodInfo method15 = typeof(Mob).GetMethod("TargetValid", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method16 = typeof(PumpkinHat).GetMethod("MobTargetPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val8 = new HarmonyMethod(method16);
harmony.Patch((MethodBase)method15, (HarmonyMethod)null, val8, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo method17 = typeof(MushroomZombie).GetMethod("SetCurrentTarget", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo method18 = typeof(PumpkinHat).GetMethod("ZombieTargetPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val9 = new HarmonyMethod(method18);
harmony.Patch((MethodBase)method17, val9, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "MummyHat":
hat.AddComponent<MummyHat>();
done = true;
break;
case "Antlers":
{
hat.AddComponent<AntlerHat>();
MethodInfo method13 = typeof(CharacterAfflictions).GetMethod("AddStatus", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method14 = typeof(AntlerHat).GetMethod("InjuryPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val7 = new HarmonyMethod(method14);
harmony.Patch((MethodBase)method13, val7, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "GnomeHat":
hat.AddComponent<GnomeHat>();
done = true;
break;
case "PlagueDoctor":
hat.AddComponent<PlagueDoctorHat>();
done = true;
break;
case "ClimbingHelmet":
hat.AddComponent<ClimbingHat>();
done = true;
break;
case "NumberOne":
hat.AddComponent<DrinkingHat>();
done = true;
break;
case "FlowerHat":
hat.AddComponent<FairyHat>();
done = true;
break;
case "Sprout":
hat.AddComponent<SproutHat>();
done = true;
break;
case "FlapperHat":
hat.AddComponent<WeirdHat>();
done = true;
break;
case "JesterHat":
hat.AddComponent<JesterHat>();
done = true;
break;
case "SleepyGuyHat":
hat.AddComponent<NapCapHat>();
done = true;
break;
case "ArrowHat":
{
hat.AddComponent<ArrowHat>();
MethodInfo method11 = typeof(CharacterAfflictions).GetMethod("AddStatus", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method12 = typeof(ArrowHat).GetMethod("InjuryPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val6 = new HarmonyMethod(method12);
harmony.Patch((MethodBase)method11, val6, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "LaurelHat":
hat.AddComponent<LaurelHat>();
done = true;
break;
case "KnightHelmet":
{
hat.AddComponent<KnightHat>();
MethodInfo method7 = typeof(CharacterAfflictions).GetMethod("SetStatus", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method8 = typeof(KnightHat).GetMethod("WeightPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val4 = new HarmonyMethod(method8);
harmony.Patch((MethodBase)method7, val4, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo method9 = typeof(CharacterAfflictions).GetMethod("AddStatus", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method10 = typeof(KnightHat).GetMethod("InjuryPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val5 = new HarmonyMethod(method10);
harmony.Patch((MethodBase)method9, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "FrogHat":
hat.AddComponent<FrogHat>();
done = true;
break;
case "GothicHat":
{
hat.AddComponent<GothicHat>();
MethodInfo method3 = typeof(CharacterAfflictions).GetMethod("AddAffliction", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method4 = typeof(GothicHat).GetMethod("NumbPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val2 = new HarmonyMethod(method4);
harmony.Patch((MethodBase)method3, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo method5 = typeof(CharacterAfflictions).GetMethod("AddStatus", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method6 = typeof(GothicHat).GetMethod("InjuryPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val3 = new HarmonyMethod(method6);
harmony.Patch((MethodBase)method5, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
case "StarboyHat":
{
MethodInfo method = typeof(CharacterData).GetMethod("SetPetrify", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method2 = typeof(StarboyHat).GetMethod("PetrifyPatch", BindingFlags.Static | BindingFlags.NonPublic);
HarmonyMethod val = new HarmonyMethod(method2);
harmony.Patch((MethodBase)method, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
done = true;
break;
}
}
}
}
else if (name == "Airport" && done)
{
done = false;
harmony.UnpatchSelf();
}
}
public static GameObject GetHat(GameObject localPlayer)
{
Renderer[] playerHats = localPlayer.GetComponent<CharacterCustomization>().refs.playerHats;
Renderer[] array = playerHats;
foreach (Renderer val in array)
{
if (((Component)val).gameObject.activeSelf)
{
return ((Component)val).gameObject;
}
}
return ((Component)playerHats[0]).gameObject;
}
}
public abstract class HatBase : MonoBehaviour
{
protected static Character localPlayer => Character.localCharacter;
protected static void PlaySound(SFX_Instance sfx)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = localPlayer.refs.hip.transform.position;
sfx.Play(position);
}
}
public abstract class HatAbility : HatBase
{
protected float cd = 0f;
protected static KeyCode button = PluginConfig.keycode.Value;
protected bool oneFrameOnly = false;
private static UI_Cooldown? uiCD;
protected abstract int cdMax { get; }
private static GameObject? uiOG => ((Component)((Component)GUIManager.instance).transform.GetChild(0).GetChild(4)).gameObject;
public void Start()
{
uiCD = MakeUI(1);
StartUp();
}
public void Update()
{
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
if (!HatBase.localPlayer.IsGhost)
{
((Behaviour)uiCD.fill).enabled = true;
((Behaviour)uiCD.empty).enabled = true;
if (cd > 0f)
{
uiCD.UpdateFill(Math.Max(cd, 0f), cdMax);
cd -= Time.deltaTime;
if (!oneFrameOnly)
{
oneFrameOnly = true;
}
return;
}
if (oneFrameOnly)
{
uiCD.UpdateFill(0f, cdMax);
HatBase.PlaySound(Plugin.audClips[0]);
oneFrameOnly = false;
}
if (Input.GetKeyDown(button))
{
RunAbility();
}
}
else
{
((Behaviour)uiCD.fill).enabled = false;
((Behaviour)uiCD.empty).enabled = false;
cd = 0f;
}
}
public virtual void StartUp()
{
}
public abstract void RunAbility();
public UI_Cooldown MakeUI(int num)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(uiOG);
val.transform.parent = uiOG.transform.parent;
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMax = new Vector2(1f, 1f);
component.anchorMin = new Vector2(1f, 1f);
component.anchoredPosition = new Vector2(-100f, (float)(num * -100));
float num2 = (float)(num - 1) * -0.075f + 1f;
((Transform)component).localScale = new Vector3(num2, num2, num2);
Object.Destroy((Object)(object)val.GetComponent<UI_UseItemProgress>(), 0f);
UI_Cooldown uI_Cooldown = val.AddComponent<UI_Cooldown>();
uI_Cooldown.color = new Color(0.75f, 0.275f, 1f, 1f);
return uI_Cooldown;
}
}
public class FedoraHat : HatBase
{
public void Start()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
((Component)HatBase.localPlayer).transform.localScale = new Vector3(1.233f, 1.233f, 1.233f);
((Component)((Component)HatBase.localPlayer).transform.GetChild(2)).GetComponent<AudioSource>().pitch = 0.9f;
CharacterAfflictions afflictions = HatBase.localPlayer.refs.afflictions;
afflictions.hungerPerSecond *= 3f;
CharacterMovement movement = HatBase.localPlayer.refs.movement;
movement.movementModifier *= 0.933f;
}
public void Update()
{
if (HatBase.localPlayer.refs.afflictions.currentStatuses[2] > 0f)
{
HatBase.localPlayer.refs.afflictions.currentStatuses[2] = 0f;
}
}
}
public class PropellerHat : HatBase
{
public void Start()
{
HatBase.localPlayer.refs.movement.gravityCurveSpeed = 0.23f;
HatBase.localPlayer.refs.movement.maxGravity = -300f;
}
}
[HarmonyPatch(typeof(CharacterAfflictions))]
public class SunHat : HatBase
{
public float cap = 0.4f;
public void Update()
{
if (HatBase.localPlayer.refs.afflictions.GetCurrentStatus((STATUSTYPE)8) > cap)
{
HatBase.localPlayer.refs.afflictions.SetStatus((STATUSTYPE)8, cap, true);
}
}
[HarmonyPatch("AddStatus")]
[HarmonyPrefix]
private static void HeatPatch(ref STATUSTYPE ___statusType, ref float ___amount, ref float[] ___currentStatuses)
{
if ((int)___statusType == 8)
{
___amount /= 2f;
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions))]
public class AviatorHat : HatBase
{
public void Start()
{
HatBase.localPlayer.refs.movement.drag = 0.88f;
}
[HarmonyPatch("AddStatus")]
[HarmonyPrefix]
private static void ColdPatch(ref STATUSTYPE ___statusType, ref float ___amount)
{
Plugin.logger.LogInfo((object)"coldpatch");
if ((int)___statusType == 2)
{
___amount /= 2f;
}
}
}
public class SailorHat : HatBase
{
public void Start()
{
HatBase.localPlayer.data.lastFroggedTime = 2E+09f;
}
public void Update()
{
if (HatBase.localPlayer.data.isInWater)
{
HatBase.localPlayer.refs.movement.movementModifier = 1.5f;
}
else
{
HatBase.localPlayer.refs.movement.movementModifier = 1f;
}
}
}
public class MedicHat : HatAbility
{
protected override int cdMax => 300;
public override void RunAbility()
{
if (HatBase.localPlayer.refs.afflictions.currentStatuses[0] > 0f)
{
HatBase.localPlayer.refs.afflictions.SubtractStatus((STATUSTYPE)0, 0.35f, false, false);
cd = cdMax;
HatBase.PlaySound(Plugin.audClips[1]);
}
}
}
public class FloraRingHat : HatBase
{
public void Start()
{
HatBase.localPlayer.refs.vineClimbing.slideDeceleration = 1f;
CharacterVineClimbing vineClimbing = HatBase.localPlayer.refs.vineClimbing;
vineClimbing.climbSpeed *= 1.25f;
}
}
public class MushroomHat : HatBase
{
private float buffer;
public void Update()
{
if (HatBase.localPlayer.data.isCrouching)
{
buffer = 0.13f;
}
if (buffer > 0f)
{
HatBase.localPlayer.refs.movement.jumpImpulse = 1250f;
HatBase.localPlayer.refs.movement.jumpStaminaUsage = 0.115f;
buffer -= Time.deltaTime;
}
else
{
HatBase.localPlayer.refs.movement.jumpStaminaUsage = 0.05f;
HatBase.localPlayer.refs.movement.jumpImpulse = 400f;
}
if (buffer > 0f && HatBase.localPlayer.input.jumpIsPressed)
{
HatBase.PlaySound(Plugin.audClips[2]);
buffer = 0f;
}
}
}
[HarmonyPatch(typeof(InventoryItemUI))]
public class MushroomExpert : HatBase
{
private static string GetRevealedName(Action_RandomMushroomEffect effect)
{
return MushroomManager.instance.mushroomEffects[effect.mushroomTypeIndex] switch
{
0 => "HYPER SHROOM",
1 => "HASTY SHROOM",
2 => "SLOW-FALL SHROOM",
3 => "GUARDING SHROOM",
4 => "REJUVENATING SHROOM",
5 => "BEANS",
6 => "BLINDNESS SHROOM",
7 => "NAPPING SHROOM",
8 => "OVERGROWN SHROOM",
9 => "NUMBNESS SHROOM",
_ => "SOMETHING WENT HORRIBLY WRONG",
};
}
[HarmonyPatch("UpdateNameText")]
[HarmonyPostfix]
private static void NamePatch(ref TextMeshProUGUI ___nameText, ref Item ____itemPrefab)
{
Action_RandomMushroomEffect effect = default(Action_RandomMushroomEffect);
if ((Object)(object)____itemPrefab != (Object)null && ((Component)____itemPrefab).gameObject.TryGetComponent<Action_RandomMushroomEffect>(ref effect))
{
((TMP_Text)___nameText).text = GetRevealedName(effect);
}
}
}
public class CrabHat : HatAbility
{
private Affliction_Aggro aggro = new Affliction_Aggro
{
totalTime = 10f
};
protected override int cdMax => 150;
public override void StartUp()
{
((Affliction)aggro).character = HatBase.localPlayer;
}
public void FixedUpdate()
{
if (HatBase.localPlayer.refs.afflictions.afflictionList.OfType<Affliction_Aggro>().Any() && HatBase.localPlayer.input.useSecondaryWasPressed)
{
HatBase.localPlayer.refs.grabbing.KickCast();
}
}
public override void RunAbility()
{
HatBase.localPlayer.refs.afflictions.afflictionList.Add((Affliction)(object)aggro);
cd = cdMax;
}
}
public class SpeedrunHat : HatBase
{
public void Start()
{
CharacterMovement movement = HatBase.localPlayer.refs.movement;
movement.sprintMultiplier *= 1.4f;
CharacterMovement movement2 = HatBase.localPlayer.refs.movement;
movement2.sprintStaminaUsage *= 1.4f;
CharacterClimbing climbing = HatBase.localPlayer.refs.climbing;
climbing.climbSpeed *= 1.4f;
CharacterClimbing climbing2 = HatBase.localPlayer.refs.climbing;
climbing2.maxStaminaUsage *= 1.4f;
CharacterClimbing climbing3 = HatBase.localPlayer.refs.climbing;
climbing3.minStaminaUsage *= 1.4f;
}
}
public class ScoutmasterHat : HatAbility
{
protected override int cdMax => 200;
public override void RunAbility()
{
if ((double)HatBase.localPlayer.data.extraStamina < 0.95)
{
HatBase.localPlayer.AddExtraStamina(0.3f);
cd = cdMax;
HatBase.PlaySound(Plugin.audClips[3]);
}
}
}
public class BandanaHat : HatBase
{
public void Start()
{
}
}
[HarmonyPatch(typeof(CharacterMovement))]
public class NarutoHat : HatBase
{
public void Start()
{
CharacterMovement movement = HatBase.localPlayer.refs.movement;
movement.sprintMultiplier += 1.1f;
}
[HarmonyPatch("AcceptableAngle")]
[HarmonyPrefix]
private static void AnglePatch(ref float ___angle)
{
___angle += 8f;
}
}
public class ChefHat : HatAbility
{
protected override int cdMax => 170;
public override void RunAbility()
{
if ((Object)(object)HatBase.localPlayer.data.currentItem != (Object)null)
{
HatBase.localPlayer.data.currentItem.cooking.FinishCooking();
cd = cdMax;
}
}
}
public class WitchHat : HatAbility
{
protected override int cdMax => 90;
private Random rng => new Random((int)Time.time);
private Transform hip => HatBase.localPlayer.refs.hip.transform;
public override void RunAbility()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: 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_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)HatBase.localPlayer.data.currentItem != (Object)null && !(HatBase.localPlayer.data.currentItem is Backpack))
{
PhotonNetwork.Destroy(((Component)HatBase.localPlayer.data.currentItem).gameObject);
HatBase.localPlayer.player.EmptySlot(HatBase.localPlayer.refs.items.currentSelectedSlot, true);
if ((int)HatBase.localPlayer.data.currentItem.itemTags == 1)
{
int num = rng.Next(3);
GameObject val = PhotonNetwork.InstantiateItemRoom(((Object)Plugin.bigPotionPrefabs[num]).name, hip.position + hip.forward, Quaternion.identity, true);
val.GetComponent<Item>().Interact(HatBase.localPlayer);
}
else
{
int num2 = rng.Next(6);
GameObject val2 = PhotonNetwork.InstantiateItemRoom(((Object)Plugin.lilPotionPrefabs[num2]).name, hip.position + hip.forward, Quaternion.identity, true);
val2.GetComponent<Item>().Interact(HatBase.localPlayer);
}
GUIManager.instance.curseSVFX.Play(1f, false);
HatBase.PlaySound(Plugin.audClips[4]);
cd = cdMax;
}
}
}
public class WolfHat : HatBase
{
private bool away = false;
public void Start()
{
((MonoBehaviour)this).InvokeRepeating("CheckDistance", 5f, 1f);
}
private void CheckDistance()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
away = false;
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter != (Object)(object)HatBase.localPlayer && Vector3.Distance(allCharacter.refs.hip.transform.position, HatBase.localPlayer.refs.hip.transform.position) >= 45f)
{
away = true;
}
}
if (away)
{
HatBase.localPlayer.refs.movement.movementForce = 37.5f;
HatBase.localPlayer.refs.climbing.climbSpeed = 6.5f;
}
else
{
HatBase.localPlayer.refs.movement.movementForce = 25f;
HatBase.localPlayer.refs.climbing.climbSpeed = 4f;
}
}
}
public class CrownHat : HatAbility
{
private Affliction_Invincibility invi = new Affliction_Invincibility
{
isFromMilk = false,
totalTime = 5.5f,
timeElapsed = 0f,
isFromAmulet = false
};
protected override int cdMax => 240;
public override void StartUp()
{
((Affliction)invi).character = ((Component)HatBase.localPlayer).GetComponent<Character>();
}
public override void RunAbility()
{
HatBase.localPlayer.refs.afflictions.AddAffliction(((Affliction)invi).Copy(), false);
HatBase.PlaySound(Plugin.audClips[10]);
cd = cdMax;
}
}
public class GoatHat : HatAbility
{
private bool oneFrameOnly2 = true;
private float cd2 = 0f;
private UI_Cooldown? uiCD2;
protected override int cdMax => 20;
public override void StartUp()
{
uiCD2 = MakeUI(2);
}
public void FixedUpdate()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
if (cd2 > 0f)
{
if (!oneFrameOnly2)
{
oneFrameOnly2 = true;
}
cd2 -= Time.deltaTime;
uiCD2.UpdateFill(cd2, cdMax);
return;
}
if (oneFrameOnly2)
{
HatBase.PlaySound(HatBase.localPlayer.poofSFX[0]);
uiCD2.UpdateFill(0f, cdMax);
oneFrameOnly2 = false;
}
if (oneFrameOnly && Input.GetKeyDown(HatAbility.button))
{
RunAbility();
cd2 = cdMax;
}
}
public override void RunAbility()
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
if (HatBase.localPlayer.data.isGrounded && HatBase.localPlayer.data.worldMovementInput.x != 0f && HatBase.localPlayer.data.worldMovementInput.z != 0f)
{
HatBase.localPlayer.refs.movement.TryJumpOffVineOrRope();
float x = HatBase.localPlayer.data.worldMovementInput.x;
x *= 2250f;
float z = HatBase.localPlayer.data.worldMovementInput.z;
z *= 2250f;
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(x, -250f, z);
HatBase.localPlayer.RPCA_AddForceToBodyPart((BodypartType)0, Vector3.zero, val);
HatBase.PlaySound(Plugin.audClips[5]);
if (cd <= 0f)
{
cd = cdMax;
}
}
}
}
public class VisorHat : HatBase
{
public void Start()
{
CharacterItems items = HatBase.localPlayer.refs.items;
items.throwChargeTime *= 0.75f;
CharacterItems items2 = HatBase.localPlayer.refs.items;
items2.maxThrowForce *= 1.5f;
CharacterItems items3 = HatBase.localPlayer.refs.items;
items3.minThrowForce *= 1.5f;
}
public void FixedUpdate()
{
if (HatBase.localPlayer.refs.afflictions.GetCurrentStatus((STATUSTYPE)8) > 0.5f)
{
HatBase.localPlayer.refs.afflictions.SetStatus((STATUSTYPE)8, 0.5f, true);
}
}
}
[HarmonyPatch(typeof(Item))]
public class CowboyHat : HatBase
{
public void Start()
{
CharacterRopeHandling ropeHandling = HatBase.localPlayer.refs.ropeHandling;
ropeHandling.staminaUsageUp *= 0.8f;
CharacterRopeHandling ropeHandling2 = HatBase.localPlayer.refs.ropeHandling;
ropeHandling2.climbSpeed *= 1.3f;
}
[HarmonyPatch("Interact")]
[HarmonyPostfix]
private static void LauncherPatch(ref ItemComponent[] ___itemComponents)
{
//IL_001c: 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)
ItemComponent[] array = ___itemComponents;
foreach (ItemComponent val in array)
{
if (val is RopeShooter)
{
((RopeShooter)val).maxLength = 45f;
}
else if (val is VineShooter)
{
((VineShooter)val).maxLength = 55f;
}
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions))]
public class IceClimbHat : HatBase
{
public void Start()
{
CharacterAfflictions afflictions = HatBase.localPlayer.refs.afflictions;
afflictions.hotReductionCooldown *= 1.5f;
CharacterAfflictions afflictions2 = HatBase.localPlayer.refs.afflictions;
afflictions2.hotReductionPerSecond *= 0.9f;
}
public void Update()
{
if (HatBase.localPlayer.refs.afflictions.GetCurrentStatus((STATUSTYPE)2) > 0f)
{
HatBase.localPlayer.refs.afflictions.SetStatus((STATUSTYPE)2, 0f, true);
}
}
[HarmonyPatch("AddStatus")]
[HarmonyPrefix]
private static void HeatPatch(ref STATUSTYPE statusType, ref float amount)
{
if ((int)statusType == 8)
{
amount *= 1.5f;
}
}
}
public class BingBongHat : HatBase
{
private float sinceLastDecreased = 5f;
private string itemName => ((Object)HatBase.localPlayer.data.currentItem).name;
public void Update()
{
if (itemName == "BingBong(Clone)" && sinceLastDecreased >= 5f)
{
for (int i = 0; i < 15; i++)
{
if (i != 1 && i != 7 && i != 12 && HatBase.localPlayer.refs.afflictions.currentStatuses[i] > 0f)
{
HatBase.localPlayer.refs.afflictions.currentStatuses[i] = Math.Max(HatBase.localPlayer.refs.afflictions.currentStatuses[i] - 0.0125f, 0f);
}
}
sinceLastDecreased = 0f;
HatBase.PlaySound(Plugin.audClips[6]);
}
else
{
sinceLastDecreased += Time.deltaTime;
}
}
}
public class RacingHat : HatAbility
{
private Affliction_FasterBoi charge = new Affliction_FasterBoi
{
timeElapsed = 0f,
climbDelay = 3f,
drowsyOnEnd = 0.05f,
climbSpeedMod = 0.1f,
moveSpeedMod = 0.1f,
totalTime = 3f
};
private Affliction_FasterBoi? copy;
protected override int cdMax => 180;
public override void StartUp()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
((Affliction)charge).character = HatBase.localPlayer;
copy = (Affliction_FasterBoi)((Affliction)charge).Copy();
}
public override void RunAbility()
{
if (copy.drowsyOnEnd < 1f)
{
Affliction_FasterBoi? obj = copy;
obj.drowsyOnEnd += 0.025f;
}
if (copy.moveSpeedMod < 4f)
{
Affliction_FasterBoi? obj2 = copy;
Affliction_FasterBoi? obj3 = copy;
obj2.moveSpeedMod = (obj3.climbSpeedMod += 0.1f);
}
if (((Affliction)copy).totalTime < 10f)
{
Affliction_FasterBoi? obj4 = copy;
((Affliction)obj4).totalTime = ((Affliction)obj4).totalTime + 0.35f;
}
cd = 0.5f;
HatBase.PlaySound(Plugin.audClips[8]);
}
public void FixedUpdate()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (copy != charge && HatBase.localPlayer.data.worldMovementInput != new Vector3(0f, 0f, 0f))
{
HatBase.localPlayer.refs.afflictions.AddAffliction(((Affliction)copy).Copy(), false);
copy = charge;
cd = cdMax;
}
}
}
public class AstronautHat : HatAbility
{
private bool oneFrameOnly2 = true;
private float cd2 = 0f;
private UI_Cooldown? uiCD2;
private bool oneFrameOnly3 = true;
private float cd3 = 0f;
private UI_Cooldown? uiCD3;
protected override int cdMax => 240;
public override void StartUp()
{
CharacterBalloons balloons = HatBase.localPlayer.refs.balloons;
balloons.balloonFloatAmount *= 1.15f;
uiCD2 = MakeUI(2);
uiCD3 = MakeUI(3);
}
public void FixedUpdate()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
if (cd2 > 0f)
{
if (!oneFrameOnly2)
{
oneFrameOnly2 = true;
}
cd2 -= Time.deltaTime;
uiCD2.UpdateFill(cd2, cdMax);
}
else
{
if (oneFrameOnly2)
{
HatBase.PlaySound(HatBase.localPlayer.poofSFX[0]);
uiCD2.UpdateFill(0f, cdMax);
oneFrameOnly2 = false;
}
if (oneFrameOnly && Input.GetKeyDown(HatAbility.button))
{
RunAbility();
cd2 = cdMax;
}
}
if (cd3 > 0f)
{
if (!oneFrameOnly3)
{
oneFrameOnly3 = true;
}
cd3 -= Time.deltaTime;
uiCD3.UpdateFill(cd3, cdMax);
return;
}
if (oneFrameOnly3)
{
HatBase.PlaySound(HatBase.localPlayer.poofSFX[0]);
uiCD3.UpdateFill(0f, cdMax);
oneFrameOnly3 = false;
}
if (oneFrameOnly2 && oneFrameOnly && Input.GetKeyDown(HatAbility.button))
{
RunAbility();
cd3 = cdMax;
}
}
public override void RunAbility()
{
HatBase.localPlayer.refs.balloons.TieNewBalloon(new Random((int)Time.time * 100).Next(7));
if (cd <= 0f)
{
cd = cdMax;
}
}
}
[HarmonyPatch]
public class PumpkinHat : HatBase
{
[HarmonyPatch(typeof(Mob), "TargetValid")]
[HarmonyPostfix]
private static void MobTargetPatch(ref bool __result, ref Character ___target)
{
if ((Object)(object)___target == (Object)(object)HatBase.localPlayer)
{
__result = false;
}
else
{
__result = true;
}
}
[HarmonyPatch(typeof(MushroomZombie), "SetCurrentTarget")]
[HarmonyPrefix]
private static bool ZombieTargetPatch(ref Character ___setCurrentTarget)
{
if ((Object)(object)___setCurrentTarget == (Object)(object)HatBase.localPlayer)
{
return false;
}
return true;
}
}
public class MummyHat : HatAbility
{
private float redTime = 0f;
protected override int cdMax => 1200;
public void FixedUpdate()
{
if (redTime <= 0f && Time.time - HatBase.localPlayer.refs.afflictions.LastAddedIncrementalStatus((STATUSTYPE)5) >= 60f)
{
HatBase.localPlayer.refs.afflictions.SubtractStatus((STATUSTYPE)5, 0.025f, false, true);
redTime = 5f;
}
if (redTime > 0f)
{
redTime -= Time.deltaTime;
}
}
public override void RunAbility()
{
if (HatBase.localPlayer.data.fullyPassedOut && !HatBase.localPlayer.data.dead && HatBase.localPlayer.refs.afflictions.currentStatuses[5] < 0.5f)
{
HatBase.localPlayer.refs.afflictions.ClearAllAfflictions();
HatBase.localPlayer.refs.afflictions.ClearAllStatus(true, true);
HatBase.localPlayer.refs.afflictions.AddStatus((STATUSTYPE)5, 0.5f, false, true, true, false);
GUIManager.instance.curseSVFX.Play(1f, true);
cd = cdMax;
}
}
}
[HarmonyPatch(typeof(CharacterAfflictions))]
public class AntlerHat : HatBase
{
public void Start()
{
CharacterMovement movement = HatBase.localPlayer.refs.movement;
movement.sprintMultiplier *= 1.25f;
CharacterMovement movement2 = HatBase.localPlayer.refs.movement;
movement2.movementModifier *= 0.9f;
}
[HarmonyPatch("AddStatus")]
[HarmonyPrefix]
private static void InjuryPatch(ref STATUSTYPE statusType, ref float amount)
{
if ((int)statusType == 0)
{
amount /= 1.33f;
}
}
}
public class PlagueDoctorHat : HatAbility
{
protected override int cdMax => 180;
private GameObject hip => ((Component)HatBase.localPlayer.refs.hip).gameObject;
public override void RunAbility()
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
if (HatBase.localPlayer.data.fullyConscious && !HatBase.localPlayer.refs.movement.rocketActive && PlayerRaycast(out IInteractible result) && result is CharacterInteractible)
{
((CharacterInteractible)result).character.refs.afflictions.AddStatus((STATUSTYPE)0, 0.175f, true, true, true, false);
GameObject val = PhotonNetwork.InstantiateItemRoom(((Object)Plugin.vialPrefab).name, hip.transform.position + hip.transform.forward, Quaternion.identity, true);
val.GetComponent<Item>().Interact(HatBase.localPlayer);
cd = cdMax;
}
}
private static bool PlayerRaycast(out IInteractible result)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_0031: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)MainCamera.instance).transform;
RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[100];
float num = 1000f;
int num2 = Physics.SphereCastNonAlloc(transform.position + transform.forward, 0.5f, transform.forward, array, 2f, LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)0)), (QueryTriggerInteraction)2);
for (int i = 0; i < num2; i++)
{
RaycastHit val = array[i];
IInteractible componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<IInteractible>();
if (((RaycastHit)(ref val)).distance <= num && componentInParent is CharacterInteractible && (Object)(object)((CharacterInteractible)componentInParent).character != (Object)(object)HatBase.localPlayer)
{
num = ((RaycastHit)(ref val)).distance;
result = componentInParent;
return true;
}
}
result = null;
return false;
}
}
[HarmonyPatch(typeof(CharacterInteractible))]
public class GnomeHat : HatBase
{
public void Start()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
((Component)HatBase.localPlayer).gameObject.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
((Component)((Component)HatBase.localPlayer).transform.GetChild(2)).GetComponent<AudioSource>().pitch = 1.1f;
}
[HarmonyPatch("CanBeCarried")]
[HarmonyPostfix]
private static void CanCarryPatch(ref bool __result, ref Character ___character)
{
Plugin.logger.LogInfo((object)"carry");
if (((Object)Plugin.GetHat(((Component)___character).gameObject)).name == "GnomeHat" && (Object)(object)HatBase.localPlayer != (Object)(object)___character)
{
__result = true;
}
else
{
__result = __result;
}
}
}
public class ClimbingHat : HatBase
{
private Vector2 newSpeed => HatBase.localPlayer.refs.climbing.playerSlide;
public void Start()
{
CharacterClimbing climbing = HatBase.localPlayer.refs.climbing;
climbing.climbSpeed *= 1.2f;
}
public void Update()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
if (HatBase.localPlayer.data.isClimbing && !HatBase.localPlayer.input.sprintIsPressed)
{
HatBase.localPlayer.refs.climbing.playerSlide = new Vector2(newSpeed.x / 1.5f, newSpeed.y / 1.5f);
}
}
}
public class DrinkingHat : HatAbility
{
private bool oneFrameOnly2 = true;
private float cd2 = 0f;
private UI_Cooldown? uiCD2;
protected override int cdMax => 300;
public override void StartUp()
{
uiCD2 = MakeUI(2);
}
public void FixedUpdate()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
if (cd2 > 0f)
{
if (!oneFrameOnly2)
{
oneFrameOnly2 = true;
}
cd2 -= Time.deltaTime;
uiCD2.UpdateFill(cd2, cdMax);
return;
}
if (oneFrameOnly2)
{
HatBase.PlaySound(HatBase.localPlayer.poofSFX[0]);
uiCD2.UpdateFill(0f, cdMax);
oneFrameOnly2 = false;
}
if (oneFrameOnly && Input.GetKeyDown(HatAbility.button))
{
RunAbility();
cd2 = cdMax;
}
}
public override void RunAbility()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Affliction_FasterBoi val = new Affliction_FasterBoi
{
character = HatBase.localPlayer,
timeElapsed = 0f,
totalTime = 10f,
drowsyOnEnd = 0.3f
};
HatBase.localPlayer.refs.afflictions.AddAffliction(((Affliction)val).Copy(), false);
HatBase.PlaySound(Plugin.audClips[11]);
if (cd <= 0f)
{
cd = cdMax;
}
}
}
public class FairyHat : HatAbility
{
protected override int cdMax => 80;
public override void RunAbility()
{
HatBase.localPlayer.refs.movement.DoSuperJump(40f, 1.25f, 1, 1.25f);
cd = cdMax;
}
}
public class SproutHat : HatAbility
{
protected override int cdMax => 210;
private GameObject hip => ((Component)HatBase.localPlayer.refs.hip).gameObject;
public override void RunAbility()
{
//IL_0016: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
GameObject val = PhotonNetwork.InstantiateItemRoom(((Object)Plugin.magicBeanPrefab).name, hip.transform.position + hip.transform.forward, Quaternion.identity, true);
val.GetComponent<Item>().Interact(HatBase.localPlayer);
cd = cdMax;
}
}
public class WeirdHat : HatBase
{
public void Start()
{
HatBase.localPlayer.refs.afflictions.poisonReductionCooldown = (HatBase.localPlayer.refs.afflictions.sporesReductionCooldown = 10f);
}
}
public class JesterHat : HatAbility
{
protected override int cdMax => 1;
private Random rng => new Random((int)(Time.time * 100f));
public override void RunAbility()
{
if (HatBase.localPlayer.data.fullyConscious)
{
float num = (float)rng.NextDouble();
if ((double)num <= 0.01)
{
HatBase.localPlayer.refs.afflictions.ClearAllStatus(true, true);
}
else if ((double)num <= 0.05)
{
HatBase.localPlayer.refs.afflictions.AddStatus((STATUSTYPE)4, 1f, false, true, true, true);
}
else if ((double)num <= 0.25)
{
HatBase.localPlayer.refs.afflictions.AddStatus((STATUSTYPE)4, 0.3f, false, true, true, true);
}
else if ((double)num <= 0.4)
{
HatBase.localPlayer.refs.afflictions.SubtractStatus((STATUSTYPE)4, 0.3f, false, false);
}
else if ((double)num <= 0.7)
{
HatBase.localPlayer.data.extraStamina = Math.Max(HatBase.localPlayer.data.extraStamina - 0.3f, 0f);
}
else
{
HatBase.localPlayer.data.extraStamina = Math.Min(HatBase.localPlayer.data.extraStamina + 0.35f, 1f);
}
HatBase.PlaySound(Plugin.audClips[7]);
cd = cdMax;
}
}
}
public class NapCapHat : HatBase
{
public void Update()
{
HatBase.localPlayer.refs.afflictions.currentStatuses[6] = 0.15f;
}
}
[HarmonyPatch(typeof(CharacterAfflictions))]
public class ArrowHat : HatBase
{
private float sinceBleed = 20f;
public void Start()
{
HatBase.localPlayer.refs.afflictions.currentStatuses[12] = 0.1f;
}
public void Update()
{
if (sinceBleed <= 0f)
{
HatBase.localPlayer.refs.afflictions.currentStatuses[0] += 0.025f;
GUIManager.instance.AddStatusFX((STATUSTYPE)0, 0.025f);
HatBase.PlaySound(Plugin.audClips[9]);
sinceBleed = 60f;
}
else
{
sinceBleed -= Time.deltaTime;
}
}
[HarmonyPatch("AddStatus")]
[HarmonyPrefix]
private static bool InjuryPatch(ref STATUSTYPE statusType, ref float amount)
{
if ((int)statusType == 0)
{
return false;
}
return true;
}
}
public class LaurelHat : HatAbility
{
private Affliction_Invincibility invi = new Affliction_Invincibility
{
isFromMilk = false,
totalTime = 2f,
timeElapsed = 0f,
isFromAmulet = false
};
private Affliction_FasterBoi speed = new Affliction_FasterBoi
{
drowsyOnEnd = 0f,
totalTime = 7.5f,
timeElapsed = 0f,
climbSpeedMod = 0.5f,
moveSpeedMod = 0.5f,
climbDelay = 3f
};
protected override int cdMax => 200;
public override void StartUp()
{
((Affliction)invi).character = ((Component)HatBase.localPlayer).GetComponent<Character>();
}
public override void RunAbility()
{
HatBase.localPlayer.refs.afflictions.AddAffliction(((Affliction)invi).Copy(), false);
HatBase.localPlayer.refs.afflictions.AddAffliction(((Affliction)speed).Copy(), false);
HatBase.PlaySound(Plugin.audClips[10]);
cd = cdMax;
}
}
[HarmonyPatch(typeof(CharacterAfflictions))]
public class KnightHat : HatBase
{
public void Start()
{
HatBase.localPlayer.refs.afflictions.SetStatus((STATUSTYPE)7, 0f, true);
}
[HarmonyPatch("SetStatus")]
[HarmonyPrefix]
private static void WeightPatch(ref STATUSTYPE statusType, ref float amount)
{
if ((int)statusType == 7)
{
amount += 0.125f;
}
}
[HarmonyPatch("AddStatus")]
[HarmonyPrefix]
private static void InjuryPatch(ref STATUSTYPE statusType, ref float amount)
{
if ((int)statusType == 0)
{
amount /= 2f;
}
if ((int)statusType == 12)
{
amount = 0f;
}
}
}
public class FrogHat : HatBase
{
public void Start()
{
HatBase.localPlayer.refs.movement.jumpImpulse = 800f;
CharacterMovement movement = HatBase.localPlayer.refs.movement;
movement.jumpStaminaUsageSprinting *= 0.8f;
HatBase.localPlayer.data.lastFroggedTime = 2E+09f;
}
}
[HarmonyPatch(typeof(CharacterAfflictions))]
public class GothicHat : HatAbility
{
protected override int cdMax => 260;
public override void StartUp()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
Transform child = ((Component)GUIManager.instance).transform.GetChild(0).GetChild(1);
((Graphic)((Component)child.GetChild(1)).GetComponent<Image>()).color = new Color(0.15f, 0.075f, 0.125f, 1f);
((Graphic)((Component)child.GetChild(1)).GetComponent<Image>()).color = new Color(0.35f, 0.215f, 0.35f, 1f);
GUIManager.instance.StartNumb();
}
public override void RunAbility()
{
GUIManager.instance.StopNumb();
((MonoBehaviour)this).Invoke("NumbAgain", 5f);
cd = cdMax;
}
public void NumbAgain()
{
GUIManager.instance.StartNumb();
}
[HarmonyPatch("AddAffliction")]
[HarmonyPrefix]
private static bool NumbPatch(ref Affliction ___affliction)
{
if (___affliction is Affliction_Numb)
{
return false;
}
return true;
}
[HarmonyPatch("AddStatus")]
[HarmonyPrefix]
private static bool InjuryPatch(ref STATUSTYPE ___statusType, ref float ___amount)
{
if ((int)___statusType == 0)
{
___amount /= 1.5f;
return true;
}
if ((int)___statusType == 2)
{
return false;
}
if ((int)___statusType == 8)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(CharacterData))]
public class StarboyHat
{
[HarmonyPatch("SetPetrify")]
[HarmonyPrefix]
private static bool PetrifyPatch(ref Character ___character, ref int ___amount)
{
___character.refs.afflictions.AddStatus((STATUSTYPE)0, (float)(___amount / 2), false, true, true, false);
return false;
}
}
public class UI_Cooldown : MonoBehaviour
{
public Image fill;
public Image empty;
public Color color;
public void Start()
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
fill = ((Component)((Component)this).transform.GetChild(1)).gameObject.GetComponent<Image>();
empty = ((Component)((Component)this).transform.GetChild(0)).gameObject.GetComponent<Image>();
Image obj = empty;
bool enabled = (((Behaviour)fill).enabled = true);
((Behaviour)obj).enabled = enabled;
fill.fillAmount = 1f;
((Graphic)fill).color = color;
}
public void UpdateFill(float cd, float cdMax)
{
float num = cd / cdMax;
num -= 1f;
num = Mathf.Abs(num);
fill.fillAmount = num;
}
}
}
namespace HatBuffs.Config
{
public static class PluginConfig
{
public static ConfigEntry<KeyCode> keycode;
public static void RegisterConfigs(ConfigFile file)
{
keycode = file.Bind<KeyCode>("General", "Ability Keybind", (KeyCode)122, "The input set to activate a hat's ability.");
}
}
}