using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using I2.Loc;
using InControl;
using Microsoft.CodeAnalysis;
using NineSolsAPI.Utils;
using TalismanSwitch.Handlers;
using TalismanSwitch.HarmonyPatches;
using TalismanSwitchComponents;
using UnityEngine;
using UnityEngine.Events;
[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("TalismanSwitch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Talisman Switch")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+01f5431bf26474ed6bcc49d87ea02f079a39af7a")]
[assembly: AssemblyProduct("TalismanSwitch")]
[assembly: AssemblyTitle("TalismanSwitch")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 TalismanSwitch
{
internal static class AssetLoader
{
internal static Dictionary<string, Object> Assets { get; private set; } = new Dictionary<string, Object>();
internal static void LoadAssets()
{
LoadAssetsFromAssetBundles();
}
private static void LoadAssetsFromAssetBundles()
{
foreach (string assetBundlesPath in ModConfig.AssetBundlesPaths)
{
AssetBundle embeddedAssetBundle = AssemblyUtils.GetEmbeddedAssetBundle(assetBundlesPath);
if ((Object)(object)embeddedAssetBundle == (Object)null)
{
continue;
}
string[] allAssetNames = embeddedAssetBundle.GetAllAssetNames();
foreach (string text in allAssetNames)
{
Log.Warning(text);
Object val = embeddedAssetBundle.LoadAsset(text);
if (!(val == (Object)null))
{
Assets[text] = val;
}
}
}
}
}
internal class TalismanStateObserver
{
private TalismanDisplayController _talismanDisplayController;
private readonly PlayerMainAbilityCollection mainAbilityCollection;
private bool _isHidden;
public AbilityWrapper FooExplodeAllStyle => mainAbilityCollection.FooExplodeAllStyle;
public AbilityWrapper FooExplodeConsecutiveStyle => mainAbilityCollection.FooExplodeConsecutiveStyle;
public AbilityWrapper FooExplodeAutoStyle => mainAbilityCollection.FooExplodeAutoStyle;
public AbilityWrapper FooExplodeAllStyleUpgrade => mainAbilityCollection.FooExplodeAllStyleUpgrade;
public AbilityWrapper FooExplodeConsecutiveStyleUpgrade => mainAbilityCollection.FooExplodeConsecutiveStyleUpgrade;
public AbilityWrapper FooExplodeAutoStyleUpgrade => mainAbilityCollection.FooExplodeAutoStyleUpgrade;
public bool IsHidden
{
get
{
return _isHidden;
}
set
{
_isHidden = value;
UpdateUIState();
}
}
internal TalismanStateObserver(TalismanDisplayController talismanDisplayController, PlayerMainAbilityCollection mainAbilityCollection)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)mainAbilityCollection == (Object)null)
{
throw new ArgumentNullException("mainAbilityCollection");
}
_talismanDisplayController = talismanDisplayController;
this.mainAbilityCollection = mainAbilityCollection;
PlayerInputBinderPatches.OnAwakePostfix = (Action)Delegate.Combine(PlayerInputBinderPatches.OnAwakePostfix, new Action(HandleInputBinderAwake));
FooExplodeAllStyle.AbilityData.OnActivate.AddListener((UnityAction<bool>)HandleTalismanChange);
FooExplodeConsecutiveStyle.AbilityData.OnActivate.AddListener((UnityAction<bool>)HandleTalismanChange);
FooExplodeAutoStyle.AbilityData.OnActivate.AddListener((UnityAction<bool>)HandleTalismanChange);
FooExplodeAllStyleUpgrade.AbilityData.OnActivate.AddListener((UnityAction<bool>)HandleTalismanChange);
FooExplodeConsecutiveStyleUpgrade.AbilityData.OnActivate.AddListener((UnityAction<bool>)HandleTalismanChange);
FooExplodeAutoStyleUpgrade.AbilityData.OnActivate.AddListener((UnityAction<bool>)HandleTalismanChange);
}
private void HandleTalismanChange(bool _)
{
UpdateUIState();
}
private void HandleInputBinderAwake()
{
if (SingletonBehaviour<PlayerInputBinder>.IsAvailable())
{
SingletonBehaviour<PlayerInputBinder>.Instance.fsm.Changed += HandlePlayerInputStateChange;
}
}
private void HandlePlayerInputStateChange(PlayerInputStateType inputState)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
if ((int)inputState != 0)
{
IsHidden = true;
}
else
{
IsHidden = false;
}
UpdateUIState();
}
internal void UpdateUIState()
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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)
EnabledTalisman enabledTalisman = (EnabledTalisman)((!IsHidden) ? ((int)ResolveEnabledTalisman()) : 0);
_talismanDisplayController.EnabledTalisman = enabledTalisman;
_talismanDisplayController.RequestUpdate();
}
private EnabledTalisman ResolveEnabledTalisman()
{
//IL_00b1: 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_000e: 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_0041: 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)
//IL_006d: 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_003d: 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)
//IL_007f: 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_0065: 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_0091: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)Player.i == (Object)null)
{
return (EnabledTalisman)0;
}
if (FooExplodeAllStyle.AbilityData.IsEquipped)
{
if (FooExplodeAllStyleUpgrade.AbilityData.IsEquipped)
{
return (EnabledTalisman)2;
}
return (EnabledTalisman)1;
}
if (FooExplodeAutoStyle.AbilityData.IsEquipped)
{
if (FooExplodeAutoStyleUpgrade.AbilityData.IsEquipped)
{
return (EnabledTalisman)4;
}
return (EnabledTalisman)3;
}
if (FooExplodeConsecutiveStyle.AbilityData.IsEquipped)
{
if (FooExplodeConsecutiveStyleUpgrade.AbilityData.IsEquipped)
{
return (EnabledTalisman)6;
}
return (EnabledTalisman)5;
}
}
catch (Exception ex)
{
Log.Error("Error resolving enabled talisman: " + ex.Message);
return (EnabledTalisman)0;
}
return (EnabledTalisman)0;
}
internal void Release()
{
if (SingletonBehaviour<PlayerInputBinder>.IsAvailable())
{
SingletonBehaviour<PlayerInputBinder>.Instance.fsm.Changed -= HandlePlayerInputStateChange;
}
PlayerInputBinderPatches.OnAwakePostfix = (Action)Delegate.Remove(PlayerInputBinderPatches.OnAwakePostfix, new Action(HandleInputBinderAwake));
}
}
internal static class Log
{
private static ManualLogSource? logSource;
internal static void Init(ManualLogSource logSource)
{
Log.logSource = logSource;
}
internal static void Debug(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogDebug(data);
}
}
internal static void Error(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogError(data);
}
}
internal static void Fatal(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogFatal(data);
}
}
internal static void Info(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogInfo(data);
}
}
internal static void Message(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogMessage(data);
}
}
internal static void Warning(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogWarning(data);
}
}
internal static void Exception(Exception ex)
{
Error("Exception occured: " + ex.Message + ". Stack trace: \n " + ex.StackTrace);
}
internal static void Exception(Exception ex, string message)
{
Error(message + "\n Exception occured: " + ex.Message + ". \nStack trace: \n " + ex.StackTrace);
}
}
internal static class ModConfig
{
private static List<string> _assetBundlesPaths = new List<string>(2) { "TalismanSwitch.Resources.main_bundle.bundle", "TalismanSwitch.Resources.modbundle.bundle" };
internal const string MAIN_ABILITY_COLLECTION_ASSET_NAME = "extraobjects/playermainabilitycollection/-0_playermainabilitycollection.prefab";
internal const string TALISMAN_DISPLAY_CANVAS_ASSET_NAME = "assets/canvas.prefab";
internal const string TALISMAN_SWITCH_COLLECTION_ASSET_NAME = "extraobjects/playerabilitysinglechoicecollection/foostyle collection 所有流派.prefab";
internal const InputControlType DEFAULT_CONTROLLER_INPUT = (InputControlType)12;
internal const Key DEFAULT_KBM_INPUT = (Key)28;
internal const string KBM_CONTROLS_PANEL_NAME = "Keyboard Mouse Binding Panel";
internal const string CONTROLLER_CONTROLS_PANEL_NAME = "Controller Panel";
internal const ActionSetType MOD_INPUT_ACTION_SET_TYPE = (ActionSetType)4;
internal const string MOD_ACTIONS_PREFIX = "TalismanSwitch";
internal const string TALISMAN_SWITCH_ACTION_NAME = "TalismanSwitch";
internal const string PLAYER_PREFS_KEY = "TALISMAN_SWITCH_PLAYER_PREFS";
internal const string CONFIG_ENTRY_LOCALIZATION_KEY = "NextTalismanKey";
internal const string TRANSLATIONS_ASSET_PATH = "TalismanSwitch.Resources.translations.json";
internal static IReadOnlyList<string> AssetBundlesPaths => _assetBundlesPaths;
}
[HarmonyPatch]
public class Patches
{
[HarmonyPatch(typeof(Player), "SetStoryWalk")]
[HarmonyPrefix]
private static bool PatchStoryWalk(ref float walkModifier)
{
walkModifier = 1f;
return true;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("TalismanSwitch", "TalismanSwitch", "1.0.0")]
public class TalismanSwitch : BaseUnityPlugin
{
private Harmony harmony;
internal static TalismanSwitch Instance;
internal TalismanDisplayController talismanDisplayController;
internal TalismanStateObserver talismanStateObserver;
internal TalismanSwitchHandler talismanSwitchHandler;
internal ModInputHandler modInputHandler;
internal SettingsPatchingHandler settingsPatchingHandler;
internal ConfigEntry<KeyboardShortcut> switchControl;
private void Awake()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
Instance = this;
Log.Init(((BaseUnityPlugin)this).Logger);
RCGLifeCycle.DontDestroyForever(((Component)this).gameObject);
try
{
LoadAssets();
talismanStateObserver = new TalismanStateObserver(talismanDisplayController, (PlayerMainAbilityCollection)AssetLoader.Assets["extraobjects/playermainabilitycollection/-0_playermainabilitycollection.prefab"]);
InitInputHandler();
talismanSwitchHandler = new TalismanSwitchHandler();
modInputHandler.OnSwitchTalismanPressed += talismanSwitchHandler.ChangeTalisman;
settingsPatchingHandler = new SettingsPatchingHandler();
AddLocalizations();
}
catch (Exception ex)
{
Log.Exception(ex);
Object.Destroy((Object)(object)this);
return;
}
harmony = Harmony.CreateAndPatchAll(typeof(TalismanSwitch).Assembly, (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TalismanSwitch is loaded!");
}
private void InitInputHandler()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
modInputHandler = new GameObject("ModInputHandler").AddComponent<ModInputHandler>();
RCGLifeCycle.DontDestroyForever(((Component)modInputHandler).gameObject);
((Object)((Component)modInputHandler).gameObject).hideFlags = (HideFlags)61;
}
private void AddLocalizations()
{
LanguageSourceData val = LocalizationManager.Sources[1];
Dictionary<string, string> embeddedJson = AssemblyUtils.GetEmbeddedJson<Dictionary<string, string>>("TalismanSwitch.Resources.translations.json");
if (embeddedJson == null)
{
Log.Error("Failed to load translations");
return;
}
TermData val2 = val.AddTerm("NextTalismanKey");
List<string> list = new List<string>();
for (int i = 0; i < val.mLanguages.Count; i++)
{
LanguageData val3 = val.mLanguages[i];
if (!embeddedJson.TryGetValue(val3.Code, out var value))
{
list.Add("");
}
else
{
list.Add(value);
}
}
val2.Languages = list.ToArray();
}
private void LoadAssets()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
AssetLoader.LoadAssets();
GameObject val = Object.Instantiate<GameObject>((GameObject)AssetLoader.Assets["assets/canvas.prefab"]);
RCGLifeCycle.DontDestroyForever(val);
((Object)val).hideFlags = (HideFlags)61;
talismanDisplayController = val.GetComponentInChildren<TalismanDisplayController>();
}
private void OnDestroy()
{
modInputHandler.OnSwitchTalismanPressed -= talismanSwitchHandler.ChangeTalisman;
talismanStateObserver.Release();
talismanSwitchHandler.Release();
Object.Destroy((Object)(object)((Component)modInputHandler).gameObject);
Object.Destroy((Object)(object)((Component)((Component)talismanDisplayController).GetComponentInParent<Canvas>()).gameObject);
harmony.UnpatchSelf();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TalismanSwitch has been unloaded");
}
}
internal class TalismanSwitchActionSet : PlayerActionSet
{
internal Action? OnSwitchTalismanPressed;
internal PlayerAction SwitchTalismanAction;
private PlayerAction CreatePlayerAction(string actionName)
{
return ((PlayerActionSet)this).CreatePlayerAction("TalismanSwitch" + actionName);
}
internal void Initialize()
{
SwitchTalismanAction = CreatePlayerAction("TalismanSwitch");
BindControls();
}
internal void Update()
{
if (((OneAxisInputControl)SwitchTalismanAction).WasPressed)
{
OnSwitchTalismanPressed?.Invoke();
}
}
protected void BindControls()
{
SwitchTalismanAction.AddDefaultBinding((InputControlType)12);
SwitchTalismanAction.AddDefaultBinding((Key[])(object)new Key[1] { (Key)28 });
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "TalismanSwitch";
public const string PLUGIN_NAME = "TalismanSwitch";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace TalismanSwitch.HarmonyPatches
{
internal class ControlsButtonDescriptor
{
internal GameObject ButtonObject { get; set; }
public ControlsButtonDescriptor(GameObject buttonObject)
{
ButtonObject = buttonObject;
}
}
[HarmonyPatch(typeof(PlayerControlBindingPanel))]
internal static class PlayerControlBindingPanelPatches
{
internal static event Action<PlayerControlBindingPanel>? OnStartPostfix;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start_Postfix(PlayerControlBindingPanel __instance)
{
try
{
PlayerControlBindingPanelPatches.OnStartPostfix?.Invoke(__instance);
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
}
[HarmonyPatch(typeof(PlayerInputBinder))]
internal static class PlayerInputBinderPatches
{
internal static Action<InputDevice>? OnSetDeviceAwake;
internal static Action? OnBindingControlPostfix;
internal static Action? OnAwakePostfix;
[HarmonyPatch("SetDevice")]
[HarmonyPostfix]
private static void SetDevice_Postfix(InputDevice device)
{
try
{
OnSetDeviceAwake?.Invoke(device);
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
[HarmonyPatch("BindingControl")]
[HarmonyPostfix]
private static void BindingControl_Postfix()
{
try
{
OnBindingControlPostfix?.Invoke();
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Awake_Postfix()
{
try
{
OnAwakePostfix?.Invoke();
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
[HarmonyPatch("FindAction")]
[HarmonyPostfix]
private static void FindAction_Postfix(ActionSetType actionSetType, string actionName, ref PlayerAction __result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
if ((int)actionSetType == 4)
{
__result = ((PlayerActionSet)TalismanSwitch.Instance.modInputHandler.modActionSet).GetPlayerActionByName(actionName);
}
}
}
[HarmonyPatch(typeof(Player))]
internal static class PlayerPatches
{
internal static event Action<Player>? OnPlayerAwakePostfix;
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Awake_Postfix(Player __instance)
{
try
{
PlayerPatches.OnPlayerAwakePostfix?.Invoke(__instance);
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
}
[HarmonyPatch(typeof(SaveManager))]
internal static class SaveManagerPatches
{
internal static event Action<SaveManager>? OnSaveInputBindingPostfix;
[HarmonyPatch("SaveInputBinding")]
[HarmonyPostfix]
private static void SaveInputBinding_Postfix(SaveManager __instance)
{
try
{
SaveManagerPatches.OnSaveInputBindingPostfix?.Invoke(__instance);
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
}
[HarmonyPatch(typeof(StartMenuLogic))]
internal static class StartMenuLogicPatches
{
internal static event Action<StartMenuLogic>? OnStartMenuAwake;
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Awake_Postfix(StartMenuLogic __instance)
{
try
{
StartMenuLogicPatches.OnStartMenuAwake?.Invoke(__instance);
}
catch (Exception ex)
{
Log.Exception(ex);
}
}
}
}
namespace TalismanSwitch.Handlers
{
internal class ModInputHandler : MonoBehaviour
{
internal TalismanSwitchActionSet modActionSet;
internal event Action? OnSwitchTalismanPressed;
private void Awake()
{
PlayerInputBinderPatches.OnSetDeviceAwake = (Action<InputDevice>)Delegate.Combine(PlayerInputBinderPatches.OnSetDeviceAwake, new Action<InputDevice>(HandleDeviceSet));
PlayerInputBinderPatches.OnBindingControlPostfix = (Action)Delegate.Combine(PlayerInputBinderPatches.OnBindingControlPostfix, new Action(HandleControlsBinding));
SaveManagerPatches.OnSaveInputBindingPostfix += HandleSaveInputBinding;
}
private void HandleSaveInputBinding(SaveManager _)
{
SavePrefs();
}
private void Update()
{
if (modActionSet != null)
{
modActionSet.Update();
}
}
private void HandleControlsBinding()
{
InitControls();
}
private void HandleDeviceSet(InputDevice device)
{
InitControls();
((PlayerActionSet)modActionSet).Device = device;
}
private void InitControls()
{
if (modActionSet == null)
{
modActionSet = new TalismanSwitchActionSet();
modActionSet.Initialize();
TalismanSwitchActionSet talismanSwitchActionSet = modActionSet;
talismanSwitchActionSet.OnSwitchTalismanPressed = (Action)Delegate.Combine(talismanSwitchActionSet.OnSwitchTalismanPressed, this.OnSwitchTalismanPressed);
}
LoadPrefs();
}
private void LoadPrefs()
{
if (PlayerPrefs.HasKey("TALISMAN_SWITCH_PLAYER_PREFS"))
{
string text = PlayerPrefs.GetString("TALISMAN_SWITCH_PLAYER_PREFS");
((PlayerActionSet)modActionSet).Load(text);
}
}
private void SavePrefs()
{
string text = ((PlayerActionSet)modActionSet).Save();
PlayerPrefs.SetString("TALISMAN_SWITCH_PLAYER_PREFS", text);
}
private void OnDestroy()
{
PlayerInputBinderPatches.OnSetDeviceAwake = (Action<InputDevice>)Delegate.Remove(PlayerInputBinderPatches.OnSetDeviceAwake, new Action<InputDevice>(HandleDeviceSet));
PlayerInputBinderPatches.OnBindingControlPostfix = (Action)Delegate.Remove(PlayerInputBinderPatches.OnBindingControlPostfix, new Action(HandleControlsBinding));
SaveManagerPatches.OnSaveInputBindingPostfix -= HandleSaveInputBinding;
}
}
internal class SettingsPatchingHandler
{
private FieldInfo _playerInputActionDataMyNameField = AccessTools.Field(typeof(PlayerInputActionData), "_myName");
public SettingsPatchingHandler()
{
PlayerControlBindingPanelPatches.OnStartPostfix += HandleControlBindingPanelStart;
}
private void HandleControlBindingPanelStart(PlayerControlBindingPanel obj)
{
if (((Object)obj).name == "Keyboard Mouse Binding Panel")
{
PatchKBMControlsPanel(obj);
}
if (((Object)obj).name == "Controller Panel")
{
PatchControllerControlsPanel(obj);
}
}
private void PatchKBMControlsPanel(PlayerControlBindingPanel panel)
{
Transform val = ((Component)panel).transform.Find("Layout/Table/Col 2/Map");
if ((Object)(object)val == (Object)null)
{
throw new InvalidOperationException();
}
CloneButton(((Component)val).gameObject);
}
private void PatchControllerControlsPanel(PlayerControlBindingPanel panel)
{
Transform val = ((Component)panel).transform.Find("Layout/Table/Col 2/Arrow Previous Remap Control ActionBindingUI (8)");
if ((Object)(object)val == (Object)null)
{
throw new InvalidOperationException();
}
CloneButton(((Component)val).gameObject);
}
private ControlsButtonDescriptor CloneButton(GameObject baseButton)
{
//IL_002c: 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)
GameObject val = Object.Instantiate<GameObject>(baseButton, ((Component)baseButton.transform.parent).transform);
val.transform.localScale = new Vector3(1f, 1f, 1f);
ConfigureSelectables(val);
val.GetComponentInChildren<Localize>(true).Term = "NextTalismanKey";
PlayerInputActionData val2 = (val.GetComponent<ActionBindingProvider>().ActionData = ScriptableObject.CreateInstance<PlayerInputActionData>());
val2.actionSetType = (ActionSetType)4;
_playerInputActionDataMyNameField.SetValue(val2, "TalismanSwitchTalismanSwitch");
return new ControlsButtonDescriptor(val);
}
private void ConfigureSelectables(GameObject buttonGameObject)
{
PlayerControlBindingPanel componentInParent = buttonGameObject.GetComponentInParent<PlayerControlBindingPanel>(true);
SelectableNavigationProvider componentInParent2 = buttonGameObject.GetComponentInParent<SelectableNavigationProvider>(true);
AutoAttributeManager.AutoReferenceAllChildren(((Component)componentInParent).gameObject);
componentInParent2.AutoNavigateBindForAll();
}
}
internal class TalismanSwitchHandler
{
private bool _styleChangeQueued;
private PlayerAbilitySingleChoiceCollection? talismanSwitchCollection;
public TalismanSwitchHandler()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
talismanSwitchCollection = (PlayerAbilitySingleChoiceCollection)AssetLoader.Assets["extraobjects/playerabilitysinglechoicecollection/foostyle collection 所有流派.prefab"];
PlayerPatches.OnPlayerAwakePostfix += HandlePlayerAwake;
}
private void HandlePlayerAwake(Player player)
{
player.fsm.Changed += HandlePlayerFsmChange;
}
private void HandlePlayerFsmChange(PlayerStateType state)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
if (_styleChangeQueued && !IsUsingTalisman(state))
{
_styleChangeQueued = false;
ChangeTalisman();
}
}
internal void ChangeTalisman()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (IsUsingTalisman(Player.i.CurrentStateType))
{
_styleChangeQueued = true;
return;
}
PlayerAbilitySingleChoiceCollection? obj = talismanSwitchCollection;
if (obj != null)
{
((AbstractGameFlagCollection)obj).Next();
}
}
private static bool IsUsingTalisman(PlayerStateType playerState)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
if ((int)playerState != 3 && (int)playerState != 60)
{
return (int)playerState == 54;
}
return true;
}
internal void Release()
{
PlayerPatches.OnPlayerAwakePostfix -= HandlePlayerAwake;
}
}
}