Decompiled source of DMC Nero v1.1.3

DMC_Nero.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
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 Microsoft.CodeAnalysis;
using Photon.Pun;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Raphael")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DMC_Nero")]
[assembly: AssemblyTitle("DMC_Nero")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
public class blue_rose_charge : MonoBehaviour
{
	public bool charged;

	private float ChargedTime;

	public float ChargedRequireTime = 4f;

	public Sound Charged;

	public Transform trigger;

	public ParticleSystem ParticleSystem;

	public ParticleSystem FlashDetect;

	public bool prevToggleState;

	public ItemToggle itemToggle;

	private void Start()
	{
		itemToggle = ((Component)this).GetComponent<ItemToggle>();
		if ((Object)(object)trigger == (Object)null)
		{
			trigger = ((Component)this).transform.Find("Trigger");
		}
		if ((Object)(object)trigger == (Object)null)
		{
			Debug.LogError((object)"trigger 尚未設定,也無法在子物件中找到 Trigger");
		}
	}

	private void Update()
	{
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>();
		if ((Object)(object)component != (Object)null && component.playerGrabbing != null && component.playerGrabbing.Count >= 1 && ChargedTime < ChargedRequireTime + 1f)
		{
			ChargedTime += Time.deltaTime;
		}
		if ((Object)(object)itemToggle != (Object)null && itemToggle.toggleState != prevToggleState)
		{
			ChargedTime = 0f;
			prevToggleState = itemToggle.toggleState;
		}
		if (ChargedTime == ChargedRequireTime && Charged != null && (Object)(object)trigger != (Object)null)
		{
			Charged.Play(trigger.position, 1f, 1f, 1f, 1f);
		}
		if (ChargedTime >= ChargedRequireTime)
		{
			ParticleSystem particleSystem = ParticleSystem;
			if (particleSystem != null)
			{
				particleSystem.Play(false);
			}
			charged = true;
		}
		else
		{
			ParticleSystem particleSystem2 = ParticleSystem;
			if (particleSystem2 != null)
			{
				particleSystem2.Stop(false);
			}
		}
	}
}
public class ExplosionBullet : MonoBehaviour
{
	private ParticleScriptExplosion particleScriptExplosion;

	public Transform explosionPosition;

	private PhotonView photonView;

	public int playerDamage = 0;

	public int enemyDamage = 50;

	public float playerTumbleForce = 30f;

	public float playerTumbleTorque = 50f;

	public GameObject GunChargeDetect;

	public GameObject bullet;

	public ParticleSystem ParticleTest;

	public bool BulletExplode;

	public bool BulletNotExplode;

	private void Start()
	{
		particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
		photonView = ((Component)this).GetComponent<PhotonView>();
		if ((Object)(object)GunChargeDetect == (Object)null)
		{
			Debug.LogError((object)"GunChargeDetect 未指派!");
		}
	}

	private void Update()
	{
		if ((Object)(object)GunChargeDetect != (Object)null)
		{
			blue_rose_charge component = GunChargeDetect.GetComponent<blue_rose_charge>();
			if ((Object)(object)component != (Object)null)
			{
				if (!component.charged)
				{
					if (!BulletExplode)
					{
						BulletNotExplode = true;
					}
				}
				else
				{
					if (!BulletNotExplode)
					{
						BulletExplode = true;
					}
					component.charged = false;
				}
			}
		}
		ItemGunBullet component2 = ((Component)this).GetComponent<ItemGunBullet>();
		if ((Object)(object)component2 != (Object)null && component2.bulletHit && BulletExplode)
		{
			Debug.Log((object)"BulletHit");
			OnHit();
		}
	}

	public void OnHit()
	{
		if (SemiFunc.IsMultiplayer())
		{
			photonView.RPC("ExplosionRPC_BlueRose", (RpcTarget)0, Array.Empty<object>());
		}
		else
		{
			ExplosionRPC_BlueRose();
		}
		BulletNotExplode = true;
		BulletExplode = false;
	}

	[PunRPC]
	public void ExplosionRPC_BlueRose()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)particleScriptExplosion == (Object)null || (Object)(object)explosionPosition == (Object)null)
		{
			Debug.LogError((object)"Explosion 實例化失敗:必要物件未設定");
			return;
		}
		ParticlePrefabExplosion val = particleScriptExplosion.Spawn(explosionPosition.position, 0.5f, 0, 250, 1f, false, false, 1f);
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogError((object)"Explosion Spawn 回傳 null!");
			return;
		}
		val.SkipHurtColliderSetup = true;
		val.HurtCollider.playerDamage = playerDamage;
		val.HurtCollider.enemyDamage = enemyDamage;
		val.HurtCollider.physImpact = (BreakImpact)3;
		val.HurtCollider.physHingeDestroy = true;
		val.HurtCollider.playerTumbleForce = playerTumbleForce;
		val.HurtCollider.playerTumbleTorque = playerTumbleTorque;
	}
}
public class EX_mode_charge : MonoBehaviour
{
	private ParticleScriptExplosion particleScriptExplosion;

	public Transform explosionPosition;

	private PhotonView photonView;

	private bool prevToggleState;

	public int Exceed;

	public Sound ChargeFail;

	public Sound ChargeSuccess;

	public GameObject triggerPrefab;

	public Transform trigger;

	private ItemToggle itemToggle;

	private float ChargeCooldownTimer;

	public float ChargeCooldown = 0.1f;

	public int chance = 10;

	public int playerDamage = 0;

	public int enemyDamage = 50;

	public float playerTumbleForce = 30f;

