using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using UnityEngine;
[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("CustomSkulls")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("CustomSkulls")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
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;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CustomSkulls
{
public enum RocketChoice
{
Pomni,
Caine,
Kinger,
Jax
}
[BepInPlugin("yourname.customskulls", "UltraCircus", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Skull), "Awake")]
private static class SkullPatch
{
private static void Postfix(Skull __instance)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected I4, but got Unknown
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: 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_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: 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_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
ItemIdentifier component = ((Component)__instance).GetComponent<ItemIdentifier>();
if ((Object)(object)component == (Object)null)
{
return;
}
int num = (int)component.itemType;
if ((num != 1 && num != 2) || (num == 1 && !ReplaceBlueSkull) || (num == 2 && !ReplaceRedSkull))
{
return;
}
GameObject val;
switch (num)
{
case 1:
val = PomniPrefab;
break;
case 2:
val = CainePrefab;
break;
default:
return;
}
if (!DisablePickupSound)
{
AddPickupSound(((Component)__instance).gameObject, PickupSound);
}
ModifyMaterial value = Traverse.Create((object)__instance).Field("mod").GetValue<ModifyMaterial>();
if ((Object)(object)value == (Object)null)
{
return;
}
Traverse val2 = Traverse.Create((object)value);
val2.Method("SetValues", Array.Empty<object>()).GetValue();
Renderer value2 = val2.Field("rend").GetValue<Renderer>();
if (!((Object)(object)value2 == (Object)null))
{
value2.enabled = false;
GameObject val3 = Object.Instantiate<GameObject>(val, ((Component)value2).transform);
val3.transform.localPosition = Vector3.zero;
if (num == 2)
{
Transform transform = val3.transform;
transform.position += Vector3.up * 0.3f;
Vector3 val4 = Vector3.ProjectOnPlane(((Component)value2).transform.forward, Vector3.up);
Vector3 normalized = ((Vector3)(ref val4)).normalized;
Transform transform2 = val3.transform;
transform2.position += ((Component)value2).transform.forward * 0.3f;
Transform transform3 = val3.transform;
transform3.position += ((Component)value2).transform.right * 0.029f;
Transform transform4 = val3.transform;
transform4.position += Vector3.down * 0.36f;
val3.transform.localRotation = Quaternion.Euler(-75f, 0f, 0f);
val3.transform.rotation = Quaternion.AngleAxis(180f, Vector3.up) * val3.transform.rotation;
val3.transform.localScale = Vector3.one * 22f;
}
else
{
Transform transform5 = val3.transform;
transform5.position += Vector3.down * 0.5f;
val3.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f);
val3.transform.localScale = Vector3.one * 10f;
}
}
}
}
[HarmonyPatch(typeof(Torch), "Start")]
private static class TorchPatch
{
private static void Postfix(Torch __instance)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
if (!ReplaceTorch)
{
return;
}
if (!DisablePickupSound)
{
AddPickupSound(((Component)__instance).gameObject, PickupSound);
}
MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>();
if (componentsInChildren.Length != 0 && !((Object)(object)KingerPrefab == (Object)null))
{
MeshRenderer[] array = componentsInChildren;
foreach (MeshRenderer val in array)
{
((Renderer)val).enabled = false;
}
GameObject val2 = Object.Instantiate<GameObject>(KingerPrefab, ((Component)__instance).transform);
val2.transform.localPosition = Vector3.zero;
Transform transform = val2.transform;
transform.position += Vector3.down * 0.42f;
val2.transform.localRotation = Quaternion.Euler(180f, 90f, 0f);
val2.transform.localScale = Vector3.one * 180f;
}
}
}
[HarmonyPatch(typeof(Grenade), "Awake")]
private static class RocketPatch
{
private static void Postfix(Grenade __instance)
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
if (!ReplaceRocket || !__instance.rocket)
{
return;
}
GameObject rocketPrefab = GetRocketPrefab();
if ((Object)(object)rocketPrefab == (Object)null)
{
return;
}
MeshRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<MeshRenderer>();
if (componentsInChildren.Length != 0)
{
MeshRenderer[] array = componentsInChildren;
foreach (MeshRenderer val in array)
{
((Renderer)val).enabled = false;
}
GameObject val2 = Object.Instantiate<GameObject>(rocketPrefab, ((Component)__instance).transform);
Vector3 zero = Vector3.zero;
Vector3 zero2 = Vector3.zero;
float num = 1f;
switch (RocketPrefabChoice)
{
case RocketChoice.Pomni:
((Vector3)(ref zero))..ctor(0f, 0f, -0.7f);
((Vector3)(ref zero2))..ctor(0f, 0f, 0f);
num = 0.22f;
break;
case RocketChoice.Caine:
((Vector3)(ref zero))..ctor(0f, 0f, 2.7f);
((Vector3)(ref zero2))..ctor(180f, 0f, 180f);
num = 0.55f;
break;
case RocketChoice.Kinger:
((Vector3)(ref zero))..ctor(0f, 0f, 0f);
((Vector3)(ref zero2))..ctor(0f, 0f, 0f);
num = 0.8f;
break;
case RocketChoice.Jax:
((Vector3)(ref zero))..ctor(0f, 0f, 2f);
((Vector3)(ref zero2))..ctor(0f, 180f, 0f);
num = 0.4f;
break;
}
val2.transform.localPosition = Vector3.up * 0.35f + zero;
val2.transform.localRotation = Quaternion.Euler(90f, 90f, 270f) * Quaternion.Euler(zero2);
val2.transform.localScale = Vector3.one * (900f * num);
}
}
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static BoolValueChangeEventDelegate <>9__12_0;
public static BoolValueChangeEventDelegate <>9__12_1;
public static BoolValueChangeEventDelegate <>9__12_2;
public static BoolValueChangeEventDelegate <>9__12_3;
public static BoolValueChangeEventDelegate <>9__12_4;
public static EnumValueChangeEventDelegate<RocketChoice> <>9__12_5;
internal void <Awake>b__12_0(BoolValueChangeEvent e)
{
DisablePickupSound = e.value;
}
internal void <Awake>b__12_1(BoolValueChangeEvent e)
{
ReplaceBlueSkull = e.value;
}
internal void <Awake>b__12_2(BoolValueChangeEvent e)
{
ReplaceRedSkull = e.value;
}
internal void <Awake>b__12_3(BoolValueChangeEvent e)
{
ReplaceTorch = e.value;
}
internal void <Awake>b__12_4(BoolValueChangeEvent e)
{
ReplaceRocket = e.value;
}
internal void <Awake>b__12_5(EnumValueChangeEvent<RocketChoice> e)
{
RocketPrefabChoice = e.value;
}
}
internal static GameObject PomniPrefab;
internal static GameObject CainePrefab;
internal static GameObject KingerPrefab;
internal static GameObject JaxPrefab;
internal static AudioClip PickupSound;
internal static bool DisablePickupSound;
internal static bool ReplaceBlueSkull = true;
internal static bool ReplaceRedSkull = true;
internal static bool ReplaceTorch = true;
internal static bool ReplaceRocket = true;
internal static RocketChoice RocketPrefabChoice = RocketChoice.Jax;
private static AssetBundle bundle;
private void Awake()
{
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Expected O, but got Unknown
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Expected O, but got Unknown
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Expected O, but got Unknown
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Expected O, but got Unknown
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Expected O, but got Unknown
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Expected O, but got Unknown
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Expected O, but got Unknown
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Expected O, but got Unknown
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Expected O, but got Unknown
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_031d: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Expected O, but got Unknown
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "customskull"));
if ((Object)(object)bundle == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Could not load customskull bundle.");
return;
}
PomniPrefab = bundle.LoadAsset<GameObject>("Pomni");
CainePrefab = bundle.LoadAsset<GameObject>("Caine");
KingerPrefab = bundle.LoadAsset<GameObject>("Kinger");
JaxPrefab = bundle.LoadAsset<GameObject>("Jax");
PickupSound = bundle.LoadAsset<AudioClip>("brassthatgoeshard");
if ((Object)(object)PomniPrefab == (Object)null || (Object)(object)CainePrefab == (Object)null || (Object)(object)KingerPrefab == (Object)null || (Object)(object)JaxPrefab == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Could not find Pomni, Caine, Kinger, or Jax in the bundle.");
return;
}
if ((Object)(object)PickupSound == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Could not find brassthatgoeshard in the customskull bundle.");
}
PluginConfigurator val = PluginConfigurator.Create("UltraCircus", "yourname.customskulls");
string text = Path.Combine(directoryName, "icon.png");
if (File.Exists(text))
{
val.SetIconWithURL(text);
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find icon.png beside the plugin DLL.");
}
BoolField val2 = new BoolField(val.rootPanel, "Disable pickup sound", "disable_pickup_sound", false);
new ConfigHeader(val.rootPanel, "────────────────────────", 24);
BoolField val3 = new BoolField(val.rootPanel, "Pomni instead of blue skulls", "replace_blue_skull", true);
BoolField val4 = new BoolField(val.rootPanel, "Caine instead of red skulls", "replace_red_skull", true);
BoolField val5 = new BoolField(val.rootPanel, "Kinger instead of torches", "replace_torch", true);
BoolField val6 = new BoolField(val.rootPanel, "Jax instead of rockets", "replace_rocket", true);
new ConfigHeader(val.rootPanel, "────────────────────────", 24);
EnumField<RocketChoice> val7 = new EnumField<RocketChoice>(val.rootPanel, "Replace rockets with", "rocket_character", RocketChoice.Jax);
DisablePickupSound = val2.value;
ReplaceBlueSkull = val3.value;
ReplaceRedSkull = val4.value;
ReplaceTorch = val5.value;
ReplaceRocket = val6.value;
RocketPrefabChoice = val7.value;
object obj = <>c.<>9__12_0;
if (obj == null)
{
BoolValueChangeEventDelegate val8 = delegate(BoolValueChangeEvent e)
{
DisablePickupSound = e.value;
};
<>c.<>9__12_0 = val8;
obj = (object)val8;
}
val2.onValueChange += (BoolValueChangeEventDelegate)obj;
object obj2 = <>c.<>9__12_1;
if (obj2 == null)
{
BoolValueChangeEventDelegate val9 = delegate(BoolValueChangeEvent e)
{
ReplaceBlueSkull = e.value;
};
<>c.<>9__12_1 = val9;
obj2 = (object)val9;
}
val3.onValueChange += (BoolValueChangeEventDelegate)obj2;
object obj3 = <>c.<>9__12_2;
if (obj3 == null)
{
BoolValueChangeEventDelegate val10 = delegate(BoolValueChangeEvent e)
{
ReplaceRedSkull = e.value;
};
<>c.<>9__12_2 = val10;
obj3 = (object)val10;
}
val4.onValueChange += (BoolValueChangeEventDelegate)obj3;
object obj4 = <>c.<>9__12_3;
if (obj4 == null)
{
BoolValueChangeEventDelegate val11 = delegate(BoolValueChangeEvent e)
{
ReplaceTorch = e.value;
};
<>c.<>9__12_3 = val11;
obj4 = (object)val11;
}
val5.onValueChange += (BoolValueChangeEventDelegate)obj4;
object obj5 = <>c.<>9__12_4;
if (obj5 == null)
{
BoolValueChangeEventDelegate val12 = delegate(BoolValueChangeEvent e)
{
ReplaceRocket = e.value;
};
<>c.<>9__12_4 = val12;
obj5 = (object)val12;
}
val6.onValueChange += (BoolValueChangeEventDelegate)obj5;
val7.onValueChange += delegate(EnumValueChangeEvent<RocketChoice> e)
{
RocketPrefabChoice = e.value;
};
new Harmony("yourname.customskulls").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Custom Skulls loaded.");
}
private static GameObject GetRocketPrefab()
{
return (GameObject)(RocketPrefabChoice switch
{
RocketChoice.Pomni => PomniPrefab,
RocketChoice.Caine => CainePrefab,
RocketChoice.Kinger => KingerPrefab,
RocketChoice.Jax => JaxPrefab,
_ => JaxPrefab,
});
}
private static void AddPickupSound(GameObject item, AudioClip clip)
{
if (!((Object)(object)item == (Object)null) && !((Object)(object)clip == (Object)null))
{
PickupSoundPlayer pickupSoundPlayer = item.GetComponent<PickupSoundPlayer>();
if ((Object)(object)pickupSoundPlayer == (Object)null)
{
pickupSoundPlayer = item.AddComponent<PickupSoundPlayer>();
}
pickupSoundPlayer.Configure(clip, item.GetComponent<ItemIdentifier>());
}
}
}
public class PickupSoundPlayer : MonoBehaviour
{
private AudioClip clip;
private ItemIdentifier itemIdentifier;
private AudioSource source;
private bool wasPickedUp;
public void Configure(AudioClip sound, ItemIdentifier identifier)
{
clip = sound;
itemIdentifier = identifier;
}
private void Update()
{
bool flag = (((Object)(object)itemIdentifier != (Object)null) ? itemIdentifier.pickedUp : IsHeldByPlayer(((Component)this).transform));
if (Plugin.DisablePickupSound)
{
wasPickedUp = flag;
return;
}
if (flag && !wasPickedUp)
{
PlayPickupSound();
}
wasPickedUp = flag;
}
private bool IsHeldByPlayer(Transform current)
{
while ((Object)(object)current != (Object)null)
{
string text = ((Object)current).name.ToLowerInvariant();
if (text.Contains("hand") || text.Contains("holder") || text.Contains("player") || text.Contains("arm"))
{
return true;
}
current = current.parent;
}
return false;
}
private void PlayPickupSound()
{
if (!((Object)(object)clip == (Object)null))
{
if ((Object)(object)source == (Object)null)
{
source = ((Component)this).gameObject.AddComponent<AudioSource>();
source.spatialBlend = 0f;
source.playOnAwake = false;
}
source.clip = clip;
source.Play();
}
}
}
internal static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.yourname.pluginname";
public const string PLUGIN_NAME = "My first plugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}