Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of YoungVagrant v1.0.2
YoungVagrant.dll
Decompiled 7 months agousing System.Collections.Generic; using System.Diagnostics; 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 EntityStates.JellyfishMonster; using EntityStates.VagrantMonster; using EntityStates.VagrantMonster.Weapon; using R2API; using RoR2; using RoR2.Navigation; 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.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("YoungVagrant")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("YoungVagrant")] [assembly: AssemblyTitle("YoungVagrant")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace YoungVagrant; [BepInPlugin("com.rob.YoungVagrant", "YoungVagrant", "1.0.2")] public class Plugin : BaseUnityPlugin { public const string MODUID = "com.rob.YoungVagrant"; public static GameObject bodyPrefab; public static GameObject masterPrefab; public static CharacterSpawnCard spawnCard; public static List<StageSpawnInfo> StageList = new List<StageSpawnInfo>(); private void Awake() { //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) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Expected O, but got Unknown //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Expected O, but got Unknown //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Expected O, but got Unknown //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Expected O, but got Unknown //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Expected O, but got Unknown //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) bodyPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Vagrant/VagrantBody.prefab").WaitForCompletion(), "RobYoungVagrantBody", true); CharacterBody component = bodyPrefab.GetComponent<CharacterBody>(); component.baseMoveSpeed = 10f; component.baseMaxHealth = 750f; component.levelMaxHealth = 225f; component.baseDamage = 9f; component.levelDamage = 1.875f; component.baseAcceleration = 20f; component.preferredInitialStateType = new SerializableEntityStateType(typeof(SpawnState)); component.hullClassification = (HullClassification)0; component.isChampion = false; component.baseNameToken = "Young Vagrant"; component.subtitleNameToken = ""; SetStateOnHurt val = bodyPrefab.AddComponent<SetStateOnHurt>(); val.canBeFrozen = true; val.canBeHitStunned = true; val.canBeStunned = true; val.hitThreshold = 0.1f; EntityStateMachine[] components = bodyPrefab.GetComponents<EntityStateMachine>(); foreach (EntityStateMachine val2 in components) { if (Object.op_Implicit((Object)(object)val2) && val2.customName == "Body") { val2.initialStateType = new SerializableEntityStateType(typeof(SpawnState)); val.targetStateMachine = val2; } else { val.idleStateMachine = (EntityStateMachine[])(object)new EntityStateMachine[1] { val2 }; } } bodyPrefab.GetComponent<DeathRewards>().logUnlockableDef = null; bodyPrefab.GetComponent<CameraTargetParams>().cameraParams = Addressables.LoadAssetAsync<CharacterCameraParams>((object)"RoR2/Base/Common/ccpStandard.asset").WaitForCompletion(); CapsuleCollider component2 = bodyPrefab.GetComponent<CapsuleCollider>(); component2.radius = 2f; component2.height = 5f; bodyPrefab.transform.Find("Model Base").localScale = Vector3.one * 1.56f; bodyPrefab.transform.Find("Model Base").rotation = Quaternion.Euler(new Vector3(0f, 0f, 180f)); ((Component)component).GetComponent<CharacterDeathBehavior>().deathState = new SerializableEntityStateType(typeof(DeathState)); GenericSkill[] components2 = bodyPrefab.GetComponents<GenericSkill>(); foreach (GenericSkill val3 in components2) { Object.Destroy((Object)(object)val3); } GenericSkill val4 = bodyPrefab.AddComponent<GenericSkill>(); SkillDef val5 = Object.Instantiate<SkillDef>(Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Vagrant/VagrantBodyJellyBarrage.asset").WaitForCompletion()); val5.activationState = new SerializableEntityStateType(typeof(ChargeBarrage)); val5.baseRechargeInterval = 12f; SkillFamily val6 = ScriptableObject.CreateInstance<SkillFamily>(); val6.catalogIndex = 0; Variant[] array = new Variant[1]; Variant val7 = new Variant { skillDef = val5, unlockableDef = null }; ((Variant)(ref val7)).viewableNode = null; array[0] = val7; val6.variants = (Variant[])(object)array; val4._skillFamily = val6; val4.skillName = "Barrage"; val4.hideInCharacterSelect = false; bodyPrefab.GetComponent<SkillLocator>().primary = val4; ContentAddition.AddSkillDef(val5); ContentAddition.AddSkillFamily(val6); ContentAddition.AddBody(bodyPrefab); masterPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/GreaterWisp/GreaterWispMaster.prefab").WaitForCompletion(), "RobYoungVagrantMaster", true); CharacterMaster component3 = masterPrefab.GetComponent<CharacterMaster>(); component3.bodyPrefab = bodyPrefab; ContentAddition.AddMaster(masterPrefab); string value = ((BaseUnityPlugin)this).Config.Bind<string>("Young Vagrant", "Stage List", "blackbeach, blackbeach2, golemplains, golemplains2, foggyswamp, shipgraveyard, rootjungle, artifactworld, itdampcave, itgolemplains, arena", "What stages the monster will show up on. Add a '- loop' after the stagename to make it only spawn after looping. List of stage names can be found at https://github.com/risk-of-thunder/R2Wiki/wiki/Mod-Creation_Developer-Reference_Scene-Names").Value; value = new string((from c in value.ToCharArray() where !char.IsWhiteSpace(c) select c).ToArray()); string[] array2 = value.Split(','); string[] array3 = array2; foreach (string text in array3) { string[] array4 = text.Split('-'); string text2 = array4[0]; int minStages = 0; if (array4.Length > 1) { minStages = 5; } SceneDef val8 = ScriptableObject.CreateInstance<SceneDef>(); val8.baseSceneNameOverride = text2; Helpers.RemoveExistingMonsterFromStage(MonsterNames.GreaterWisp, DirectorAPI.GetStageEnumFromSceneDef(val8), text2); StageList.Add(new StageSpawnInfo(text2, minStages)); } CharacterSpawnCard val9 = ScriptableObject.CreateInstance<CharacterSpawnCard>(); ((Object)val9).name = "cscRobYoungVagrant"; ((SpawnCard)val9).prefab = masterPrefab; ((SpawnCard)val9).sendOverNetwork = true; ((SpawnCard)val9).hullSize = (HullClassification)0; ((SpawnCard)val9).nodeGraphType = (GraphType)1; ((SpawnCard)val9).requiredFlags = (NodeFlags)0; ((SpawnCard)val9).forbiddenFlags = (NodeFlags)2; ((SpawnCard)val9).directorCreditCost = 200; ((SpawnCard)val9).occupyPosition = false; val9.loadout = new SerializableLoadout(); val9.noElites = false; val9.forbiddenAsBoss = false; DirectorCard val10 = new DirectorCard { spawnCard = (SpawnCard)(object)val9, selectionWeight = 1, preventOverhead = false, minimumStageCompletions = 0, spawnDistance = (MonsterSpawnDistance)0 }; DirectorCardHolder val11 = new DirectorCardHolder { Card = val10, MonsterCategory = (MonsterCategory)3 }; DirectorCard card = new DirectorCard { spawnCard = (SpawnCard)(object)val9, selectionWeight = 1, preventOverhead = false, minimumStageCompletions = 5, spawnDistance = (MonsterSpawnDistance)1 }; DirectorCardHolder val12 = new DirectorCardHolder { Card = card, MonsterCategory = (MonsterCategory)3 }; DirectorCardCategorySelection val13 = Addressables.LoadAssetAsync<DirectorCardCategorySelection>((object)"RoR2/Base/MixEnemy/dccsMixEnemy.asset").WaitForCompletion(); val13.AddCard(FindCategoryIndexByName(val13, "Minibosses"), val10); foreach (StageSpawnInfo stage in StageList) { DirectorCardHolder val14 = ((stage.GetMinStages() == 0) ? val11 : val12); Helpers.AddNewMonsterToStage(val14, false, DirectorAPI.ParseInternalStageName(stage.GetStageName()), stage.GetStageName()); } AddMonsterToCardCategory(val10, "Minibosses", (DirectorCardCategorySelection)(object)Addressables.LoadAssetAsync<FamilyDirectorCardCategorySelection>((object)"RoR2/Base/Common/dccsJellyfishFamily.asset").WaitForCompletion()); bool flag = default(bool); ContentAddition.AddEntityState<SpawnState>(ref flag); bool flag2 = default(bool); ContentAddition.AddEntityState<DeathState>(ref flag2); bool flag3 = default(bool); ContentAddition.AddEntityState<ChargeBarrage>(ref flag3); } private void AddMonsterToCardCategory(DirectorCard card, string categoryName, DirectorCardCategorySelection stageCard) { int num = FindCategoryIndexByName(stageCard, categoryName); if (num >= 0) { stageCard.AddCard(num, card); } } public static int FindCategoryIndexByName(DirectorCardCategorySelection dcs, string categoryName) { for (int i = 0; i < dcs.categories.Length; i++) { if (string.CompareOrdinal(dcs.categories[i].name, categoryName) == 0) { return i; } } return -1; } } public class StageSpawnInfo { private string stageName; private int minStages; public StageSpawnInfo(string stageName, int minStages) { this.stageName = stageName; this.minStages = minStages; } public string GetStageName() { return stageName; } public int GetMinStages() { return minStages; } } public class SpawnState : BaseState { public override void OnEnter() { ((BaseState)this).OnEnter(); ((EntityState)this).PlayAnimation("Body", "Spawn", "Spawn.playbackRate", 2f, 0f); Util.PlaySound(SpawnState.spawnSoundString, ((EntityState)this).gameObject); } public override void FixedUpdate() { ((EntityState)this).FixedUpdate(); if (((EntityState)this).fixedAge >= 2f && ((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)7; } } public class DeathState : GenericCharacterDeath { public override void OnEnter() { ((GenericCharacterDeath)this).OnEnter(); ((GenericCharacterDeath)this).DestroyModel(); if (NetworkServer.active) { ((GenericCharacterDeath)this).DestroyBodyAsapServer(); } } public override void CreateDeathEffects() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) ((GenericCharacterDeath)this).CreateDeathEffects(); if (Object.op_Implicit((Object)(object)DeathState.enterEffectPrefab)) { EffectManager.SimpleEffect(DeathState.enterEffectPrefab, ((EntityState)this).transform.position, ((EntityState)this).transform.rotation, false); } } 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)7; } } public class ChargeBarrage : BaseState { private float duration; private float stopwatch; private GameObject chargeEffectInstance; private uint soundID; public override void OnEnter() { //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) ((BaseState)this).OnEnter(); stopwatch = 0f; duration = 1.5f / base.attackSpeedStat; Transform modelTransform = ((EntityState)this).GetModelTransform(); ((EntityState)this).PlayCrossfade("Gesture, Override", "ChargeTrackingBomb", "ChargeTrackingBomb.playbackRate", duration, 0.3f); soundID = Util.PlayAttackSpeedSound(ChargeTrackingBomb.chargingSoundString, ((EntityState)this).gameObject, base.attackSpeedStat); if (Object.op_Implicit((Object)(object)modelTransform)) { ChildLocator component = ((Component)modelTransform).GetComponent<ChildLocator>(); if (Object.op_Implicit((Object)(object)component)) { Transform val = component.FindChild("TrackingBombMuzzle"); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)ChargeTrackingBomb.chargingEffectPrefab)) { chargeEffectInstance = Object.Instantiate<GameObject>(ChargeTrackingBomb.chargingEffectPrefab, val.position, val.rotation); chargeEffectInstance.transform.parent = val; chargeEffectInstance.GetComponent<ScaleParticleSystemDuration>().newDuration = duration; } } } if (NetworkServer.active) { ((EntityState)this).characterBody.AddTimedBuff(Buffs.Slow50, duration); } } public override void OnExit() { ((EntityState)this).OnExit(); AkSoundEngine.StopPlayingID(soundID); if (Object.op_Implicit((Object)(object)chargeEffectInstance)) { EntityState.Destroy((Object)(object)chargeEffectInstance); } } public override void FixedUpdate() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown ((EntityState)this).FixedUpdate(); stopwatch += Time.fixedDeltaTime; if (stopwatch >= duration) { ((EntityState)this).PlayAnimation("Gesture, Override", "FireTrackingBomb", "FireTrackingBomb.playbackRate", FireTrackingBomb.baseDuration, 0f); EffectManager.SimpleMuzzleFlash(FireTrackingBomb.muzzleEffectPrefab, ((EntityState)this).gameObject, "TrackingBombMuzzle", false); if (((EntityState)this).isAuthority) { ((EntityState)this).outer.SetNextState((EntityState)new JellyBarrage()); } } } 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)3; } }