using System;
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 GGECS;
using GGUtil;
using Inventory.Unity;
using Skins;
using UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("WWAG_EYE_MENU")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WWAG_EYE_MENU")]
[assembly: AssemblyTitle("WWAG_EYE_MENU")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace WWAG_EYE_MENU;
public class ConstInfo
{
public const string PLUGIN_GUID = "WWAG_EYE_MENU";
public const string PLUGIN_NAME = "WWAG_EYE_MENU";
public const string PLUGIN_VERSION = "1.0.0";
}
public class EyeShapeVisualsSlotUI : PlayerVisualsSlotUI
{
private GameObject[] _eyeShapeItems;
private AssetHandle<SkinGroup> _eyeShape;
private Color _eyeColor;
public void SetData(GameObject[] eyeShapeItems)
{
_eyeShapeItems = eyeShapeItems;
}
public void UpdateSlot(bool force = false)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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_002c: 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)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0053: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
if (!((Behaviour)this).enabled)
{
return;
}
PersistentPlayerData mainThreadData = ((PlayerBehaviour)this).world.GetMainThreadData<PersistentPlayerData>();
ECSEntity persistentEntity = ((PersistentPlayerData)(ref mainThreadData)).GetPersistentEntity(NetUtil.GetMyId());
PlayerVisualsComp playerVisualsData = ((PersistentPlayerData)(ref mainThreadData)).GetPlayerVisualsData(persistentEntity);
if (force || playerVisualsData.eyes != _eyeShape || playerVisualsData.eyeColor != _eyeColor)
{
SkinGroup val = Assets<SkinGroup>.Get(playerVisualsData.eyes);
if ((Object)(object)val != (Object)null)
{
Sprite icon = GetSprite(val) ?? val.skins[0].skin;
base.selectableButton.SetIcon(icon);
base.selectableButton.SetColor(playerVisualsData.eyeColor);
_eyeShape = playerVisualsData.eyes;
_eyeColor = playerVisualsData.eyeColor;
}
}
}
private Sprite GetSprite(SkinGroup skinGroup)
{
GameObject[] eyeShapeItems = _eyeShapeItems;
foreach (GameObject val in eyeShapeItems)
{
StaticItemEquipmentComponent component = val.GetComponent<StaticItemEquipmentComponent>();
if (!((Object)(object)component.skinGroup != (Object)(object)skinGroup))
{
StaticItem component2 = val.GetComponent<StaticItem>();
if (!((Object)(object)component2 == (Object)null))
{
return component2.icon;
}
}
}
return null;
}
protected override void OnPlayerUpdate()
{
UpdateSlot();
}
}
[BepInPlugin("WWAG_EYE_MENU", "WWAG_EYE_MENU", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const BindingFlags PrivateFlags = BindingFlags.Instance | BindingFlags.NonPublic;
private PlayerVisualsSlotUI _slotUI;
private PlayerEquipmentUI _playerEquipmentUI;
private Sprite _slotSprite;
private void Awake()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin WWAG_EYE_MENU is loaded!");
LoadSprite();
UIDialogueStack.OnFocusChanged += new FocusChangedHandler(OnFocusChanged);
}
private void LoadSprite()
{
string location = Assembly.GetExecutingAssembly().Location;
string directoryName = Path.GetDirectoryName(location);
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "clothingui"));
_slotSprite = val.LoadAsset<Sprite>("clothes-slot.png");
}
private void OnFocusChanged(IUIDialogue from, IUIDialogue to)
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
UIWindow val = (UIWindow)(object)((to is UIWindow) ? to : null);
if (val == null)
{
return;
}
PlayerInventoryUI component = ((Component)val).GetComponent<PlayerInventoryUI>();
if ((Object)(object)component == (Object)null || IsButtonExists())
{
return;
}
GameObject val2 = GameObject.Find("ui/cross-world-ui(Clone)/inventory-ui/window/panel/equipment-panel");
_playerEquipmentUI = val2.GetComponent<PlayerEquipmentUI>();
PlayerVisualsSlotUI eyeSlot = GetEyeSlot(_playerEquipmentUI);
if (!((Object)(object)eyeSlot == (Object)null))
{
_slotUI = CreateSlot(eyeSlot);
if (!((Object)(object)_slotUI == (Object)null))
{
_slotUI.Initialize(new UnityAction(OpenVisualsPanel));
}
}
}
private bool IsButtonExists()
{
GameObject val = GameObject.Find("ui/cross-world-ui(Clone)/inventory-ui/window/panel/equipment-panel/eye-shape");
return (Object)(object)val != (Object)null;
}
private PlayerVisualsSlotUI GetEyeSlot(PlayerEquipmentUI equipmentUi)
{
Type typeFromHandle = typeof(PlayerEquipmentUI);
object obj = typeFromHandle.GetField("_eyeVisualSlot", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(equipmentUi);
return (PlayerVisualsSlotUI)((obj is PlayerVisualsSlotUI) ? obj : null);
}
private PlayerVisualsSlotUI CreateSlot(PlayerVisualsSlotUI eyeSlot)
{
//IL_0043: 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_005a: 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_006e: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)eyeSlot).gameObject;
RectTransform component = gameObject.GetComponent<RectTransform>();
GameObject val = Object.Instantiate<GameObject>(gameObject);
((Object)val).name = "eye-shape";
val.transform.SetParent(gameObject.transform.parent, false);
RectTransform component2 = val.GetComponent<RectTransform>();
component2.sizeDelta = component.sizeDelta * 0.7f;
((Transform)component2).position = ((Transform)component).position - new Vector3(120f, 45f);
PlayerVisualsSlotUI component3 = val.GetComponent<PlayerVisualsSlotUI>();
EyeShapeVisualsSlotUI eyeShapeVisualsSlotUI = val.AddComponent<EyeShapeVisualsSlotUI>();
((PlayerVisualsSlotUI)eyeShapeVisualsSlotUI).selectableButton = component3.selectableButton;
((PlayerVisualsSlotUI)eyeShapeVisualsSlotUI).equipSlot = (EquipSlot)7;
Type typeFromHandle = typeof(PlayerEquipmentUI);
FieldInfo field = typeFromHandle.GetField("_spawnGameData", BindingFlags.Instance | BindingFlags.NonPublic);
PlayerSpawnGameData val2 = (PlayerSpawnGameData)field.GetValue(_playerEquipmentUI);
eyeShapeVisualsSlotUI.SetData(val2.eyeShapeItems);
Image val3 = ((Component)eyeShapeVisualsSlotUI).gameObject.AddComponent<Image>();
val3.sprite = _slotSprite;
((Graphic)val3).SetNativeSize();
Transform transform = ((PlayerVisualsSlotUI)eyeShapeVisualsSlotUI).selectableButton.selectionBorder.transform;
transform.localScale *= 0.7f;
RectTransform component4 = ((Component)val3).GetComponent<RectTransform>();
component4.sizeDelta *= 0.7f;
CopyWorldAndPlayer(eyeSlot, (PlayerVisualsSlotUI)(object)eyeShapeVisualsSlotUI);
Object.Destroy((Object)(object)component3);
return (PlayerVisualsSlotUI)(object)eyeShapeVisualsSlotUI;
}
private void CopyWorldAndPlayer(PlayerVisualsSlotUI eyeSlot, PlayerVisualsSlotUI uiSlot)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_003c: 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_009d: Unknown result type (might be due to invalid IL or missing references)
Type typeFromHandle = typeof(PlayerBehaviour);
PropertyInfo property = typeFromHandle.GetProperty("world", BindingFlags.Instance | BindingFlags.NonPublic);
PropertyInfo property2 = typeFromHandle.GetProperty("player", BindingFlags.Instance | BindingFlags.NonPublic);
ECSWorld val = (ECSWorld)property.GetValue(eyeSlot);
ECSEntity val2 = (ECSEntity)property2.GetValue(eyeSlot);
PlayerBehaviourSystem system = GameUniverse.persistentWorld.world.GetSystem<PlayerBehaviourSystem>();
Type typeFromHandle2 = typeof(PlayerBehaviourSystem);
FieldInfo field = typeFromHandle2.GetField("_playerBehaviours", BindingFlags.Instance | BindingFlags.NonPublic);
PlayerBehaviour[] source = (PlayerBehaviour[])field.GetValue(system);
PlayerBehaviour[] value = source.Append((PlayerBehaviour)(object)uiSlot).ToArray();
field.SetValue(system, value);
((PlayerBehaviour)uiSlot).PlayerStart(val, val2);
}
private void OpenVisualsPanel()
{
if (!((Object)(object)_slotUI == (Object)null))
{
Type typeFromHandle = typeof(PlayerEquipmentUI);
MethodInfo method = typeFromHandle.GetMethod("OpenVisualItemPanel", BindingFlags.Instance | BindingFlags.NonPublic);
if (!(method == null))
{
method.Invoke(_playerEquipmentUI, new object[2] { false, _slotUI });
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "WWAG_EYE_MENU";
public const string PLUGIN_NAME = "WWAG_EYE_MENU";
public const string PLUGIN_VERSION = "1.0.0";
}