Decompiled source of CommandoFMJ v1.1.1

CommandoFMJ.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
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 BepInEx;
using BepInEx.Logging;
using EntityStates;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("CommandoFMJ")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CommandoFMJ")]
[assembly: AssemblyTitle("CommandoFMJ")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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;
		}
	}
}
namespace CommandoFMJ
{
	[BepInPlugin("pseudopulse.CommandoFMJ", "CommandoFMJ", "1.0.0")]
	public class CommandoFMJ : BaseUnityPlugin
	{
		public const string PluginGUID = "pseudopulse.CommandoFMJ";

		public const string PluginAuthor = "pseudopulse";

		public const string PluginName = "CommandoFMJ";

		public const string PluginVersion = "1.0.0";

		public static ManualLogSource ModLogger;

		public static float DAMAGE_COEFFICIENT;

		public static float COOLDOWN;

		public static float DURATION;

		public static float KNOCKBACK;

		public static GameObject Tracer;

		public static GameObject HitImpact;

		private static GameObject TracerHolder;

		public static GameObject MuzzleFlash;

		private static string FMJNAME;

		private static string FMJDESC;

		private static FMJContentPack pack;

		public void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			ModLogger = ((BaseUnityPlugin)this).Logger;
			TracerHolder = new GameObject("FMJ Tracer Holder");
			TracerHolder.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)TracerHolder);
			DAMAGE_COEFFICIENT = ((BaseUnityPlugin)this).Config.Bind<float>("FMJ :: Stats", "Damage Coefficient", 7f, "The base damage dealt by this skill.").Value;
			COOLDOWN = ((BaseUnityPlugin)this).Config.Bind<float>("FMJ :: Stats", "Cooldown", 4f, "The base cooldown (in seconds) of this skill.").Value;
			DURATION = ((BaseUnityPlugin)this).Config.Bind<float>("FMJ :: Stats", "Duration", 0.2f, "The base duration of the FMJ state.").Value;
			KNOCKBACK = ((BaseUnityPlugin)this).Config.Bind<float>("FMJ :: Stats", "Knockback Force", 4200f, "The base knockback dealt by this skill.").Value;
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/Railgunner/TracerRailgunLight.prefab").WaitForCompletion();
			Tracer = Object.Instantiate<GameObject>(val, TracerHolder.transform);
			((Object)Tracer).name = "CommandoFMJTracer";
			Transform transform = Tracer.transform;
			transform.localScale *= 2f;
			Tracer.GetComponent<EffectComponent>().applyScale = false;
			HitImpact = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Junk/Commando/FMJImpact.prefab").WaitForCompletion();
			MuzzleFlash = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/MuzzleflashFMJ.prefab").WaitForCompletion();
			Material material = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Commando/matCommandoFMJBullet.mat").WaitForCompletion();
			ParticleSystemRenderer[] components = Tracer.GetComponents<ParticleSystemRenderer>();
			foreach (ParticleSystemRenderer val2 in components)
			{
				((Renderer)val2).material = material;
			}
			FMJContentPack fMJContentPack = new FMJContentPack("FMJCONTENTPACK");
			fMJContentPack.RegisterEntityState<FMJState>();
			fMJContentPack.RegisterGameObject(Tracer);
			SkillDef val3 = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Commando/CommandoBodyFireFMJ.asset").WaitForCompletion();
			val3.activationState = new SerializableEntityStateType(typeof(FMJState));
			val3.baseRechargeInterval = COOLDOWN;
			FMJNAME = "COMMANDOSKILLFMJ_NAME";
			FMJDESC = "COMMANDOSKILLFMJ_DESC";
			val3.skillNameToken = FMJNAME;
			val3.skillDescriptionToken = FMJDESC;
			Language.LoadStrings += new hook_LoadStrings(AddNewText);
		}

		public float d(float f)
		{
			return f * 100f;
		}

		public void AddNewText(orig_LoadStrings orig, Language self)
		{
			orig.Invoke(self);
			if (!self.TokenIsRegistered(FMJNAME))
			{
				self.stringsByToken.Add(FMJNAME, "Full Metal Jacket");
			}
			if (!self.TokenIsRegistered(FMJDESC))
			{
				self.stringsByToken.Add(FMJDESC, $"Fire a <style=cIsUtility>piercing round</style> for <style=cIsDamage>{d(DAMAGE_COEFFICIENT)}% damage</style>, knocking targets back.");
			}
		}
	}
	public class FMJState : BaseSkillState
	{
		public float duration;

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			duration = CommandoFMJ.DURATION / ((BaseState)this).attackSpeedStat;
			FireRound();
		}

		public void FireRound()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			((EntityState)this).PlayAnimation("Gesture, Additive", "FireFMJ", "FireFMJ.playbackRate", duration * 2f);
			((EntityState)this).PlayAnimation("Gesture, Override", "FireFMJ", "FireFMJ.playbackRate", duration * 2f);
			AkSoundEngine.PostEvent(1069717260u, ((EntityState)this).gameObject);
			EffectManager.SimpleMuzzleFlash(CommandoFMJ.MuzzleFlash, ((EntityState)this).gameObject, "MuzzleLeft", false);
			BulletAttack val = new BulletAttack();
			val.damage = ((BaseState)this).damageStat * CommandoFMJ.DAMAGE_COEFFICIENT;
			val.force = CommandoFMJ.KNOCKBACK;
			Ray aimRay = ((EntityState)this).inputBank.GetAimRay();
			val.aimVector = ((Ray)(ref aimRay)).direction;
			val.muzzleName = "MuzzleLeft";
			val.falloffModel = (FalloffModel)0;
			val.tracerEffectPrefab = CommandoFMJ.Tracer;
			val.hitEffectPrefab = CommandoFMJ.HitImpact;
			val.isCrit = ((BaseState)this).RollCrit();
			val.owner = ((EntityState)this).gameObject;
			val.procCoefficient = 1f;
			val.radius = 0.4f;
			val.stopperMask = ((LayerIndex)(ref LayerIndex.world)).mask;
			val.origin = ((EntityState)this).inputBank.aimOrigin;
			val.smartCollision = false;
			val.maxSpread = 0f;
			val.minSpread = 0f;
			val.weapon = ((EntityState)this).gameObject;
			if (((EntityState)this).isAuthority)
			{
				val.Fire();
			}
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return (InterruptPriority)2;
		}
	}
	public class FMJContentPack : IContentPackProvider
	{
		private string _identifier;

		private ContentPack pack = new ContentPack();

		private Assembly assembly;

		public List<Type> entityStates = new List<Type>();

		public List<EffectDef> effectDefs = new List<EffectDef>();

		public string identifier
		{
			get
			{
				return _identifier;
			}
			set
			{
				_identifier = value;
			}
		}

		public FMJContentPack(string identifier)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			this.identifier = identifier;
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)delegate(AddContentPackProviderDelegate addContentPackProvider)
			{
				addContentPackProvider.Invoke((IContentPackProvider)(object)this);
			};
		}

		public void RegisterGameObject(GameObject asset)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)asset.GetComponent<EffectComponent>()))
			{
				EffectDef val = new EffectDef();
				val._prefab = asset;
				val.prefabName = ((Object)asset).name;
				val.prefabEffectComponent = asset.GetComponent<EffectComponent>();
				effectDefs.Add(val);
			}
		}

		public void RegisterEntityState<T>() where T : EntityState
		{
			entityStates.Add(typeof(T));
		}

		public void RegisterEntityState(Type stateType)
		{
			if (!stateType.IsAssignableFrom(typeof(EntityState)))
			{
				throw new Exception("Attempted to register state that wasn't assignable from type EntityState. This isn't allowed");
			}
			entityStates.Add(stateType);
		}

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			pack.entityStateTypes.Add(entityStates.ToArray());
			pack.effectDefs.Add(effectDefs.ToArray());
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			pack.identifier = identifier;
			ContentPack.Copy(pack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
}