using System;
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 UnityEngine;
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 = "")]
[assembly: AssemblyCompany("SlabManBuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A rework for the Alt Marksman Revolver")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SlabManBuff")]
[assembly: AssemblyTitle("SlabManBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SlabManBuff;
public class CoinAddAttr : MonoBehaviour
{
public int hitAmmount = Property.CoinTotalHitAmmount;
public float bounceForce = Property.CoinHitBounceForce;
public bool noDeadCoin = false;
public GameObject coinClone = null;
public void CreateClone(Coin sourceCoin)
{
//IL_0022: 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)
if (Object.op_Implicit((Object)(object)coinClone))
{
return;
}
coinClone = Object.Instantiate<GameObject>(((Component)sourceCoin).gameObject, ((Component)sourceCoin).transform.position, Quaternion.identity);
((Object)coinClone).name = "NewCoin+" + (sourceCoin.power - 2f);
coinClone.SetActive(false);
Transform[] children = Extensions.GetChildren(coinClone.transform);
foreach (Transform val in children)
{
GameObject gameObject = ((Component)val).gameObject;
if (gameObject.transform.GetSiblingIndex() != 0)
{
Object.Destroy((Object)(object)gameObject);
}
}
Coin component = coinClone.GetComponent<Coin>();
if (Object.op_Implicit((Object)(object)component))
{
component.shot = false;
component.ricochets = 0;
component.power += 1f;
component.hitTimes = 1;
}
CoinAddAttr component2 = coinClone.GetComponent<CoinAddAttr>();
if (Object.op_Implicit((Object)(object)component2))
{
component2.noDeadCoin = true;
component2.hitAmmount--;
}
}
public void DelayedBounce()
{
if (Object.op_Implicit((Object)(object)coinClone))
{
((MonoBehaviour)this).Invoke("Bounce", 0f);
}
}
private void Bounce()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)coinClone))
{
coinClone.SetActive(true);
Rigidbody component = coinClone.GetComponent<Rigidbody>();
if (Object.op_Implicit((Object)(object)component))
{
component.isKinematic = false;
component.velocity = Vector3.zero;
component.AddForce(Vector3.up * bounceForce, (ForceMode)2);
}
coinClone = null;
}
}
}
public class WeaponChargesAddAttr : MonoBehaviour
{
public bool rev1alt = false;
}
internal class AssetManager
{
private const string assetBundlePath = "src.assets.slabmanbuff";
private static AssetBundle assetBundle = null;
private static Dictionary<string, Object> loadedAssets = new Dictionary<string, Object>();
public static void LoadAssetBundle()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using Stream stream = executingAssembly.GetManifestResourceStream(executingAssembly.GetName().Name + ".src.assets.slabmanbuff");
assetBundle = AssetBundle.LoadFromStream(stream);
}
public static T LoadAsset<T>(string name) where T : Object
{
if (!Object.op_Implicit((Object)(object)assetBundle))
{
return default(T);
}
if (!loadedAssets.ContainsKey(name))
{
T val = assetBundle.LoadAsset<T>(name);
loadedAssets.Add(name, (Object)(object)val);
return val;
}
return (T)(object)loadedAssets[name];
}
}
[HarmonyPatch(typeof(Coin), "ReflectRevolver")]
internal class Coin_ReflectRevolverPatch
{
public static void Postfix(Coin __instance, int ___hitTimes, GameObject ___altBeam)
{
CoinAddAttr component = ((Component)__instance).gameObject.GetComponent<CoinAddAttr>();
if (Object.op_Implicit((Object)(object)component) && (___hitTimes <= 0 || !((Object)(object)___altBeam == (Object)null)) && Object.op_Implicit((Object)(object)component.coinClone))
{
component.DelayedBounce();
}
}
}
[HarmonyPatch(typeof(Coin), "DelayedReflectRevolver")]
internal class Coin_DelayedReflectRevolverPatch
{
public static void Prefix(Coin __instance, bool ___checkingSpeed)
{
CoinAddAttr component = ((Component)__instance).gameObject.GetComponent<CoinAddAttr>();
if (Object.op_Implicit((Object)(object)component) && ___checkingSpeed && component.hitAmmount > 1 && !Object.op_Implicit((Object)(object)component.coinClone))
{
component.CreateClone(__instance);
component.hitAmmount = 0;
}
}
}
[HarmonyPatch(typeof(Coin), "Start")]
internal class Coin_StartPatch
{
public static void Postfix(Coin __instance, Collider[] ___cols, ref bool ___checkingSpeed)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
CoinAddAttr component = ((Component)__instance).gameObject.GetComponent<CoinAddAttr>();
if (!Object.op_Implicit((Object)(object)component))
{
return;
}
if (component.noDeadCoin)
{
for (int i = 0; i < ___cols.Length; i++)
{
___cols[i].enabled = false;
}
___checkingSpeed = true;
component.noDeadCoin = false;
}
((Component)__instance).gameObject.transform.localScale = Property.CoinScale;
Texture val = AssetManager.LoadAsset<Texture>("assets/textures/coin01_2.png");
if (Object.op_Implicit((Object)(object)val))
{
MeshRenderer component2 = ((Component)__instance).GetComponent<MeshRenderer>();
((Renderer)component2).material.SetTexture("_MainTex", val);
}
}
}
[HarmonyPatch(typeof(Coin), "TripleTime")]
internal class Coin_TripleTimePatch
{
public static void Postfix(Coin __instance, GameObject ___currentCharge)
{
CoinAddAttr component = ((Component)__instance).gameObject.GetComponent<CoinAddAttr>();
if (Object.op_Implicit((Object)(object)component) && !__instance.shot && Object.op_Implicit((Object)(object)___currentCharge))
{
SpriteRenderer componentInChildren = ___currentCharge.GetComponentInChildren<SpriteRenderer>();
componentInChildren.sprite = AssetManager.LoadAsset<Sprite>("assets/textures/muzzleflash.png");
}
}
}
[HarmonyPatch(typeof(Coin), "DelayedEnemyReflect")]
internal class Coin_DelayedEnemyReflectPatch
{
public static void Prefix(Coin __instance)
{
CoinAddAttr component = ((Component)__instance).gameObject.GetComponent<CoinAddAttr>();
if (Object.op_Implicit((Object)(object)component) && !__instance.shot && component.hitAmmount > 1 && !Object.op_Implicit((Object)(object)component.coinClone))
{
component.CreateClone(__instance);
component.hitAmmount = 0;
}
}
}
[HarmonyPatch(typeof(Coin), "EnemyReflect")]
internal class Coin_EnemyReflectPatch
{
public static void Postfix(Coin __instance)
{
CoinAddAttr component = ((Component)__instance).gameObject.GetComponent<CoinAddAttr>();
if (Object.op_Implicit((Object)(object)component) && !__instance.shotByEnemy && Object.op_Implicit((Object)(object)component.coinClone))
{
component.DelayedBounce();
}
}
}
[HarmonyPatch(typeof(Coin), "ShootAtPlayer")]
internal class Coin_ShootAtPlayerPatch
{
public static void Postfix(Coin __instance)
{
CoinAddAttr component = ((Component)__instance).gameObject.GetComponent<CoinAddAttr>();
if (Object.op_Implicit((Object)(object)component) && !__instance.shotByEnemy && Object.op_Implicit((Object)(object)component.coinClone))
{
component.DelayedBounce();
}
}
}
[HarmonyPatch(typeof(Revolver), "Start")]
internal class Revolver_Start
{
public static void Postfix(Revolver __instance)
{
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: 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_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
if (__instance.gunVariation != 1 || !__instance.altVersion)
{
return;
}
Canvas componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<Canvas>();
if (!Object.op_Implicit((Object)(object)componentInChildren))
{
return;
}
GameObject gameObject = ((Component)((Component)componentInChildren).transform.GetChild(0)).gameObject;
if (!Object.op_Implicit((Object)(object)gameObject))
{
return;
}
for (int i = 0; i < gameObject.transform.childCount; i++)
{
GameObject gameObject2 = ((Component)gameObject.transform.GetChild(i)).gameObject;
Object.Destroy((Object)(object)gameObject2);
}
GameObject[] array = (GameObject[])(object)new GameObject[2];
for (int j = 0; j < array.Length; j++)
{
GameObject val = new GameObject("coinPanel");
val.AddComponent<CanvasRenderer>();
val.AddComponent<RectTransform>();
val.AddComponent<Image>();
val.transform.SetParent(gameObject.transform, false);
array[j] = val;
}
Image[] array2 = (Image[])(object)new Image[array.Length];
Sprite sprite = AssetManager.LoadAsset<Sprite>("assets/textures/coincharges.png");
for (int k = 0; k < array.Length; k++)
{
GameObject val2 = array[k];
RectTransform component = val2.GetComponent<RectTransform>();
component.pivot = new Vector2(0.5f, 0.5f);
component.anchorMin = new Vector2(0f, 0.5f * (float)(1 - k));
component.anchorMax = new Vector2(1f, 0.5f * (float)(2 - k));
switch (k)
{
case 0:
component.offsetMin = new Vector2(2f, 1f);
component.offsetMax = new Vector2(-2f, -2f);
break;
case 1:
component.offsetMin = new Vector2(2f, 2f);
component.offsetMax = new Vector2(-2f, -1f);
break;
}
Image component2 = val2.GetComponent<Image>();
component2.sprite = sprite;
component2.type = (Type)3;
component2.fillMethod = (FillMethod)0;
component2.fillOrigin = 1;
array2[k] = component2;
}
__instance.coinPanels = array2;
}
}
[HarmonyPatch(typeof(Revolver), "ThrowCoin")]
internal class Revolver_ThrowCoinPatch
{
public static bool Prefix(Revolver __instance, ref Punch ___punch, GameObject ___camObj, ref bool ___pierceReady)
{
//IL_0073: 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_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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
if (__instance.gunVariation != 1 || !__instance.altVersion)
{
return true;
}
if ((Object)(object)___punch == (Object)null || !((Component)___punch).gameObject.activeInHierarchy)
{
___punch = MonoSingleton<FistControl>.Instance.currentPunch;
}
if (Object.op_Implicit((Object)(object)___punch))
{
___punch.CoinFlip();
}
GameObject val = Object.Instantiate<GameObject>(__instance.coin, ___camObj.transform.position + ___camObj.transform.up * -0.5f, ___camObj.transform.rotation);
val.AddComponent<CoinAddAttr>();
val.GetComponent<Coin>().sourceWeapon = __instance.gc.currentWeapon;
MonoSingleton<RumbleManager>.Instance.SetVibration(RumbleProperties.CoinToss);
NewMovement instance = MonoSingleton<NewMovement>.Instance;
Vector3 val2 = (Object.op_Implicit((Object)(object)instance.ridingRocket) ? instance.ridingRocket.rb.velocity : instance.rb.velocity);
Vector3 val3 = ___camObj.transform.forward * 20f + Vector3.up * 15f + val2;
val.GetComponent<Rigidbody>().AddForce(val3, (ForceMode)2);
__instance.pierceCharge = 0f;
___pierceReady = false;
return false;
}
}
[HarmonyPatch(typeof(Revolver), "Update")]
internal class Revolver_UpdatePatch
{
public static bool Prefix(Revolver __instance, ref bool ___shootReady, ref bool ___pierceReady, bool ___gunReady, InputManager ___inman, float ___coinCharge, CameraController ___cc, WeaponIdentifier ___wid, WeaponCharges ___wc, AudioSource ___ceaud, Light ___celight, MaterialPropertyBlock ___screenProps)
{
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
if (__instance.gunVariation != 1 || !__instance.altVersion)
{
return true;
}
Traverse val = Traverse.Create((object)__instance);
if (!___shootReady)
{
if (__instance.shootCharge + 200f * Time.deltaTime < 100f)
{
__instance.shootCharge += 200f * Time.deltaTime;
}
else
{
__instance.shootCharge = 100f;
___shootReady = true;
}
}
if (!___pierceReady)
{
if (__instance.pierceCharge + 480f * Time.deltaTime < 100f)
{
__instance.pierceCharge += 480f * Time.deltaTime;
}
else
{
__instance.pierceCharge = 100f;
___pierceReady = true;
}
}
float marksmanChargeCost = Property.MarksmanChargeCost;
if (__instance.gc.activated)
{
if ((___inman.InputSource.Fire2.WasPerformedThisFrame & ___pierceReady) && ___coinCharge >= marksmanChargeCost)
{
___cc.StopShake();
if (!Object.op_Implicit((Object)(object)___wid) || ___wid.delay == 0f)
{
___wc.rev1charge -= marksmanChargeCost;
val.Method("ThrowCoin", Array.Empty<object>()).GetValue();
}
else
{
((MonoBehaviour)__instance).Invoke("ThrowCoin", ___wid.delay);
___pierceReady = false;
__instance.pierceCharge = 0f;
}
}
else if ((___gunReady && !___inman.PerformingCheatMenuCombo() && ___inman.InputSource.Fire1.IsPressed) & ___shootReady)
{
if (!Object.op_Implicit((Object)(object)___wid) || ___wid.delay == 0f)
{
val.Method("Shoot", new object[1] { 1 }).GetValue();
}
else
{
___shootReady = false;
__instance.shootCharge = 0f;
((MonoBehaviour)__instance).Invoke("DelayedShoot", ___wid.delay);
}
if (Object.op_Implicit((Object)(object)___ceaud) && ___ceaud.volume != 0f)
{
___ceaud.volume = 0f;
}
}
}
if (Object.op_Implicit((Object)(object)___celight))
{
if (__instance.pierceShotCharge == 0f && ((Behaviour)___celight).enabled)
{
((Behaviour)___celight).enabled = false;
}
else if (__instance.pierceShotCharge != 0f)
{
((Behaviour)___celight).enabled = true;
___celight.range = __instance.pierceShotCharge * 0.01f;
}
}
if (__instance.gunVariation != 0)
{
val.Method("CheckCoinCharges", Array.Empty<object>()).GetValue();
}
else if (__instance.pierceCharge == 100f && Object.op_Implicit((Object)(object)MonoSingleton<ColorBlindSettings>.Instance))
{
___screenProps.SetColor("_Color", MonoSingleton<ColorBlindSettings>.Instance.variationColors[__instance.gunVariation]);
}
return false;
}
}
[HarmonyPatch(typeof(Revolver), "OnEnable")]
internal class Revolver_OnEnable
{
public static void Postfix(Revolver __instance, WeaponCharges ___wc)
{
if (__instance.gunVariation == 1 && __instance.altVersion)
{
WeaponChargesAddAttr component = ((Component)___wc).gameObject.GetComponent<WeaponChargesAddAttr>();
if (!Object.op_Implicit((Object)(object)component))
{
((Component)___wc).gameObject.AddComponent<WeaponChargesAddAttr>();
component = ((Component)___wc).gameObject.GetComponent<WeaponChargesAddAttr>();
}
component.rev1alt = __instance.altVersion;
}
}
}
[HarmonyPatch(typeof(Revolver), "CheckCoinCharges")]
internal class Revolver_CheckCoinCharges
{
public static bool Prefix(Revolver __instance, ref float ___coinCharge, ref AudioSource ___screenAud, WeaponCharges ___wc, WeaponIdentifier ___wid)
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
if (__instance.gunVariation != 1 || !__instance.altVersion)
{
return true;
}
if (__instance.coinPanelsCharged == null || __instance.coinPanelsCharged.Length == 0)
{
__instance.coinPanelsCharged = new bool[__instance.coinPanels.Length];
}
___coinCharge = ___wc.rev1charge;
for (int i = 0; i < __instance.coinPanels.Length; i++)
{
float marksmanChargeCost = Property.MarksmanChargeCost;
__instance.coinPanels[i].fillAmount = ___coinCharge / marksmanChargeCost - (float)i;
if (__instance.coinPanels[i].fillAmount < 1f)
{
((Graphic)__instance.coinPanels[i]).color = Color.red;
__instance.coinPanelsCharged[i] = false;
continue;
}
ColorBlindSettings instance = MonoSingleton<ColorBlindSettings>.Instance;
if (Object.op_Implicit((Object)(object)instance) && ((Graphic)__instance.coinPanels[i]).color != instance.variationColors[__instance.gunVariation])
{
((Graphic)__instance.coinPanels[i]).color = instance.variationColors[__instance.gunVariation];
}
if (!__instance.coinPanelsCharged[i] && (!Object.op_Implicit((Object)(object)___wid) || ___wid.delay == 0f))
{
if (!Object.op_Implicit((Object)(object)___screenAud))
{
___screenAud = ((Component)((Component)__instance).GetComponentInChildren<Canvas>()).GetComponent<AudioSource>();
}
___screenAud.pitch = 1f + (float)i / 2f;
___screenAud.Play();
__instance.coinPanelsCharged[i] = true;
}
}
return false;
}
}
[HarmonyPatch(typeof(WeaponCharges), "Charge")]
internal class WeaponCharges_Charge
{
public static void Postfix(WeaponCharges __instance, float amount)
{
WeaponChargesAddAttr component = ((Component)__instance).gameObject.GetComponent<WeaponChargesAddAttr>();
if (Object.op_Implicit((Object)(object)component))
{
float marksmanChargesSeconds = Property.MarksmanChargesSeconds;
float num = Property.MarksmanChargeCost / marksmanChargesSeconds;
if (__instance.rev1charge < 400f && component.rev1alt)
{
__instance.rev1charge = Mathf.MoveTowards(__instance.rev1charge, 400f, (num - 25f) * amount);
}
}
}
}
[BepInPlugin("yuu.slabman_buff", "Alt Marksman Buff", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string pluginGuid = "yuu.slabman_buff";
public const string pluginName = "Alt Marksman Buff";
public const string pluginVersion = "1.0.0";
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Alt Marksman Buff is loaded!");
AssetManager.LoadAssetBundle();
ConfigBuilder val = new ConfigBuilder("yuu.slabman_buff", "Alt Marksman Buff");
val.BuildAll();
Harmony val2 = new Harmony("yuu.slabman_buff");
val2.PatchAll();
}
}
internal class Property
{
[Configgable("", "Alt-Marksman Revolver Coin Charges", 0, "Determines how many charges the alt-marksman has (It doesn't change the revolver display).")]
private static int marksmanCharges = 2;
[Configgable("", "Alt-Marksman Revolver Coin Reharge Time", 0, "Determines how many seconds it takes for 1 charge to recharge.")]
private static float marksmanChargesSeconds = 6.5f;
[Configgable("", "Coin Bounce Times", 0, "Determines how many times you can shoot the coin before breaking.")]
private static int coinTotalHitAmmount = 2;
[Configgable("", "Coin Bounce Force", 0, "Determines the force with which the coin bounces after shooting it.")]
private static float coinHitBounceForce = 25f;
[Configgable("", "Coin size scale", 0, "Determines the size of the coin, relative to the original size.")]
private static float coinScale = 1.25f;
public static int CoinTotalHitAmmount => coinTotalHitAmmount;
public static float CoinHitBounceForce => coinHitBounceForce;
public static int MarksmanCharges => marksmanCharges;
public static float MarksmanChargeCost => 400 / marksmanCharges;
public static float MarksmanChargesSeconds => marksmanChargesSeconds;
public static Vector3 CoinScale => coinScale * new Vector3(0.1f, 0.1f, 0.01f);
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "SlabManBuff";
public const string PLUGIN_NAME = "SlabManBuff";
public const string PLUGIN_VERSION = "1.0.0";
}