Decompiled source of SharedBeds v1.0.0

SharedBeds.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Employees;
using Il2CppScheduleOne.Interaction;
using Il2CppScheduleOne.ObjectScripts;
using Il2CppScheduleOne.Tools;
using MelonLoader;
using Microsoft.CodeAnalysis;
using TestBot;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "Shared Beds", "1.0", "Akermi", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SharedBeds")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SharedBeds")]
[assembly: AssemblyTitle("SharedBeds")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace TestBot
{
	public class Mod : MelonMod
	{
		private Harmony _harmony;

		public override void OnInitializeMelon()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_harmony = new Harmony("multi.bed.compat.mod");
			MultiBedCompatManager.Init(_harmony);
			((MelonBase)this).LoggerInstance.Msg("MultiBedCompat initialized.");
		}
	}
	public static class MultiBedCompatManager
	{
		[HarmonyPatch(typeof(Bed), "SetAssignedEmployee")]
		public static class Patch_Bed_SetAssignedEmployee
		{
			public static bool Prefix(Bed __instance, Employee employee)
			{
				AssignEmployeeToBed(employee, __instance);
				return false;
			}
		}

		[HarmonyPatch(typeof(Bed), "Hovered")]
		public static class Patch_Bed_Hovered
		{
			public static bool Prefix(Bed __instance)
			{
				InteractableObject value = Traverse.Create((object)__instance).Field("intObj").GetValue<InteractableObject>();
				if ((Object)(object)value == (Object)null)
				{
					return true;
				}
				if (Singleton<ManagementClipboard>.Instance.IsEquipped)
				{
					value.SetInteractableState((EInteractableState)2);
					return false;
				}
				List<Employee> employeesForBed = GetEmployeesForBed(__instance);
				value.SetInteractableState((EInteractableState)(employeesForBed.Count > 0));
				return false;
			}
		}

		private static readonly Dictionary<Bed, List<Employee>> BedAssignments = new Dictionary<Bed, List<Employee>>();

		private static readonly HashSet<Bed> DirtyBeds = new HashSet<Bed>();

		public static void Init(Harmony harmony)
		{
			harmony.PatchAll(typeof(MultiBedCompatManager).Assembly);
		}

		public static List<Employee> GetEmployeesForBed(Bed bed)
		{
			if (!BedAssignments.TryGetValue(bed, out List<Employee> value))
			{
				return new List<Employee>();
			}
			return value;
		}

		public static void AssignEmployeeToBed(Employee emp, Bed bed)
		{
			if (!BedAssignments.TryGetValue(bed, out List<Employee> value))
			{
				value = new List<Employee>();
				BedAssignments[bed] = value;
			}
			if (!value.Contains(emp))
			{
				value.Add(emp);
				DirtyBeds.Add(bed);
			}
		}
	}
}