using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using InControl;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Sonigon;
using SoundImplementation;
using TMPro;
using UnboundLib;
using UnboundLib.GameModes;
using UnityEngine;
using UnityEngine.Audio;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[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 WeaponsManager
{
public class ManagedWeaponAdder : MonoBehaviour
{
public Gun weapon;
public bool applyCardStats;
public float inactiveReloadTimeMultiplier;
public GameObject icon;
public string weaponName;
internal void Apply(Player player, WeaponManager weaponManager)
{
SetTeamColor[] componentsInChildren = ((Component)weapon).GetComponentsInChildren<SetTeamColor>();
int frontSortingLayerID = ((Component)player).gameObject.GetComponentInChildren<SpriteMask>().frontSortingLayerID;
SetTeamColor[] array = componentsInChildren;
foreach (SetTeamColor val in array)
{
SpriteMask component = ((Component)val).gameObject.GetComponent<SpriteMask>();
component.frontSortingLayerID = frontSortingLayerID;
component.backSortingLayerID = frontSortingLayerID;
}
weaponManager.AddWeapon(weapon, applyCardStats, icon, weaponName, inactiveReloadTimeMultiplier);
}
}
[HarmonyPatch(typeof(ApplyCardStats), "ApplyStats")]
[HarmonyPriority(200)]
public class ApplyPlayerStatsPatch
{
private static void Postfix(ApplyCardStats __instance, Player ___playerToUpgrade)
{
ManagedWeaponAdder component = ((Component)__instance).GetComponent<ManagedWeaponAdder>();
if (component != null)
{
WeaponManager orAddComponent = ExtensionMethods.GetOrAddComponent<WeaponManager>(((Component)___playerToUpgrade).gameObject, false);
component.Apply(___playerToUpgrade, orAddComponent);
}
}
}
public class RightLeftScale : MonoBehaviour
{
public Vector3 leftScale;
private Vector3 rightScale;
private Holdable holdable;
private void Start()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
holdable = ((Component)((Component)this).transform.root).GetComponent<Holdable>();
rightScale = ((Component)this).transform.localScale;
}
private void Update()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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.op_Implicit((Object)(object)holdable) && Object.op_Implicit((Object)(object)holdable.holder))
{
Vector3 localScale = ((((Component)this).transform.root.position.x - 0.1f < ((Component)holdable.holder).transform.position.x) ? leftScale : rightScale);
((Component)this).transform.localScale = localScale;
}
}
}
public class WeaponManager : MonoBehaviour
{
[CompilerGenerated]
private sealed class <RoundStart>d__34 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IGameModeHandler gm;
public WeaponManager <>4__this;
private int <i>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RoundStart>d__34(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
if (<>1__state != 0)
{
return false;
}
<>1__state = -1;
<i>5__1 = 0;
while (<i>5__1 < <>4__this.willReload.Count)
{
if (<i>5__1 != <>4__this.activeWeapon)
{
<>4__this.willReload[<i>5__1] = true;
}
<i>5__1++;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public List<Gun> weapons = new List<Gun>();
public List<bool> shouldUpdateStats = new List<bool>();
public List<bool> willReload = new List<bool>();
public List<GameObject> icons = new List<GameObject>();
public List<string> names = new List<string>();
public List<float> reloadTimers = new List<float>();
public List<float> reloadMultipliers = new List<float>();
private Player player;
private WeaponHandler weaponHandler;
private Holding holding;
private GameObject visualizer;
private Transform activeSlot;
private Transform prevSlot;
private Transform nextSlot;
private TextMeshProUGUI activeName;
private TextMeshProUGUI prevName;
private TextMeshProUGUI nextName;
public int activeWeapon { get; private set; } = 0;
public void Awake()
{
player = ((Component)this).GetComponentInParent<Player>();
weaponHandler = ((Component)this).GetComponentInParent<WeaponHandler>();
holding = ((Component)this).GetComponentInParent<Holding>();
Gun gun = player.data.weaponHandler.gun;
weapons.Add(gun);
shouldUpdateStats.Add(item: true);
willReload.Add(item: false);
reloadTimers.Add(0f);
reloadMultipliers.Add(0.25f);
if (player.data.view.IsMine)
{
visualizer = Object.Instantiate<GameObject>(WeaponsManager.assets.LoadAsset<GameObject>("SlotVisualizer"), GameObject.Find("Game/UI/UI_Game/Canvas").transform);
visualizer.GetComponent<Canvas>().sortingLayerName = "MostFront";
activeSlot = visualizer.transform.GetChild(0);
prevSlot = visualizer.transform.GetChild(1);
nextSlot = visualizer.transform.GetChild(2);
activeName = ((Component)activeSlot).GetComponentInChildren<TextMeshProUGUI>();
prevName = ((Component)prevSlot).GetComponentInChildren<TextMeshProUGUI>();
nextName = ((Component)nextSlot).GetComponentInChildren<TextMeshProUGUI>();
names.Add("Pistol");
icons.Add(Object.Instantiate<GameObject>(WeaponsManager.assets.LoadAsset<GameObject>("PistolIcon"), visualizer.transform));
}
}
public void Start()
{
visualizer.SetActive(false);
GameModeManager.AddHook("RoundStart", (Func<IGameModeHandler, IEnumerator>)RoundStart);
}
public void FixedUpdate()
{
for (int i = 0; i < weapons.Count; i++)
{
if (i != activeWeapon)
{
reloadTimers[i] += Time.fixedDeltaTime * reloadMultipliers[i];
}
}
}
public void AddWeapon(Gun weapon, bool applyCardStats, GameObject icon, string name, float reloadMultiplier = 0.25f)
{
Gun val = Object.Instantiate<Gun>(weapon);
weapons.Add(val);
shouldUpdateStats.Add(applyCardStats);
willReload.Add(item: false);
reloadTimers.Add(0f);
reloadMultipliers.Add(reloadMultiplier);
if (player.data.view.IsMine)
{
icons.Add(Object.Instantiate<GameObject>(icon, visualizer.transform));
names.Add(name);
UpdateIcons();
}
((Component)val).gameObject.SetActive(false);
if (applyCardStats)
{
GunAmmo componentInChildren = ((Component)weapons[0]).GetComponentInChildren<GunAmmo>();
GunAmmo componentInChildren2 = ((Component)val).GetComponentInChildren<GunAmmo>();
componentInChildren2.ammoReg += componentInChildren.ammoReg;
componentInChildren2.maxAmmo += componentInChildren.maxAmmo - 3;
componentInChildren2.maxAmmo = Mathf.Clamp(componentInChildren2.maxAmmo, 1, 90);
componentInChildren2.reloadTimeMultiplier *= componentInChildren.reloadTime;
componentInChildren2.reloadTimeAdd += componentInChildren.reloadTimeAdd;
try
{
ApplyCardStats.CopyGunStats(weapons[0], val);
}
catch
{
}
}
FixNewGunSound(val);
visualizer.SetActive(true);
}
private void FixNewGunSound(Gun gun)
{
GunAmmo componentInChildren = ((Component)gun).GetComponentInChildren<GunAmmo>();
SoundGun soundGun = gun.soundGun;
AudioMixerGroup audioMixerGroup = SoundVolumeManager.Instance.audioMixer.FindMatchingGroups("SFX")[0];
componentInChildren.soundReloadComplete.variables.audioMixerGroup = audioMixerGroup;
componentInChildren.soundReloadInProgressLoop.variables.audioMixerGroup = audioMixerGroup;
SoundEvent[] triggerOnPlaySoundEvents = componentInChildren.soundReloadInProgressLoop.variables.triggerOnPlaySoundEvents;
foreach (SoundEvent val in triggerOnPlaySoundEvents)
{
val.variables.audioMixerGroup = audioMixerGroup;
}
SoundEvent[] triggerOnStopSoundEvents = componentInChildren.soundReloadInProgressLoop.variables.triggerOnStopSoundEvents;
foreach (SoundEvent val2 in triggerOnStopSoundEvents)
{
val2.variables.audioMixerGroup = audioMixerGroup;
}
soundGun.soundShotModifierBasic.single.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundShotModifierBasic.singleAutoLoop.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundShotModifierBasic.singleAutoTail.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundShotModifierBasic.shotgun.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundShotModifierBasic.shotgunAutoLoop.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundShotModifierBasic.shotgunAutoTail.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundImpactModifierBasic.impactCharacter.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundImpactModifierBasic.impactEnvironment.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundImpactModifierDamageToExplosionHuge.impactCharacter.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundImpactModifierDamageToExplosionHuge.impactEnvironment.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundImpactModifierDamageToExplosionMedium.impactCharacter.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundImpactModifierDamageToExplosionMedium.impactEnvironment.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundImpactBounce.variables.audioMixerGroup = audioMixerGroup;
soundGun.soundImpactBullet.variables.audioMixerGroup = audioMixerGroup;
}
public void UpdateIcons()
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: 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_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
foreach (GameObject icon in icons)
{
ExtensionMethods.SetYPosition(icon.transform, -1000f);
}
if (weapons.Count > 2)
{
icons[(activeWeapon + icons.Count - 1) % icons.Count].transform.SetPositionAndRotation(prevSlot.position, prevSlot.rotation);
icons[(activeWeapon + icons.Count - 1) % icons.Count].transform.localScale = new Vector3(2f, 2f, 2f);
((TMP_Text)prevName).text = names[(activeWeapon + icons.Count - 1) % icons.Count];
}
else
{
((TMP_Text)prevName).text = "";
}
if (weapons.Count > 1)
{
icons[(activeWeapon + 1) % icons.Count].transform.SetPositionAndRotation(nextSlot.position, nextSlot.rotation);
icons[(activeWeapon + 1) % icons.Count].transform.localScale = new Vector3(2f, 2f, 2f);
((TMP_Text)nextName).text = names[(activeWeapon + 1) % icons.Count];
}
else
{
((TMP_Text)nextName).text = "";
}
icons[activeWeapon].transform.SetPositionAndRotation(activeSlot.position, activeSlot.rotation);
icons[activeWeapon].transform.localScale = new Vector3(3f, 3f, 3f);
((TMP_Text)activeName).text = names[activeWeapon];
}
public void RemoveWeapon(Predicate<Gun> weapon)
{
int index = weapons.FindIndex(weapon);
weapons.RemoveAt(index);
shouldUpdateStats.RemoveAt(index);
icons.RemoveAt(index);
names.RemoveAt(index);
willReload.RemoveAt(index);
reloadTimers.RemoveAt(index);
reloadMultipliers.RemoveAt(index);
}
public void NextWeapon()
{
SetActiveWeapon((activeWeapon + 1) % weapons.Count);
}
public void PreviousWeapon()
{
SetActiveWeapon((activeWeapon - 1 + weapons.Count) % weapons.Count);
}
private void SetActiveWeapon(int index)
{
//IL_0045: 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)
((Component)weapons[activeWeapon]).gameObject.SetActive(false);
((Component)weapons[index]).transform.SetPositionAndRotation(((Component)weapons[activeWeapon]).transform.position, ((Component)weapons[activeWeapon]).transform.rotation);
activeWeapon = index;
((Component)weapons[activeWeapon]).gameObject.SetActive(true);
weaponHandler.gun = weapons[activeWeapon];
ExtensionMethods.SetFieldValue((object)holding, "gun", (object)weapons[activeWeapon]);
holding.holdable = ((Component)weapons[activeWeapon]).GetComponentInParent<Holdable>();
GunAmmo componentInChildren = ((Component)weapons[activeWeapon]).gameObject.GetComponentInChildren<GunAmmo>();
if ((int)ExtensionMethods.GetFieldValue((object)componentInChildren, "currentAmmo") <= 0)
{
try
{
componentInChildren.reloadAnim.PlayIn();
}
catch
{
}
}
else
{
try
{
componentInChildren.reloadAnim.PlayOut();
}
catch
{
}
}
for (int i = 1; i < ((Component)componentInChildren.populate).transform.childCount; i++)
{
if (i <= (int)ExtensionMethods.GetFieldValue((object)componentInChildren, "currentAmmo"))
{
try
{
((Component)((Component)componentInChildren.populate).transform.GetChild(i)).GetComponent<CurveAnimation>().PlayIn();
}
catch
{
}
}
else
{
try
{
((Component)((Component)componentInChildren.populate).transform.GetChild(i)).GetComponent<CurveAnimation>().PlayOut();
}
catch
{
}
}
}
ExtensionMethods.SetFieldValue((object)componentInChildren, "reloadCounter", (object)((float)ExtensionMethods.GetFieldValue((object)componentInChildren, "reloadCounter") - reloadTimers[index]));
reloadTimers[index] = 0f;
if (willReload[index])
{
((Weapon)weapons[index]).sinceAttack = 100f;
GunAmmo componentInChildren2 = ((Component)weapons[index]).gameObject.GetComponentInChildren<GunAmmo>();
if (componentInChildren2 != null)
{
componentInChildren2.ReloadAmmo(true);
}
willReload[index] = false;
}
if (player.data.view.IsMine)
{
UpdateIcons();
}
}
public void Reset()
{
SetActiveWeapon(0);
for (int i = weapons.Count - 1; i > 0; i++)
{
Object.Destroy((Object)(object)weapons[i]);
}
Object.Destroy((Object)(object)this);
}
[PunRPC]
public void RPCNextWeapon()
{
NextWeapon();
}
[PunRPC]
public void RPCPreviousWeapon()
{
PreviousWeapon();
}
[IteratorStateMachine(typeof(<RoundStart>d__34))]
private IEnumerator RoundStart(IGameModeHandler gm)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RoundStart>d__34(0)
{
<>4__this = this,
gm = gm
};
}
private void OnDestroy()
{
GameModeManager.RemoveHook("RoundStart", (Func<IGameModeHandler, IEnumerator>)RoundStart);
}
}
[HarmonyPatch(typeof(Player), "FullReset")]
public class FullResetPatch
{
private static void Prefix(Player __instance)
{
WeaponManager component = ((Component)__instance).gameObject.GetComponent<WeaponManager>();
if (Object.op_Implicit((Object)(object)component))
{
component.Reset();
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.rsmind.rounds.weaponsmanager", "Weapon Manager", "1.3.2")]
[BepInProcess("Rounds.exe")]
public class WeaponsManager : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <GameStart>d__12 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IGameModeHandler gm;
public WeaponsManager <>4__this;
private List<Player>.Enumerator <>s__1;
private Player <player>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GameStart>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<player>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
if (<>1__state != 0)
{
return false;
}
<>1__state = -1;
<>s__1 = PlayerManager.instance.players.GetEnumerator();
try
{
while (<>s__1.MoveNext())
{
<player>5__2 = <>s__1.Current;
ExtensionMethods.GetOrAddComponent<WeaponManager>(((Component)<player>5__2).gameObject, false);
<player>5__2 = null;
}
}
finally
{
((IDisposable)<>s__1).Dispose();
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private const string ModId = "com.rsmind.rounds.weaponsmanager";
private const string ModName = "Weapon Manager";
public const string Version = "1.3.2";
public const string ModInitials = "WM";
internal static AssetBundle assets;
public static bool Debug;
public static WeaponsManager instance { get; private set; }
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("com.rsmind.rounds.weaponsmanager");
val.PatchAll();
assets = AssetUtils.LoadAssetBundleFromResources("weaponsmanager", typeof(WeaponsManager).Assembly);
if ((Object)(object)assets == (Object)null)
{
Debug.Log((object)"Failed to load Weapons Manager asset bundle");
}
}
private void Start()
{
instance = this;
GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)GameStart);
}
[IteratorStateMachine(typeof(<GameStart>d__12))]
private IEnumerator GameStart(IGameModeHandler gm)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GameStart>d__12(0)
{
<>4__this = this,
gm = gm
};
}
}
}
namespace WeaponsManager.Utilities
{
[Serializable]
public class PlayerActionsAdditionalData
{
public PlayerAction nextWeapon;
public PlayerAction previousWeapon;
public PlayerActionsAdditionalData()
{
nextWeapon = null;
previousWeapon = null;
}
}
public static class PlayerActionsExtension
{
public static readonly ConditionalWeakTable<PlayerActions, PlayerActionsAdditionalData> data = new ConditionalWeakTable<PlayerActions, PlayerActionsAdditionalData>();
public static PlayerActionsAdditionalData GetAdditionalData(this PlayerActions playerActions)
{
return data.GetOrCreateValue(playerActions);
}
public static void AddData(this PlayerActions playerActions, PlayerActionsAdditionalData value)
{
try
{
data.Add(playerActions, value);
}
catch (Exception)
{
}
}
}
[HarmonyPatch(typeof(PlayerActions))]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(new Type[] { })]
internal class PlayerActionsPatchPlayerActions
{
private static void Postfix(PlayerActions __instance)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
__instance.GetAdditionalData().nextWeapon = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Next Weapon" });
__instance.GetAdditionalData().previousWeapon = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Previous Weapon" });
}
}
[HarmonyPatch(typeof(PlayerActions), "CreateWithControllerBindings")]
internal class PlayerActionsPatchCreateWithControllerBindings
{
private static void Postfix(ref PlayerActions __result)
{
__result.GetAdditionalData().nextWeapon.AddDefaultBinding((InputControlType)14);
__result.GetAdditionalData().previousWeapon.AddDefaultBinding((InputControlType)13);
}
}
[HarmonyPatch(typeof(PlayerActions), "CreateWithKeyboardBindings")]
internal class PlayerActionsPatchCreateWithKeyboardBindings
{
private static void Postfix(ref PlayerActions __result)
{
__result.GetAdditionalData().nextWeapon.AddDefaultBinding((Key[])(object)new Key[1] { (Key)40 });
__result.GetAdditionalData().previousWeapon.AddDefaultBinding((Key[])(object)new Key[1] { (Key)52 });
}
}
[HarmonyPatch(typeof(GeneralInput), "Update")]
internal class GeneralInputPatchUpdate
{
private static void Postfix(GeneralInput __instance)
{
if (!((Component)__instance).GetComponent<CharacterData>().view.IsMine)
{
return;
}
if (((OneAxisInputControl)((Component)__instance).GetComponent<CharacterData>().playerActions.GetAdditionalData().nextWeapon).WasPressed)
{
WeaponManager component = ((Component)__instance).GetComponent<WeaponManager>();
if (component != null)
{
((Component)__instance).GetComponent<CharacterData>().view.RPC("RPCNextWeapon", (RpcTarget)0, Array.Empty<object>());
}
}
if (((OneAxisInputControl)((Component)__instance).GetComponent<CharacterData>().playerActions.GetAdditionalData().previousWeapon).WasPressed)
{
WeaponManager component2 = ((Component)__instance).GetComponent<WeaponManager>();
if (component2 != null)
{
((Component)__instance).GetComponent<CharacterData>().view.RPC("RPCPreviousWeapon", (RpcTarget)0, Array.Empty<object>());
}
}
}
}
}
namespace WeaponsManager.Patches
{
[HarmonyPatch(typeof(ApplyCardStats), "ApplyStats")]
[HarmonyPriority(600)]
internal class ApplyCardStatsPatch
{
private static void Prefix(ApplyCardStats __instance, Player ___playerToUpgrade, Gun ___myGunStats, out int __state)
{
__state = -1;
WeaponManager component = ((Component)___playerToUpgrade).gameObject.GetComponent<WeaponManager>();
if (!((Object)(object)component != (Object)null) || component.shouldUpdateStats[component.activeWeapon])
{
return;
}
GunAmmo componentInChildren = ((Component)component.weapons[component.activeWeapon]).gameObject.GetComponentInChildren<GunAmmo>();
if (Object.op_Implicit((Object)(object)componentInChildren))
{
componentInChildren.ammoReg -= ___myGunStats.ammoReg;
componentInChildren.maxAmmo -= ___myGunStats.ammo;
__state = componentInChildren.maxAmmo;
if (___myGunStats.reloadTime != 0f)
{
componentInChildren.reloadTimeMultiplier /= ___myGunStats.reloadTime;
}
componentInChildren.reloadTimeAdd -= ___myGunStats.reloadTimeAdd;
}
}
private static void Postfix(ApplyCardStats __instance, Player ___playerToUpgrade, Gun ___myGunStats, int __state)
{
WeaponManager component = ((Component)___playerToUpgrade).gameObject.GetComponent<WeaponManager>();
if (!((Object)(object)component != (Object)null) || !Object.op_Implicit((Object)(object)___myGunStats))
{
return;
}
if (__state != -1)
{
GunAmmo componentInChildren = ((Component)component.weapons[component.activeWeapon]).gameObject.GetComponentInChildren<GunAmmo>();
componentInChildren.maxAmmo = __state;
}
for (int i = 0; i < component.weapons.Count; i++)
{
if (i != component.activeWeapon && Object.op_Implicit((Object)(object)component.weapons[i]) && component.shouldUpdateStats[i])
{
GunAmmo componentInChildren2 = ((Component)component.weapons[i]).gameObject.GetComponentInChildren<GunAmmo>();
if (Object.op_Implicit((Object)(object)componentInChildren2))
{
componentInChildren2.ammoReg += ___myGunStats.ammoReg;
componentInChildren2.maxAmmo += ___myGunStats.ammo;
componentInChildren2.maxAmmo = Mathf.Clamp(componentInChildren2.maxAmmo, 1, 90);
componentInChildren2.reloadTimeMultiplier *= ___myGunStats.reloadTime;
componentInChildren2.reloadTimeAdd += ___myGunStats.reloadTimeAdd;
}
if (___myGunStats.lockGunToDefault)
{
component.weapons[i].defaultCooldown = ___myGunStats.forceSpecificAttackSpeed;
component.weapons[i].lockGunToDefault = ___myGunStats.lockGunToDefault;
}
try
{
ApplyCardStats.CopyGunStats(___myGunStats, component.weapons[i]);
}
catch
{
}
}
}
}
}
[HarmonyPatch(typeof(ApplyCardStats), "CopyGunStats")]
[HarmonyPriority(600)]
internal class CopyGunStatsPatch
{
private static bool Prefix(ApplyCardStats __instance, Gun copyToGun)
{
if (Object.op_Implicit((Object)(object)copyToGun.player))
{
WeaponManager component = ((Component)copyToGun.player).GetComponent<WeaponManager>();
if (component != null && (Object)(object)component.weapons[component.activeWeapon] == (Object)(object)copyToGun && !component.shouldUpdateStats[component.activeWeapon])
{
return false;
}
}
return true;
}
}
}