using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Configgy;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.UI;
[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ConscientiousObjector")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ConscientiousObjector")]
[assembly: AssemblyTitle("ConscientiousObjector")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ConscientiousObjector
{
public class ConscientiousObjectorWeapon : MonoBehaviour
{
public Animator anim;
public AudioClip Equip;
public AudioClip Hitmiss;
public AudioClip[] HitSuccessArray;
public AudioClip HitCrit;
public AudioSource SoundPlayer;
public static Image FunnyImage;
public GameObject CritParticle;
private float lastAnimationTime = 0f;
private void Start()
{
Transform val = ((Component)this).transform.Find("v1arm/Arm_Blue/Armature/Upper Arm/Bone/Forearm/Hand/c_picket.001/Canvas/reallyfunnyimage");
if ((Object)(object)val != (Object)null)
{
FunnyImage = ((Component)val).GetComponent<Image>();
if ((Object)(object)FunnyImage != (Object)null)
{
Plugin.SetImageToFirstImage(FunnyImage);
}
}
}
private void Update()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
if (MonoSingleton<InputManager>.Instance.InputSource.Fire1.IsPressed && Time.time - lastAnimationTime >= ((ConfigValueElement<float>)(object)Plugin.HitCooldown).Value)
{
Hit();
}
if (Input.GetKeyDown(((ConfigValueElement<KeyCode>)(object)Plugin.Keybind).Value))
{
Inspect();
}
}
private void Hit()
{
anim.Play("Hit", 0, 0f);
lastAnimationTime = Time.time;
((MonoBehaviour)this).StartCoroutine(DelayedHit());
}
private IEnumerator DelayedHit()
{
yield return (object)new WaitForSeconds(0.4f);
Ray ray = new Ray(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward);
RaycastHit[] hits = Physics.RaycastAll(ray, ((ConfigValueElement<float>)(object)Plugin.RangeHit).Value);
bool hitEnemyTrigger = false;
RaycastHit[] array = hits;
Breakable breakable = default(Breakable);
Glass glass = default(Glass);
for (int i = 0; i < array.Length; i++)
{
RaycastHit hit = array[i];
if (((Component)((RaycastHit)(ref hit)).collider).TryGetComponent<Breakable>(ref breakable))
{
breakable.Break();
}
if (((Component)((RaycastHit)(ref hit)).collider).TryGetComponent<Glass>(ref glass))
{
glass.Shatter();
}
if (((Component)((RaycastHit)(ref hit)).collider).gameObject.layer == LayerMask.NameToLayer("EnemyTrigger"))
{
int critRoll = Random.Range(1, 101);
if (critRoll <= ((ConfigValueElement<int>)(object)Plugin.CritChance).Value)
{
SoundPlayer.PlayOneShot(HitCrit);
ApplyCriticalDamage(hit);
}
else
{
SoundPlayer.PlayOneShot(HitSuccessArray[Random.Range(0, HitSuccessArray.Length)]);
ApplyNormalDamage(hit);
}
hitEnemyTrigger = true;
break;
}
if (((Component)((RaycastHit)(ref hit)).collider).gameObject.layer == LayerMask.NameToLayer("Environment") || ((Component)((RaycastHit)(ref hit)).collider).gameObject.layer == LayerMask.NameToLayer("Outdoor"))
{
SoundPlayer.PlayOneShot(Hitmiss);
yield break;
}
breakable = null;
glass = null;
hit = default(RaycastHit);
}
if (!hitEnemyTrigger)
{
SoundPlayer.PlayOneShot(Hitmiss);
}
}
private void ApplyNormalDamage(RaycastHit hit)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
EnemyIdentifier component = ((Component)((RaycastHit)(ref hit)).collider).GetComponent<EnemyIdentifier>();
if ((Object)(object)component == (Object)null && ((Component)((RaycastHit)(ref hit)).collider).transform.childCount > 0)
{
component = ((Component)((Component)((RaycastHit)(ref hit)).collider).transform.GetChild(0)).GetComponent<EnemyIdentifier>();
}
if ((Object)(object)component != (Object)null)
{
component.DeliverDamage(((Component)component).gameObject, ((Component)Camera.main).transform.forward * 5000f, ((RaycastHit)(ref hit)).point, ((ConfigValueElement<float>)(object)Plugin.NormalDamage).Value, true, 1f, ((Component)this).gameObject, false, false);
MonoSingleton<StyleHUD>.Instance.AddPoints(30, "<color=orange>BONK!</color>", ((Component)this).gameObject, component, -1, "", "");
}
}
private void ApplyCriticalDamage(RaycastHit hit)
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
float num = ((ConfigValueElement<float>)(object)Plugin.NormalDamage).Value * (float)((ConfigValueElement<int>)(object)Plugin.CritMultipler).Value;
EnemyIdentifier component = ((Component)((RaycastHit)(ref hit)).collider).GetComponent<EnemyIdentifier>();
if ((Object)(object)component == (Object)null && ((Component)((RaycastHit)(ref hit)).collider).transform.childCount > 0)
{
component = ((Component)((Component)((RaycastHit)(ref hit)).collider).transform.GetChild(0)).GetComponent<EnemyIdentifier>();
}
if ((Object)(object)component != (Object)null)
{
Bounds bounds = ((RaycastHit)(ref hit)).collider.bounds;
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).center.z);
component.DeliverDamage(((Component)component).gameObject, ((Component)Camera.main).transform.forward * 5000f, ((RaycastHit)(ref hit)).point, num, true, 1f, ((Component)this).gameObject, false, false);
GameObject val2 = Object.Instantiate<GameObject>(CritParticle, val, Quaternion.identity);
val2.AddComponent<ParticleDestroyer>();
MonoSingleton<StyleHUD>.Instance.AddPoints(150, "<color=green>CRITICAL HIT!</color>", ((Component)this).gameObject, component, -1, "", "");
}
}
private void Inspect()
{
anim.Play("Inspect", 0, 0f);
}
private void OnEnable()
{
SoundPlayer.PlayOneShot(Equip);
anim.Play("Equip", 0, 0f);
}
}
public class ParticleDestroyer : MonoBehaviour
{
public float animationDuration = 2.5f;
private IEnumerator Start()
{
float elapsedTime = 0f;
Vector3 startPosition = ((Component)this).transform.position;
Vector3 endPosition = startPosition + Vector3.up * 2f;
TextMeshPro textMeshPro = ((Component)this).GetComponent<TextMeshPro>();
Color startColor = ((Graphic)textMeshPro).color;
Color endColor = new Color(startColor.r, startColor.g, startColor.b, 0f);
while (elapsedTime < animationDuration)
{
float t = elapsedTime / animationDuration;
((Component)this).transform.position = Vector3.Lerp(startPosition, endPosition, t);
((Graphic)textMeshPro).color = Color.Lerp(startColor, endColor, t);
elapsedTime += Time.deltaTime;
yield return null;
}
((Component)this).transform.position = endPosition;
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public static class Loader
{
public static AssetBundle LoadObjector()
{
try
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string name = "ConscientiousObjector.objector.bundle";
using Stream stream = executingAssembly.GetManifestResourceStream(name);
if (stream == null)
{
Debug.LogError((object)"Resource 'object.bundle' not found in embedded resources.");
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
return AssetBundle.LoadFromMemory(array);
}
catch (Exception ex)
{
Debug.LogError((object)("Error loading objector: " + ex.Message));
return null;
}
}
}
[BepInPlugin("doomahreal.ultrakill.ConscientiousObjector", "ConscientiousObjector", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static AssetBundle objectorBundle;
public GameObject Gun;
public static bool candostuff;
[Configgable("Weapon Related Stuff", null, 0, null)]
[Range(0f, 9999f)]
public static ConfigInputField<float> HitCooldown = new ConfigInputField<float>(2f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Weapon Related Stuff", null, 0, null)]
[Range(0f, 9999f)]
public static ConfigInputField<float> NormalDamage = new ConfigInputField<float>(3.5f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Weapon Related Stuff", null, 0, null)]
public static IntegerSlider CritChance = new IntegerSlider(15, 0, 100);
[Configgable("Weapon Related Stuff", null, 0, null)]
[Range(0f, 9999f)]
public static ConfigInputField<int> CritMultipler = new ConfigInputField<int>(10, (Func<int, bool>)null, (Func<string, ValueTuple<bool, int>>)null);
[Configgable("Weapon Related Stuff", null, 0, null)]
[Range(0f, 9999f)]
public static ConfigInputField<float> RangeHit = new ConfigInputField<float>(5.5f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("", "Slot", 0, null)]
public static IntegerSlider SlotG = new IntegerSlider(6, 1, 6);
[Configgable("", "Variation", 0, null)]
public static IntegerSlider VariationG = new IntegerSlider(1, 1, 4);
[Configgable("", "Inspect", 0, null)]
public static ConfigKeybind Keybind = new ConfigKeybind((KeyCode)102);
[Configgable("", "Open Folder", 0, null)]
public static ConfigButton MyConfigButton = new ConfigButton((Action)delegate
{
OpenFilesFolder();
}, (string)null);
[Configgable("", "Refresh Image", 0, null)]
public static ConfigButton MyConfigButton2 = new ConfigButton((Action)delegate
{
SetImageToFirstImage(ConscientiousObjectorWeapon.FunnyImage);
}, (string)null);
private int previousSlotValue;
private int previousVariationValue;
public static ConfigBuilder ConfigBuilder { get; private set; }
private void Awake()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
ConfigBuilder = new ConfigBuilder("doomahreal.ultrakill.ConscientiousObjector", "ConscientiousObjector");
ConfigBuilder.BuildAll();
previousSlotValue = ((ConfigValueElement<int>)(object)SlotG).Value;
previousVariationValue = ((ConfigValueElement<int>)(object)VariationG).Value;
IntegerSlider slotG = SlotG;
((ConfigValueElement<int>)(object)slotG).OnValueChanged = (Action<int>)Delegate.Combine(((ConfigValueElement<int>)(object)slotG).OnValueChanged, (Action<int>)delegate
{
ImRunningOutOfIdeas();
});
IntegerSlider variationG = VariationG;
((ConfigValueElement<int>)(object)variationG).OnValueChanged = (Action<int>)Delegate.Combine(((ConfigValueElement<int>)(object)variationG).OnValueChanged, (Action<int>)delegate
{
PlonkIsDecent();
});
objectorBundle = Loader.LoadObjector();
Harmony val = new Harmony("doomahreal.ultrakill.ConscientiousObjector");
val.PatchAll();
}
private void Update()
{
if (!candostuff && SceneHelper.CurrentScene == "Main Menu")
{
if ((Object)(object)objectorBundle != (Object)null)
{
candostuff = true;
}
else
{
Debug.Log((object)"Fuck.");
}
}
if (candostuff && SceneHelper.CurrentScene != "Main Menu" && (Object)(object)Gun == (Object)null)
{
Gun = MakeGun(1);
}
}
private void ImRunningOutOfIdeas()
{
if (!((Object)(object)Gun == (Object)null) && !((Object)(object)MonoSingleton<GunControl>.instance == (Object)null))
{
int index = previousSlotValue - 1;
int num = ((ConfigValueElement<int>)(object)SlotG).Value - 1;
MonoSingleton<GunControl>.Instance.slots[index].Remove(Gun);
MonoSingleton<GunControl>.Instance.allWeapons.Remove(Gun);
MonoSingleton<GunControl>.Instance.slotDict.Remove(Gun);
MonoSingleton<GunControl>.Instance.slots[num].Add(Gun);
MonoSingleton<GunControl>.Instance.allWeapons.Add(Gun);
MonoSingleton<GunControl>.Instance.slotDict.Add(Gun, num);
previousSlotValue = ((ConfigValueElement<int>)(object)SlotG).Value;
}
}
private void PlonkIsDecent()
{
if (!((Object)(object)Gun == (Object)null) && !((Object)(object)MonoSingleton<GunControl>.instance == (Object)null))
{
int index = ((ConfigValueElement<int>)(object)SlotG).Value - 1;
int index2 = ((ConfigValueElement<int>)(object)VariationG).Value - 1;
MonoSingleton<GunControl>.Instance.slots[((ConfigValueElement<int>)(object)SlotG).Value - 1].Remove(Gun);
MonoSingleton<GunControl>.Instance.slots[index].Insert(index2, Gun);
previousVariationValue = ((ConfigValueElement<int>)(object)VariationG).Value;
}
}
public static GameObject MakeGun(int var)
{
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
int num = ((ConfigValueElement<int>)(object)SlotG).Value - 1;
if ((Object)(object)MonoSingleton<GunControl>.Instance == (Object)null || (Object)(object)MonoSingleton<StyleHUD>.Instance == (Object)null)
{
return null;
}
if (!((Behaviour)MonoSingleton<GunControl>.Instance).enabled || !((Behaviour)MonoSingleton<StyleHUD>.Instance).enabled)
{
return null;
}
GameObject val = objectorBundle.LoadAsset<GameObject>("assets/something.prefab");
GameObject val2 = Object.Instantiate<GameObject>(val);
if ((Object)(object)val2 == (Object)null)
{
return null;
}
Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val3 in array)
{
Material[] sharedMaterials = val3.sharedMaterials;
Material[] array2 = sharedMaterials;
foreach (Material material in array2)
{
if (!(((Object)material.shader).name == "psx/vertexlit/vertexlit"))
{
continue;
}
AsyncOperationHandle<Shader> val4 = Addressables.LoadAssetAsync<Shader>((object)"Assets/Shaders/Main/ULTRAKILL-vertexlit.shader");
val4.Completed += delegate(AsyncOperationHandle<Shader> shaderOp)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)shaderOp.Status == 1)
{
Shader result = shaderOp.Result;
material.shader = result;
}
};
}
}
val2.transform.parent = ((Component)MonoSingleton<GunControl>.Instance).transform;
val2.transform.position = ((Component)MonoSingleton<GunControl>.Instance).transform.position;
val2.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
MonoSingleton<GunControl>.Instance.slots[num].Add(val2);
MonoSingleton<GunControl>.Instance.allWeapons.Add(val2);
MonoSingleton<GunControl>.Instance.slotDict.Add(val2, num);
MonoSingleton<StyleHUD>.Instance.weaponFreshness.Add(val2, 10f);
val2.SetActive(false);
MonoSingleton<GunControl>.Instance.noWeapons = false;
MonoSingleton<GunControl>.Instance.YesWeapon();
Debug.Log((object)"made Objector");
for (int k = 0; k < ((Component)MonoSingleton<GunControl>.instance).transform.childCount; k++)
{
((Component)((Component)MonoSingleton<GunControl>.Instance).transform.GetChild(k)).gameObject.SetActive(false);
}
return val2;
}
public static void OpenFilesFolder()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Invalid comparison between Unknown and I4
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Invalid comparison between Unknown and I4
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Invalid comparison between Unknown and I4
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Invalid comparison between Unknown and I4
string location = Assembly.GetExecutingAssembly().Location;
string directoryName = Path.GetDirectoryName(location);
RuntimePlatform platform = Application.platform;
RuntimePlatform val = platform;
if ((int)val <= 2)
{
if ((int)val <= 1)
{
Process.Start("open", directoryName);
return;
}
if ((int)val == 2)
{
goto IL_003f;
}
}
else
{
if ((int)val == 7)
{
goto IL_003f;
}
if ((int)val == 13 || (int)val == 16)
{
Process.Start("xdg-open", directoryName);
return;
}
}
Debug.LogWarning((object)"BROTHER WHAT IS YOUR OS?????");
return;
IL_003f:
Process.Start("explorer.exe", directoryName.Replace("/", "\\"));
}
public static void SetImageToFirstImage(Image image)
{
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Expected O, but got Unknown
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
string location = Assembly.GetExecutingAssembly().Location;
string directoryName = Path.GetDirectoryName(location);
string[] array = new string[3] { "*.png", "*.jpg", "*.jpeg" };
List<string> list = new List<string>();
string[] array2 = array;
foreach (string searchPattern in array2)
{
list.AddRange(Directory.GetFiles(directoryName, searchPattern));
}
if (list.Count == 0)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string name = executingAssembly.GetName().Name + ".missing.png";
using Stream stream = executingAssembly.GetManifestResourceStream(name);
if (stream != null)
{
byte[] array3 = new byte[stream.Length];
stream.Read(array3, 0, (int)stream.Length);
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, array3);
((Texture)val).filterMode = (FilterMode)0;
Sprite sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
image.sprite = sprite;
}
return;
}
foreach (string item in list)
{
string text = Path.GetFileName(item).ToLower();
if (text != "icon.png")
{
byte[] array4 = File.ReadAllBytes(item);
Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false);
ImageConversion.LoadImage(val2, array4);
((Texture)val2).filterMode = (FilterMode)0;
Sprite sprite2 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), Vector2.zero);
image.sprite = sprite2;
break;
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(LeaderboardController), "SubmitLevelScore")]
[HarmonyPatch(typeof(LeaderboardController), "SubmitCyberGrindScore")]
private static bool DisableLeaderboardSubmissions()
{
return false;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ConscientiousObjector";
public const string PLUGIN_NAME = "ConscientiousObjector";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}