using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Antro.FurniturePresets")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.FurniturePresets")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("Antro.FurniturePresets")]
[assembly: AssemblyTitle("Antro.FurniturePresets")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 DiscordInviteMod
{
[BepInPlugin("Antro.discord_invite", "Discord Invite Button", "1.0.3")]
public class DiscordInvitePlugin : BaseUnityPlugin
{
private const string SharedObjectName = "SharedDiscordInviteButton_BG";
private void Awake()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
if ((Object)(object)GameObject.Find("SharedDiscordInviteButton_BG") == (Object)null)
{
GameObject val = new GameObject("SharedDiscordInviteButton_BG");
Object.DontDestroyOnLoad((Object)(object)val);
val.AddComponent<DiscordInviteComponent>();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Discord Invite Button initialized successfully!");
}
else
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Discord Invite Button already exists from another mod. Skipping creation.");
}
}
}
public class DiscordInviteComponent : MonoBehaviour
{
private readonly string discordUrl = "https://discord.gg/bPjcrJxBmP";
private readonly string logoUrl = "https://i.imgur.com/48jKo1r_d.png?maxwidth=520&shape=thumb&fidelity=high";
private readonly string arrowUrl = "https://i.imgur.com/TUT8ICu_d.png?maxwidth=520&shape=thumb&fidelity=high";
private readonly float logoSize = 300f;
private readonly float padding = 40f;
private readonly float arrowSize = 160f;
private readonly float baseRadius = 260f;
private readonly float animAmplitude = 25f;
private readonly float animSpeed = 5f;
private Texture2D logoTexture;
private Texture2D arrowTexture;
private GUIStyle transparentStyle;
private string folderPath;
private bool hasClickedLogo = false;
private const string PrefsKey = "Antro_DiscordInvite_HasClicked";
private bool shouldShowButton = false;
private bool isSubMenuOpen = false;
private HashSet<Button> hookedButtons = new HashSet<Button>();
private void Start()
{
hasClickedLogo = PlayerPrefs.GetInt("Antro_DiscordInvite_HasClicked", 0) == 1;
folderPath = Path.Combine(Paths.PluginPath, "DiscordInviteMod");
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
((MonoBehaviour)this).StartCoroutine(LoadOrDownloadImage(logoUrl, "DiscordLogoCache.png", delegate(Texture2D result)
{
logoTexture = result;
}));
if (!hasClickedLogo)
{
((MonoBehaviour)this).StartCoroutine(LoadOrDownloadImage(arrowUrl, "DiscordArrowCache.png", delegate(Texture2D result)
{
arrowTexture = result;
}));
}
((MonoBehaviour)this).StartCoroutine(CheckMenuState());
}
private void Update()
{
if (Input.GetKeyDown((KeyCode)27))
{
isSubMenuOpen = false;
}
}
private IEnumerator CheckMenuState()
{
while (true)
{
GameObject mainButtonsObj = GameObject.Find("Canvas/Menu/Button parent/Buttons");
if ((Object)(object)mainButtonsObj == (Object)null)
{
GameObject temp = GameObject.Find("Buttons");
if ((Object)(object)temp != (Object)null && (Object)(object)temp.transform.parent != (Object)null && ((Object)temp.transform.parent).name == "Button parent")
{
mainButtonsObj = temp;
}
}
if ((Object)(object)mainButtonsObj == (Object)null)
{
shouldShowButton = false;
isSubMenuOpen = false;
}
else
{
CanvasGroup cg = mainButtonsObj.GetComponentInParent<CanvasGroup>();
if (!((Object)(object)cg == (Object)null) && (!(cg.alpha > 0.01f) || !cg.interactable))
{
shouldShowButton = false;
isSubMenuOpen = false;
}
else
{
shouldShowButton = !isSubMenuOpen;
Button[] buttons = mainButtonsObj.GetComponentsInChildren<Button>(true);
Button[] array = buttons;
foreach (Button btn in array)
{
if (hookedButtons.Add(btn))
{
((UnityEvent)btn.onClick).AddListener((UnityAction)delegate
{
isSubMenuOpen = true;
});
}
}
}
}
yield return (object)new WaitForSeconds(0.5f);
}
}
private IEnumerator LoadOrDownloadImage(string url, string fileName, Action<Texture2D> onLoaded)
{
string localPath = Path.Combine(folderPath, fileName);
if (File.Exists(localPath))
{
string fileUrl = "file://" + localPath.Replace("\\", "/");
UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(fileUrl);
try
{
yield return uwr.SendWebRequest();
if ((int)uwr.result == 1)
{
onLoaded?.Invoke(DownloadHandlerTexture.GetContent(uwr));
yield break;
}
}
finally
{
((IDisposable)uwr)?.Dispose();
}
}
UnityWebRequest uwr2 = UnityWebRequestTexture.GetTexture(url);
try
{
yield return uwr2.SendWebRequest();
if ((int)uwr2.result == 1)
{
Texture2D tex = DownloadHandlerTexture.GetContent(uwr2);
onLoaded?.Invoke(tex);
try
{
File.WriteAllBytes(localPath, uwr2.downloadHandler.data);
}
catch
{
}
}
}
finally
{
((IDisposable)uwr2)?.Dispose();
}
}
private void OnGUI()
{
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Expected O, but got Unknown
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Expected O, but got Unknown
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: 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_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
if (!shouldShowButton || ((Object)(object)NetworkManager.Singleton != (Object)null && (NetworkManager.Singleton.IsClient || NetworkManager.Singleton.IsServer)))
{
return;
}
GUI.depth = -1000;
Rect val = default(Rect);
((Rect)(ref val))..ctor((float)Screen.width - logoSize - padding, padding, logoSize, logoSize);
if (!hasClickedLogo && (Object)(object)logoTexture != (Object)null && (Object)(object)arrowTexture != (Object)null)
{
float num = ((Rect)(ref val)).x + logoSize / 2f;
float num2 = ((Rect)(ref val)).y + logoSize / 2f;
float[,] array = new float[3, 3]
{
{
(float)Math.PI,
90f,
0f
},
{
(float)Math.PI * 3f / 4f,
45f,
2f
},
{
(float)Math.PI / 2f,
0f,
4f
}
};
Rect val2 = default(Rect);
for (int i = 0; i < 3; i++)
{
float num3 = array[i, 0];
float num4 = array[i, 1];
float num5 = array[i, 2];
float num6 = baseRadius + Mathf.Sin(Time.realtimeSinceStartup * animSpeed + num5) * animAmplitude;
float num7 = num + Mathf.Cos(num3) * num6;
float num8 = num2 + Mathf.Sin(num3) * num6;
((Rect)(ref val2))..ctor(num7 - arrowSize / 2f, num8 - arrowSize / 2f, arrowSize, arrowSize);
Matrix4x4 matrix = GUI.matrix;
GUIUtility.RotateAroundPivot(num4, new Vector2(num7, num8));
GUI.DrawTexture(val2, (Texture)(object)arrowTexture, (ScaleMode)2, true);
GUI.matrix = matrix;
}
}
if ((Object)(object)logoTexture != (Object)null)
{
if (transparentStyle == null)
{
transparentStyle = new GUIStyle(GUI.skin.button);
transparentStyle.normal.background = null;
transparentStyle.hover.background = null;
transparentStyle.active.background = null;
}
if (GUI.Button(val, (Texture)(object)logoTexture, transparentStyle))
{
HandleLogoClick();
}
}
else
{
GUIStyle val3 = new GUIStyle(GUI.skin.button)
{
fontSize = 14,
fontStyle = (FontStyle)1
};
if (GUI.Button(new Rect((float)(Screen.width - 150) - padding, padding, 150f, 50f), "Discord", val3))
{
HandleLogoClick();
}
}
}
private void HandleLogoClick()
{
if (!hasClickedLogo)
{
hasClickedLogo = true;
PlayerPrefs.SetInt("Antro_DiscordInvite_HasClicked", 1);
PlayerPrefs.Save();
if ((Object)(object)arrowTexture != (Object)null)
{
Object.Destroy((Object)(object)arrowTexture);
arrowTexture = null;
}
}
Application.OpenURL(discordUrl);
}
}
}
namespace FurniturePresetsMod
{
[BepInPlugin("Antro.furniture_presets", "Furniture Presets", "2.3.0")]
public class FurniturePresetsPlugin : BaseUnityPlugin
{
public static ConfigEntry<KeyCode> MenuKey;
private void Awake()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
MenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "MenuKey", (KeyCode)107, "Кнопка меню пресетов");
Harmony val = new Harmony("Antro.furniture_presets");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Furniture Presets 2.3.0 loaded! 100% Item Save/Load Fixed.");
}
}
[HarmonyPatch(typeof(PlayerNetworking), "OnEntitySpawned")]
public class PlayerSpawnPresetPatch
{
private static void Postfix(PlayerNetworking __instance)
{
if (((NetworkBehaviour)__instance).IsServer && ((NetworkBehaviour)__instance).IsLocalPlayer)
{
((Component)__instance).gameObject.AddComponent<FurniturePresetsComponent>();
}
}
}
public class PresetData
{
public List<SavedFurniture> furniture = new List<SavedFurniture>();
public List<SavedMannequin> mannequins = new List<SavedMannequin>();
}
public class SavedFurniture
{
public string idName = "";
public string dataName = "";
public string objName = "";
public Vector3 position;
public Quaternion rotation;
}
public class SavedMannequin
{
public Vector3 position;
public Quaternion rotation;
public int poseIndex;
public List<SavedMannequinItem> items = new List<SavedMannequinItem>();
}
public class SavedMannequinItem
{
public int slotIndex;
public string itemName;
}
public class PooledItem
{
public InstanceData data;
public string name;
}
public class FurniturePresetsComponent : MonoBehaviour
{
private bool isUiOpen = false;
private bool isRebinding = false;
private PlayerNetworking localPlayer;
private string presetsDirectory;
private List<string> availablePresets = new List<string>();
private string newPresetName = "MyBaseSetup";
private Sprite customPanelSprite;
private Sprite customButtonSprite;
private bool uiStolen = false;
private Vector2 scrollPosition;
private bool cachedCanLoad = false;
private string cachedLoadReason = "";
private float cacheTimer = 0f;
private string statusMessage = "";
private float statusTimer = 0f;
private readonly List<string> blacklist = new List<string> { "stockpile", "gamebutton", "medicalterminal", "gnomehouse", "graphics" };
private void Start()
{
localPlayer = ((Component)this).GetComponent<PlayerNetworking>();
presetsDirectory = Path.Combine(Paths.PluginPath, "FurniturePresets");
if (!Directory.Exists(presetsDirectory))
{
Directory.CreateDirectory(presetsDirectory);
}
RefreshPresetsList();
}
private void TryStealUI()
{
if (uiStolen)
{
return;
}
Image[] array = Resources.FindObjectsOfTypeAll<Image>();
Image[] array2 = array;
foreach (Image val in array2)
{
if (!((Object)(object)val.sprite == (Object)null) && !((Object)(object)((Component)val).transform.parent == (Object)null))
{
if (((Object)((Component)val).gameObject).name == "Image" && ((Object)((Component)val).transform.parent).name == "Settings")
{
customPanelSprite = val.sprite;
}
if (((Object)((Component)val).gameObject).name == "Bg" && ((Object)((Component)val).transform.parent).name.Contains("SGButtonPrimaryUGUI"))
{
customButtonSprite = val.sprite;
}
}
}
if ((Object)(object)customPanelSprite != (Object)null || (Object)(object)customButtonSprite != (Object)null)
{
uiStolen = true;
}
}
private void Update()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)localPlayer == (Object)null || !((NetworkBehaviour)localPlayer).IsServer || !((NetworkBehaviour)localPlayer).IsLocalPlayer)
{
return;
}
if (Input.GetKeyDown(FurniturePresetsPlugin.MenuKey.Value) && !isRebinding)
{
TryStealUI();
isUiOpen = !isUiOpen;
if ((Object)(object)localPlayer.Controller != (Object)null)
{
localPlayer.Controller.ShowCursor(isUiOpen);
}
if (isUiOpen)
{
UpdateCache();
}
}
if (isUiOpen)
{
cacheTimer -= Time.deltaTime;
if (cacheTimer <= 0f)
{
UpdateCache();
cacheTimer = 1f;
}
if (statusTimer > 0f)
{
statusTimer -= Time.deltaTime;
}
}
}
private void ShowStatus(string msg)
{
statusMessage = msg;
statusTimer = 5f;
}
private void UpdateCache()
{
cachedCanLoad = CanLoadPreset(out cachedLoadReason);
}
private void RefreshPresetsList()
{
availablePresets.Clear();
if (Directory.Exists(presetsDirectory))
{
string[] files = Directory.GetFiles(presetsDirectory, "*.txt");
string[] array = files;
foreach (string path in array)
{
availablePresets.Add(Path.GetFileNameWithoutExtension(path));
}
}
}
private bool CanLoadPreset(out string reason)
{
//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)
reason = "";
try
{
HomeManager val = Object.FindFirstObjectByType<HomeManager>();
if ((Object)(object)val == (Object)null)
{
reason = "Must be in the Base to load presets!";
return false;
}
if ((Object)(object)GameProgressionManager.Instance != (Object)null && ((object)GameProgressionManager.Instance.CurrentGameState/*cast due to .constrained prefix*/).ToString() != "InLobby")
{
reason = "Cannot load preset while the raid is active!";
return false;
}
return true;
}
catch
{
return false;
}
}
private bool IsBlacklisted(Furniture f)
{
if ((Object)(object)f == (Object)null || (Object)(object)((Component)f).gameObject == (Object)null)
{
return true;
}
string text = ((Object)((Component)f).gameObject).name.ToLower();
string text2 = (((Object)(object)f.FurnitureData != (Object)null) ? ((Object)f.FurnitureData).name.ToLower() : "");
foreach (string item in blacklist)
{
if (text.Contains(item) || text2.Contains(item))
{
return true;
}
}
return false;
}
private string FormatFloat(float f)
{
return f.ToString("G9", CultureInfo.InvariantCulture);
}
private float ParseFloat(string s)
{
float result;
return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out result) ? result : 0f;
}
private void SavePreset(string presetName)
{
//IL_0167: 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_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: 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_010a: Unknown result type (might be due to invalid IL or missing references)
try
{
PresetData presetData = new PresetData();
Furniture[] array = Object.FindObjectsByType<Furniture>((FindObjectsInactive)0, (FindObjectsSortMode)0);
Furniture[] array2 = array;
foreach (Furniture val in array2)
{
if (!IsBlacklisted(val) && !((Object)(object)((Component)val).GetComponent<Mannequin>() != (Object)null))
{
presetData.furniture.Add(new SavedFurniture
{
idName = (((Object)(object)val.FurnitureData != (Object)null) ? ((Object)val.FurnitureData).name : ((Object)((Component)val).gameObject).name.Replace("(Clone)", "").Trim()),
dataName = (((Object)(object)val.FurnitureData != (Object)null) ? ((Object)val.FurnitureData).name : ""),
objName = ((Object)((Component)val).gameObject).name.Replace("(Clone)", "").Trim(),
position = ((Component)val).transform.position,
rotation = ((Component)val).transform.rotation
});
}
}
Mannequin[] array3 = Object.FindObjectsByType<Mannequin>((FindObjectsInactive)0, (FindObjectsSortMode)0);
FieldInfo field = typeof(Mannequin).GetField("n_poseIndex", BindingFlags.Instance | BindingFlags.NonPublic);
Mannequin[] array4 = array3;
foreach (Mannequin val2 in array4)
{
SavedMannequin savedMannequin = new SavedMannequin
{
position = ((Component)val2).transform.position,
rotation = ((Component)val2).transform.rotation
};
if (field != null && field.GetValue(val2) is NetworkVariable<int> val3)
{
savedMannequin.poseIndex = val3.Value;
}
int num = 0;
for (int k = 0; k < 10; k++)
{
InventoryItem itemInSlot = ((InventoryBase)val2).GetItemInSlot(k);
if (((InventoryItem)(ref itemInSlot)).IsValidItem)
{
ItemData itemData = ((InventoryBase)val2).GetItemData((int)((InventoryItem)(ref itemInSlot)).ItemIndex);
if ((Object)(object)itemData != (Object)null && !string.IsNullOrEmpty(((Object)itemData).name))
{
savedMannequin.items.Add(new SavedMannequinItem
{
slotIndex = k,
itemName = ((Object)itemData).name
});
num++;
}
}
}
Debug.Log((object)$"[FurniturePresets] Mannequin saved with {num} items and Pose {savedMannequin.poseIndex}.");
presetData.mannequins.Add(savedMannequin);
}
StringBuilder stringBuilder = new StringBuilder();
foreach (SavedFurniture item in presetData.furniture)
{
stringBuilder.AppendLine("[FURNITURE]");
stringBuilder.AppendLine("IDName=" + item.idName);
stringBuilder.AppendLine("DataName=" + item.dataName);
stringBuilder.AppendLine("ObjName=" + item.objName);
stringBuilder.AppendLine("Pos=" + FormatFloat(item.position.x) + "," + FormatFloat(item.position.y) + "," + FormatFloat(item.position.z));
stringBuilder.AppendLine("Rot=" + FormatFloat(item.rotation.x) + "," + FormatFloat(item.rotation.y) + "," + FormatFloat(item.rotation.z) + "," + FormatFloat(item.rotation.w));
}
foreach (SavedMannequin mannequin in presetData.mannequins)
{
stringBuilder.AppendLine("[MANNEQUIN]");
stringBuilder.AppendLine("Pos=" + FormatFloat(mannequin.position.x) + "," + FormatFloat(mannequin.position.y) + "," + FormatFloat(mannequin.position.z));
stringBuilder.AppendLine("Rot=" + FormatFloat(mannequin.rotation.x) + "," + FormatFloat(mannequin.rotation.y) + "," + FormatFloat(mannequin.rotation.z) + "," + FormatFloat(mannequin.rotation.w));
stringBuilder.AppendLine($"Pose={mannequin.poseIndex}");
foreach (SavedMannequinItem item2 in mannequin.items)
{
stringBuilder.AppendLine($"Item={item2.slotIndex},{item2.itemName}");
}
}
File.WriteAllText(Path.Combine(presetsDirectory, presetName + ".txt"), stringBuilder.ToString());
ShowStatus($"Saved {presetData.furniture.Count} furn & {presetData.mannequins.Count} mannequins!");
RefreshPresetsList();
}
catch (Exception ex)
{
Debug.LogError((object)("[FurniturePresets] Save error: " + ex.Message));
ShowStatus("Error saving preset!");
}
}
private void LoadPreset(string presetName)
{
//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
//IL_049e: Unknown result type (might be due to invalid IL or missing references)
//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0962: Unknown result type (might be due to invalid IL or missing references)
//IL_0967: Unknown result type (might be due to invalid IL or missing references)
//IL_0971: Unknown result type (might be due to invalid IL or missing references)
//IL_0976: Unknown result type (might be due to invalid IL or missing references)
//IL_093a: Unknown result type (might be due to invalid IL or missing references)
//IL_093f: Unknown result type (might be due to invalid IL or missing references)
//IL_0949: Unknown result type (might be due to invalid IL or missing references)
//IL_094e: Unknown result type (might be due to invalid IL or missing references)
//IL_097b: Unknown result type (might be due to invalid IL or missing references)
//IL_0517: Unknown result type (might be due to invalid IL or missing references)
//IL_051c: Unknown result type (might be due to invalid IL or missing references)
//IL_0666: Unknown result type (might be due to invalid IL or missing references)
//IL_09a8: Unknown result type (might be due to invalid IL or missing references)
//IL_09c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0700: Unknown result type (might be due to invalid IL or missing references)
//IL_09e8: Unknown result type (might be due to invalid IL or missing references)
//IL_09f2: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: 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_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
//IL_080f: Unknown result type (might be due to invalid IL or missing references)
if (!cachedCanLoad)
{
return;
}
string path = Path.Combine(presetsDirectory, presetName + ".txt");
if (!File.Exists(path))
{
return;
}
try
{
PresetData presetData = new PresetData();
SavedFurniture savedFurniture = null;
SavedMannequin savedMannequin = null;
string[] array = File.ReadAllLines(path);
string[] array2 = array;
Vector3 position = default(Vector3);
Quaternion rotation = default(Quaternion);
foreach (string text in array2)
{
string text2 = text.Trim();
if (text2 == "[FURNITURE]")
{
savedFurniture = new SavedFurniture();
presetData.furniture.Add(savedFurniture);
savedMannequin = null;
}
else if (text2 == "[MANNEQUIN]")
{
savedMannequin = new SavedMannequin();
presetData.mannequins.Add(savedMannequin);
savedFurniture = null;
}
else if (text2.StartsWith("IDName=") && savedFurniture != null)
{
savedFurniture.idName = text2.Substring(7);
}
else if (text2.StartsWith("DataName=") && savedFurniture != null)
{
savedFurniture.dataName = text2.Substring(9);
}
else if (text2.StartsWith("ObjName=") && savedFurniture != null)
{
savedFurniture.objName = text2.Substring(8);
}
else if (text2.StartsWith("Pose=") && savedMannequin != null)
{
savedMannequin.poseIndex = int.Parse(text2.Substring(5));
}
else if (text2.StartsWith("Pos="))
{
string[] array3 = text2.Substring(4).Split(new char[1] { ',' });
if (array3.Length >= 3)
{
((Vector3)(ref position))..ctor(ParseFloat(array3[0]), ParseFloat(array3[1]), ParseFloat(array3[2]));
if (savedFurniture != null)
{
savedFurniture.position = position;
}
if (savedMannequin != null)
{
savedMannequin.position = position;
}
}
}
else if (text2.StartsWith("Rot="))
{
string[] array4 = text2.Substring(4).Split(new char[1] { ',' });
if (array4.Length >= 4)
{
((Quaternion)(ref rotation))..ctor(ParseFloat(array4[0]), ParseFloat(array4[1]), ParseFloat(array4[2]), ParseFloat(array4[3]));
if (savedFurniture != null)
{
savedFurniture.rotation = rotation;
}
if (savedMannequin != null)
{
savedMannequin.rotation = rotation;
}
}
}
else if (text2.StartsWith("Item=") && savedMannequin != null)
{
string[] array5 = text2.Substring(5).Split(new char[1] { ',' });
if (array5.Length >= 2)
{
savedMannequin.items.Add(new SavedMannequinItem
{
slotIndex = int.Parse(array5[0]),
itemName = array5[1]
});
}
}
}
int num = 0;
int num2 = 0;
List<Furniture> list = (from f in Object.FindObjectsByType<Furniture>((FindObjectsInactive)0, (FindObjectsSortMode)0)
where (Object)(object)f != (Object)null && !IsBlacklisted(f) && (Object)(object)((Component)f).GetComponent<Mannequin>() == (Object)null
select f).ToList();
foreach (SavedFurniture savedFurn in presetData.furniture)
{
Furniture val = ((IEnumerable<Furniture>)list).FirstOrDefault((Func<Furniture, bool>)delegate(Furniture f)
{
string text3 = (((Object)(object)f.FurnitureData != (Object)null && ((Object)f.FurnitureData).name != null) ? ((Object)f.FurnitureData).name : "");
string text4 = ((Object)((Component)f).gameObject).name.Replace("(Clone)", "").Trim();
return (!string.IsNullOrEmpty(savedFurn.idName) && (text3 == savedFurn.idName || text4.Contains(savedFurn.idName))) || (!string.IsNullOrEmpty(savedFurn.dataName) && text3 == savedFurn.dataName) || (!string.IsNullOrEmpty(savedFurn.objName) && text4.Contains(savedFurn.objName));
});
if ((Object)(object)val != (Object)null)
{
ForceMoveObject(((Component)val).gameObject, savedFurn.position, savedFurn.rotation);
list.Remove(val);
num++;
}
}
List<Mannequin> list2 = Object.FindObjectsByType<Mannequin>((FindObjectsInactive)0, (FindObjectsSortMode)0).ToList();
List<ItemInstance> list3 = Object.FindObjectsByType<ItemInstance>((FindObjectsInactive)0, (FindObjectsSortMode)0).ToList();
FieldInfo field = typeof(Mannequin).GetField("n_poseIndex", BindingFlags.Instance | BindingFlags.NonPublic);
List<Mannequin> list4 = new List<Mannequin>();
List<PooledItem> list5 = new List<PooledItem>();
for (int num3 = 0; num3 < presetData.mannequins.Count && num3 < list2.Count; num3++)
{
Mannequin val2 = list2[num3];
list4.Add(val2);
ForceMoveObject(((Component)val2).gameObject, presetData.mannequins[num3].position, presetData.mannequins[num3].rotation);
for (int num4 = 0; num4 < 10; num4++)
{
InventoryItem itemInSlot = ((InventoryBase)val2).GetItemInSlot(num4);
if (((InventoryItem)(ref itemInSlot)).IsValidItem)
{
ItemData itemData = ((InventoryBase)val2).GetItemData((int)((InventoryItem)(ref itemInSlot)).ItemIndex);
if ((Object)(object)itemData != (Object)null && !string.IsNullOrEmpty(((Object)itemData).name))
{
list5.Add(new PooledItem
{
data = ((InventoryItem)(ref itemInSlot)).InstanceData,
name = ((Object)itemData).name
});
}
}
}
((InventoryBase)val2).ClearInventory();
}
for (int num5 = 0; num5 < presetData.mannequins.Count; num5++)
{
if (num5 >= list4.Count)
{
break;
}
Mannequin matchMan = list4[num5];
SavedMannequin savedMannequin2 = presetData.mannequins[num5];
num2++;
if (field != null && field.GetValue(matchMan) is NetworkVariable<int> val3)
{
val3.Value = savedMannequin2.poseIndex;
}
foreach (SavedMannequinItem savedItem in savedMannequin2.items)
{
bool flag = false;
PooledItem pooledItem = list5.FirstOrDefault((PooledItem p) => p.name == savedItem.itemName);
if (pooledItem != null)
{
int num6 = ((InventoryBase)matchMan).TryAddItemToSlot(pooledItem.data, savedItem.slotIndex);
if (num6 > 0)
{
list5.Remove(pooledItem);
flag = true;
Debug.Log((object)("[FurniturePresets] Equipped " + savedItem.itemName + " from Virtual Pool."));
continue;
}
}
if (!flag)
{
ItemInstance val4 = ((IEnumerable<ItemInstance>)list3).FirstOrDefault((Func<ItemInstance, bool>)delegate(ItemInstance item)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)item == (Object)null)
{
return false;
}
ItemData itemData3 = ((InventoryBase)matchMan).GetItemData((int)item.InstanceData.itemIndex);
return (Object)(object)itemData3 != (Object)null && ((Object)itemData3).name == savedItem.itemName;
});
if ((Object)(object)val4 != (Object)null)
{
int num7 = ((InventoryBase)matchMan).TryAddItemToSlot(val4.InstanceData, savedItem.slotIndex);
if (num7 > 0)
{
val4.Despawn();
list3.Remove(val4);
flag = true;
Debug.Log((object)("[FurniturePresets] Equipped " + savedItem.itemName + " from Floor."));
continue;
}
}
}
if (!flag)
{
foreach (Mannequin item in list2)
{
if (list4.Contains(item))
{
continue;
}
bool flag2 = false;
for (int num8 = 0; num8 < 10; num8++)
{
InventoryItem itemInSlot2 = ((InventoryBase)item).GetItemInSlot(num8);
if (!((InventoryItem)(ref itemInSlot2)).IsValidItem)
{
continue;
}
ItemData itemData2 = ((InventoryBase)item).GetItemData((int)((InventoryItem)(ref itemInSlot2)).ItemIndex);
if ((Object)(object)itemData2 != (Object)null && ((Object)itemData2).name == savedItem.itemName)
{
int num9 = ((InventoryBase)matchMan).TryAddItemToSlot(((InventoryItem)(ref itemInSlot2)).InstanceData, savedItem.slotIndex);
if (num9 > 0)
{
((InventoryBase)item).RemoveFromSlot(num8);
flag2 = true;
Debug.Log((object)("[FurniturePresets] Equipped " + savedItem.itemName + " from OTHER Mannequin."));
break;
}
}
}
if (!flag2)
{
continue;
}
flag = true;
break;
}
}
if (!flag)
{
Debug.LogWarning((object)("[FurniturePresets] Warning: Could not find item '" + savedItem.itemName + "' anywhere!"));
}
}
}
if (list5.Count > 0)
{
Vector3 val5 = ((list4.Count > 0) ? (((Component)list4[0]).transform.position + Vector3.up * 1.5f) : (((Component)localPlayer).transform.position + Vector3.up * 1.5f));
foreach (PooledItem item2 in list5)
{
ItemInstance val6 = ((InventoryBase)localPlayer.Inventory).SpawnItem(item2.name, val5);
if ((Object)(object)val6 != (Object)null)
{
val6.SetInstanceData(item2.data);
Rigidbody component = ((Component)val6).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.linearVelocity = Random.insideUnitSphere * 2f;
}
Debug.Log((object)("[FurniturePresets] Dropped leftover item '" + item2.name + "' onto the floor."));
}
}
}
ShowStatus($"Loaded {num} Furn, {num2} Mannequins!");
Debug.Log((object)("[FurniturePresets] Successfully loaded preset: " + presetName));
}
catch (Exception ex)
{
Debug.LogError((object)("[FurniturePresets] Load error: " + ex.Message + "\n" + ex.StackTrace));
ShowStatus("Load Error! Check Log.");
}
}
private void ForceMoveObject(GameObject obj, Vector3 pos, Quaternion rot)
{
//IL_003e: 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)
//IL_00cb: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)obj == (Object)null)
{
return;
}
Rigidbody component = obj.GetComponent<Rigidbody>();
bool isKinematic = true;
if ((Object)(object)component != (Object)null)
{
isKinematic = component.isKinematic;
component.isKinematic = true;
}
obj.transform.position = pos;
obj.transform.rotation = rot;
NetworkTransform component2 = obj.GetComponent<NetworkTransform>();
if ((Object)(object)component2 != (Object)null)
{
try
{
MethodInfo method = typeof(NetworkTransform).GetMethod("Teleport", BindingFlags.Instance | BindingFlags.Public, null, new Type[3]
{
typeof(Vector3),
typeof(Quaternion),
typeof(Vector3)
}, null);
if (method != null)
{
method.Invoke(component2, new object[3]
{
pos,
rot,
obj.transform.localScale
});
}
}
catch
{
}
}
Physics.SyncTransforms();
if ((Object)(object)component != (Object)null)
{
component.isKinematic = isKinematic;
}
}
private void DrawSpriteRect(Rect rect, Sprite sprite)
{
//IL_007b: 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_0024: 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_0071: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)sprite != (Object)null && (Object)(object)sprite.texture != (Object)null)
{
Rect textureRect = sprite.textureRect;
Texture2D texture = sprite.texture;
Rect val = default(Rect);
((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
GUI.DrawTextureWithTexCoords(rect, (Texture)(object)texture, val);
}
else
{
GUI.Box(rect, "");
}
}
private void OnGUI()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Invalid comparison between Unknown and I4
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_00aa: 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_00b8: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Expected O, but got Unknown
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
//IL_041b: Unknown result type (might be due to invalid IL or missing references)
//IL_0420: Unknown result type (might be due to invalid IL or missing references)
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03d7: Expected O, but got Unknown
//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0530: Unknown result type (might be due to invalid IL or missing references)
//IL_0545: Unknown result type (might be due to invalid IL or missing references)
//IL_054a: Unknown result type (might be due to invalid IL or missing references)
//IL_056f: Unknown result type (might be due to invalid IL or missing references)
//IL_055f: Unknown result type (might be due to invalid IL or missing references)
//IL_057c: Unknown result type (might be due to invalid IL or missing references)
//IL_0595: Unknown result type (might be due to invalid IL or missing references)
if (!isUiOpen)
{
return;
}
Event current = Event.current;
if (isRebinding && current.isKey && (int)current.type == 4)
{
FurniturePresetsPlugin.MenuKey.Value = current.keyCode;
isRebinding = false;
current.Use();
}
GUI.depth = -100;
GUIStyle val = new GUIStyle(GUI.skin.label)
{
fontSize = 26,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
val.normal.textColor = Color.white;
GUIStyle val2 = val;
GUIStyle val3 = new GUIStyle(GUI.skin.label)
{
fontSize = 20,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
val3.normal.textColor = Color.white;
GUIStyle val4 = val3;
float num = 600f;
float num2 = 620f;
Rect val5 = default(Rect);
((Rect)(ref val5))..ctor(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2);
if ((Object)(object)customPanelSprite != (Object)null)
{
DrawSpriteRect(val5, customPanelSprite);
}
else
{
GUI.Box(val5, "");
}
GUILayout.BeginArea(new Rect(((Rect)(ref val5)).x + 60f, ((Rect)(ref val5)).y + 55f, num - 120f, num2 - 80f));
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("Furniture Presets", val2, Array.Empty<GUILayoutOption>());
string text = (isRebinding ? "Press Key..." : $"Key: [{FurniturePresetsPlugin.MenuKey.Value}]");
Rect rect = GUILayoutUtility.GetRect(130f, 35f);
if ((Object)(object)customButtonSprite != (Object)null)
{
DrawSpriteRect(rect, customButtonSprite);
}
else
{
GUI.Box(rect, "");
}
if (GUI.Button(rect, text, val4))
{
isRebinding = true;
}
GUILayout.EndHorizontal();
if (statusTimer > 0f)
{
GUI.color = new Color(0.4f, 1f, 0.4f);
GUILayout.Label(statusMessage, new GUIStyle(GUI.skin.label)
{
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
}, Array.Empty<GUILayoutOption>());
GUI.color = Color.white;
}
else
{
GUILayout.Space(25f);
}
GUILayout.Label("Save Current Layout:", Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
newPresetName = GUILayout.TextField(newPresetName, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(330f),
GUILayout.Height(35f)
});
GUILayout.Space(10f);
Rect rect2 = GUILayoutUtility.GetRect(120f, 35f);
if ((Object)(object)customButtonSprite != (Object)null)
{
DrawSpriteRect(rect2, customButtonSprite);
}
else
{
GUI.Box(rect2, "");
}
if (GUI.Button(rect2, "SAVE", val4) && !string.IsNullOrEmpty(newPresetName))
{
SavePreset(newPresetName);
}
GUILayout.EndHorizontal();
GUILayout.Space(20f);
GUILayout.Label("Load Preset:", Array.Empty<GUILayoutOption>());
if (!cachedCanLoad)
{
GUI.color = new Color(1f, 0.4f, 0.4f);
GUILayout.Label("Blocked: " + cachedLoadReason, new GUIStyle(GUI.skin.label)
{
fontStyle = (FontStyle)1
}, Array.Empty<GUILayoutOption>());
GUI.color = Color.white;
}
GUILayout.Space(10f);
scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(num - 120f),
GUILayout.Height(num2 - 290f)
});
string text2 = null;
if (availablePresets.Count == 0)
{
GUILayout.Label("No presets found.", Array.Empty<GUILayoutOption>());
}
else
{
foreach (string availablePreset in availablePresets)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(availablePreset, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(220f),
GUILayout.Height(40f)
});
GUI.enabled = cachedCanLoad;
Rect rect3 = GUILayoutUtility.GetRect(120f, 40f);
if ((Object)(object)customButtonSprite != (Object)null)
{
DrawSpriteRect(rect3, customButtonSprite);
}
else
{
GUI.Box(rect3, "");
}
if (GUI.Button(rect3, "LOAD", val4))
{
LoadPreset(availablePreset);
}
GUI.enabled = true;
GUILayout.Space(20f);
GUI.color = new Color(1f, 0.4f, 0.4f);
Rect rect4 = GUILayoutUtility.GetRect(40f, 40f);
if ((Object)(object)customButtonSprite != (Object)null)
{
DrawSpriteRect(rect4, customButtonSprite);
}
else
{
GUI.Box(rect4, "");
}
if (GUI.Button(rect4, "X", val4))
{
text2 = availablePreset;
}
GUI.color = Color.white;
GUILayout.EndHorizontal();
GUILayout.Space(10f);
}
}
GUILayout.EndScrollView();
GUILayout.EndArea();
if (text2 != null)
{
File.Delete(Path.Combine(presetsDirectory, text2 + ".txt"));
RefreshPresetsList();
}
}
}
}