Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TwelveShooter v1.0.3
plugins/TwelveShooter/TwelveShooter.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using EntityStates; using On.RoR2; using R2API; using R2API.Utils; using RoR2; using RoR2.Skills; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; [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("TwelveShooter")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TwelveShooter")] [assembly: AssemblyTitle("TwelveShooter")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace TwelveShooter; public static class Assets { public static AssetBundle mainBundle; public const string bundleName = "twelveshooter"; public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(Main.PInfo.Location), "twelveshooter"); public static void Init() { mainBundle = AssetBundle.LoadFromFile(AssetBundlePath); } } public class mandrEnterReload : BaseState { public static string enterSoundString = "Play_bandit2_R_load"; public static float baseDuration = 0f; private float duration => baseDuration / base.attackSpeedStat; public override void OnEnter() { ((BaseState)this).OnEnter(); } public override void FixedUpdate() { ((EntityState)this).FixedUpdate(); if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge > duration) { ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(1) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(3)).transform).gameObject.SetActive(true); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(2) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(3)).transform).gameObject.SetActive(true); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(1) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(4)).transform).gameObject.SetActive(false); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(2) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(4)).transform).gameObject.SetActive(false); int num = (int)Util.PlaySound(enterSoundString, ((EntityState)this).gameObject); if (((EntityState)this).skillLocator.primary.stock < 12) { mandrReload.realDuration = mandrReload.totalDuration / base.attackSpeedStat / (float)(12 - ((EntityState)this).skillLocator.primary.stock); } else { mandrReload.realDuration = 0.01f; } ((EntityState)this).outer.SetNextState((EntityState)(object)new mandrReload()); } } public override InterruptPriority GetMinimumInterruptPriority() { return (InterruptPriority)1; } } [BepInDependency("com.bepis.r2api", "5.0.8")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("TeamCreature.TwelveShooter", "TwelveShooter", "1.0.3")] [R2APISubmoduleDependency(new string[] { "PrefabAPI" })] public class Main : BaseUnityPlugin { private Sprite twelveShooterIcon; private GameObject mandr = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/CommandoBody.prefab").WaitForCompletion(); public static ReloadSkillDef twelveShooterSkillDef = ScriptableObject.CreateInstance<ReloadSkillDef>(); private static BodyIndex mandrBodyIndex; public static PluginInfo PInfo { get; private set; } public void Awake() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown PInfo = ((BaseUnityPlugin)this).Info; Assets.Init(); twelveShooterIcon = Assets.mainBundle.LoadAsset<Sprite>("Assets/Textures/Icons/Skills/TwelveShooter.png"); initializeSkill(); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad)); bool flag = default(bool); ContentAddition.AddEntityState<TwelveShooter>(ref flag); ContentAddition.AddEntityState<mandrReload>(ref flag); ContentAddition.AddEntityState<mandrEnterReload>(ref flag); CharacterModel.Start += new hook_Start(Revolvers.CharacterModel_Start); } private void OnLoad() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) mandrBodyIndex = BodyCatalog.FindBodyIndex("CommandoBody"); } public void initializeSkill() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) ((SkillDef)twelveShooterSkillDef).skillName = "TwelveShooter"; ((Object)twelveShooterSkillDef).name = "TwelveShooter"; ((SkillDef)twelveShooterSkillDef).skillNameToken = "Twelve Shooter"; ((SkillDef)twelveShooterSkillDef).skillDescriptionToken = "Repeatedly shoot an enemy for <style=cIsDamage>200% damage</style>. Has a ammo maximum of <style=cIsDamage>12 bullets</style>"; ((SkillDef)twelveShooterSkillDef).icon = twelveShooterIcon; ((SkillDef)twelveShooterSkillDef).activationState = new SerializableEntityStateType(typeof(TwelveShooter)); ((SkillDef)twelveShooterSkillDef).activationStateMachineName = "Weapon"; ((SkillDef)twelveShooterSkillDef).interruptPriority = (InterruptPriority)0; ((SkillDef)twelveShooterSkillDef).baseMaxStock = 12; ((SkillDef)twelveShooterSkillDef).baseRechargeInterval = 0f; ((SkillDef)twelveShooterSkillDef).rechargeStock = 0; ((SkillDef)twelveShooterSkillDef).requiredStock = 1; ((SkillDef)twelveShooterSkillDef).stockToConsume = 1; ((SkillDef)twelveShooterSkillDef).dontAllowPastMaxStocks = true; ((SkillDef)twelveShooterSkillDef).beginSkillCooldownOnSkillEnd = false; ((SkillDef)twelveShooterSkillDef).canceledFromSprinting = false; ((SkillDef)twelveShooterSkillDef).forceSprintDuringState = false; ((SkillDef)twelveShooterSkillDef).fullRestockOnAssign = true; ((SkillDef)twelveShooterSkillDef).resetCooldownTimerOnUse = false; ((SkillDef)twelveShooterSkillDef).isCombatSkill = true; ((SkillDef)twelveShooterSkillDef).mustKeyPress = false; ((SkillDef)twelveShooterSkillDef).cancelSprintingOnActivation = true; twelveShooterSkillDef.graceDuration = 1f; twelveShooterSkillDef.reloadState = new SerializableEntityStateType(typeof(mandrEnterReload)); twelveShooterSkillDef.reloadInterruptPriority = (InterruptPriority)0; ContentAddition.AddSkillDef((SkillDef)(object)twelveShooterSkillDef); SkillFamily skillFamily = mandr.GetComponent<SkillLocator>().primary.skillFamily; Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1); Variant[] variants = skillFamily.variants; int num = skillFamily.variants.Length - 1; Variant val = new Variant { skillDef = (SkillDef)(object)twelveShooterSkillDef }; ((Variant)(ref val)).viewableNode = new Node(((SkillDef)twelveShooterSkillDef).skillNameToken, false, (Node)null); variants[num] = val; } } public class mandrReload : BaseState { public static float enterSoundPitch; public static float exitSoundPitch; public static string enterSoundString; public static string exitSoundString; public static GameObject mandrReloadEffectPrefab; public static string mandrReloadEffectMuzzleString; public static float realDuration; public static float totalDuration = 0.7f; private static EntityState reloadState; private bool hasGivenStock; public override void OnEnter() { ((BaseState)this).OnEnter(); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(1) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(3)).transform).gameObject.SetActive(true); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(2) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(3)).transform).gameObject.SetActive(true); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(1) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(4)).transform).gameObject.SetActive(false); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(2) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(4)).transform).gameObject.SetActive(false); } public override void FixedUpdate() { ((EntityState)this).FixedUpdate(); if ((double)((EntityState)this).fixedAge >= (double)realDuration / 2.0 && ((EntityState)this).skillLocator.primary.stock < ((EntityState)this).skillLocator.primary.maxStock) { GiveStock(); } if (((EntityState)this).isAuthority && !((double)((EntityState)this).fixedAge < (double)realDuration)) { if (((EntityState)this).skillLocator.primary.stock < ((EntityState)this).skillLocator.primary.maxStock) { reloadState = (EntityState)(object)new mandrReload(); ((EntityState)this).outer.SetNextState(reloadState); return; } ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(1) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(3)).transform).gameObject.SetActive(false); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(2) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(3)).transform).gameObject.SetActive(false); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(1) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(4)).transform).gameObject.SetActive(true); ((Component)((Component)((EntityState)this).modelLocator.modelTransform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(2) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(4)).transform).gameObject.SetActive(true); ((EntityState)this).outer.SetNextStateToMain(); } } public override void OnExit() { ((EntityState)this).OnExit(); } private void GiveStock() { if (!hasGivenStock) { ((EntityState)this).skillLocator.primary.AddOneStock(); hasGivenStock = true; } } public override InterruptPriority GetMinimumInterruptPriority() { return (InterruptPriority)3; } } public class Revolvers { private static Material hatMat = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Bandit2/matBandit2Revolver.mat").WaitForCompletion(); private static GameObject revolver = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Bandit2/mdlBanditRevolver.fbx").WaitForCompletion().gameObject; public GameObject gun1; public GameObject gun2; public static void CharacterModel_Start(orig_Start orig, CharacterModel self) { orig.Invoke(self); ((MonoBehaviour)self).StartCoroutine(Gun(self)); } private static IEnumerator Gun(CharacterModel model) { yield return (object)new WaitForFixedUpdate(); if (Object.op_Implicit((Object)(object)model.body) && ((Object)model.body).name == "CommandoBody(Clone)" && model.body.skillLocator.GetSkill((SkillSlot)0).skillNameToken == "Twelve Shooter") { ((Component)((Component)((Component)model).transform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(1) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(1)).transform).gameObject.SetActive(false); ((Component)((Component)((Component)model).transform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(2) .GetChild(0) .GetChild(0) .GetChild(8) .GetChild(1)).transform).gameObject.SetActive(false); GameObject gun1 = Object.Instantiate<GameObject>(revolver, ((Component)model).transform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(1) .GetChild(0) .GetChild(0) .GetChild(8)); gun1.AddComponent<NetworkIdentity>(); gun1.transform.localScale = new Vector3(1f, 1f, 1f); gun1.transform.localPosition = new Vector3(0.012f, 0.21f, 0f); gun1.transform.localEulerAngles = new Vector3(90f, 90f, 0f); ((Renderer)gun1.GetComponent<MeshRenderer>()).material = hatMat; List<RendererInfo> rendererInfos = model.baseRendererInfos.ToList(); Renderer[] componentsInChildren = gun1.GetComponentsInChildren<Renderer>(); foreach (Renderer renderer in componentsInChildren) { rendererInfos.Add(new RendererInfo { renderer = renderer, defaultMaterial = renderer.sharedMaterial, defaultShadowCastingMode = renderer.shadowCastingMode, hideOnDeath = false, ignoreOverlays = false }); } GameObject gun2 = Object.Instantiate<GameObject>(revolver, ((Component)model).transform.GetChild(0).GetChild(0).GetChild(0) .GetChild(3) .GetChild(0) .GetChild(2) .GetChild(0) .GetChild(0) .GetChild(8)); gun2.AddComponent<NetworkIdentity>(); gun2.transform.localScale = new Vector3(1f, 1f, 1f); gun2.transform.localPosition = new Vector3(-0.022f, 0.21f, 0f); gun2.transform.Rotate(new Vector3(180f, 0f, 90f)); ((Renderer)gun2.GetComponent<MeshRenderer>()).material = hatMat; Renderer[] componentsInChildren2 = gun2.GetComponentsInChildren<Renderer>(); foreach (Renderer renderer2 in componentsInChildren2) { rendererInfos.Add(new RendererInfo { renderer = renderer2, defaultMaterial = renderer2.sharedMaterial, defaultShadowCastingMode = renderer2.shadowCastingMode, hideOnDeath = false, ignoreOverlays = false }); } model.baseRendererInfos = rendererInfos.ToArray(); } } } internal class TwelveShooter : BaseSkillState { public static GameObject muzzleEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Bandit2/MuzzleflashBandit2.prefab").WaitForCompletion(); public static GameObject hitEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/HitsparkCommando.prefab").WaitForCompletion(); public static GameObject tracerEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/TracerCommandoDefault.prefab").WaitForCompletion(); public static float damageCoefficient = 2f; public static float force = 1f; public static float baseDuration = 0.25f; public static string firePistolSoundString = "Play_engi_R_turret_shot"; public static string fireLastShotsSoundString = "Play_bandit2_m1_shotgun"; public static float recoilAmplitude = 3f; public static float spreadBloomValue = 0.6f; private Ray aimRay; private float duration; public override void OnEnter() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) ((BaseState)this).OnEnter(); duration = baseDuration / ((BaseState)this).attackSpeedStat; aimRay = ((BaseState)this).GetAimRay(); ((BaseState)this).StartAimMode(aimRay, duration + 2f, false); if (((BaseSkillState)this).activatorSkillSlot.stock % 2 == 0) { ((EntityState)this).PlayAnimation("Gesture Additive, Left", "FirePistol, Left"); FireBullet("MuzzleLeft"); } else { ((EntityState)this).PlayAnimation("Gesture Additive, Right", "FirePistol, Right"); FireBullet("MuzzleRight"); } } public override void OnExit() { ((EntityState)this).OnExit(); } private void FireBullet(string targetMuzzle) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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) if (((BaseSkillState)this).activatorSkillSlot.stock > 1) { int num = (int)Util.PlaySound(firePistolSoundString, ((EntityState)this).gameObject); } else { int num2 = (int)Util.PlaySound(fireLastShotsSoundString, ((EntityState)this).gameObject); } if (Object.op_Implicit((Object)(object)muzzleEffectPrefab)) { EffectManager.SimpleMuzzleFlash(muzzleEffectPrefab, ((EntityState)this).gameObject, targetMuzzle, false); } ((BaseState)this).AddRecoil(-0.4f * recoilAmplitude, -0.8f * recoilAmplitude, -0.3f * recoilAmplitude, 0.3f * recoilAmplitude); if (((EntityState)this).isAuthority) { new BulletAttack { owner = ((EntityState)this).gameObject, weapon = ((EntityState)this).gameObject, origin = ((Ray)(ref aimRay)).origin, aimVector = ((Ray)(ref aimRay)).direction, minSpread = 0f, maxSpread = ((EntityState)this).characterBody.spreadBloomAngle, damage = damageCoefficient * ((BaseState)this).damageStat, force = force, tracerEffectPrefab = tracerEffectPrefab, muzzleName = targetMuzzle, hitEffectPrefab = hitEffectPrefab, isCrit = Util.CheckRoll(((BaseState)this).critStat, ((EntityState)this).characterBody.master), radius = 0.25f, smartCollision = true, procCoefficient = 1.1f, falloffModel = (FalloffModel)0, _maxDistance = 150f }.Fire(); } ((EntityState)this).characterBody.AddSpreadBloom(spreadBloomValue); } public override void FixedUpdate() { ((EntityState)this).FixedUpdate(); if (!((double)((EntityState)this).fixedAge < (double)duration) && ((EntityState)this).isAuthority) { ((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)1; } }