	public float playerTumbleTorque = 50f;

	public ParticleSystem fireParticleSystem;

	public ParticleSystem fireParticleSystem2;

	public ParticleSystem fireParticleSystem3;

	private void Start()
	{
		itemToggle = ((Component)this).GetComponent<ItemToggle>();
		particleScriptExplosion = ((Component)this).GetComponent<ParticleScriptExplosion>();
		explosionPosition = ((Component)this).transform.Find("Explosion Position");
		photonView = ((Component)this).GetComponent<PhotonView>();
		if ((Object)(object)itemToggle == (Object)null)
		{
			Debug.LogError((object)"ItemToggle 未掛載!");
		}
		if ((Object)(object)trigger == (Object)null)
		{
			trigger = ((Component)this).transform.Find("Trigger");
		}
		if ((Object)(object)trigger == (Object)null)
		{
			Debug.LogError((object)"Trigger 尚未指派!");
		}
	}

	private void Update()
	{
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)itemToggle != (Object)null && itemToggle.toggleState != prevToggleState)
		{
			ChargeCooldownTimer = ChargeCooldown;
			if (Random.Range(0, chance) == 0 && Exceed < 3)
			{
				Exceed++;
				Sound chargeSuccess = ChargeSuccess;
				if (chargeSuccess != null)
				{
					chargeSuccess.Play(trigger.position, 1f, 1f, 1f, 1f);
				}
			}
			else
			{
				Sound chargeFail = ChargeFail;
				if (chargeFail != null)
				{
					chargeFail.Play(trigger.position, 1f, 1f, 1f, 1f);
				}
			}
			if (Exceed == 3)
			{
				Sound chargeSuccess2 = ChargeSuccess;
				if (chargeSuccess2 != null)
				{
					chargeSuccess2.Play(trigger.position, 1f, 1f, 1f, 1f);
				}
			}
			prevToggleState = itemToggle.toggleState;
		}
		if (Exceed >= 1)
		{
			ParticleSystem obj = fireParticleSystem;
			if (obj != null)
			{
				obj.Play(false);
			}
		}
		else
		{
			ParticleSystem obj2 = fireParticleSystem;
			if (obj2 != null)
			{
				obj2.Stop(false);
			}
		}
		if (Exceed >= 2)
		{
			ParticleSystem obj3 = fireParticleSystem2;
			if (obj3 != null)
			{
				obj3.Play(false);
			}
		}
		else
		{
			ParticleSystem obj4 = fireParticleSystem2;
			if (obj4 != null)
			{
				obj4.Stop(false);
			}
		}
		if (Exceed >= 3)
		{
			ParticleSystem obj5 = fireParticleSystem3;
			if (obj5 != null)
			{
				obj5.Play(false);
			}
		}
		else
		{
			ParticleSystem obj6 = fireParticleSystem3;
			if (obj6 != null)
			{
				obj6.Stop(false);
			}
		}
		ItemMelee component = ((Component)this).GetComponent<ItemMelee>();
		if ((Object)(object)component != (Object)null && (component.particleSystem.isPlaying || component.particleSystemGroundHit.isPlaying))
		{
			OnHit();
		}
	}

	public void OnHit()
	{
		if (SemiFunc.IsMasterClientOrSingleplayer() && Exceed >= 1)
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("ExplosionRPC_RedQueen", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				ExplosionRPC_RedQueen();
			}
			Exceed = 0;
		}
	}

	[PunRPC]
	public void ExplosionRPC_RedQueen()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)particleScriptExplosion == (Object)null || (Object)(object)explosionPosition == (Object)null)
		{
			Debug.LogError((object)"爆炸生成失敗:必要參考為 null!");
			return;
		}
		ParticlePrefabExplosion val = particleScriptExplosion.Spawn(explosionPosition.position, 0.5f, 0, 250, 1f, false, false, 1f);
		if (!((Object)(object)val == (Object)null))
		{
			val.SkipHurtColliderSetup = true;
			val.HurtCollider.playerDamage = playerDamage;
			val.HurtCollider.enemyDamage = enemyDamage * Exceed;
			val.HurtCollider.physImpact = (BreakImpact)3;
			val.HurtCollider.physHingeDestroy = true;
			val.HurtCollider.playerTumbleForce = playerTumbleForce;
			val.HurtCollider.playerTumbleTorque = playerTumbleTorque;
		}
	}
}
namespace DMC_Nero
{
	[BepInPlugin("Raphael.DMC_Nero", "DMC_Nero", "1.0")]
	public class DMC_Nero : BaseUnityPlugin
	{
		internal static DMC_Nero Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		internal EX_mode_charge? mycustomscriptInstance { get; private set; }

		internal blue_rose_charge? mycustomscriptInstance1 { get; private set; }

		internal ExplosionBullet? mycustomscriptInstance2 { get; private set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			mycustomscriptInstance = ((Component)this).gameObject.AddComponent<EX_mode_charge>();
			mycustomscriptInstance1 = ((Component)this).gameObject.AddComponent<blue_rose_charge>();
			mycustomscriptInstance2 = ((Component)this).gameObject.AddComponent<ExplosionBullet>();
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: 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_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
	[HarmonyPatch(typeof(PlayerController))]
	internal static class ExamplePlayerControllerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void Start_Prefix(PlayerController __instance)
		{
			DMC_Nero.Logger.LogDebug((object)$"{__instance} Start Prefix");
		}

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Postfix(PlayerController __instance)
		{
			DMC_Nero.Logger.LogDebug((object)$"{__instance} Start Postfix");
		}
	}
}