using System; 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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ClusterBomb { public enum EBombType { Explosive, Liquid, EMCapsule } public class BombProfile { public ConfigEntry Enabled; public ConfigEntry ClusterWaves; public ConfigEntry RadiusPerWave; public ConfigEntry DelayBetweenWaves; public ConfigEntry DamageMultiplier; public ConfigEntry HeightOffset; public int[] GetWaveCounts() { try { string[] array = ClusterWaves.Value.Split(new char[1] { ',' }); int[] array2 = new int[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = int.Parse(array[i].Trim()); } return array2; } catch { return new int[3] { 5, 10, 15 }; } } } [BepInPlugin("com.lll.clusterbomb", "ClusterBomb", "1.1.0")] public class ClusterBombPlugin : BaseUnityPlugin { public const string GUID = "com.lll.clusterbomb"; public const string NAME = "ClusterBomb"; public const string VERSION = "1.1.0"; public static BombProfile ExplosiveProfile; public static BombProfile LiquidProfile; public static BombProfile EMCapsuleProfile; public static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ExplosiveProfile = CreateProfile("Explosive", "5,10,15", 20f, 10, 1f, 2f); LiquidProfile = CreateProfile("Liquid", "6,6,6,6,6,12,12,12,12,12", 4f, 8, 1f, 2f); EMCapsuleProfile = CreateProfile("EMCapsule", "4", 50f, 12, 1f, 2f); _harmony = new Harmony("com.lll.clusterbomb"); _harmony.PatchAll(typeof(ClusterBombPatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ClusterBomb 1.1.0 loaded!"); } private BombProfile CreateProfile(string section, string defaultWaves, float defaultRadius, int defaultDelay, float defaultDamage, float defaultHeightOffset) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown return new BombProfile { Enabled = ((BaseUnityPlugin)this).Config.Bind(section, "Enabled", true, "Enable cluster effect for " + section + " bombs"), ClusterWaves = ((BaseUnityPlugin)this).Config.Bind(section, "ClusterWaves", defaultWaves, "Comma-separated list of bomb counts per wave (e.g., '5,10,15' means 5 bombs in wave 1, 10 in wave 2, 15 in wave 3)"), RadiusPerWave = ((BaseUnityPlugin)this).Config.Bind(section, "RadiusPerWave", defaultRadius, new ConfigDescription("Radius expansion per wave (wave 1 = 1x, wave 2 = 2x, etc.)", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 100f), Array.Empty())), DelayBetweenWaves = ((BaseUnityPlugin)this).Config.Bind(section, "DelayBetweenWaves", defaultDelay, new ConfigDescription("Delay in game ticks between each wave (60 ticks = 1 second)", (AcceptableValueBase)(object)new AcceptableValueRange(1, 120), Array.Empty())), DamageMultiplier = ((BaseUnityPlugin)this).Config.Bind(section, "DamageMultiplier", defaultDamage, new ConfigDescription("Damage multiplier for cluster bombs (1.0 = same as original)", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 10f), Array.Empty())), HeightOffset = ((BaseUnityPlugin)this).Config.Bind(section, "HeightOffset", defaultHeightOffset, new ConfigDescription("Height offset above ground for cluster explosions", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())) }; } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } public static BombProfile GetProfile(EBombType type) { return type switch { EBombType.Explosive => ExplosiveProfile, EBombType.Liquid => LiquidProfile, EBombType.EMCapsule => EMCapsuleProfile, _ => ExplosiveProfile, }; } } [HarmonyPatch] public static class ClusterBombPatch { private struct PendingClusterWave { public long triggerTick; public Vector3 centerLocalPos; public int nearStarId; public int nearPlanetAstroId; public int protoId; public int abilityValue; public ETargetTypeMask mask; public SkillTarget caster; public float radius; public int bombCount; public float blastRadius0; public float blastRadius1; public float blastFalloff; public int hitIndex; public int bombModelId; public EBombType bombType; public float heightOffset; } private static readonly List pendingWaves = new List(); private static readonly Dictionary<(EBombType, int), Vector3> bombTargetPositions = new Dictionary<(EBombType, int), Vector3>(); [HarmonyPatch(typeof(PlayerAction_Combat), "Bombing")] [HarmonyPostfix] public static void Bombing_Postfix(PlayerAction_Combat __instance) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Invalid comparison between Unknown and I4 //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Invalid comparison between Unknown and I4 //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Invalid comparison between Unknown and I4 //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if (__instance.curvePointsCursor <= 0) { return; } VectorLF3 val = __instance.curvePoints[__instance.curvePointsCursor - 1]; SkillSystem skillSystem = GameMain.data.spaceSector.skillSystem; Player player = ((PlayerAction)__instance).player; Mecha val2 = ((player != null) ? player.mecha : null); if (val2 == null || val2.bombStorage == null || val2.bombStorage.size == 0) { return; } int itemId = val2.bombStorage.grids[0].itemId; if (itemId <= 0) { return; } ItemProto val3 = ((ProtoSet)(object)LDB.items).Select(itemId); if (val3 == null) { return; } int num; EBombType eBombType; if ((int)val3.BombType == 2) { num = skillSystem.explosiveUnitBombs.cursor - 1; eBombType = EBombType.Explosive; } else if ((int)val3.BombType == 1) { num = skillSystem.liquidBombs.cursor - 1; eBombType = EBombType.Liquid; } else { if ((int)val3.BombType != 3) { return; } num = skillSystem.emCapsuleBombs.cursor - 1; eBombType = EBombType.EMCapsule; } if (num > 0) { bombTargetPositions[(eBombType, num)] = VectorLF3.op_Implicit(val); ClusterBombPlugin.Log.LogInfo((object)$"Captured target for {eBombType} bomb {num}: {val}"); } } [HarmonyPatch(typeof(Bomb_Explosive), "TickSkillLogic")] [HarmonyPrefix] public static void Explosive_TickSkillLogic_Prefix(ref Bomb_Explosive __instance, out int __state) { __state = __instance.life; } [HarmonyPatch(typeof(Bomb_Explosive), "TickSkillLogic")] [HarmonyPostfix] public static void Explosive_TickSkillLogic_Postfix(ref Bomb_Explosive __instance, SkillSystem skillSystem, long time, int __state) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) BombProfile explosiveProfile = ClusterBombPlugin.ExplosiveProfile; if (explosiveProfile.Enabled.Value && __state > 0 && __instance.life == 0 && __instance.id > 0) { Vector3 targetPosition = GetTargetPosition(EBombType.Explosive, __instance.id, __instance.nearPlanetAstroId, __instance.uPos, skillSystem); ScheduleClusterWaves(EBombType.Explosive, explosiveProfile, __instance.nearStarId, __instance.nearPlanetAstroId, __instance.protoId, __instance.abilityValue, __instance.mask, __instance.caster, __instance.blastRadius0, __instance.blastRadius1, __instance.blastFalloff, __instance.hitIndex, __instance.bombModelId, time, targetPosition); } } [HarmonyPatch(typeof(Bomb_Liquid), "TickSkillLogic")] [HarmonyPrefix] public static void Liquid_TickSkillLogic_Prefix(ref Bomb_Liquid __instance, out int __state) { __state = __instance.life; } [HarmonyPatch(typeof(Bomb_Liquid), "TickSkillLogic")] [HarmonyPostfix] public static void Liquid_TickSkillLogic_Postfix(ref Bomb_Liquid __instance, SkillSystem skillSystem, long time, int __state) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) BombProfile liquidProfile = ClusterBombPlugin.LiquidProfile; if (liquidProfile.Enabled.Value && __state > 0 && __instance.life == 0 && __instance.id > 0) { Vector3 targetPosition = GetTargetPosition(EBombType.Liquid, __instance.id, __instance.nearPlanetAstroId, __instance.uPos, skillSystem); ScheduleClusterWaves(EBombType.Liquid, liquidProfile, __instance.nearStarId, __instance.nearPlanetAstroId, __instance.protoId, 0, (ETargetTypeMask)0, __instance.caster, __instance.blastRadius0, __instance.blastRadius1, __instance.blastFalloff, __instance.hitIndex, __instance.bombModelId, time, targetPosition); } } [HarmonyPatch(typeof(Bomb_EMCapsule), "TickSkillLogic")] [HarmonyPrefix] public static void EMCapsule_TickSkillLogic_Prefix(ref Bomb_EMCapsule __instance, out int __state) { __state = __instance.life; } [HarmonyPatch(typeof(Bomb_EMCapsule), "TickSkillLogic")] [HarmonyPostfix] public static void EMCapsule_TickSkillLogic_Postfix(ref Bomb_EMCapsule __instance, SkillSystem skillSystem, long time, int __state) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) BombProfile eMCapsuleProfile = ClusterBombPlugin.EMCapsuleProfile; if (eMCapsuleProfile.Enabled.Value && __state > 0 && __instance.life == 0 && __instance.id > 0) { Vector3 targetPosition = GetTargetPosition(EBombType.EMCapsule, __instance.id, __instance.nearPlanetAstroId, __instance.uPos, skillSystem); ScheduleClusterWaves(EBombType.EMCapsule, eMCapsuleProfile, __instance.nearStarId, __instance.nearPlanetAstroId, __instance.protoId, __instance.abilityValue, __instance.mask, __instance.caster, __instance.blastRadius0, __instance.blastRadius1, __instance.blastFalloff, __instance.hitIndex, __instance.bombModelId, time, targetPosition); } } [HarmonyPatch(typeof(SkillSystem), "GameTick")] [HarmonyPostfix] public static void GameTick_Postfix(SkillSystem __instance, long time) { for (int num = pendingWaves.Count - 1; num >= 0; num--) { PendingClusterWave wave = pendingWaves[num]; if (time >= wave.triggerTick) { ClusterBombPlugin.Log.LogInfo((object)$"Spawning {wave.bombType} wave with {wave.bombCount} bombs at radius {wave.radius}"); SpawnClusterBombs(__instance, ref wave); pendingWaves.RemoveAt(num); } } } private static Vector3 GetTargetPosition(EBombType type, int bombId, int astroId, VectorLF3 uPos, SkillSystem skillSystem) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (bombTargetPositions.TryGetValue((type, bombId), out var value)) { ClusterBombPlugin.Log.LogInfo((object)$"{type} bomb {bombId} exploded, using designated target {value}"); bombTargetPositions.Remove((type, bombId)); return value; } VectorLF3 val = default(VectorLF3); skillSystem.sector.InverseTransformToAstro_ref(astroId, ref uPos, ref val); ClusterBombPlugin.Log.LogInfo((object)$"{type} bomb {bombId} exploded, using explosion pos {val}"); return VectorLF3.op_Implicit(val); } private static void ScheduleClusterWaves(EBombType bombType, BombProfile profile, int nearStarId, int nearPlanetAstroId, int protoId, int abilityValue, ETargetTypeMask mask, SkillTarget caster, float blastRadius0, float blastRadius1, float blastFalloff, int hitIndex, int bombModelId, long currentTime, Vector3 targetLocalPos) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) int[] waveCounts = profile.GetWaveCounts(); float value = profile.RadiusPerWave.Value; int value2 = profile.DelayBetweenWaves.Value; float value3 = profile.DamageMultiplier.Value; for (int i = 0; i < waveCounts.Length; i++) { PendingClusterWave pendingClusterWave = default(PendingClusterWave); pendingClusterWave.triggerTick = currentTime + (i + 1) * value2; pendingClusterWave.centerLocalPos = targetLocalPos; pendingClusterWave.nearStarId = nearStarId; pendingClusterWave.nearPlanetAstroId = nearPlanetAstroId; pendingClusterWave.protoId = protoId; pendingClusterWave.abilityValue = (int)((float)abilityValue * value3); pendingClusterWave.mask = mask; pendingClusterWave.caster = caster; pendingClusterWave.radius = value * (float)(i + 1); pendingClusterWave.bombCount = waveCounts[i]; pendingClusterWave.blastRadius0 = blastRadius0; pendingClusterWave.blastRadius1 = blastRadius1; pendingClusterWave.blastFalloff = blastFalloff; pendingClusterWave.hitIndex = hitIndex; pendingClusterWave.bombModelId = bombModelId; pendingClusterWave.bombType = bombType; pendingClusterWave.heightOffset = profile.HeightOffset.Value; PendingClusterWave item = pendingClusterWave; pendingWaves.Add(item); } } private static void SpawnClusterBombs(SkillSystem skillSystem, ref PendingClusterWave wave) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) Random random = new Random((int)(wave.triggerTick & 0x7FFFFFFF)); if (wave.nearPlanetAstroId <= 0) { ClusterBombPlugin.Log.LogWarning((object)"Skipping wave - no planet astro ID"); return; } PlanetData val = GameMain.galaxy.PlanetById(wave.nearPlanetAstroId); if (val == null || val.data == null) { ClusterBombPlugin.Log.LogWarning((object)"Skipping wave - planet data not available"); return; } PlanetRawData data = val.data; Vector3 centerLocalPos = wave.centerLocalPos; for (int i = 0; i < wave.bombCount; i++) { double num = random.NextDouble() * Math.PI * 2.0; double num2 = (double)wave.radius * (0.5 + random.NextDouble() * 0.5); Vector3 normalized = ((Vector3)(ref centerLocalPos)).normalized; Vector3 val2 = Vector3.Cross(normalized, Vector3.up); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; if (((Vector3)(ref normalized2)).magnitude < 0.1f) { val2 = Vector3.Cross(normalized, Vector3.right); normalized2 = ((Vector3)(ref val2)).normalized; } val2 = Vector3.Cross(normalized2, normalized); Vector3 normalized3 = ((Vector3)(ref val2)).normalized; Vector3 val3 = normalized2 * (float)(Math.Cos(num) * num2) + normalized3 * (float)(Math.Sin(num) * num2); Vector3 lPos = centerLocalPos + val3; Vector3 normalized4 = ((Vector3)(ref lPos)).normalized; float num3 = data.QueryHeight(normalized4) + wave.heightOffset; lPos = normalized4 * num3; float height = num3; switch (wave.bombType) { case EBombType.Explosive: SpawnExplosiveEffect(skillSystem, ref wave, height, ref lPos); break; case EBombType.Liquid: SpawnLiquidEffect(skillSystem, ref wave, height, ref lPos); break; case EBombType.EMCapsule: SpawnEMCapsuleEffect(skillSystem, ref wave, height, ref lPos); break; } if (wave.nearPlanetAstroId == skillSystem.localAstroId && wave.hitIndex > 0) { ref ParticleData reference = ref skillSystem.hitEffects[wave.hitIndex].Add(); reference.duration = 120; reference.astroId = wave.nearPlanetAstroId; reference.pos = lPos; reference.size = 1f; } } } private static void SpawnExplosiveEffect(SkillSystem skillSystem, ref PendingClusterWave wave, float height, ref Vector3 lPos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) Bomb_Explosive val = default(Bomb_Explosive); val.nearStarId = wave.nearStarId; val.nearPlanetAstroId = wave.nearPlanetAstroId; val.uPos = VectorLF3.zero; val.mask = wave.mask; val.abilityValue = wave.abilityValue; val.caster = wave.caster; val.protoId = wave.protoId; val.blastRadius0 = wave.blastRadius0; val.blastRadius1 = wave.blastRadius1; val.blastFalloff = wave.blastFalloff; val.hitIndex = wave.hitIndex; Bomb_Explosive val2 = val; SkillTarget val3 = default(SkillTarget); ((Bomb_Explosive)(ref val2)).BombFactoryObjects(skillSystem, height, ref val3, ref lPos); } private static void SpawnLiquidEffect(SkillSystem skillSystem, ref PendingClusterWave wave, float height, ref Vector3 lPos) { } private static void SpawnEMCapsuleEffect(SkillSystem skillSystem, ref PendingClusterWave wave, float height, ref Vector3 lPos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) Bomb_EMCapsule val = default(Bomb_EMCapsule); val.nearStarId = wave.nearStarId; val.nearPlanetAstroId = wave.nearPlanetAstroId; val.uPos = VectorLF3.zero; val.mask = wave.mask; val.abilityValue = wave.abilityValue; val.caster = wave.caster; val.protoId = wave.protoId; val.blastRadius0 = wave.blastRadius0; val.blastRadius1 = wave.blastRadius1; val.blastFalloff = wave.blastFalloff; val.hitIndex = wave.hitIndex; Bomb_EMCapsule val2 = val; ((Bomb_EMCapsule)(ref val2)).BombFactoryObjects(skillSystem, height, ref lPos); } } }