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 Destructible Environments v1.0.0
EmpressDestruction.dll
Decompiled 4 hours agousing 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 Photon.Pun; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EmpressDestruction")] [assembly: AssemblyTitle("EmpressDestruction")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 Empress.REPO.Destruction { [BepInPlugin("Empress.REPO.Destruction", "Empress REPO Destruction", "1.0.0")] public sealed class EmpressRepoDestructionPlugin : BaseUnityPlugin { internal const string PluginGuid = "Empress.REPO.Destruction"; internal const string PluginName = "Empress REPO Destruction"; internal const string PluginVersion = "1.0.0"; private Harmony _harmony; internal static ManualLogSource Log { get; private set; } internal static ConfigEntry<bool> EnableTrueMeshHoles { get; private set; } internal static ConfigEntry<bool> EnableProxyFracture { get; private set; } internal static ConfigEntry<bool> HostAuthoritativeOnly { get; private set; } internal static ConfigEntry<int> MaxMeshVertices { get; private set; } internal static ConfigEntry<int> MaxCutsPerFrame { get; private set; } internal static ConfigEntry<int> MaxFragmentsPerImpact { get; private set; } internal static ConfigEntry<float> BulletHoleRadius { get; private set; } internal static ConfigEntry<float> BulletEnergy { get; private set; } internal static ConfigEntry<float> BulletEndpointFallbackRadius { get; private set; } internal static ConfigEntry<float> ExplosionRadiusMultiplier { get; private set; } internal static ConfigEntry<float> FractureEnergyThreshold { get; private set; } internal static ConfigEntry<float> LifetimeSeconds { get; private set; } internal static ConfigEntry<int> MaxExplosionTargets { get; private set; } internal static ConfigEntry<bool> BreakStaticMapProps { get; private set; } internal static ConfigEntry<float> StaticMapPropBreakEnergy { get; private set; } internal static ConfigEntry<bool> ReleaseSupportedObjects { get; private set; } internal static ConfigEntry<float> SupportReleaseHeight { get; private set; } internal static ConfigEntry<int> MaxSupportReleaseObjects { get; private set; } private void Awake() { //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; EnableTrueMeshHoles = ((BaseUnityPlugin)this).Config.Bind<bool>("Core", "TrueMeshHoles", true, "Cut real triangle holes in readable runtime mesh instances."); EnableProxyFracture = ((BaseUnityPlugin)this).Config.Bind<bool>("Core", "ProxyFractureForUnreadableMeshes", true, "Create optimized physical fracture chunks when shipped meshes cannot be read."); HostAuthoritativeOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Multiplayer", "HostAuthoritativeOnly", true, "Accept destruction events only from master-authorized game paths."); MaxMeshVertices = ((BaseUnityPlugin)this).Config.Bind<int>("Performance", "MaxMeshVerticesForCutting", 22000, "Meshes above this vertex count use proxy fractures instead of CPU cutting."); MaxCutsPerFrame = ((BaseUnityPlugin)this).Config.Bind<int>("Performance", "MaxCutsPerFrame", 3, "Maximum mesh mutations per frame."); MaxFragmentsPerImpact = ((BaseUnityPlugin)this).Config.Bind<int>("Performance", "MaxFragmentsPerImpact", 14, "Maximum fracture chunks created for one impact."); BulletHoleRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Impacts", "BulletHoleRadius", 0.34f, "World radius for bullet holes."); BulletEnergy = ((BaseUnityPlugin)this).Config.Bind<float>("Impacts", "BulletEnergy", 26f, "Damage energy assigned to bullet impacts."); BulletEndpointFallbackRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Impacts", "BulletEndpointFallbackRadius", 0.55f, "Fallback search radius around bullet hit points."); ExplosionRadiusMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Explosions", "ExplosionRadiusMultiplier", 1.65f, "World destruction radius multiplier for explosion size."); MaxExplosionTargets = ((BaseUnityPlugin)this).Config.Bind<int>("Explosions", "MaxExplosionTargets", 18, "Maximum colliders converted into destruction jobs for one explosion."); FractureEnergyThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Fracture", "FractureEnergyThreshold", 42f, "Energy needed to break an object into fragments."); BreakStaticMapProps = ((BaseUnityPlugin)this).Config.Bind<bool>("Fracture", "BreakStaticMapProps", true, "Disable eligible static map props after spawning debris."); StaticMapPropBreakEnergy = ((BaseUnityPlugin)this).Config.Bind<float>("Fracture", "StaticMapPropBreakEnergy", 30f, "Energy needed to break eligible static map props."); ReleaseSupportedObjects = ((BaseUnityPlugin)this).Config.Bind<bool>("Support", "ReleaseSupportedObjects", true, "Wake or physics-enable small objects resting on destroyed props."); SupportReleaseHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Support", "SupportReleaseHeight", 1.4f, "Vertical scan height above a destroyed prop."); MaxSupportReleaseObjects = ((BaseUnityPlugin)this).Config.Bind<int>("Support", "MaxSupportReleaseObjects", 16, "Maximum objects released by one destroyed support."); LifetimeSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Fracture", "FragmentLifetimeSeconds", 18f, "Seconds before generated chunks fade out."); _harmony = new Harmony("Empress.REPO.Destruction"); _harmony.PatchAll(typeof(EmpressRepoDestructionPlugin).Assembly); SceneManager.sceneLoaded += OnSceneLoaded; EmpressDestructionRuntime.Ensure(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Empress REPO Destruction 1.0.0 loaded"); } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { EmpressDestructionRuntime.ResetSceneState(); EmpressDestructionRuntime.Ensure(); } } internal sealed class EmpressDestructionRuntime : MonoBehaviour { private static readonly string[] AlwaysSkipPathTokens = new string[12] { "canvas", "ui", "player", "enemy", "truck", "start room", "startroom", "start_room", "extraction", "level point", "navmesh", "death pit" }; private static readonly string[] StructuralPathTokens = new string[11] { "wall", "floor", "ceiling", "roof", "ground", "terrain", "module collision", "collision wall", "collision floor", "bounds", "blockout" }; private static EmpressDestructionRuntime? _instance; private readonly Queue<DestructionRequest> _requests = new Queue<DestructionRequest>(); private readonly Dictionary<int, float> _impactCooldown = new Dictionary<int, float>(); private readonly Dictionary<int, EmpressDestructibleSurface> _surfaces = new Dictionary<int, EmpressDestructibleSurface>(); private Material? _voidMaterial; private Material? _chunkMaterial; private int _frameCuts; internal static void Ensure() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { GameObject val = new GameObject("EMPRESS_Destruction_Runtime"); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); _instance = val.AddComponent<EmpressDestructionRuntime>(); } } internal static void ResetSceneState() { if (!((Object)(object)_instance == (Object)null)) { _instance._requests.Clear(); _instance._impactCooldown.Clear(); _instance._surfaces.Clear(); } } internal static void Bullet(Vector3 origin, Vector3 end, float radius, float energy, int seed) { //IL_000a: 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) Ensure(); _instance.QueueRay(origin, end, radius, energy, seed, DestructionKind.Bullet); } internal static void Explosion(Vector3 position, float radius, float energy, int seed) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Ensure(); _instance._requests.Enqueue(new DestructionRequest(position, Vector3.up, radius, energy, seed, DestructionKind.Explosion, null)); } internal static void Pulse(Vector3 position, Vector3 normal, float radius, float energy, int seed) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Ensure(); _instance._requests.Enqueue(new DestructionRequest(position, normal, radius, energy, seed, DestructionKind.Pulse, null)); } internal static void Direct(PhysGrabObject physGrabObject, Vector3 point, Vector3 normal, float radius, float energy, int seed) { //IL_0028: 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) if (Object.op_Implicit((Object)(object)physGrabObject)) { Ensure(); Collider componentInChildren = ((Component)physGrabObject).GetComponentInChildren<Collider>(); if (Object.op_Implicit((Object)(object)componentInChildren)) { _instance._requests.Enqueue(new DestructionRequest(point, normal, radius, energy, seed, DestructionKind.Physics, componentInChildren)); } } } private void QueueRay(Vector3 origin, Vector3 end, float radius, float energy, int seed, DestructionKind kind) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - origin; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.05f) { return; } int mask = LayerMask.GetMask(new string[3] { "Default", "PhysGrabObject", "PhysGrabObjectHinge" }); RaycastHit[] array = Physics.SphereCastAll(origin, Mathf.Min(radius * 0.35f, 0.12f), ((Vector3)(ref val)).normalized, magnitude + 0.05f, mask, (QueryTriggerInteraction)1); if (array.Length == 0) { RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(origin, ((Vector3)(ref val)).normalized, ref val2, magnitude + 0.05f, mask, (QueryTriggerInteraction)1)) { _requests.Enqueue(new DestructionRequest(((RaycastHit)(ref val2)).point, ((RaycastHit)(ref val2)).normal, radius, energy, seed, kind, ((RaycastHit)(ref val2)).collider)); } else { QueueEndpointFallback(end, ((Vector3)(ref val)).normalized, radius, energy, seed, kind, mask); } return; } Array.Sort(array, (RaycastHit left, RaycastHit right) => ((RaycastHit)(ref left)).distance.CompareTo(((RaycastHit)(ref right)).distance)); for (int i = 0; i < array.Length; i++) { Collider collider = ((RaycastHit)(ref array[i])).collider; if (Object.op_Implicit((Object)(object)collider) && IsEligible(collider)) { _requests.Enqueue(new DestructionRequest(((RaycastHit)(ref array[i])).point, ((RaycastHit)(ref array[i])).normal, radius, energy, seed + i, kind, collider)); return; } } QueueEndpointFallback(end, ((Vector3)(ref val)).normalized, radius, energy, seed, kind, mask); } private void QueueEndpointFallback(Vector3 end, Vector3 direction, float radius, float energy, int seed, DestructionKind kind, int mask) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_009b: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(radius, EmpressRepoDestructionPlugin.BulletEndpointFallbackRadius.Value); Collider[] array = Physics.OverlapSphere(end, num, mask, (QueryTriggerInteraction)1); if (array.Length == 0) { return; } Array.Sort(array, delegate(Collider left, Collider right) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = left.bounds; float num2 = Vector3.SqrMagnitude(((Bounds)(ref bounds)).center - end); bounds = right.bounds; return num2.CompareTo(Vector3.SqrMagnitude(((Bounds)(ref bounds)).center - end)); }); foreach (Collider val in array) { if (Object.op_Implicit((Object)(object)val) && IsEligible(val)) { Vector3 val2 = ResolveImpactPoint(val, end); Vector3 val3 = end - val2; Vector3 normal = ((Vector3)(ref val3)).normalized; if (((Vector3)(ref normal)).sqrMagnitude < 0.01f) { normal = -direction; } _requests.Enqueue(new DestructionRequest(val2, normal, radius, energy, seed + ((Object)val).GetInstanceID(), kind, val)); break; } } } private void Update() { _frameCuts = 0; if (_impactCooldown.Count > 0) { List<int> list = new List<int>(_impactCooldown.Keys); for (int i = 0; i < list.Count; i++) { int key = list[i]; float num = _impactCooldown[key] - Time.deltaTime; if (num <= 0f) { _impactCooldown.Remove(key); } else { _impactCooldown[key] = num; } } } int num2 = Mathf.Max(1, EmpressRepoDestructionPlugin.MaxCutsPerFrame.Value); while (_requests.Count > 0 && _frameCuts < num2) { Apply(_requests.Dequeue()); } } private void Apply(DestructionRequest request) { //IL_0049: 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_0069: Unknown result type (might be due to invalid IL or missing references) if (request.Kind == DestructionKind.Explosion || request.Kind == DestructionKind.Pulse) { ApplyExplosion(request); return; } Collider collider = request.Collider; if (!Object.op_Implicit((Object)(object)collider) || !IsEligible(collider)) { return; } GameObject val = ResolveTarget(collider); if (Object.op_Implicit((Object)(object)val)) { int key = HashCode.Combine(((Object)val).GetInstanceID(), Quantize(request.Point.x), Quantize(request.Point.y), Quantize(request.Point.z), request.Kind); if (!_impactCooldown.ContainsKey(key)) { _impactCooldown[key] = ((request.Kind == DestructionKind.Bullet) ? 0.08f : 0.2f); EmpressDestructibleSurface surface = GetSurface(val); surface.ApplyImpact(request, GetVoidMaterial(), GetChunkMaterial()); _frameCuts++; } } } private void ApplyExplosion(DestructionRequest request) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c3: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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) int mask = LayerMask.GetMask(new string[3] { "Default", "PhysGrabObject", "PhysGrabObjectHinge" }); Collider[] array = Physics.OverlapSphere(request.Point, request.Radius, mask, (QueryTriggerInteraction)1); int num = Mathf.Min(array.Length, Mathf.Clamp(EmpressRepoDestructionPlugin.MaxExplosionTargets.Value, 1, 64)); Array.Sort(array, delegate(Collider left, Collider right) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = left.bounds; float num5 = Vector3.SqrMagnitude(((Bounds)(ref bounds)).center - request.Point); bounds = right.bounds; return num5.CompareTo(Vector3.SqrMagnitude(((Bounds)(ref bounds)).center - request.Point)); }); int num2 = 0; for (int i = 0; i < array.Length; i++) { if (num2 >= num) { break; } Collider val = array[i]; if (IsEligible(val)) { Vector3 val2 = ResolveImpactPoint(val, request.Point); Vector3 val3 = val2 - request.Point; Vector3 normal = ((Vector3)(ref val3)).normalized; if (((Vector3)(ref normal)).sqrMagnitude < 0.01f) { normal = Vector3.up; } float num3 = Vector3.Distance(val2, request.Point); float num4 = Mathf.Clamp01(1f - num3 / Mathf.Max(0.1f, request.Radius)); _requests.Enqueue(new DestructionRequest(val2, normal, Mathf.Lerp(0.22f, request.Radius * 0.45f, num4), request.Energy * Mathf.Lerp(0.35f, 1f, num4), request.Seed + ((Object)val).GetInstanceID(), DestructionKind.Physics, val)); num2++; } } } private EmpressDestructibleSurface GetSurface(GameObject target) { int instanceID = ((Object)target).GetInstanceID(); if (_surfaces.TryGetValue(instanceID, out EmpressDestructibleSurface value) && Object.op_Implicit((Object)(object)value)) { return value; } value = target.GetComponent<EmpressDestructibleSurface>(); if (!Object.op_Implicit((Object)(object)value)) { value = target.AddComponent<EmpressDestructibleSurface>(); } _surfaces[instanceID] = value; return value; } private static GameObject ResolveTarget(Collider collider) { PhysGrabObject componentInParent = ((Component)collider).GetComponentInParent<PhysGrabObject>(); if (Object.op_Implicit((Object)(object)componentInParent)) { return ((Component)componentInParent).gameObject; } MeshFilter componentInParent2 = ((Component)collider).GetComponentInParent<MeshFilter>(); if (Object.op_Implicit((Object)(object)componentInParent2)) { return ((Component)componentInParent2).gameObject; } Renderer componentInParent3 = ((Component)collider).GetComponentInParent<Renderer>(); if (Object.op_Implicit((Object)(object)componentInParent3)) { return ((Component)componentInParent3).gameObject; } return ((Component)collider).gameObject; } internal static GameObject ResolveSupportTarget(Collider collider) { return ResolveTarget(collider); } private static bool IsEligible(Collider collider) { if (!Object.op_Implicit((Object)(object)collider) || collider.isTrigger) { return false; } GameObject gameObject = ((Component)collider).gameObject; if (gameObject.CompareTag("Player") || gameObject.CompareTag("Enemy")) { return false; } int layer = gameObject.layer; if (layer == LayerMask.NameToLayer("Player") || layer == LayerMask.NameToLayer("Enemy") || layer == LayerMask.NameToLayer("UI") || layer == LayerMask.NameToLayer("Ignore Raycast")) { return false; } string text = BuildPath(gameObject.transform); for (int i = 0; i < AlwaysSkipPathTokens.Length; i++) { if (text.IndexOf(AlwaysSkipPathTokens[i], StringComparison.OrdinalIgnoreCase) >= 0) { return false; } } return true; } internal static bool IsStaticMapPropBreakable(GameObject gameObject, Bounds bounds) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00ca: 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) if (!EmpressRepoDestructionPlugin.BreakStaticMapProps.Value || !Object.op_Implicit((Object)(object)gameObject) || Object.op_Implicit((Object)(object)gameObject.GetComponentInParent<PhysGrabObject>())) { return false; } string text = BuildPath(gameObject.transform); for (int i = 0; i < AlwaysSkipPathTokens.Length; i++) { if (text.IndexOf(AlwaysSkipPathTokens[i], StringComparison.OrdinalIgnoreCase) >= 0) { return false; } } for (int j = 0; j < StructuralPathTokens.Length; j++) { if (text.IndexOf(StructuralPathTokens[j], StringComparison.OrdinalIgnoreCase) >= 0) { return false; } } Renderer componentInChildren = gameObject.GetComponentInChildren<Renderer>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { return false; } Vector3 size = ((Bounds)(ref bounds)).size; float num = Mathf.Max(size.x, Mathf.Max(size.y, size.z)); float num2 = Mathf.Max(0.001f, Mathf.Min(size.x, Mathf.Min(size.y, size.z))); if (num > 12f || num / num2 > 18f) { return false; } Vector3 extents = ((Bounds)(ref bounds)).extents; return ((Vector3)(ref extents)).magnitude >= 0.08f; } private static Vector3 ResolveImpactPoint(Collider collider, Vector3 source) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) MeshCollider val = (MeshCollider)(object)(((collider is MeshCollider) ? collider : null) ?? null); if (Object.op_Implicit((Object)(object)val) && !val.convex) { Bounds bounds = collider.bounds; return ((Bounds)(ref bounds)).ClosestPoint(source); } return collider.ClosestPoint(source); } private static string BuildPath(Transform transform) { string text = ((Object)transform).name; Transform parent = transform.parent; int num = 0; while (Object.op_Implicit((Object)(object)parent) && num++ < 8) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } private Material GetVoidMaterial() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_voidMaterial)) { return _voidMaterial; } Shader val = Shader.Find("Standard") ?? Shader.Find("Unlit/Color"); _voidMaterial = new Material(val); ((Object)_voidMaterial).name = "EMPRESS_Destruction_Void"; SetMaterialColor(_voidMaterial, new Color(0.015f, 0.012f, 0.01f, 1f)); if (_voidMaterial.HasProperty("_Glossiness")) { _voidMaterial.SetFloat("_Glossiness", 0f); } return _voidMaterial; } private Material GetChunkMaterial() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_chunkMaterial)) { return _chunkMaterial; } Shader val = Shader.Find("Standard") ?? Shader.Find("Diffuse"); _chunkMaterial = new Material(val); ((Object)_chunkMaterial).name = "EMPRESS_Destruction_Fragment"; SetMaterialColor(_chunkMaterial, new Color(0.28f, 0.25f, 0.22f, 1f)); if (_chunkMaterial.HasProperty("_Glossiness")) { _chunkMaterial.SetFloat("_Glossiness", 0.05f); } return _chunkMaterial; } private static int Quantize(float value) { return Mathf.RoundToInt(value * 8f); } internal static bool TryGetMaterialColor(Material material, out Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty("_Color")) { color = material.GetColor("_Color"); return true; } if (material.HasProperty("_BaseColor")) { color = material.GetColor("_BaseColor"); return true; } color = Color.white; return false; } internal static void SetMaterialColor(Material material, Color color) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty("_Color")) { material.SetColor("_Color", color); } else if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", color); } } } internal sealed class EmpressDestructibleSurface : MonoBehaviour { private MeshFilter? _meshFilter; private MeshRenderer? _meshRenderer; private MeshCollider? _meshCollider; private Mesh? _workingMesh; private int _cuts; private float _energy; private float _lastFragmentTime; private bool _broken; private void Awake() { _meshFilter = ((Component)this).GetComponent<MeshFilter>(); _meshRenderer = ((Component)this).GetComponent<MeshRenderer>(); _meshCollider = ((Component)this).GetComponent<MeshCollider>(); } internal void ApplyImpact(DestructionRequest request, Material voidMaterial, Material chunkMaterial) { //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (_broken) { return; } _energy += request.Energy; bool flag = false; if (EmpressRepoDestructionPlugin.EnableTrueMeshHoles.Value) { flag = TryCutMesh(request, voidMaterial); } if (!flag) { PlaceVoidMark(request, voidMaterial); } if (EmpressRepoDestructionPlugin.EnableProxyFracture.Value && ShouldFracture(request)) { SpawnFragments(request, chunkMaterial); Bounds val = ResolveBounds(request.Point); if (ShouldDisableOriginal(request, val)) { ReleaseSupportedObjects(val, request); DisableOriginal(); } } } private bool TryCutMesh(DestructionRequest request, Material voidMaterial) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_010c: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: 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) MeshFilter meshFilter = _meshFilter; MeshRenderer meshRenderer = _meshRenderer; if (!Object.op_Implicit((Object)(object)meshFilter) || !Object.op_Implicit((Object)(object)meshFilter.sharedMesh) || !Object.op_Implicit((Object)(object)meshRenderer)) { return false; } Mesh val = (Mesh)(Object.op_Implicit((Object)(object)_workingMesh) ? ((object)_workingMesh) : ((object)meshFilter.sharedMesh)); if (!val.isReadable || val.vertexCount > EmpressRepoDestructionPlugin.MaxMeshVertices.Value) { return false; } if (!Object.op_Implicit((Object)(object)_workingMesh)) { _workingMesh = Object.Instantiate<Mesh>(val); ((Object)_workingMesh).name = ((Object)val).name + "_EMPRESS_DESTRUCTIBLE"; meshFilter.sharedMesh = _workingMesh; MeshCollider meshCollider = _meshCollider; if (Object.op_Implicit((Object)(object)meshCollider) && (Object)(object)meshCollider.sharedMesh == (Object)(object)val) { meshCollider.sharedMesh = _workingMesh; } } Mesh workingMesh = _workingMesh; Vector3 val2 = ((Component)this).transform.InverseTransformPoint(request.Point); float num = Mathf.Max(0.001f, (Mathf.Abs(((Component)this).transform.lossyScale.x) + Mathf.Abs(((Component)this).transform.lossyScale.y) + Mathf.Abs(((Component)this).transform.lossyScale.z)) / 3f); float num2 = request.Radius / num; float num3 = num2 * num2; int num4 = 0; for (int i = 0; i < workingMesh.subMeshCount; i++) { int[] triangles = workingMesh.GetTriangles(i); List<int> list = new List<int>(triangles.Length); Vector3[] vertices = workingMesh.vertices; for (int j = 0; j < triangles.Length; j += 3) { Vector3 val3 = (vertices[triangles[j]] + vertices[triangles[j + 1]] + vertices[triangles[j + 2]]) * (1f / 3f); Vector3 val4 = val3 - val2; if (((Vector3)(ref val4)).sqrMagnitude <= num3 * RandomizedEdge(request.Seed, j)) { num4++; continue; } list.Add(triangles[j]); list.Add(triangles[j + 1]); list.Add(triangles[j + 2]); } if (num4 > 0) { workingMesh.SetTriangles(list, i, true); } } if (num4 == 0) { return false; } workingMesh.RecalculateBounds(); workingMesh.RecalculateNormals(); MeshCollider meshCollider2 = _meshCollider; if (Object.op_Implicit((Object)(object)meshCollider2)) { meshCollider2.sharedMesh = null; meshCollider2.sharedMesh = workingMesh; } workingMesh.UploadMeshData(false); _cuts++; PlaceVoidMark(request, voidMaterial); return true; } private static float RandomizedEdge(int seed, int index) { int num = seed ^ (index * 73856093); num ^= num << 13; num ^= num >> 17; num ^= num << 5; return Mathf.Lerp(0.72f, 1.25f, (float)(num & 0x3FF) / 1023f); } private void PlaceVoidMark(DestructionRequest request, Material material) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = "EMPRESS_ImpactVoid"; val.transform.position = request.Point + request.Normal * 0.012f; val.transform.rotation = Quaternion.LookRotation(request.Normal); float num = Mathf.Max(0.08f, request.Radius * 1.75f); val.transform.localScale = new Vector3(num, num, 1f); Renderer component = val.GetComponent<Renderer>(); component.sharedMaterial = material; Collider component2 = val.GetComponent<Collider>(); if (Object.op_Implicit((Object)(object)component2)) { Object.Destroy((Object)(object)component2); } val.transform.SetParent(((Component)this).transform, true); Object.Destroy((Object)(object)val, EmpressRepoDestructionPlugin.LifetimeSeconds.Value); } private bool ShouldFracture(DestructionRequest request) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //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) if (Time.time - _lastFragmentTime < 0.12f) { return false; } Bounds bounds = ResolveBounds(request.Point); if (EmpressDestructionRuntime.IsStaticMapPropBreakable(((Component)this).gameObject, bounds)) { if (!(request.Energy >= EmpressRepoDestructionPlugin.StaticMapPropBreakEnergy.Value * 0.45f) && !(_energy >= EmpressRepoDestructionPlugin.StaticMapPropBreakEnergy.Value)) { return _cuts >= 2; } return true; } PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>(); if (!Object.op_Implicit((Object)(object)component) && !(_energy >= EmpressRepoDestructionPlugin.FractureEnergyThreshold.Value)) { return _cuts >= 4; } return true; } private bool ShouldDisableOriginal(DestructionRequest request, Bounds bounds) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!EmpressDestructionRuntime.IsStaticMapPropBreakable(((Component)this).gameObject, bounds)) { return false; } if (!(request.Energy >= EmpressRepoDestructionPlugin.StaticMapPropBreakEnergy.Value * 0.45f)) { return _energy >= EmpressRepoDestructionPlugin.StaticMapPropBreakEnergy.Value; } return true; } private void SpawnFragments(DestructionRequest request, Material fallbackMaterial) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0248: 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) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00bd: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: 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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) _lastFragmentTime = Time.time; Bounds val = ResolveBounds(request.Point); int num = Mathf.Clamp(Mathf.RoundToInt(request.Energy / 7f), 4, EmpressRepoDestructionPlugin.MaxFragmentsPerImpact.Value); Material sharedMaterial = ResolveMaterial(fallbackMaterial); State state = Random.state; Random.InitState(request.Seed); for (int i = 0; i < num; i++) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)((!(Random.value > 0.38f)) ? 1 : 3)); ((Object)val2).name = "EMPRESS_Fragment"; Vector3 val3 = Random.insideUnitSphere * Mathf.Max(0.08f, request.Radius * 0.7f); val2.transform.position = request.Point + request.Normal * 0.08f + val3; val2.transform.rotation = Random.rotation; float num2 = request.Radius * Random.Range(0.18f, 0.42f); Vector3 val4 = ((Bounds)(ref val)).extents; float num3 = Mathf.Clamp(num2, 0.045f, Mathf.Max(0.08f, ((Vector3)(ref val4)).magnitude * 0.18f)); val2.transform.localScale = new Vector3(num3 * Random.Range(0.7f, 1.4f), num3 * Random.Range(0.5f, 1.15f), num3 * Random.Range(0.45f, 1.25f)); Renderer component = val2.GetComponent<Renderer>(); component.sharedMaterial = sharedMaterial; Rigidbody val5 = val2.AddComponent<Rigidbody>(); val5.mass = Mathf.Clamp(num3 * 8f, 0.04f, 2.5f); val5.interpolation = (RigidbodyInterpolation)1; val4 = request.Normal + Random.insideUnitSphere * 0.65f; Vector3 val6 = ((Vector3)(ref val4)).normalized * Mathf.Clamp(request.Energy * 0.06f, 0.8f, 12f); val5.AddForce(val6, (ForceMode)1); val5.AddTorque(Random.insideUnitSphere * Mathf.Clamp(request.Energy * 0.025f, 0.2f, 5f), (ForceMode)1); val2.AddComponent<EmpressFragmentLifetime>().Arm(EmpressRepoDestructionPlugin.LifetimeSeconds.Value); } Random.state = state; } private void DisableOriginal() { _broken = true; Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (Object.op_Implicit((Object)(object)componentsInChildren[i])) { componentsInChildren[i].enabled = false; } } Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Collider>(); for (int j = 0; j < componentsInChildren2.Length; j++) { if (Object.op_Implicit((Object)(object)componentsInChildren2[j])) { componentsInChildren2[j].enabled = false; } } } private void ReleaseSupportedObjects(Bounds destroyedBounds, DestructionRequest request) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0063: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (!EmpressRepoDestructionPlugin.ReleaseSupportedObjects.Value) { return; } float num = Mathf.Clamp(EmpressRepoDestructionPlugin.SupportReleaseHeight.Value, 0.25f, 4f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Bounds)(ref destroyedBounds)).center.x, ((Bounds)(ref destroyedBounds)).max.y + num * 0.5f, ((Bounds)(ref destroyedBounds)).center.z); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Mathf.Max(0.25f, ((Bounds)(ref destroyedBounds)).extents.x + 0.35f), num * 0.5f, Mathf.Max(0.25f, ((Bounds)(ref destroyedBounds)).extents.z + 0.35f)); int mask = LayerMask.GetMask(new string[3] { "Default", "PhysGrabObject", "PhysGrabObjectHinge" }); Collider[] array = Physics.OverlapBox(val, val2, Quaternion.identity, mask, (QueryTriggerInteraction)1); HashSet<int> hashSet = new HashSet<int>(); int num2 = 0; int num3 = Mathf.Clamp(EmpressRepoDestructionPlugin.MaxSupportReleaseObjects.Value, 1, 64); for (int i = 0; i < array.Length; i++) { if (num2 >= num3) { break; } Collider val3 = array[i]; if (!Object.op_Implicit((Object)(object)val3) || ((Component)val3).transform.IsChildOf(((Component)this).transform)) { continue; } GameObject val4 = EmpressDestructionRuntime.ResolveSupportTarget(val3); if (Object.op_Implicit((Object)(object)val4) && !((Object)(object)val4 == (Object)(object)((Component)this).gameObject) && !val4.transform.IsChildOf(((Component)this).transform)) { int instanceID = ((Object)val4).GetInstanceID(); if (hashSet.Add(instanceID) && IsRestingAbove(destroyedBounds, val4) && (WakePhysGrabObject(val4, request) || ConvertStaticSupportToDynamic(val4, request))) { num2++; } } } } private static bool IsRestingAbove(Bounds supportBounds, GameObject target) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00c2: Unknown result type (might be due to invalid IL or missing references) Bounds val = ResolveObjectBounds(target, target.transform.position); if (((Bounds)(ref val)).max.y < ((Bounds)(ref supportBounds)).max.y - 0.05f) { return false; } if (((Bounds)(ref val)).min.y > ((Bounds)(ref supportBounds)).max.y + EmpressRepoDestructionPlugin.SupportReleaseHeight.Value) { return false; } float num = Mathf.Min(((Bounds)(ref supportBounds)).max.x, ((Bounds)(ref val)).max.x) - Mathf.Max(((Bounds)(ref supportBounds)).min.x, ((Bounds)(ref val)).min.x); float num2 = Mathf.Min(((Bounds)(ref supportBounds)).max.z, ((Bounds)(ref val)).max.z) - Mathf.Max(((Bounds)(ref supportBounds)).min.z, ((Bounds)(ref val)).min.z); if (num > 0.02f) { return num2 > 0.02f; } return false; } private static bool WakePhysGrabObject(GameObject target, DestructionRequest request) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_008f: 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) PhysGrabObject componentInParent = target.GetComponentInParent<PhysGrabObject>(); if (!Object.op_Implicit((Object)(object)componentInParent) || !Object.op_Implicit((Object)(object)componentInParent.rb)) { return false; } Rigidbody rb = componentInParent.rb; rb.WakeUp(); if (rb.isKinematic) { rb.isKinematic = false; } Vector3 val = Vector3.down * 0.55f + Random.insideUnitSphere * 0.35f; Vector3 val2 = ((Vector3)(ref val)).normalized * Mathf.Clamp(request.Energy * 0.025f, 0.12f, 2.5f); rb.AddForce(val2, (ForceMode)1); rb.AddTorque(Random.insideUnitSphere * Mathf.Clamp(request.Energy * 0.015f, 0.08f, 1.5f), (ForceMode)1); return true; } private static bool ConvertStaticSupportToDynamic(GameObject target, DestructionRequest request) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0090: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)target.GetComponentInParent<Rigidbody>())) { return false; } Bounds bounds = ResolveObjectBounds(target, target.transform.position); if (!EmpressDestructionRuntime.IsStaticMapPropBreakable(target, bounds)) { return false; } Vector3 val = ((Bounds)(ref bounds)).extents; if (((Vector3)(ref val)).magnitude > 4f) { return false; } PrepareDynamicColliders(target, bounds); Rigidbody val2 = target.AddComponent<Rigidbody>(); val = ((Bounds)(ref bounds)).extents; val2.mass = Mathf.Clamp(((Vector3)(ref val)).magnitude * 2.5f, 0.15f, 12f); val2.interpolation = (RigidbodyInterpolation)1; val2.collisionDetectionMode = (CollisionDetectionMode)0; val2.WakeUp(); val = Vector3.down * 0.65f + Random.insideUnitSphere * 0.45f; Vector3 val3 = ((Vector3)(ref val)).normalized * Mathf.Clamp(request.Energy * 0.018f, 0.1f, 2f); val2.AddForce(val3, (ForceMode)1); val2.AddTorque(Random.insideUnitSphere * Mathf.Clamp(request.Energy * 0.012f, 0.08f, 1.25f), (ForceMode)1); return true; } private static void PrepareDynamicColliders(GameObject target, Bounds bounds) { //IL_0069: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00f2: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Collider[] componentsInChildren = target.GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val)) { MeshCollider val2 = (MeshCollider)(object)(((val is MeshCollider) ? val : null) ?? null); if (Object.op_Implicit((Object)(object)val2) && !val2.convex) { val.enabled = false; } else { flag = true; } } } if (!flag) { BoxCollider val3 = target.AddComponent<BoxCollider>(); Vector3 center = target.transform.InverseTransformPoint(((Bounds)(ref bounds)).center); Vector3 lossyScale = target.transform.lossyScale; val3.center = center; val3.size = new Vector3(((Bounds)(ref bounds)).size.x / Mathf.Max(0.001f, Mathf.Abs(lossyScale.x)), ((Bounds)(ref bounds)).size.y / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y)), ((Bounds)(ref bounds)).size.z / Mathf.Max(0.001f, Mathf.Abs(lossyScale.z))); } } private static Bounds ResolveObjectBounds(GameObject target, Vector3 fallback) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Renderer componentInChildren = target.GetComponentInChildren<Renderer>(); if (Object.op_Implicit((Object)(object)componentInChildren)) { Bounds bounds = componentInChildren.bounds; Renderer[] componentsInChildren = target.GetComponentsInChildren<Renderer>(); for (int i = 1; i < componentsInChildren.Length; i++) { if (Object.op_Implicit((Object)(object)componentsInChildren[i])) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren[i].bounds); } } return bounds; } Collider componentInChildren2 = target.GetComponentInChildren<Collider>(); if (Object.op_Implicit((Object)(object)componentInChildren2)) { return componentInChildren2.bounds; } return new Bounds(fallback, Vector3.one * 0.25f); } private Bounds ResolveBounds(Vector3 point) { //IL_0010: 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) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Renderer componentInChildren = ((Component)this).GetComponentInChildren<Renderer>(); if (Object.op_Implicit((Object)(object)componentInChildren)) { return componentInChildren.bounds; } Collider componentInChildren2 = ((Component)this).GetComponentInChildren<Collider>(); if (Object.op_Implicit((Object)(object)componentInChildren2)) { return componentInChildren2.bounds; } return new Bounds(point, Vector3.one * 0.5f); } private Material ResolveMaterial(Material fallback) { Renderer val = (Renderer)(Object.op_Implicit((Object)(object)_meshRenderer) ? ((object)_meshRenderer) : ((object)((Component)this).GetComponentInChildren<Renderer>())); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.sharedMaterial)) { return val.sharedMaterial; } return fallback; } } internal sealed class EmpressFragmentLifetime : MonoBehaviour { private float _life; private float _fadeStart; private Renderer? _renderer; private Material? _material; private Color _color; internal void Arm(float lifetime) { _life = Mathf.Max(1f, lifetime); _fadeStart = _life * 0.72f; } private void Awake() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown _renderer = ((Component)this).GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)_renderer) && Object.op_Implicit((Object)(object)_renderer.sharedMaterial)) { _material = new Material(_renderer.sharedMaterial); _renderer.sharedMaterial = _material; if (!EmpressDestructionRuntime.TryGetMaterialColor(_material, out _color)) { _material = null; } } } private void Update() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) _life -= Time.deltaTime; if (_life <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Material material = _material; if (Object.op_Implicit((Object)(object)material) && _life < _fadeStart) { Color color = _color; color.a = Mathf.Clamp01(_life / Mathf.Max(0.01f, _fadeStart)); EmpressDestructionRuntime.SetMaterialColor(material, color); } } } internal readonly struct DestructionRequest { internal readonly Vector3 Point; internal readonly Vector3 Normal; internal readonly float Radius; internal readonly float Energy; internal readonly int Seed; internal readonly DestructionKind Kind; internal readonly Collider? Collider; internal DestructionRequest(Vector3 point, Vector3 normal, float radius, float energy, int seed, DestructionKind kind, Collider? collider) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) Point = point; Normal = ((((Vector3)(ref normal)).sqrMagnitude > 0.01f) ? ((Vector3)(ref normal)).normalized : Vector3.up); Radius = Mathf.Max(0.04f, radius); Energy = Mathf.Max(0f, energy); Seed = seed; Kind = kind; Collider = collider; } } internal enum DestructionKind { Bullet, Explosion, Pulse, Physics } [HarmonyPatch] internal static class ItemGunShootBulletRpcPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(ItemGun), "ShootBulletRPC", (Type[])null, (Type[])null); } private static void Postfix(ItemGun __instance, Vector3 _endPosition, bool _hit, PhotonMessageInfo _info = default(PhotonMessageInfo)) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) if (_hit && Authorized(_info) && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.gunMuzzle)) { Vector3 position = __instance.gunMuzzle.position; float x = _endPosition.x; float y = _endPosition.y; float z = _endPosition.z; int seed = HashCode.Combine(((Object)__instance).GetInstanceID(), Quantize(x), Quantize(y), Quantize(z)); EmpressDestructionRuntime.Bullet(position, _endPosition, EmpressRepoDestructionPlugin.BulletHoleRadius.Value, EmpressRepoDestructionPlugin.BulletEnergy.Value, seed); } } private static bool Authorized(PhotonMessageInfo info) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (EmpressRepoDestructionPlugin.HostAuthoritativeOnly.Value) { return SemiFunc.MasterOnlyRPC(info); } return true; } private static int Quantize(float value) { return Mathf.RoundToInt(value * 16f); } } [HarmonyPatch] internal static class EnemyHunterShootRpcPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(EnemyHunter), "ShootRPC", (Type[])null, (Type[])null); } private static void Postfix(EnemyHunter __instance, Vector3 _hitPosition, PhotonMessageInfo _info = default(PhotonMessageInfo)) { //IL_0000: 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_002a: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0063: Unknown result type (might be due to invalid IL or missing references) if (Authorized(_info) && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.gunTipTransform)) { Vector3 position = __instance.gunTipTransform.position; float x = _hitPosition.x; float y = _hitPosition.y; float z = _hitPosition.z; int seed = HashCode.Combine(((Object)__instance).GetInstanceID(), Quantize(x), Quantize(y), Quantize(z)); EmpressDestructionRuntime.Bullet(position, _hitPosition, EmpressRepoDestructionPlugin.BulletHoleRadius.Value * 1.15f, EmpressRepoDestructionPlugin.BulletEnergy.Value * 1.2f, seed); } } private static bool Authorized(PhotonMessageInfo info) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (EmpressRepoDestructionPlugin.HostAuthoritativeOnly.Value) { return SemiFunc.MasterOnlyRPC(info); } return true; } private static int Quantize(float value) { return Mathf.RoundToInt(value * 16f); } } [HarmonyPatch] internal static class ItemGunLaserPatch { private static readonly Dictionary<int, float> NextImpact = new Dictionary<int, float>(); private static MethodBase TargetMethod() { return AccessTools.Method(typeof(ItemGunLaser), "LaserShooting", (Type[])null, (Type[])null); } private static void Postfix(ItemGunLaser __instance) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_008d: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.muzzleTransform) || !Object.op_Implicit((Object)(object)__instance.itemGun)) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!NextImpact.TryGetValue(instanceID, out var value) || !(Time.time < value)) { NextImpact[instanceID] = Time.time + 0.12f; Vector3 position = __instance.muzzleTransform.position; Vector3 end = position + __instance.muzzleTransform.forward * __instance.itemGun.gunRange; RaycastHit val = default(RaycastHit); if (Physics.Raycast(position, __instance.muzzleTransform.forward, ref val, __instance.itemGun.gunRange, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1)) { end = ((RaycastHit)(ref val)).point; } int seed = HashCode.Combine(instanceID, Mathf.RoundToInt(Time.time * 8f)); EmpressDestructionRuntime.Bullet(position, end, EmpressRepoDestructionPlugin.BulletHoleRadius.Value * 0.7f, EmpressRepoDestructionPlugin.BulletEnergy.Value * 0.45f, seed); } } } [HarmonyPatch] internal static class ParticleScriptExplosionSpawnPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(ParticleScriptExplosion), "Spawn", (Type[])null, (Type[])null); } private static void Postfix(Vector3 position, float size, int damage, int enemyDamage, float forceMulti, bool onlyParticleEffect, ParticlePrefabExplosion __result) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) if (!onlyParticleEffect) { float num = (float)Mathf.Max(damage, enemyDamage) * Mathf.Max(0.5f, forceMulti); if (!(num <= 0f) || !(size < 0.2f)) { float radius = Mathf.Max(0.35f, size * EmpressRepoDestructionPlugin.ExplosionRadiusMultiplier.Value); float x = position.x; float y = position.y; float z = position.z; int seed = HashCode.Combine(Quantize(x), Quantize(y), Quantize(z), Quantize(size)); EmpressDestructionRuntime.Explosion(position, radius, Mathf.Max(num, size * 35f), seed); } } } private static int Quantize(float value) { return Mathf.RoundToInt(value * 8f); } } [HarmonyPatch] internal static class HurtColliderPhysObjectHurtPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(HurtCollider), "PhysObjectHurt", (Type[])null, (Type[])null); } private static void Postfix(HurtCollider __instance, PhysGrabObject physGrabObject, BreakImpact impact, float hitForce, bool __result) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected I4, but got Unknown //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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_009b: 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) if (__result && Object.op_Implicit((Object)(object)physGrabObject) && (!EmpressRepoDestructionPlugin.HostAuthoritativeOnly.Value || SemiFunc.IsMasterClientOrSingleplayer())) { float radius = (impact - 1) switch { 2 => 0.55f, 1 => 0.36f, 0 => 0.22f, _ => 0.16f, }; Vector3 centerPoint = physGrabObject.centerPoint; Vector3 val = centerPoint - ((Component)__instance).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; int seed = HashCode.Combine(((Object)physGrabObject).GetInstanceID(), Mathf.RoundToInt(Time.time * 10f)); EmpressDestructionRuntime.Direct(physGrabObject, centerPoint, normalized, radius, Mathf.Max(12f, hitForce * 6f), seed); } } } [HarmonyPatch] internal static class HurtColliderOnEnablePatch { private static readonly Dictionary<int, float> NextPulse = new Dictionary<int, float>(); private static MethodBase TargetMethod() { return AccessTools.Method(typeof(HurtCollider), "OnEnable", (Type[])null, (Type[])null); } private static void Postfix(HurtCollider __instance) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)__instance) || (EmpressRepoDestructionPlugin.HostAuthoritativeOnly.Value && !SemiFunc.IsMasterClientOrSingleplayer())) { return; } float num = Mathf.Max(__instance.physHitForce * 2.5f, (float)Mathf.Max(__instance.playerDamage, __instance.enemyDamage)); if ((int)__instance.physImpact == 3) { num = Mathf.Max(num, 55f); } else if ((int)__instance.physImpact == 2) { num = Mathf.Max(num, 32f); } if (!(num < 24f)) { int instanceID = ((Object)__instance).GetInstanceID(); if (!NextPulse.TryGetValue(instanceID, out var value) || !(Time.time < value)) { NextPulse[instanceID] = Time.time + 0.35f; Collider val = (Object.op_Implicit((Object)(object)__instance.Collider) ? __instance.Collider : ((Component)__instance).GetComponent<Collider>()); Bounds val2 = (Bounds)(Object.op_Implicit((Object)(object)val) ? val.bounds : new Bounds(((Component)__instance).transform.position, Vector3.one)); Vector3 extents = ((Bounds)(ref val2)).extents; float radius = Mathf.Clamp(((Vector3)(ref extents)).magnitude * 1.35f, 0.35f, 3.5f); int seed = HashCode.Combine(instanceID, Mathf.RoundToInt(Time.time * 10f)); EmpressDestructionRuntime.Pulse(((Bounds)(ref val2)).center, ((Component)__instance).transform.forward, radius, num, seed); } } } } }