using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UltraSilverCoins")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0+0c7499bfac987385c91a77b83655a1aa459e2415")]
[assembly: AssemblyProduct("UltraSilverCoins")]
[assembly: AssemblyTitle("UltraSilverCoins")]
[assembly: AssemblyVersion("0.3.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[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 UltraSilverCoins
{
internal static class AltMarksmanChargeController
{
private static readonly MethodInfo CheckCoinChargesMethod = AccessTools.Method(typeof(Revolver), "CheckCoinCharges", (Type[])null, (Type[])null);
private static readonly FieldInfo CoinChargeField = AccessTools.Field(typeof(Revolver), "coinCharge");
internal static float MaxCharge => (float)SilverCoinsConfig.CoinCharges * 100f;
private static float ChargePerSecond => 100f / SilverCoinsConfig.RechargeSeconds;
internal static bool Active { get; private set; }
internal static void OnRevolverEnabled(Revolver revolver)
{
if (!((Object)(object)revolver == (Object)null) && revolver.gunVariation == 1)
{
Active = revolver.altVersion;
if (revolver.altVersion)
{
EnforceAltMarksman(revolver);
InvokeCheckCoinCharges(revolver);
}
else
{
RestorePanelVisibility(revolver);
}
}
}
internal static void OnRevolverDisabled(Revolver revolver)
{
if (Plugin.IsAltMarksman(revolver))
{
Active = false;
}
}
internal static void ClampCharge(WeaponCharges charges)
{
if (!((Object)(object)charges == (Object)null))
{
if (charges.rev1charge > MaxCharge)
{
charges.rev1charge = MaxCharge;
}
if (charges.rev1charge < 0f)
{
charges.rev1charge = 0f;
}
}
}
internal static void EnforceAltMarksman(Revolver revolver)
{
if (Plugin.IsAltMarksman(revolver))
{
Active = true;
WeaponCharges weaponCharges = GetWeaponCharges();
ClampCharge(weaponCharges);
SetCoinCharge(revolver, ((Object)(object)weaponCharges == (Object)null) ? 0f : weaponCharges.rev1charge);
}
}
internal static void RechargeAltMarksman(WeaponCharges charges, float amount, float previousRev1Charge)
{
if (!((Object)(object)charges == (Object)null))
{
float num = Mathf.Min(previousRev1Charge, MaxCharge);
charges.rev1charge = Mathf.MoveTowards(num, MaxCharge, ChargePerSecond * Mathf.Max(0f, amount));
ClampCharge(charges);
}
}
internal static void UpdateMarksmanDisplay(Revolver revolver)
{
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)revolver == (Object)null || revolver.gunVariation != 1)
{
return;
}
if (!revolver.altVersion)
{
RestorePanelVisibility(revolver);
return;
}
Image[] coinPanels = revolver.coinPanels;
if (coinPanels == null || coinPanels.Length == 0)
{
return;
}
WeaponCharges weaponCharges = GetWeaponCharges();
ClampCharge(weaponCharges);
float num = (((Object)(object)weaponCharges == (Object)null) ? 0f : weaponCharges.rev1charge);
SetCoinCharge(revolver, num);
bool[] coinPanelsCharged = revolver.coinPanelsCharged;
int num2 = Mathf.Clamp(SilverCoinsConfig.CoinCharges, 1, coinPanels.Length);
HashSet<Transform> hashSet = new HashSet<Transform>();
for (int i = 0; i < coinPanels.Length && i < num2; i++)
{
if ((Object)(object)coinPanels[i] != (Object)null && (Object)(object)((Component)coinPanels[i]).transform.parent != (Object)null)
{
hashSet.Add(((Component)coinPanels[i]).transform.parent);
}
}
for (int j = 0; j < coinPanels.Length; j++)
{
Image val = coinPanels[j];
if (!((Object)(object)val == (Object)null))
{
bool flag = j < num2;
ApplySlotVisibility(val, flag, hashSet);
if (!flag)
{
SetCharged(coinPanelsCharged, j, charged: false);
continue;
}
float num3 = (val.fillAmount = Mathf.Clamp01(num / 100f - (float)j));
((Graphic)val).color = ((num3 >= 1f) ? SilverCoinStyle.SilverColor : Color.gray);
SetCharged(coinPanelsCharged, j, num3 >= 1f);
}
}
}
private static void ApplySlotVisibility(Image panel, bool visible, HashSet<Transform> visibleParents)
{
Transform parent = ((Component)panel).transform.parent;
if (visible)
{
if ((Object)(object)parent != (Object)null && !((Component)parent).gameObject.activeSelf)
{
((Component)parent).gameObject.SetActive(true);
}
((Component)panel).gameObject.SetActive(true);
((Behaviour)panel).enabled = true;
return;
}
panel.fillAmount = 0f;
((Behaviour)panel).enabled = false;
((Component)panel).gameObject.SetActive(false);
if ((Object)(object)parent != (Object)null && !visibleParents.Contains(parent))
{
((Component)parent).gameObject.SetActive(false);
}
}
private static void RestorePanelVisibility(Revolver revolver)
{
Image[] array = revolver?.coinPanels;
if (array == null)
{
return;
}
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null)
{
Transform parent = ((Component)array[i]).transform.parent;
if ((Object)(object)parent != (Object)null && !((Component)parent).gameObject.activeSelf)
{
((Component)parent).gameObject.SetActive(true);
}
((Component)array[i]).gameObject.SetActive(true);
((Behaviour)array[i]).enabled = true;
}
}
}
private static void SetCharged(bool[] chargedPanels, int index, bool charged)
{
if (chargedPanels != null && index >= 0 && index < chargedPanels.Length)
{
chargedPanels[index] = charged;
}
}
private static void InvokeCheckCoinCharges(Revolver revolver)
{
CheckCoinChargesMethod?.Invoke(revolver, null);
}
private static void SetCoinCharge(Revolver revolver, float charge)
{
CoinChargeField?.SetValue(revolver, Mathf.Clamp(charge, 0f, MaxCharge));
}
private static WeaponCharges GetWeaponCharges()
{
return MonoSingleton<WeaponCharges>.Instance;
}
}
[BepInPlugin("ultrasilvercoins.kiyroprower.ultrakill", "UltraSilverCoins", "0.3.0")]
[BepInProcess("ULTRAKILL.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "ultrasilvercoins.kiyroprower.ultrakill";
public const string PluginName = "UltraSilverCoins";
public const string PluginVersion = "0.3.0";
public const string PluginConfiguratorGuid = "com.eternalUnion.pluginConfigurator";
internal static ManualLogSource Log;
private Harmony harmony;
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
SilverCoinsConfig.Initialize(((BaseUnityPlugin)this).Logger);
harmony = new Harmony("ultrasilvercoins.kiyroprower.ultrakill");
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"UltraSilverCoins 0.3.0 loaded.");
}
private void OnDestroy()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
internal static bool IsAltMarksman(Revolver revolver)
{
if ((Object)(object)revolver != (Object)null && revolver.gunVariation == 1)
{
return revolver.altVersion;
}
return false;
}
internal static bool IsAltMarksmanWeapon(GameObject weapon)
{
Revolver revolver = default(Revolver);
if ((Object)(object)weapon != (Object)null && weapon.TryGetComponent<Revolver>(ref revolver))
{
return IsAltMarksman(revolver);
}
return false;
}
}
internal sealed class SilverBeamMarker : MonoBehaviour
{
}
internal sealed class SilverCoinBehaviour : MonoBehaviour
{
private const float MinBounceSpeedSqr = 0.01f;
private const float TripleTimeDelay = 0.35f;
private const float TripleTimeEndDelay = 0.417f;
private const float DoubleTimeDelay = 1f;
private static readonly FieldInfo CurrentChargeField = AccessTools.Field(typeof(Coin), "currentCharge");
private static bool continuationPending;
private static int continuationShotsRemaining;
private static int continuationSolidBouncesRemaining;
private static Vector3 vanillaCoinScale = Vector3.zero;
private bool initialized;
private int shotsRemaining = MaxShots;
private int solidBouncesRemaining = MaxSolidBounces;
private Vector3 lastVelocity;
private Rigidbody cachedBody;
private static int MaxShots => SilverCoinsConfig.BounceTimes;
private static float ScaleMultiplier => SilverCoinsConfig.CoinSizeScale;
private static float BounceVelocity => SilverCoinsConfig.BounceForce;
private static int MaxSolidBounces => SilverCoinsConfig.SolidBounces;
internal static SilverCoinBehaviour Attach(Coin coin)
{
if ((Object)(object)coin == (Object)null)
{
return null;
}
SilverCoinBehaviour silverCoinBehaviour = default(SilverCoinBehaviour);
if (!((Component)coin).TryGetComponent<SilverCoinBehaviour>(ref silverCoinBehaviour))
{
silverCoinBehaviour = ((Component)coin).gameObject.AddComponent<SilverCoinBehaviour>();
}
silverCoinBehaviour.Initialize(coin);
return silverCoinBehaviour;
}
internal static bool TryGet(Coin coin, out SilverCoinBehaviour behaviour)
{
behaviour = null;
if ((Object)(object)coin != (Object)null)
{
return ((Component)coin).TryGetComponent<SilverCoinBehaviour>(ref behaviour);
}
return false;
}
internal void Initialize(Coin coin)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if (!initialized && !((Object)(object)coin == (Object)null))
{
initialized = true;
shotsRemaining = MaxShots;
solidBouncesRemaining = MaxSolidBounces;
if (vanillaCoinScale == Vector3.zero)
{
vanillaCoinScale = ((Component)coin).transform.localScale;
}
ApplySilverScale(coin);
SilverCoinStyle.ApplyCoin(((Component)coin).gameObject);
}
}
private void FixedUpdate()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (solidBouncesRemaining > 0)
{
Rigidbody val = ResolveBody();
if ((Object)(object)val != (Object)null && !val.isKinematic)
{
lastVelocity = val.velocity;
}
}
}
internal void HandleReflectFinished(Coin coin)
{
if (!((Object)(object)coin == (Object)null) && !((Component)coin).gameObject.activeSelf)
{
shotsRemaining--;
if (shotsRemaining > 0)
{
RemoveCollectorsTargeting(((Component)coin).gameObject);
ReviveAndBounce(coin);
}
}
}
internal static void RecordContinuation(Coin coin)
{
if (TryGet(coin, out var behaviour))
{
continuationPending = true;
continuationShotsRemaining = behaviour.shotsRemaining;
continuationSolidBouncesRemaining = behaviour.solidBouncesRemaining;
}
}
internal static void HandleCloneContinuation(Coin coin)
{
if (TryGet(coin, out var behaviour))
{
behaviour.initialized = true;
if (continuationPending)
{
behaviour.shotsRemaining = continuationShotsRemaining;
behaviour.solidBouncesRemaining = continuationSolidBouncesRemaining;
continuationPending = false;
}
ApplySilverScale(coin);
SilverCoinStyle.ApplyCoin(((Component)coin).gameObject);
ApplyBounceVelocity(coin);
}
}
private static void ApplySilverScale(Coin coin)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_002b: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)coin == (Object)null) && !(vanillaCoinScale == Vector3.zero))
{
((Component)coin).transform.localScale = vanillaCoinScale * ScaleMultiplier;
}
}
private static void ApplyBounceVelocity(Coin coin)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
Rigidbody val = (((Object)(object)coin.rb != (Object)null) ? coin.rb : ((Component)coin).GetComponent<Rigidbody>());
if ((Object)(object)val != (Object)null && !val.isKinematic)
{
val.velocity = Vector3.up * BounceVelocity;
}
}
internal bool TryBounceOffSolid(Coin coin, Collision collision)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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_0097: 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_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)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
if (solidBouncesRemaining <= 0 || collision == null || collision.contactCount == 0)
{
return false;
}
if (!LayerMaskDefaults.IsMatchingLayer(collision.gameObject.layer, (LMD)1))
{
return false;
}
Rigidbody val = (((Object)(object)coin != (Object)null && (Object)(object)coin.rb != (Object)null) ? coin.rb : ResolveBody());
if ((Object)(object)val == (Object)null || val.isKinematic)
{
return false;
}
Vector3 val2 = ((((Vector3)(ref lastVelocity)).sqrMagnitude > 0.01f) ? lastVelocity : val.velocity);
if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
{
return false;
}
ContactPoint contact = collision.GetContact(0);
Vector3 normal = ((ContactPoint)(ref contact)).normal;
Vector3 val3 = Vector3.Reflect(val2, normal);
if (Vector3.Dot(val3, normal) < 0f)
{
val3 = normal * ((Vector3)(ref val2)).magnitude;
}
val.velocity = val3;
val.angularVelocity = Vector3.zero;
lastVelocity = val3;
solidBouncesRemaining--;
return true;
}
private Rigidbody ResolveBody()
{
if ((Object)(object)cachedBody == (Object)null)
{
cachedBody = ((Component)this).GetComponent<Rigidbody>();
}
return cachedBody;
}
private static void RemoveCollectorsTargeting(GameObject coinObject)
{
CoinCollector[] array = Object.FindObjectsOfType<CoinCollector>();
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null && (Object)(object)array[i].coin == (Object)(object)coinObject)
{
Object.Destroy((Object)(object)((Component)array[i]).gameObject);
}
}
}
private void ReviveAndBounce(Coin coin)
{
//IL_0076: 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)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)coin).gameObject;
gameObject.SetActive(true);
coin.shot = false;
coin.shotByEnemy = false;
coin.hitTimes = 1;
coin.doubled = false;
Collider[] components = ((Component)coin).GetComponents<Collider>();
for (int i = 0; i < components.Length; i++)
{
components[i].enabled = true;
}
Rigidbody val = (((Object)(object)coin.rb != (Object)null) ? coin.rb : ((Component)coin).GetComponent<Rigidbody>());
if ((Object)(object)val != (Object)null)
{
val.isKinematic = false;
val.velocity = Vector3.zero;
val.angularVelocity = Vector3.zero;
val.AddForce(Vector3.up * BounceVelocity, (ForceMode)2);
}
((MonoBehaviour)coin).CancelInvoke("GetDeleted");
((MonoBehaviour)coin).Invoke("GetDeleted", 5f);
RestartChargeGlowWindow(coin);
ApplySilverScale(coin);
SilverCoinStyle.ApplyCoin(gameObject);
}
private static void RestartChargeGlowWindow(Coin coin)
{
DestroyCurrentCharge(coin);
((MonoBehaviour)coin).CancelInvoke("TripleTime");
((MonoBehaviour)coin).CancelInvoke("TripleTimeEnd");
((MonoBehaviour)coin).CancelInvoke("DoubleTime");
((MonoBehaviour)coin).Invoke("TripleTime", 0.35f);
((MonoBehaviour)coin).Invoke("TripleTimeEnd", 0.417f);
((MonoBehaviour)coin).Invoke("DoubleTime", 1f);
}
private static void DestroyCurrentCharge(Coin coin)
{
object? obj = CurrentChargeField?.GetValue(coin);
GameObject val = (GameObject)((obj is GameObject) ? obj : null);
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val);
CurrentChargeField.SetValue(coin, null);
}
}
}
internal static class SilverCoinsConfig
{
[CompilerGenerated]
private static class <>O
{
public static PostBoolValueChangeEvent <0>__UpdateExperimentalVisibility;
}
public const string PluginGuid = "ultrasilvercoins.kiyroprower.ultrakill";
private const int DefaultCoinCharges = 2;
private const float DefaultRechargeSeconds = 6.5f;
private const int DefaultBounceTimes = 2;
private const float DefaultBounceForce = 25f;
private const float DefaultCoinSizeScale = 1.25f;
private const int DefaultSolidBounces = 0;
private const int MinCoinCharges = 1;
private const int MaxCoinCharges = 4;
private const int MinBounceTimes = 1;
private const int MaxBounceTimes = 10;
private const float MinRechargeSeconds = 0.1f;
private const float MaxRechargeSeconds = 60f;
private const float MinBounceForce = 0f;
private const float MaxBounceForce = 200f;
private const float MinCoinSizeScale = 0.1f;
private const float MaxCoinSizeScale = 5f;
private const int MinSolidBounces = 0;
private const int MaxSolidBounces = 10;
private static PluginConfigurator _configurator;
private static ManualLogSource _log;
private static ConfigHeader _experimentalHeader;
private static ConfigHeader _railgunThunderboltDescription;
public static IntField CoinChargesField { get; private set; }
public static FloatField RechargeTimeField { get; private set; }
public static IntField BounceTimesField { get; private set; }
public static FloatField BounceForceField { get; private set; }
public static FloatField CoinSizeScaleField { get; private set; }
public static IntField SolidBouncesField { get; private set; }
public static BoolField SuperSecretSettingsField { get; private set; }
public static BoolField RailgunThunderboltField { get; private set; }
public static int CoinCharges
{
get
{
if (CoinChargesField != null)
{
return Mathf.Clamp(CoinChargesField.value, 1, 4);
}
return 2;
}
}
public static float RechargeSeconds
{
get
{
if (RechargeTimeField != null)
{
return Mathf.Max(0.1f, RechargeTimeField.value);
}
return 6.5f;
}
}
public static int BounceTimes
{
get
{
if (BounceTimesField != null)
{
return Mathf.Clamp(BounceTimesField.value, 1, 10);
}
return 2;
}
}
public static float BounceForce
{
get
{
if (BounceForceField != null)
{
return Mathf.Max(0f, BounceForceField.value);
}
return 25f;
}
}
public static float CoinSizeScale
{
get
{
if (CoinSizeScaleField != null)
{
return Mathf.Max(0.1f, CoinSizeScaleField.value);
}
return 1.25f;
}
}
public static int SolidBounces
{
get
{
if (SolidBouncesField != null)
{
return Mathf.Clamp(SolidBouncesField.value, 0, 10);
}
return 0;
}
}
public static bool SuperSecretSettings
{
get
{
if (SuperSecretSettingsField != null)
{
return SuperSecretSettingsField.value;
}
return false;
}
}
public static bool RailgunThunderbolt
{
get
{
if (SuperSecretSettings && RailgunThunderboltField != null)
{
return RailgunThunderboltField.value;
}
return false;
}
}
public static void Initialize(ManualLogSource log)
{
_log = log;
try
{
CreateMenu();
}
catch (Exception ex)
{
ManualLogSource log2 = _log;
if (log2 != null)
{
log2.LogWarning((object)("PluginConfigurator menu could not be initialized: " + ex.GetType().Name + ": " + ex.Message));
}
}
}
private static void CreateMenu()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Expected O, but got Unknown
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Expected O, but got Unknown
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Expected O, but got Unknown
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
if (_configurator == null)
{
_configurator = PluginConfigurator.Create("Ultra Silver Coins", "ultrasilvercoins.kiyroprower.ultrakill");
ConfigPanel rootPanel = _configurator.rootPanel;
CoinChargesField = new IntField(rootPanel, "Alt-Marksman Coin Charges", "ultrasilvercoins.coinCharges", 2, 1, 4);
AddDescription(rootPanel, "How many coins the Alt-Marksman revolver can hold and throw.");
RechargeTimeField = new FloatField(rootPanel, "Alt-Marksman Coin Recharge Time", "ultrasilvercoins.rechargeTime", 6.5f, 0.1f, 60f);
AddDescription(rootPanel, "Seconds to recharge a single coin charge.");
BounceTimesField = new IntField(rootPanel, "Coin Bounce Times", "ultrasilvercoins.bounceTimes", 2, 1, 10);
AddDescription(rootPanel, "How many times a silver coin can be shot before it is consumed.");
BounceForceField = new FloatField(rootPanel, "Coin Bounce Force", "ultrasilvercoins.bounceForce", 25f, 0f, 200f);
AddDescription(rootPanel, "Upward velocity applied to a silver coin each time it bounces.");
CoinSizeScaleField = new FloatField(rootPanel, "Coin Size Scale", "ultrasilvercoins.coinSizeScale", 1.25f, 0.1f, 5f);
AddDescription(rootPanel, "Size multiplier applied to silver coins.");
SolidBouncesField = new IntField(rootPanel, "Coin Solid Bounces", "ultrasilvercoins.solidBounces", 0, 0, 10);
AddDescription(rootPanel, "How many times a silver coin ricochets off solid surfaces instead of vanishing on impact. Set to 0 to disable.");
SuperSecretSettingsField = new BoolField(rootPanel, "Super Secret Settings", "ultrasilvercoins.superSecretSettings", false);
AddDescription(rootPanel, "Reveals experimental, untested, goofy silver coin options. Everything below is off by default.");
_experimentalHeader = new ConfigHeader(rootPanel, "Experimental Silver Coin Mechanics", 18);
RailgunThunderboltField = new BoolField(rootPanel, "Railgun Coin Thunderbolt", "ultrasilvercoins.railgunThunderbolt", false);
_railgunThunderboltDescription = AddDescription(rootPanel, "Shoot a silver coin with the Railcannon and the reflected beam calls a Ferryman thunderbolt down on each enemy it hits. The blast will not hurt you.");
BoolField superSecretSettingsField = SuperSecretSettingsField;
object obj = <>O.<0>__UpdateExperimentalVisibility;
if (obj == null)
{
PostBoolValueChangeEvent val = UpdateExperimentalVisibility;
<>O.<0>__UpdateExperimentalVisibility = val;
obj = (object)val;
}
superSecretSettingsField.postValueChangeEvent += (PostBoolValueChangeEvent)obj;
UpdateExperimentalVisibility(SuperSecretSettings);
}
}
private static void UpdateExperimentalVisibility(bool visible)
{
bool hidden = !visible;
if (_experimentalHeader != null)
{
((ConfigField)_experimentalHeader).hidden = hidden;
}
if (RailgunThunderboltField != null)
{
((ConfigField)RailgunThunderboltField).hidden = hidden;
}
if (_railgunThunderboltDescription != null)
{
((ConfigField)_railgunThunderboltDescription).hidden = hidden;
}
}
private static ConfigHeader AddDescription(ConfigPanel root, string text)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
return new ConfigHeader(root, text, 14)
{
textColor = Color.gray
};
}
}
internal static class SilverCoinStyle
{
internal static readonly Color SilverColor = new Color(0.78f, 0.82f, 0.88f, 1f);
private static readonly Color SilverEmission = new Color(0.55f, 0.65f, 0.85f, 1f);
private static readonly Color TransparentSilver = new Color(0.78f, 0.82f, 0.88f, 0f);
private const string CoinTexture2Resource = "UltraSilverCoins.Assets.coin01_2.png";
private const string CoinTexture3Resource = "UltraSilverCoins.Assets.coin01_3.png";
private const string MuzzleFlashSilverResource = "UltraSilverCoins.Assets.muzzleflashsilver.png";
private static bool attemptedTextureLoad;
private static Texture2D coinTexture2;
private static Texture2D coinTexture3;
private static Texture2D muzzleFlashSilverTexture;
private static Sprite silverMuzzleFlashSprite;
internal static void ApplyCoin(GameObject coinObject)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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)
if (!((Object)(object)coinObject == (Object)null))
{
MeshRenderer[] componentsInChildren = coinObject.GetComponentsInChildren<MeshRenderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
ApplyRendererMaterials((Renderer)(object)componentsInChildren[i], SilverColor, replaceCoinTextures: true);
}
TrailRenderer[] componentsInChildren2 = coinObject.GetComponentsInChildren<TrailRenderer>(true);
for (int j = 0; j < componentsInChildren2.Length; j++)
{
componentsInChildren2[j].startColor = SilverColor;
componentsInChildren2[j].endColor = TransparentSilver;
ApplyRendererMaterials((Renderer)(object)componentsInChildren2[j], SilverColor);
}
Light[] componentsInChildren3 = coinObject.GetComponentsInChildren<Light>(true);
for (int k = 0; k < componentsInChildren3.Length; k++)
{
componentsInChildren3[k].color = SilverColor;
}
}
}
internal static void ApplySpentCoin(GameObject coinObject)
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)coinObject == (Object)null)
{
return;
}
EnsureCoinTexturesLoaded();
Texture2D val = coinTexture3 ?? coinTexture2;
if ((Object)(object)val == (Object)null)
{
return;
}
MeshRenderer[] componentsInChildren = coinObject.GetComponentsInChildren<MeshRenderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
if ((Object)(object)componentsInChildren[i] == (Object)null)
{
continue;
}
Material material = ((Renderer)componentsInChildren[i]).material;
if (!((Object)(object)material == (Object)null))
{
if (material.HasProperty("_MainTex"))
{
material.SetTexture("_MainTex", (Texture)(object)val);
}
if (material.HasProperty("_BaseMap"))
{
material.SetTexture("_BaseMap", (Texture)(object)val);
}
if (material.HasProperty("_Color"))
{
material.SetColor("_Color", Color.white);
}
if (material.HasProperty("_BaseColor"))
{
material.SetColor("_BaseColor", Color.white);
}
}
}
}
internal static void ApplyBeam(GameObject beamObject)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)beamObject == (Object)null))
{
SilverBeamMarker silverBeamMarker = default(SilverBeamMarker);
if (!beamObject.TryGetComponent<SilverBeamMarker>(ref silverBeamMarker))
{
beamObject.AddComponent<SilverBeamMarker>();
}
LineRenderer[] componentsInChildren = beamObject.GetComponentsInChildren<LineRenderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].startColor = SilverColor;
componentsInChildren[i].endColor = SilverColor;
ApplyRendererMaterials((Renderer)(object)componentsInChildren[i], SilverColor);
}
TrailRenderer[] componentsInChildren2 = beamObject.GetComponentsInChildren<TrailRenderer>(true);
for (int j = 0; j < componentsInChildren2.Length; j++)
{
componentsInChildren2[j].startColor = SilverColor;
componentsInChildren2[j].endColor = TransparentSilver;
ApplyRendererMaterials((Renderer)(object)componentsInChildren2[j], SilverColor);
}
Renderer[] componentsInChildren3 = beamObject.GetComponentsInChildren<Renderer>(true);
for (int k = 0; k < componentsInChildren3.Length; k++)
{
ApplyRendererMaterials(componentsInChildren3[k], SilverColor);
}
Light[] componentsInChildren4 = beamObject.GetComponentsInChildren<Light>(true);
for (int l = 0; l < componentsInChildren4.Length; l++)
{
componentsInChildren4[l].color = SilverColor;
}
ParticleSystem[] componentsInChildren5 = beamObject.GetComponentsInChildren<ParticleSystem>(true);
for (int m = 0; m < componentsInChildren5.Length; m++)
{
MainModule main = componentsInChildren5[m].main;
((MainModule)(ref main)).startColor = new MinMaxGradient(SilverColor);
}
}
}
internal static void ApplyEffect(GameObject effectObject)
{
if (!((Object)(object)effectObject == (Object)null))
{
RecolorEffect(effectObject);
SilverEffectTint silverEffectTint = default(SilverEffectTint);
if (!effectObject.TryGetComponent<SilverEffectTint>(ref silverEffectTint))
{
effectObject.AddComponent<SilverEffectTint>();
}
}
}
internal static void RecolorEffect(GameObject effectObject)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)effectObject == (Object)null)
{
return;
}
Renderer[] componentsInChildren = effectObject.GetComponentsInChildren<Renderer>(true);
foreach (Renderer obj in componentsInChildren)
{
TintSpriteRenderer((SpriteRenderer)(object)((obj is SpriteRenderer) ? obj : null));
}
Light[] componentsInChildren2 = effectObject.GetComponentsInChildren<Light>(true);
for (int j = 0; j < componentsInChildren2.Length; j++)
{
if ((Object)(object)componentsInChildren2[j] != (Object)null)
{
componentsInChildren2[j].color = SilverColor;
}
}
ParticleSystem[] componentsInChildren3 = effectObject.GetComponentsInChildren<ParticleSystem>(true);
for (int k = 0; k < componentsInChildren3.Length; k++)
{
RecolorParticleSystem(componentsInChildren3[k]);
}
}
internal static void TintSpriteRenderer(SpriteRenderer spriteRenderer)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)spriteRenderer == (Object)null)
{
return;
}
if (IsMuzzleFlashSprite(spriteRenderer.sprite))
{
Sprite val = GetSilverMuzzleFlashSprite(spriteRenderer.sprite);
if ((Object)(object)val != (Object)null && (Object)(object)spriteRenderer.sprite != (Object)(object)val)
{
spriteRenderer.sprite = val;
}
Color color = spriteRenderer.color;
spriteRenderer.color = new Color(1f, 1f, 1f, color.a);
}
else
{
Color color2 = spriteRenderer.color;
spriteRenderer.color = new Color(SilverColor.r, SilverColor.g, SilverColor.b, color2.a);
}
}
private static bool IsMuzzleFlashSprite(Sprite sprite)
{
if ((Object)(object)sprite == (Object)null)
{
return false;
}
if ((Object)(object)sprite == (Object)(object)silverMuzzleFlashSprite)
{
return true;
}
string text = (((Object)sprite).name ?? string.Empty).ToLowerInvariant();
string text2 = (((Object)(object)sprite.texture != (Object)null) ? (((Object)sprite.texture).name ?? string.Empty).ToLowerInvariant() : string.Empty);
if (!text.Contains("muzzleflash"))
{
return text2.Contains("muzzleflash");
}
return true;
}
private static Sprite GetSilverMuzzleFlashSprite(Sprite original)
{
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_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_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)silverMuzzleFlashSprite != (Object)null)
{
return silverMuzzleFlashSprite;
}
Texture2D val = GetMuzzleFlashSilverTexture();
if ((Object)(object)val == (Object)null)
{
return null;
}
float num = 100f;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0.5f, 0.5f);
if ((Object)(object)original != (Object)null)
{
Rect rect = original.rect;
if (((Rect)(ref rect)).width > 0f)
{
rect = original.rect;
if (((Rect)(ref rect)).height > 0f && original.pixelsPerUnit > 0f)
{
rect = original.rect;
float num2 = ((Rect)(ref rect)).width / original.pixelsPerUnit;
if (num2 > 0f)
{
num = (float)((Texture)val).width / num2;
}
float x = original.pivot.x;
rect = original.rect;
float num3 = x / ((Rect)(ref rect)).width;
float y = original.pivot.y;
rect = original.rect;
((Vector2)(ref val2))..ctor(num3, y / ((Rect)(ref rect)).height);
}
}
}
silverMuzzleFlashSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), val2, num);
((Object)silverMuzzleFlashSprite).name = "muzzleflashsilver_sprite";
return silverMuzzleFlashSprite;
}
internal static void RecolorParticleSystem(ParticleSystem particles)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//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_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)particles == (Object)null))
{
MainModule main = particles.main;
((MainModule)(ref main)).startColor = RecolorGradient(((MainModule)(ref main)).startColor);
ColorOverLifetimeModule colorOverLifetime = particles.colorOverLifetime;
if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
{
((ColorOverLifetimeModule)(ref colorOverLifetime)).color = RecolorGradient(((ColorOverLifetimeModule)(ref colorOverLifetime)).color);
}
ColorBySpeedModule colorBySpeed = particles.colorBySpeed;
if (((ColorBySpeedModule)(ref colorBySpeed)).enabled)
{
((ColorBySpeedModule)(ref colorBySpeed)).color = RecolorGradient(((ColorBySpeedModule)(ref colorBySpeed)).color);
}
}
}
private static MinMaxGradient RecolorGradient(MinMaxGradient source)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected I4, but got Unknown
//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)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_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_0089: Unknown result type (might be due to invalid IL or missing references)
ParticleSystemGradientMode mode = ((MinMaxGradient)(ref source)).mode;
switch ((int)mode)
{
case 0:
return new MinMaxGradient(WithSilverRgb(((MinMaxGradient)(ref source)).color));
case 2:
return new MinMaxGradient(WithSilverRgb(((MinMaxGradient)(ref source)).colorMin), WithSilverRgb(((MinMaxGradient)(ref source)).colorMax));
case 1:
case 4:
return new MinMaxGradient(RecolorGradientKeys(((MinMaxGradient)(ref source)).gradient));
case 3:
return new MinMaxGradient(RecolorGradientKeys(((MinMaxGradient)(ref source)).gradientMin), RecolorGradientKeys(((MinMaxGradient)(ref source)).gradientMax));
default:
return new MinMaxGradient(SilverColor);
}
}
private static Gradient RecolorGradientKeys(Gradient source)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_0012: 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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
Gradient val = new Gradient();
if (source == null)
{
val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(SilverColor, 0f),
new GradientColorKey(SilverColor, 1f)
}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
{
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0f, 1f)
});
return val;
}
GradientColorKey[] colorKeys = source.colorKeys;
for (int i = 0; i < colorKeys.Length; i++)
{
colorKeys[i].color = SilverColor;
}
val.mode = source.mode;
val.SetKeys(colorKeys, source.alphaKeys);
return val;
}
private static Color WithSilverRgb(Color original)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
return new Color(SilverColor.r, SilverColor.g, SilverColor.b, original.a);
}
private static void ApplyRendererMaterials(Renderer renderer, Color color, bool replaceCoinTextures = false)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)renderer == (Object)null))
{
Material[] materials = renderer.materials;
for (int i = 0; i < materials.Length; i++)
{
ApplyMaterial(materials[i], color, replaceCoinTextures);
}
}
}
private static void ApplyMaterial(Material material, Color color, bool replaceCoinTextures = false)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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)
//IL_0017: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)material == (Object)null))
{
Color val = color;
if (replaceCoinTextures && ApplyCoinTexture(material))
{
val = Color.white;
}
if (material.HasProperty("_Color"))
{
material.SetColor("_Color", val);
}
if (material.HasProperty("_BaseColor"))
{
material.SetColor("_BaseColor", val);
}
if (material.HasProperty("_TintColor"))
{
material.SetColor("_TintColor", val);
}
if (material.HasProperty("_EmissionColor"))
{
material.SetColor("_EmissionColor", SilverEmission);
material.EnableKeyword("_EMISSION");
}
}
}
private static bool ApplyCoinTexture(Material material)
{
EnsureCoinTexturesLoaded();
if ((Object)(object)coinTexture2 == (Object)null && (Object)(object)coinTexture3 == (Object)null)
{
return false;
}
Texture val = (material.HasProperty("_MainTex") ? material.GetTexture("_MainTex") : null);
string obj = ((Object)material).name ?? string.Empty;
string text = (((Object)(object)val == (Object)null) ? string.Empty : (((Object)val).name ?? string.Empty));
string text2 = (obj + " " + text).ToLowerInvariant();
Texture2D val2 = null;
if (text2.Contains("coin01_3"))
{
val2 = coinTexture3 ?? coinTexture2;
}
else if (text2.Contains("coin01_2"))
{
val2 = coinTexture2 ?? coinTexture3;
}
else if (text2.Contains("coin"))
{
val2 = coinTexture2 ?? coinTexture3;
}
if ((Object)(object)val2 == (Object)null)
{
return false;
}
bool result = false;
if (material.HasProperty("_MainTex"))
{
material.SetTexture("_MainTex", (Texture)(object)val2);
result = true;
}
if (material.HasProperty("_BaseMap"))
{
material.SetTexture("_BaseMap", (Texture)(object)val2);
result = true;
}
return result;
}
private static void EnsureCoinTexturesLoaded()
{
if (!attemptedTextureLoad)
{
attemptedTextureLoad = true;
coinTexture2 = LoadEmbeddedTexture("UltraSilverCoins.Assets.coin01_2.png", "coin01_2_silver");
coinTexture3 = LoadEmbeddedTexture("UltraSilverCoins.Assets.coin01_3.png", "coin01_3_silver");
muzzleFlashSilverTexture = LoadEmbeddedTexture("UltraSilverCoins.Assets.muzzleflashsilver.png", "muzzleflashsilver");
}
}
private static Texture2D GetMuzzleFlashSilverTexture()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
EnsureCoinTexturesLoaded();
if ((Object)(object)muzzleFlashSilverTexture == (Object)null)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogWarning((object)"[UltraSilverCoins] muzzleflashsilver texture unavailable; using solid silver fallback.");
}
muzzleFlashSilverTexture = CreateSolidTexture(SilverColor);
}
return muzzleFlashSilverTexture;
}
private static Texture2D CreateSolidTexture(Color color)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false);
((Object)val).name = "muzzleflashsilver_fallback";
Color[] array = (Color[])(object)new Color[((Texture)val).width * ((Texture)val).height];
for (int i = 0; i < array.Length; i++)
{
array[i] = color;
}
val.SetPixels(array);
val.Apply();
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).filterMode = (FilterMode)1;
return val;
}
private static Texture2D LoadEmbeddedTexture(string resourceName, string textureName)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
if (stream == null)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogWarning((object)("[UltraSilverCoins] embedded resource missing: " + resourceName));
}
return null;
}
byte[] array;
using (MemoryStream memoryStream = new MemoryStream())
{
stream.CopyTo(memoryStream);
array = memoryStream.ToArray();
}
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
((Object)val).name = textureName;
if (!ImageConversion.LoadImage(val, array, false))
{
ManualLogSource log2 = Plugin.Log;
if (log2 != null)
{
log2.LogWarning((object)$"[UltraSilverCoins] ImageConversion.LoadImage failed for {textureName} ({array.Length} bytes)");
}
Object.Destroy((Object)(object)val);
return null;
}
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).filterMode = (FilterMode)1;
ManualLogSource log3 = Plugin.Log;
if (log3 != null)
{
log3.LogInfo((object)$"[UltraSilverCoins] loaded texture {textureName}: {((Texture)val).width}x{((Texture)val).height} ({array.Length} bytes)");
}
return val;
}
}
internal sealed class SilverEffectTint : MonoBehaviour
{
private void LateUpdate()
{
SilverCoinStyle.RecolorEffect(((Component)this).gameObject);
}
}
internal sealed class SilverThunderboltBeam : MonoBehaviour
{
private readonly HashSet<EnemyIdentifier> struckEnemies = new HashSet<EnemyIdentifier>();
internal bool TryRegisterHit(EnemyIdentifier enemy)
{
if ((Object)(object)enemy != (Object)null)
{
return struckEnemies.Add(enemy);
}
return false;
}
}
internal static class SilverThunderbolt
{
private static readonly FieldInfo LightningBoltField = AccessTools.Field(typeof(Ferryman), "lightningBolt");
private static LightningStrikeExplosive boltPrefab;
internal static void TagBeam(GameObject beam)
{
SilverThunderboltBeam silverThunderboltBeam = default(SilverThunderboltBeam);
if ((Object)(object)beam != (Object)null && !beam.TryGetComponent<SilverThunderboltBeam>(ref silverThunderboltBeam))
{
beam.AddComponent<SilverThunderboltBeam>();
}
}
internal static void Strike(Vector3 position)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
LightningStrikeExplosive val = ResolvePrefab();
if ((Object)(object)val == (Object)null || (Object)(object)val.normal == (Object)null)
{
return;
}
Explosion[] componentsInChildren = Object.Instantiate<GameObject>(val.normal, position, Quaternion.identity).GetComponentsInChildren<Explosion>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
if ((Object)(object)componentsInChildren[i] != (Object)null)
{
componentsInChildren[i].canHit = (AffectedSubjects)2;
}
}
}
private static LightningStrikeExplosive ResolvePrefab()
{
if ((Object)(object)boltPrefab != (Object)null)
{
return boltPrefab;
}
if (LightningBoltField == null)
{
return null;
}
DefaultReferenceManager instance = MonoSingleton<DefaultReferenceManager>.Instance;
if ((Object)(object)instance == (Object)null || (Object)(object)instance.ferryman == (Object)null)
{
ManualLogSource log = Plugin.Log;
if (log != null)
{
log.LogWarning((object)"[UltraSilverCoins] Ferryman reference unavailable; cannot summon a thunderbolt yet.");
}
return null;
}
Ferryman componentInChildren = instance.ferryman.GetComponentInChildren<Ferryman>(true);
if ((Object)(object)componentInChildren == (Object)null)
{
return null;
}
object? value = LightningBoltField.GetValue(componentInChildren);
boltPrefab = (LightningStrikeExplosive)((value is LightningStrikeExplosive) ? value : null);
return boltPrefab;
}
}
}
namespace UltraSilverCoins.Patches
{
[HarmonyPatch(typeof(Coin), "Start")]
internal static class CoinStartPatch
{
private static void Postfix(Coin __instance)
{
if (Plugin.IsAltMarksmanWeapon(__instance.sourceWeapon))
{
if (SilverCoinBehaviour.TryGet(__instance, out var _))
{
SilverCoinBehaviour.HandleCloneContinuation(__instance);
}
else
{
SilverCoinBehaviour.Attach(__instance);
}
}
}
}
[HarmonyPatch(typeof(Coin), "Punchflection")]
internal static class CoinPunchflectionPatch
{
private static void Prefix(Coin __instance)
{
SilverCoinBehaviour.RecordContinuation(__instance);
}
}
[HarmonyPatch(typeof(Coin), "Bounce")]
internal static class CoinBouncePatch
{
private static void Prefix(Coin __instance)
{
SilverCoinBehaviour.RecordContinuation(__instance);
}
}
[HarmonyPatch(typeof(Coin), "OnCollisionEnter")]
internal static class CoinOnCollisionEnterPatch
{
private static bool Prefix(Coin __instance, Collision collision)
{
if (SilverCoinBehaviour.TryGet(__instance, out var behaviour) && behaviour.TryBounceOffSolid(__instance, collision))
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Coin), "DelayedReflectRevolver")]
internal static class CoinDelayedReflectRevolverPatch
{
private static void Prefix(Coin __instance, GameObject beam)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Invalid comparison between Unknown and I4
RevolverBeam val = default(RevolverBeam);
if (!((Object)(object)beam == (Object)null) && SilverCoinBehaviour.TryGet(__instance, out var _) && beam.TryGetComponent<RevolverBeam>(ref val))
{
if (Plugin.IsAltMarksmanWeapon(val.sourceWeapon))
{
SilverCoinStyle.ApplyBeam(beam);
}
else if ((int)val.beamType == 1 && SilverCoinsConfig.RailgunThunderbolt)
{
SilverThunderbolt.TagBeam(beam);
}
}
}
}
[HarmonyPatch(typeof(Coin), "GetDeleted")]
internal static class CoinGetDeletedPatch
{
private static void Postfix(Coin __instance)
{
if (SilverCoinBehaviour.TryGet(__instance, out var _))
{
SilverCoinStyle.ApplySpentCoin(((Component)__instance).gameObject);
}
}
}
[HarmonyPatch(typeof(RevolverBeam), "ExecuteHits")]
internal static class RevolverBeamExecuteHitsPatch
{
private static void Postfix(RevolverBeam __instance, PhysicsCastResult currentHit)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
SilverThunderboltBeam silverThunderboltBeam = default(SilverThunderboltBeam);
if ((Object)(object)__instance == (Object)null || !((Component)__instance).TryGetComponent<SilverThunderboltBeam>(ref silverThunderboltBeam))
{
return;
}
Transform transform = currentHit.transform;
if (!((Object)(object)transform == (Object)null))
{
EnemyIdentifierIdentifier componentInParent = ((Component)transform).GetComponentInParent<EnemyIdentifierIdentifier>();
if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent.eid == (Object)null) && silverThunderboltBeam.TryRegisterHit(componentInParent.eid))
{
SilverThunderbolt.Strike(currentHit.point);
}
}
}
}
[HarmonyPatch(typeof(Coin), "ReflectRevolver")]
internal static class CoinReflectRevolverPatch
{
private static void Postfix(Coin __instance)
{
if (SilverCoinBehaviour.TryGet(__instance, out var behaviour))
{
behaviour.HandleReflectFinished(__instance);
}
}
}
[HarmonyPatch(typeof(Coin), "SpawnBeam")]
internal static class CoinSpawnBeamPatch
{
private static void Postfix(Coin __instance, GameObject __result)
{
if ((Object)(object)__result != (Object)null && SilverCoinBehaviour.TryGet(__instance, out var _))
{
SilverCoinStyle.ApplyBeam(__result);
}
}
}
internal static class CoinChargeEffectTint
{
private static readonly FieldInfo CurrentChargeField = AccessTools.Field(typeof(Coin), "currentCharge");
internal static void Apply(Coin coin)
{
if (SilverCoinBehaviour.TryGet(coin, out var _))
{
object? obj = CurrentChargeField?.GetValue(coin);
SilverCoinStyle.ApplyEffect((GameObject)((obj is GameObject) ? obj : null));
}
}
}
[HarmonyPatch(typeof(Coin), "TripleTime")]
internal static class CoinTripleTimePatch
{
private static void Postfix(Coin __instance)
{
CoinChargeEffectTint.Apply(__instance);
}
}
[HarmonyPatch(typeof(Coin), "DoubleTime")]
internal static class CoinDoubleTimePatch
{
private static void Postfix(Coin __instance)
{
CoinChargeEffectTint.Apply(__instance);
}
}
[HarmonyPatch(typeof(RevolverBeam), "Start")]
internal static class RevolverBeamStartPatch
{
private static void Postfix(RevolverBeam __instance)
{
SilverBeamMarker silverBeamMarker = default(SilverBeamMarker);
if ((Object)(object)__instance != (Object)null && ((Component)__instance).TryGetComponent<SilverBeamMarker>(ref silverBeamMarker))
{
SilverCoinStyle.ApplyBeam(((Component)__instance).gameObject);
}
}
}
[HarmonyPatch(typeof(Revolver), "OnEnable")]
internal static class RevolverOnEnablePatch
{
private static void Postfix(Revolver __instance)
{
AltMarksmanChargeController.OnRevolverEnabled(__instance);
}
}
[HarmonyPatch(typeof(Revolver), "OnDisable")]
internal static class RevolverOnDisablePatch
{
private static void Postfix(Revolver __instance)
{
AltMarksmanChargeController.OnRevolverDisabled(__instance);
}
}
[HarmonyPatch(typeof(Revolver), "CheckCoinCharges")]
internal static class RevolverCheckCoinChargesPatch
{
private static void Prefix(Revolver __instance)
{
if (Plugin.IsAltMarksman(__instance))
{
AltMarksmanChargeController.ClampCharge(MonoSingleton<WeaponCharges>.Instance);
}
}
private static void Postfix(Revolver __instance)
{
AltMarksmanChargeController.UpdateMarksmanDisplay(__instance);
}
}
[HarmonyPatch(typeof(Revolver), "Update")]
internal static class RevolverUpdatePatch
{
private static void Prefix(Revolver __instance)
{
AltMarksmanChargeController.EnforceAltMarksman(__instance);
}
}
[HarmonyPatch(typeof(Revolver), "ThrowCoin")]
internal static class RevolverThrowCoinPatch
{
private static void Postfix(Revolver __instance)
{
if (Plugin.IsAltMarksman(__instance))
{
AltMarksmanChargeController.ClampCharge(MonoSingleton<WeaponCharges>.Instance);
}
}
}
[HarmonyPatch(typeof(WeaponCharges), "Charge")]
internal static class WeaponChargesChargePatch
{
private static void Prefix(WeaponCharges __instance, ref float __state)
{
__state = __instance.rev1charge;
}
private static void Postfix(WeaponCharges __instance, float amount, float __state)
{
if (AltMarksmanChargeController.Active)
{
AltMarksmanChargeController.RechargeAltMarksman(__instance, amount, __state);
}
}
}
[HarmonyPatch(typeof(WeaponCharges), "MaxCharges")]
internal static class WeaponChargesMaxChargesPatch
{
private static void Postfix(WeaponCharges __instance)
{
if (AltMarksmanChargeController.Active)
{
AltMarksmanChargeController.ClampCharge(__instance);
}
}
}
}