Decompiled source of ObservantCopsMono v1.1.0

Mods/ObservantCops.Mono.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Fxcpds;
using MelonLoader;
using Microsoft.CodeAnalysis;
using ObservantCops;
using ScheduleOne.Core.Items.Framework;
using ScheduleOne.DevUtilities;
using ScheduleOne.ItemFramework;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Vision;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Mod), "Observant Cops", "1.1.0", "Foxcapades", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ObservantCops")]
[assembly: AssemblyConfiguration("Mono")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ff6cf9b12f56eb4361f196da32ffb1ac2acfd6e4")]
[assembly: AssemblyProduct("ObservantCops")]
[assembly: AssemblyTitle("ObservantCops")]
[assembly: AssemblyVersion("1.0.0.0")]
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 Fxcpds
{
	public abstract class FxMod : MelonMod
	{
		private static FxMod? instance;

		protected const string SCENE_NAME_MAIN = "Main";

		public static FxMod Instance => instance;

		public static Instance Logger => ((MelonBase)instance).LoggerInstance;

		protected string Scene { get; private set; } = "";


		public bool InMainScene { get; private set; }

		public override void OnEarlyInitializeMelon()
		{
			instance = this;
		}

		public override void OnInitializeMelon()
		{
			Player.onPlayerSpawned = (Action<Player>)Delegate.Combine(Player.onPlayerSpawned, new Action<Player>(onPlayerSpawned));
		}

		public override void OnSceneWasLoaded(int _, string sceneName)
		{
			Scene = sceneName;
			if (sceneName == "Main")
			{
				InMainScene = true;
				onMainLoaded();
			}
		}

		public override void OnSceneWasInitialized(int _, string sceneName)
		{
			if (sceneName == "Main")
			{
				onMainInitialized();
			}
		}

		public override void OnSceneWasUnloaded(int _, string sceneName)
		{
			if (Scene == sceneName)
			{
				Scene = "";
			}
			if (sceneName == "Main")
			{
				InMainScene = false;
				onMainUnloaded();
			}
		}

		private void onPlayerSpawned(Player player)
		{
			if (player.IsLocalPlayer)
			{
				onLocalPlayerLoaded(player);
			}
		}

		protected virtual void onLocalPlayerLoaded(Player player)
		{
		}

		protected virtual void onMainLoaded()
		{
		}

		protected virtual void onMainInitialized()
		{
		}

		protected virtual void onMainUnloaded()
		{
		}
	}
}
namespace ObservantCops
{
	public class Mod : FxMod
	{
		public const string MOD_NAME = "Observant Cops";

		private const string STATE_LABEL = "holding_suspicious_item";

		protected override void onMainUnloaded()
		{
			teardown();
		}

		protected override void onLocalPlayerLoaded(Player player)
		{
			setupActions();
		}

		private void setupActions()
		{
			PlayerInventory val = PlayerSingleton<PlayerInventory>.Instance;
			if ((Object)(object)val == (Object)null)
			{
				((MelonBase)this).LoggerInstance.Error("inventory was null");
			}
			else
			{
				playerSetup(val);
			}
		}

		private static void onEquippedSlotChanged(int _)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Invalid comparison between Unknown and I4
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Invalid comparison between Unknown and I4
			PlayerInventory obj = PlayerSingleton<PlayerInventory>.Instance;
			ELegalStatus? obj2;
			if (obj == null)
			{
				obj2 = null;
			}
			else
			{
				ItemInstance equippedItem = obj.EquippedItem;
				obj2 = ((equippedItem == null) ? null : ((BaseItemDefinition)(equippedItem.Definition?)).legalStatus);
			}
			ELegalStatus? val = obj2;
			ELegalStatus valueOrDefault = val.GetValueOrDefault();
			Player local = Player.Local;
			if (local.IsInVehicle)
			{
				local.Visibility.RemoveState("holding_suspicious_item", 0f);
			}
			else if ((int)local.CrimeData.CurrentPursuitLevel == 0)
			{
				if ((int)valueOrDefault > 0)
				{
					local.Visibility.ApplyState("holding_suspicious_item", (EVisualState)2, 0f);
				}
				else
				{
					local.Visibility.RemoveState("holding_suspicious_item", 0f);
				}
			}
			else
			{
				local.Visibility.RemoveState("holding_suspicious_item", 4f);
			}
		}

		private static void playerSetup(PlayerInventory inv)
		{
			inv.onEquippedSlotChanged = (Action<int>)Delegate.Combine(inv.onEquippedSlotChanged, new Action<int>(onEquippedSlotChanged));
		}

		private void teardown()
		{
			Player.onLocalPlayerSpawned = (Action)Delegate.Remove(Player.onLocalPlayerSpawned, new Action(setupActions));
			PlayerInventory val = PlayerSingleton<PlayerInventory>.Instance;
			if ((Object)(object)val != (Object)null)
			{
				val.onEquippedSlotChanged = (Action<int>)Delegate.Remove(val.onEquippedSlotChanged, new Action<int>(onEquippedSlotChanged));
			}
		}
	}
}