Decompiled source of Grenade Explode On Impact v1.0.1

plugins/GrenadeExplodeOnImpact.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using SideLoader;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GrenadeExplodeOnImpact;

[BepInPlugin("johbenji.grenadeexplodeonimpact", "Grenade Explode On Impact", "1.0.0")]
public class GrenadeExplodeOnImpactPlugin : BaseUnityPlugin
{
	public const string GUID = "johbenji.grenadeexplodeonimpact";

	public const string NAME = "Grenade Explode On Impact";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	internal void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
	}
}
public class SL_GrenadeExplodeOnImpact : SL_Effect, ICustomModel
{
	public string FXLookupstring;

	public Type SLTemplateModel => typeof(SL_GrenadeExplodeOnImpact);

	public Type GameModel => typeof(GrenadeExplodeOnImpact);

	public override void ApplyToComponent<T>(T component)
	{
		GrenadeExplodeOnImpact grenadeExplodeOnImpact = component as GrenadeExplodeOnImpact;
		grenadeExplodeOnImpact.FXLookupstring = FXLookupstring;
	}

	public override void SerializeEffect<T>(T effect)
	{
		GrenadeExplodeOnImpact grenadeExplodeOnImpact = effect as GrenadeExplodeOnImpact;
		FXLookupstring = grenadeExplodeOnImpact.FXLookupstring;
	}
}
public class GrenadeExplodeOnImpact : Effect
{
	public string FXLookupstring;

	public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		Transform fXTransform = _affectedCharacter.FXTransform;
		GameObject gameObject = ((Component)fXTransform).gameObject;
		List<GameObject> list = new List<GameObject>();
		foreach (Transform item in gameObject.transform)
		{
			Transform val = item;
			if (((Object)((Component)val).gameObject).name.Contains(FXLookupstring))
			{
				list.Add(((Component)val).gameObject);
			}
		}
		if (list.Count > 0)
		{
			foreach (GameObject item2 in list)
			{
				PhysicProjectile component = item2.GetComponent<PhysicProjectile>();
				if ((Object)(object)component != (Object)null && ((Projectile)component).IsFlying && ((Projectile)component).OnlyExplodeOnLayers)
				{
					((Projectile)component).OnlyExplodeOnLayers = false;
				}
			}
			return;
		}
		GrenadeExplodeOnImpactPlugin.Log.LogMessage((object)("No grenade found in characterFXs with the name " + FXLookupstring));
	}
}