using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
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: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SkillHotSwapper")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SkillHotSwapper")]
[assembly: AssemblyTitle("SkillHotSwapper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 SkillPicker
{
[Serializable]
[BepInPlugin("com.brynzananas.skillhotswapper", "Skill Hot Swapper", "1.0.0")]
[BepInDependency("com.bepis.r2api", "5.0.10")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Main : BaseUnityPlugin
{
public class RadialLayout : LayoutGroup
{
public float fDistance;
[Range(0f, 360f)]
public float MinAngle;
[Range(0f, 360f)]
public float MaxAngle;
[Range(0f, 360f)]
public float StartAngle;
public bool OnlyLayoutVisible = false;
public override void OnEnable()
{
((LayoutGroup)this).OnEnable();
CalculateRadial();
}
public override void SetLayoutHorizontal()
{
}
public override void SetLayoutVertical()
{
}
public override void CalculateLayoutInputVertical()
{
CalculateRadial();
}
public override void CalculateLayoutInputHorizontal()
{
CalculateRadial();
}
public override void OnDisable()
{
((DrivenRectTransformTracker)(ref base.m_Tracker)).Clear();
LayoutRebuilder.MarkLayoutForRebuild(((LayoutGroup)this).rectTransform);
}
private void CalculateRadial()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: 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)
((DrivenRectTransformTracker)(ref base.m_Tracker)).Clear();
if (((Component)this).transform.childCount == 0)
{
return;
}
int num = 0;
if (OnlyLayoutVisible)
{
for (int i = 0; i < ((Component)this).transform.childCount; i++)
{
RectTransform val = (RectTransform)((Component)this).transform.GetChild(i);
if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf)
{
num++;
}
}
}
else
{
num = ((Component)this).transform.childCount;
}
float num2 = (MaxAngle - MinAngle) / (float)num;
float num3 = StartAngle;
Vector3 val3 = default(Vector3);
Vector2 val4 = default(Vector2);
for (int j = 0; j < ((Component)this).transform.childCount; j++)
{
RectTransform val2 = (RectTransform)((Component)this).transform.GetChild(j);
if ((Object)(object)val2 != (Object)null && (!OnlyLayoutVisible || ((Component)val2).gameObject.activeSelf))
{
((DrivenRectTransformTracker)(ref base.m_Tracker)).Add((Object)(object)this, val2, (DrivenTransformProperties)52998);
((Vector3)(ref val3))..ctor(Mathf.Cos(num3 * (MathF.PI / 180f)), Mathf.Sin(num3 * (MathF.PI / 180f)), 0f);
((Transform)val2).localPosition = val3 * fDistance;
((Vector2)(ref val4))..ctor(0.5f, 0.5f);
val2.pivot = val4;
Vector2 anchorMin = (val2.anchorMax = val4);
val2.anchorMin = anchorMin;
num3 += num2;
}
}
}
}
public class StupidThing : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
{
public SkillPickerComponent skillPickerComponent;
public void OnPointerEnter(PointerEventData eventData)
{
skillPickerComponent.eventSystem.SetSelectedObject(((Component)this).gameObject);
}
public void OnPointerExit(PointerEventData eventData)
{
skillPickerComponent.eventSystem.SetSelectedObject((GameObject)null);
}
public void OnDisable()
{
skillPickerComponent.eventSystem.SetSelectedObject((GameObject)null);
}
}
public class SkillPickerComponent : MonoBehaviour
{
public Dictionary<SkillInFamilyComponent, SkillFamilyComponent> SkillFamilies = new Dictionary<SkillInFamilyComponent, SkillFamilyComponent>();
public List<SkillFamilyComponent> skillFamilyComponents = new List<SkillFamilyComponent>();
public MPEventSystem eventSystem;
public bool switchOff = false;
public void OnDestroy()
{
if (Object.op_Implicit((Object)(object)eventSystem) && switchOff)
{
MPEventSystem obj = eventSystem;
int cursorOpenerCount = obj.cursorOpenerCount;
obj.cursorOpenerCount = cursorOpenerCount - 1;
MPEventSystem obj2 = eventSystem;
cursorOpenerCount = obj2.cursorOpenerForGamepadCount;
obj2.cursorOpenerForGamepadCount = cursorOpenerCount - 1;
switchOff = false;
}
}
}
public class SkillFamilyComponent : MonoBehaviour
{
public SkillPickerComponent skillPickerComponent;
public Dictionary<SkillDef, GameObject> Skills = new Dictionary<SkillDef, GameObject>();
public List<SkillComponent> skillComponents = new List<SkillComponent>();
}
public class SkillInFamilyComponent : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler
{
public SkillPickerComponent skillPickerComponent;
public SkillFamilyComponent skillFamilyComponent;
public Image ownImage;
public Image skillImage;
public void Awake()
{
ownImage = ((Component)this).GetComponent<Image>();
}
public void OnPointerClick(PointerEventData eventData)
{
foreach (SkillFamilyComponent skillFamilyComponent in skillPickerComponent.skillFamilyComponents)
{
((Component)skillFamilyComponent).gameObject.SetActive(false);
}
((Component)this.skillFamilyComponent).gameObject.SetActive(true);
((Component)((Component)this).transform.parent).gameObject.SetActive(false);
}
public void OnPointerEnter(PointerEventData eventData)
{
//IL_0016: 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)
((Component)this).transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
((Graphic)ownImage).color = activeColor;
skillPickerComponent.eventSystem.SetSelectedObject(((Component)this).gameObject);
}
public void OnPointerExit(PointerEventData eventData)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.localScale = Vector3.one;
((Graphic)ownImage).color = Color.white;
skillPickerComponent.eventSystem.SetSelectedObject((GameObject)null);
}
public void OnDisable()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.localScale = Vector3.one;
((Graphic)ownImage).color = Color.white;
skillPickerComponent.eventSystem.SetSelectedObject((GameObject)null);
}
}
public class SkillComponent : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler
{
public SkillFamilyComponent skillFamilyComponent;
public SkillInFamilyComponent skillInFamilyComponent;
public GenericSkill genericSkill;
public SkillDef skillDef;
public void OnPointerClick(PointerEventData eventData)
{
bool flag = false;
if ((Object)(object)genericSkill.baseSkill == (Object)(object)skillDef)
{
flag = true;
}
genericSkill.baseSkill = skillDef;
skillInFamilyComponent.skillImage.sprite = skillDef.icon;
if (!flag && genericSkill.skillOverrides.Count() <= 0)
{
genericSkill.SetSkillInternal(skillDef);
genericSkill.stock = 0;
genericSkill.rechargeStopwatch = 0f;
}
foreach (SkillFamilyComponent skillFamilyComponent in skillFamilyComponent.skillPickerComponent.skillFamilyComponents)
{
((Component)skillFamilyComponent).gameObject.SetActive(false);
}
((Component)((Component)this.skillFamilyComponent.skillPickerComponent).transform.GetChild(1)).gameObject.SetActive(true);
((Component)this.skillFamilyComponent.skillPickerComponent).gameObject.SetActive(false);
if (Object.op_Implicit((Object)(object)this.skillFamilyComponent.skillPickerComponent.eventSystem))
{
MPEventSystem eventSystem = this.skillFamilyComponent.skillPickerComponent.eventSystem;
int cursorOpenerCount = eventSystem.cursorOpenerCount;
eventSystem.cursorOpenerCount = cursorOpenerCount - 1;
MPEventSystem eventSystem2 = this.skillFamilyComponent.skillPickerComponent.eventSystem;
cursorOpenerCount = eventSystem2.cursorOpenerForGamepadCount;
eventSystem2.cursorOpenerForGamepadCount = cursorOpenerCount - 1;
}
((Component)this.skillFamilyComponent.skillPickerComponent).GetComponent<SkillPickerComponent>().switchOff = false;
}
public void OnPointerEnter(PointerEventData eventData)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
skillInFamilyComponent.skillPickerComponent.eventSystem.SetSelectedObject(((Component)this).gameObject);
}
public void OnPointerExit(PointerEventData eventData)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.localScale = Vector3.one;
skillInFamilyComponent.skillPickerComponent.eventSystem.SetSelectedObject((GameObject)null);
}
public void OnDisable()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.localScale = Vector3.one;
skillInFamilyComponent.skillPickerComponent.eventSystem.SetSelectedObject((GameObject)null);
}
}
public const string ModGuid = "com.brynzananas.skillhotswapper";
public const string ModName = "Skill Hot Swapper";
public const string ModVer = "1.0.0";
private static bool emotesEnabled;
public static AssetBundle Assets;
public static GameObject SkillPicker;
public static GameObject SkillFamily;
public static GameObject SkillInFamily;
public static GameObject Skill;
public static ConfigEntry<KeyboardShortcut> OpenCloseKey;
public static Color activeColor = new Color(1f, 8f, 0f);
public MPEventSystem eventSystem;
public GameObject hud;
public GameObject currentSkillPicker;
public static PluginInfo PInfo { get; private set; }
public void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Expected O, but got Unknown
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Expected O, but got Unknown
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Expected O, but got Unknown
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Expected O, but got Unknown
PInfo = ((BaseUnityPlugin)this).Info;
OpenCloseKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Open/Close", new KeyboardShortcut((KeyCode)107, Array.Empty<KeyCode>()), "Key open/close skill hotswapper");
Assets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PInfo.Location), "assetbundles", "skillpicker"));
SkillPicker = Assets.LoadAsset<GameObject>("Assets/SkillPicker/SkillPicker.prefab");
SkillPicker.AddComponent<SkillPickerComponent>();
RadialLayout radialLayout = ((Component)SkillPicker.transform.GetChild(1)).gameObject.AddComponent<RadialLayout>();
radialLayout.fDistance = 64f;
radialLayout.MaxAngle = 360f;
radialLayout.StartAngle = 90f;
((Component)SkillPicker.transform.GetChild(0)).gameObject.AddComponent<StupidThing>();
((Component)SkillPicker.transform.GetChild(0)).gameObject.AddComponent<UIInputPassthrough>().OnlyAllowMovement = true;
SkillFamily = Assets.LoadAsset<GameObject>("Assets/SkillPicker/SkillFamily.prefab");
SkillFamily.AddComponent<SkillFamilyComponent>();
radialLayout = ((Component)SkillFamily.transform.GetChild(0)).gameObject.AddComponent<RadialLayout>();
radialLayout.fDistance = 64f;
radialLayout.MaxAngle = 360f;
radialLayout.StartAngle = 90f;
SkillInFamily = Assets.LoadAsset<GameObject>("Assets/SkillPicker/SkillInFamily.prefab");
SkillInFamily.AddComponent<SkillInFamilyComponent>();
SkillInFamily.AddComponent<UIInputPassthrough>().OnlyAllowMovement = true;
Skill = Assets.LoadAsset<GameObject>("Assets/SkillPicker/Skill.prefab");
Skill.AddComponent<SkillComponent>();
Skill.AddComponent<UIInputPassthrough>().OnlyAllowMovement = true;
PlayerCharacterMasterController.OnBodyStart += new hook_OnBodyStart(PlayerCharacterMasterController_OnBodyStart);
PlayerCharacterMasterController.Update += new hook_Update(PlayerCharacterMasterController_Update);
PlayerCharacterMasterController.OnBodyDeath += new hook_OnBodyDeath(PlayerCharacterMasterController_OnBodyDeath);
if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
{
ModSettingsManager.AddOption((BaseOption)new KeyBindOption(OpenCloseKey));
ModSettingsManager.SetModIcon(Assets.LoadAsset<Sprite>("Assets/SkillPicker/UltrakillWeaponWheel.png"));
}
}
private void PlayerCharacterMasterController_OnBodyDeath(orig_OnBodyDeath orig, PlayerCharacterMasterController self)
{
orig.Invoke(self);
if (Object.op_Implicit((Object)(object)currentSkillPicker))
{
Object.DestroyImmediate((Object)(object)currentSkillPicker);
}
}
private void PlayerCharacterMasterController_Update(orig_Update orig, PlayerCharacterMasterController self)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
KeyboardShortcut value = OpenCloseKey.Value;
if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey) && Object.op_Implicit((Object)(object)currentSkillPicker))
{
if (currentSkillPicker.activeSelf)
{
currentSkillPicker.SetActive(false);
currentSkillPicker.GetComponent<SkillPickerComponent>().switchOff = false;
if (Object.op_Implicit((Object)(object)eventSystem))
{
MPEventSystem obj = eventSystem;
int cursorOpenerCount = obj.cursorOpenerCount;
obj.cursorOpenerCount = cursorOpenerCount - 1;
MPEventSystem obj2 = eventSystem;
cursorOpenerCount = obj2.cursorOpenerForGamepadCount;
obj2.cursorOpenerForGamepadCount = cursorOpenerCount - 1;
}
}
else
{
currentSkillPicker.SetActive(true);
currentSkillPicker.GetComponent<SkillPickerComponent>().switchOff = true;
if (Object.op_Implicit((Object)(object)eventSystem))
{
MPEventSystem obj3 = eventSystem;
int cursorOpenerCount = obj3.cursorOpenerCount;
obj3.cursorOpenerCount = cursorOpenerCount + 1;
MPEventSystem obj4 = eventSystem;
cursorOpenerCount = obj4.cursorOpenerForGamepadCount;
obj4.cursorOpenerForGamepadCount = cursorOpenerCount + 1;
}
}
}
if (Input.GetKeyDown((KeyCode)27) && Object.op_Implicit((Object)(object)currentSkillPicker) && currentSkillPicker.activeSelf)
{
currentSkillPicker.SetActive(false);
currentSkillPicker.GetComponent<SkillPickerComponent>().switchOff = false;
if (Object.op_Implicit((Object)(object)eventSystem))
{
MPEventSystem obj5 = eventSystem;
int cursorOpenerCount = obj5.cursorOpenerCount;
obj5.cursorOpenerCount = cursorOpenerCount - 1;
MPEventSystem obj6 = eventSystem;
cursorOpenerCount = obj6.cursorOpenerForGamepadCount;
obj6.cursorOpenerForGamepadCount = cursorOpenerCount - 1;
}
}
}
private void PlayerCharacterMasterController_OnBodyStart(orig_OnBodyStart orig, PlayerCharacterMasterController self)
{
//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Expected I4, but got Unknown
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
eventSystem = self.networkUser.localUser.eventSystem;
hud = ((Component)self.networkUser.localUser.cameraRigController.hud).gameObject;
if (!Object.op_Implicit((Object)(object)hud))
{
return;
}
if (Object.op_Implicit((Object)(object)currentSkillPicker))
{
Object.DestroyImmediate((Object)(object)currentSkillPicker);
}
currentSkillPicker = Object.Instantiate<GameObject>(SkillPicker, hud.transform.GetChild(0));
StupidThing component = ((Component)currentSkillPicker.transform.Find("background")).gameObject.GetComponent<StupidThing>();
SkillPickerComponent component2 = currentSkillPicker.GetComponent<SkillPickerComponent>();
component2.eventSystem = eventSystem;
component.skillPickerComponent = component2;
if (Object.op_Implicit((Object)(object)self.master.GetBodyObject()))
{
SkillLocator skillLocator = self.master.GetBody().skillLocator;
if ((Object)(object)skillLocator != (Object)null)
{
int num = 0;
GenericSkill[] allSkills = skillLocator.allSkills;
foreach (GenericSkill val in allSkills)
{
GameObject val2 = Object.Instantiate<GameObject>(SkillFamily, currentSkillPicker.transform);
((Object)val2).name = "SkillFamily" + num;
SkillFamilyComponent component3 = val2.GetComponent<SkillFamilyComponent>();
component3.skillPickerComponent = component2;
component2.skillFamilyComponents.Add(component3);
GameObject val3 = Object.Instantiate<GameObject>(SkillInFamily, currentSkillPicker.transform.GetChild(1));
Image component4 = ((Component)val3.transform.GetChild(0)).GetComponent<Image>();
component4.sprite = val.baseSkill.icon;
TextMeshProUGUI component5 = ((Component)val3.transform.GetChild(1)).GetComponent<TextMeshProUGUI>();
SkillSlot val4 = skillLocator.FindSkillSlot(val);
SkillSlot val5 = val4;
((TMP_Text)component5).text = Language.GetString((val5 - -1) switch
{
0 => "LOADOUT_SKILL_MISC",
1 => "LOADOUT_SKILL_PRIMARY",
2 => "LOADOUT_SKILL_SECONDARY",
3 => "LOADOUT_SKILL_UTILITY",
4 => "LOADOUT_SKILL_SPECIAL",
_ => throw new ArgumentOutOfRangeException(),
});
SkillInFamilyComponent component6 = val3.GetComponent<SkillInFamilyComponent>();
component6.skillFamilyComponent = component3;
component6.skillPickerComponent = component2;
component6.skillImage = component4;
SkillFamily skillFamily = val.skillFamily;
component2.SkillFamilies.Add(component6, component3);
if ((Object)(object)skillFamily != (Object)null)
{
Variant[] variants = skillFamily.variants;
foreach (Variant val6 in variants)
{
if (Object.op_Implicit((Object)(object)val6.skillDef))
{
GameObject val7 = Object.Instantiate<GameObject>(Skill, ((Component)val2.transform).transform.GetChild(0));
((Object)val7).name = val6.skillDef.skillName;
SkillComponent component7 = val7.GetComponent<SkillComponent>();
component7.skillDef = val6.skillDef;
component7.skillFamilyComponent = component3;
component7.genericSkill = val;
component7.skillInFamilyComponent = component6;
component3.skillComponents.Add(component7);
Image component8 = ((Component)val7.transform.GetChild(0)).GetComponent<Image>();
component8.sprite = val6.skillDef.icon;
TextMeshProUGUI component9 = ((Component)val7.transform.GetChild(1)).GetComponent<TextMeshProUGUI>();
((TMP_Text)component9).text = Language.GetString(val6.skillDef.skillNameToken);
val7.SetActive(true);
}
}
}
val3.SetActive(true);
val2.SetActive(false);
num++;
}
}
}
currentSkillPicker.SetActive(false);
currentSkillPicker.transform.localScale = new Vector3(2f, 2f, 2f);
}
}
}