Decompiled source of RobeCalling v1.0.5

RobeCalling.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Vippy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+470709163a232d905bc3ebf0ba6ede88d8eba76e")]
[assembly: AssemblyProduct("RobeCalling")]
[assembly: AssemblyTitle("RobeCalling")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
	[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 RobeCalling
{
	internal static class BuildInfo
	{
		public const string Version = "1.0.5";
	}
	[BepInPlugin("Vippy.RobeCalling", "RobeCalling", "1.0.5")]
	public class Plugin : BaseUnityPlugin
	{
		internal static AudioClip? Ringtone;

		internal static Texture2D? PhoneScreen;

		private void Awake()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "RobeCalling.bundle"));
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"RobeCalling.bundle is missing next to RobeCalling.dll, the phone keeps its stock ringtone");
				return;
			}
			Ringtone = val.LoadAsset<AudioClip>("phone ringtone_robe");
			PhoneScreen = val.LoadAsset<Texture2D>("arctic small valuables_DefaultMaterial_Emissive_Robe");
			if ((Object)(object)Ringtone == (Object)null || (Object)(object)PhoneScreen == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"RobeCalling.bundle loaded but an asset is missing (ringtone={(Object)(object)Ringtone != (Object)null}, screen={(Object)(object)PhoneScreen != (Object)null})");
			}
			new Harmony("Vippy.RobeCalling").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"RobeCalling v1.0.5 loaded");
		}
	}
}
namespace RobeCalling.Patches
{
	[HarmonyPatch(typeof(PhoneValuable), "Start")]
	internal static class PhoneValuablePatch
	{
		private static void Postfix(PhoneValuable __instance)
		{
			if ((Object)(object)Plugin.Ringtone != (Object)null && __instance.ringTone != null)
			{
				__instance.ringTone.Sounds = (AudioClip[])(object)new AudioClip[1] { Plugin.Ringtone };
				__instance.ringTone.StartTimeOverride = 0f;
			}
			if ((Object)(object)Plugin.PhoneScreen != (Object)null)
			{
				Material material = ((Renderer)__instance.meshRenderer).material;
				if (material.HasProperty("_EmissionMap"))
				{
					material.SetTexture("_EmissionMap", (Texture)(object)Plugin.PhoneScreen);
				}
			}
		}
	}
}