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 BepInEx.Logging;
using HarmonyLib;
using PotionCraft.ManagersSystem.Game;
using PotionCraft.ObjectBased.Shelf;
using PotionCraft.SceneLoader;
using UnityEngine;
[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.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Shelves")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Shelves")]
[assembly: AssemblyTitle("Shelves")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Shelves;
public class Functions
{
private static ManualLogSource Log => Plugin.Log;
public static void CloneShelf(string name, int num, string room, Vector3 pos, bool isHidden = false)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
Shelf val = Resources.FindObjectsOfTypeAll<Shelf>().First();
val = Object.Instantiate<Shelf>(val, GameObject.Find(room).transform);
((Component)val).transform.localPosition = pos;
if (isHidden)
{
GameObject gameObject = ((Component)((Component)val).transform.GetChild(0)).gameObject;
SpriteRenderer component = gameObject.GetComponent<SpriteRenderer>();
((Renderer)component).enabled = false;
}
else
{
GameObject gameObject2 = ((Component)((Component)val).transform.GetChild(0)).gameObject;
SpriteRenderer component2 = gameObject2.GetComponent<SpriteRenderer>();
((Renderer)component2).enabled = true;
}
((Object)val).name = "(Shelf) " + num + " " + name;
Log.LogInfo((object)$"Added shelf {num} in {room}");
}
public static void PlaceShelves()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
Log.LogInfo((object)"Building Shelves...");
int num = 1;
Vector3[] shelvesMeeting = Storage.shelvesMeeting;
foreach (Vector3 pos in shelvesMeeting)
{
CloneShelf("Meeting", num, "Room Meeting", pos);
num++;
}
num = 1;
Vector3[] shelvesBasement = Storage.shelvesBasement;
foreach (Vector3 pos2 in shelvesBasement)
{
CloneShelf("Basement", num, "Room Basement", pos2);
num++;
}
num = 1;
Vector3[] shelvesBedroom = Storage.shelvesBedroom;
foreach (Vector3 pos3 in shelvesBedroom)
{
CloneShelf("Bedroom", num, "Room Bedroom", pos3);
num++;
}
CloneShelf("Desk", 1, "Room Bedroom", Storage.shelvesDesk, isHidden: true);
}
}
internal class GamePatchManager
{
[HarmonyPostfix]
[HarmonyPatch(typeof(GameManager), "Start")]
public static void Start_Postfix()
{
ObjectsLoader.AddLast("SaveLoadManager.SaveNewGameState", (Action)delegate
{
Functions.PlaceShelves();
});
}
}
[BepInPlugin("Shelves", "Shelves", "1.1.1.0")]
public class Plugin : BaseUnityPlugin
{
public static string pluginLoc = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static ManualLogSource Log { get; set; }
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Shelves is loaded!");
Log = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
Harmony.CreateAndPatchAll(typeof(Functions), (string)null);
Harmony.CreateAndPatchAll(typeof(Storage), (string)null);
Harmony.CreateAndPatchAll(typeof(GamePatchManager), (string)null);
}
}
internal class Storage
{
public static string[] rooms = new string[4] { "Room Bedroom", "Room Meeting", "Room Lab", "Room Basement" };
public static Vector3[] shelvesBedroom = (Vector3[])(object)new Vector3[3]
{
new Vector3(-9.1f, 1.6f, 0f),
new Vector3(-9.1f, -0.7f, 0f),
new Vector3(3.6f, 0.5f, 0f)
};
public static Vector3[] shelvesMeeting = (Vector3[])(object)new Vector3[4]
{
new Vector3(-8f, 5f, 0f),
new Vector3(-8f, 1.7f, 0f),
new Vector3(-9.9f, -5.73f, 0f),
new Vector3(-5f, -5.73f, 0f)
};
public static Vector3[] shelvesBasement = (Vector3[])(object)new Vector3[2]
{
new Vector3(3.7f, 3.5f, 0f),
new Vector3(-10.1f, 4.3f, 0f)
};
public static Vector3 shelvesDesk = new Vector3(4.5f, -2.2f, 0f);
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "Shelves";
public const string PLUGIN_NAME = "Shelves";
public const string PLUGIN_VERSION = "1.0.0";
}