using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using FMOD;
using FMODUnity;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("EmergencyDoorOverride")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Doors stay sealed on power loss and can be permanently blown off with E")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmergencyDoorOverride")]
[assembly: AssemblyTitle("EmergencyDoorOverride")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 EmergencyDoorOverride
{
[BepInPlugin("com.wyatt.emergencydooroverride", "Emergency Door Override", "1.0.0")]
public class Plugin : BasePlugin
{
internal static ManualLogSource ModLog;
public override void Load()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
ModLog = ((BasePlugin)this).Log;
ClassInjector.RegisterTypeInIl2Cpp<DoorOverrideUpdater>();
GameObject val = new GameObject("EmergencyDoorOverrideUpdater");
Object.DontDestroyOnLoad((Object)(object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<DoorOverrideUpdater>();
((BasePlugin)this).Log.LogInfo((object)"Emergency Door Override loaded!");
}
}
public class DoorOverrideUpdater : MonoBehaviour
{
private struct BlownDoorState
{
public float OpenTarget;
public float BlownTime;
}
private class LaunchedDebrisItem
{
public Entity VisualEntity;
public float3 Velocity;
public float3 AngularVelocity;
public float SpawnTime;
public int Bounces;
public bool Settled;
}
private readonly Dictionary<(int Index, int Version), BlownDoorState> _blownDoors = new Dictionary<(int, int), BlownDoorState>();
private readonly List<LaunchedDebrisItem> _launchedDebris = new List<LaunchedDebrisItem>();
private EntityQuery _activeDoorQuery;
private EntityQuery _playerQuery;
private EntityQuery _physicsWorldQuery;
private bool _queriesInitialized;
private bool _wasInBuildMode;
private float _nextBuildCheckTime;
private bool _cachedBuildMode;
private Sound _proceduralBangSound;
private IntPtr _proceduralBangPtr = IntPtr.Zero;
private bool _hasProceduralBang;
public void Update()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
if (defaultGameObjectInjectionWorld != null && defaultGameObjectInjectionWorld.IsCreated)
{
StepLaunchedDebris(defaultGameObjectInjectionWorld.EntityManager, Time.deltaTime);
}
ProcessDoors(checkInput: true);
}
public void LateUpdate()
{
ProcessDoors(checkInput: false);
}
public void OnDestroy()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (_hasProceduralBang)
{
try
{
((Sound)(ref _proceduralBangSound)).release();
}
catch
{
}
_hasProceduralBang = false;
}
if (_proceduralBangPtr != IntPtr.Zero)
{
Marshal.FreeHGlobal(_proceduralBangPtr);
_proceduralBangPtr = IntPtr.Zero;
}
}
private bool CheckBuildModeActive()
{
if (Time.unscaledTime < _nextBuildCheckTime)
{
return _cachedBuildMode;
}
_nextBuildCheckTime = Time.unscaledTime + 0.1f;
GameObject val = GameObject.Find("Canvas/Hand Components List");
if ((Object)(object)val != (Object)null && val.activeInHierarchy)
{
_cachedBuildMode = true;
return true;
}
GameObject val2 = GameObject.Find("Canvas/Garage Mouse Over Part Info");
if ((Object)(object)val2 != (Object)null && val2.activeInHierarchy)
{
_cachedBuildMode = true;
return true;
}
_cachedBuildMode = false;
return false;
}
private void CleanupDebris(EntityManager em)
{
//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_0028: 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)
for (int i = 0; i < _launchedDebris.Count; i++)
{
LaunchedDebrisItem launchedDebrisItem = _launchedDebris[i];
if (launchedDebrisItem.VisualEntity != Entity.Null && ((EntityManager)(ref em)).Exists(launchedDebrisItem.VisualEntity))
{
((EntityManager)(ref em)).DestroyEntity(launchedDebrisItem.VisualEntity);
}
}
_launchedDebris.Clear();
}
private void StepLaunchedDebris(EntityManager em, float dt)
{
//IL_0092: 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_00a7: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: 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)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: 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_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: 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_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_0382: Unknown result type (might be due to invalid IL or missing references)
//IL_0386: Unknown result type (might be due to invalid IL or missing references)
//IL_0388: Unknown result type (might be due to invalid IL or missing references)
//IL_038f: Unknown result type (might be due to invalid IL or missing references)
//IL_0391: Unknown result type (might be due to invalid IL or missing references)
//IL_0393: Unknown result type (might be due to invalid IL or missing references)
//IL_0398: Unknown result type (might be due to invalid IL or missing references)
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: 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_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: 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_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
if (_launchedDebris.Count == 0 || dt <= 0f)
{
return;
}
dt = math.min(dt, 0.05f);
bool flag = false;
CollisionWorld val = null;
if (_queriesInitialized && !((EntityQuery)(ref _physicsWorldQuery)).IsEmpty)
{
PhysicsWorldSingleton singleton = ((EntityQuery)(ref _physicsWorldQuery)).GetSingleton<PhysicsWorldSingleton>();
val = singleton.CollisionWorld;
flag = true;
}
RaycastHit val6 = default(RaycastHit);
for (int num = _launchedDebris.Count - 1; num >= 0; num--)
{
LaunchedDebrisItem launchedDebrisItem = _launchedDebris[num];
if (launchedDebrisItem.VisualEntity == Entity.Null || !((EntityManager)(ref em)).Exists(launchedDebrisItem.VisualEntity))
{
_launchedDebris.RemoveAt(num);
}
else if (!launchedDebrisItem.Settled)
{
LocalTransform componentData = ((EntityManager)(ref em)).GetComponentData<LocalTransform>(launchedDebrisItem.VisualEntity);
float3 position = componentData.Position;
launchedDebrisItem.Velocity += new float3(0f, -18f, 0f) * dt;
launchedDebrisItem.Velocity *= math.max(0f, 1f - 0.12f * dt);
float3 val2 = position + launchedDebrisItem.Velocity * dt;
float num2 = Time.time - launchedDebrisItem.SpawnTime;
if (flag && num2 > 0.08f)
{
float3 val3 = val2 - position;
float num3 = math.length(val3);
if (num3 > 0.0005f)
{
RaycastInput val4 = default(RaycastInput);
((RaycastInput)(ref val4)).Start = position + new float3(0f, 0.08f, 0f);
((RaycastInput)(ref val4)).End = val2 - new float3(0f, 0.08f, 0f);
val4.Filter = CollisionFilter.Default;
RaycastInput val5 = val4;
if (val.CastRay(val5, ref val6))
{
float3 val7 = math.normalizesafe(((RaycastHit)(ref val6)).SurfaceNormal, new float3(0f, 1f, 0f));
val2 = ((RaycastHit)(ref val6)).Position + val7 * 0.1f;
float num4 = math.dot(launchedDebrisItem.Velocity, val7);
if (num4 < 0f)
{
float num5 = 0.42f;
launchedDebrisItem.Velocity -= (1f + num5) * num4 * val7;
launchedDebrisItem.Velocity *= 0.78f;
launchedDebrisItem.AngularVelocity *= 0.65f;
launchedDebrisItem.Bounces++;
if (launchedDebrisItem.Bounces >= 4 && math.lengthsq(launchedDebrisItem.Velocity) < 0.45f)
{
launchedDebrisItem.Velocity = float3.zero;
launchedDebrisItem.AngularVelocity = float3.zero;
launchedDebrisItem.Settled = true;
}
}
}
}
}
if (val2.y < -50f)
{
((EntityManager)(ref em)).DestroyEntity(launchedDebrisItem.VisualEntity);
_launchedDebris.RemoveAt(num);
}
else
{
quaternion val8 = quaternion.EulerXYZ(launchedDebrisItem.AngularVelocity * dt);
componentData.Position = val2;
componentData.Rotation = math.normalize(math.mul(val8, componentData.Rotation));
((EntityManager)(ref em)).SetComponentData<LocalTransform>(launchedDebrisItem.VisualEntity, componentData);
}
}
}
}
private void EnsureProceduralBangSound()
{
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Invalid comparison between Unknown and I4
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
if (_hasProceduralBang)
{
return;
}
try
{
int num = 44100;
float num2 = 0.85f;
int num3 = (int)((float)num * num2);
int num4 = num3 * 2;
_proceduralBangPtr = Marshal.AllocHGlobal(num4);
Random random = new Random(42069);
float num5 = 0f;
float num6 = 0f;
float num7 = 0f;
for (int i = 0; i < num3; i++)
{
float num8 = (float)i / (float)num;
float num9 = MathF.Exp((0f - num8) * 14f);
float num10 = MathF.Exp((0f - num8) * 9.5f);
float num11 = MathF.Exp((0f - num8) * 6.5f);
float num12 = 135f * MathF.Exp((0f - num8) * 16f) + 36f;
num5 += (float)Math.PI * 2f * num12 / (float)num;
float num13 = MathF.Sin(num5) * num9 * 0.85f;
float num14 = (float)(random.NextDouble() * 2.0 - 1.0);
float num15 = num14 * num10 * 0.75f;
num6 += (float)Math.PI * 1040f / (float)num;
num7 += (float)Math.PI * 1780f / (float)num;
float num16 = (MathF.Sin(num6) * 0.5f + MathF.Sin(num7) * 0.5f) * num11 * 0.3f;
float num17 = num13 + num15 + num16;
num17 = MathF.Tanh(num17 * 1.8f);
short val = (short)Math.Clamp(num17 * 32000f, -32768f, 32767f);
Marshal.WriteInt16(_proceduralBangPtr, i * 2, val);
}
CREATESOUNDEXINFO val2 = new CREATESOUNDEXINFO
{
cbsize = Marshal.SizeOf<CREATESOUNDEXINFO>(),
length = (uint)num4,
numchannels = 1,
defaultfrequency = num,
format = (SOUND_FORMAT)2
};
MODE val3 = (MODE)6161;
System coreSystem = RuntimeManager.CoreSystem;
RESULT val4 = ((System)(ref coreSystem)).createSound(_proceduralBangPtr, val3, ref val2, ref _proceduralBangSound);
if ((int)val4 == 0)
{
((Sound)(ref _proceduralBangSound)).set3DMinMaxDistance(3f, 80f);
_hasProceduralBang = true;
}
}
catch (Exception ex)
{
ManualLogSource modLog = Plugin.ModLog;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Failed to create procedural FMOD sound: ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message);
}
modLog.LogWarning(val5);
}
}
private void PlayBlowExplosionSound(float3 worldPos)
{
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_001d: 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_0028: 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_0032: 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_003b: 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_003e: Invalid comparison between Unknown and I4
//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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_007f: 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_00ab: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
try
{
EnsureProceduralBangSound();
if (_hasProceduralBang)
{
ChannelGroup val = default(ChannelGroup);
System coreSystem = RuntimeManager.CoreSystem;
Channel val3 = default(Channel);
RESULT val2 = ((System)(ref coreSystem)).playSound(_proceduralBangSound, val, true, ref val3);
if ((int)val2 == 0)
{
VECTOR val4 = new VECTOR
{
x = worldPos.x,
y = worldPos.y,
z = worldPos.z
};
VECTOR val5 = new VECTOR
{
x = 0f,
y = 0f,
z = 0f
};
((Channel)(ref val3)).set3DAttributes(ref val4, ref val5);
((Channel)(ref val3)).setVolume(1f);
((Channel)(ref val3)).setPaused(false);
}
}
}
catch (Exception ex)
{
ManualLogSource modLog = Plugin.ModLog;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val6 = new BepInExWarningLogInterpolatedStringHandler(24, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Audio playback warning: ");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(ex.Message);
}
modLog.LogWarning(val6);
}
}
private void ProcessDoors(bool checkInput)
{
//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_0066: 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_0072: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_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_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_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: 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_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: 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_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_040f: Unknown result type (might be due to invalid IL or missing references)
//IL_0411: Unknown result type (might be due to invalid IL or missing references)
//IL_0416: Unknown result type (might be due to invalid IL or missing references)
//IL_041a: Unknown result type (might be due to invalid IL or missing references)
//IL_041c: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_0425: Unknown result type (might be due to invalid IL or missing references)
//IL_0427: Unknown result type (might be due to invalid IL or missing references)
//IL_042c: Unknown result type (might be due to invalid IL or missing references)
//IL_042e: Unknown result type (might be due to invalid IL or missing references)
//IL_0430: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Unknown result type (might be due to invalid IL or missing references)
//IL_0456: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Invalid comparison between Unknown and I4
//IL_0480: Unknown result type (might be due to invalid IL or missing references)
//IL_0485: Unknown result type (might be due to invalid IL or missing references)
//IL_0487: Unknown result type (might be due to invalid IL or missing references)
//IL_048c: Unknown result type (might be due to invalid IL or missing references)
//IL_048e: Unknown result type (might be due to invalid IL or missing references)
//IL_0493: Unknown result type (might be due to invalid IL or missing references)
//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
//IL_050f: Unknown result type (might be due to invalid IL or missing references)
//IL_0511: Unknown result type (might be due to invalid IL or missing references)
//IL_051c: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_031c: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_0387: Unknown result type (might be due to invalid IL or missing references)
//IL_039f: Unknown result type (might be due to invalid IL or missing references)
//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
if (defaultGameObjectInjectionWorld == null || !defaultGameObjectInjectionWorld.IsCreated)
{
_queriesInitialized = false;
_blownDoors.Clear();
_launchedDebris.Clear();
return;
}
EntityManager entityManager = defaultGameObjectInjectionWorld.EntityManager;
if (!_queriesInitialized)
{
_activeDoorQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[4]
{
ComponentType.ReadOnly<SCTypeElectricGate>(),
ComponentType.ReadWrite<SCValueAccelerator>(),
ComponentType.ReadOnly<SCElectricPower>(),
ComponentType.ReadOnly<LocalToWorld>()
});
_playerQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2]
{
ComponentType.ReadOnly<ActionablesController>(),
ComponentType.ReadOnly<LocalToWorld>()
});
_physicsWorldQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<PhysicsWorldSingleton>() });
_queriesInitialized = true;
}
bool flag = CheckBuildModeActive();
if (flag && !_wasInBuildMode && (_blownDoors.Count > 0 || _launchedDebris.Count > 0))
{
_blownDoors.Clear();
CleanupDebris(entityManager);
}
_wasInBuildMode = flag;
if (((EntityQuery)(ref _activeDoorQuery)).IsEmpty || flag)
{
return;
}
bool flag2 = checkInput && Keyboard.current != null && ((ButtonControl)Keyboard.current.eKey).wasPressedThisFrame;
bool flag3 = false;
float3 val = float3.zero;
float3 val2 = float3.zero;
if (flag2 && !((EntityQuery)(ref _playerQuery)).IsEmpty)
{
NativeArray<LocalToWorld> val3 = ((EntityQuery)(ref _playerQuery)).ToComponentDataArray<LocalToWorld>(AllocatorHandle.op_Implicit((Allocator)2));
try
{
Enumerator<LocalToWorld> enumerator = val3.GetEnumerator();
if (enumerator.MoveNext())
{
LocalToWorld current = enumerator.Current;
flag3 = true;
val = ((LocalToWorld)(ref current)).Position;
val2 = math.normalize(((LocalToWorld)(ref current)).Forward);
}
}
finally
{
val3.Dispose();
}
}
Entity val4 = Entity.Null;
float num = -1f;
NativeArray<Entity> val5 = ((EntityQuery)(ref _activeDoorQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
try
{
Enumerator<Entity> enumerator2 = val5.GetEnumerator();
float3 val7 = default(float3);
float3 val8 = default(float3);
while (enumerator2.MoveNext())
{
Entity current2 = enumerator2.Current;
(int, int) key = (current2.Index, current2.Version);
if (_blownDoors.TryGetValue(key, out var value))
{
SCValueAccelerator componentData = ((EntityManager)(ref entityManager)).GetComponentData<SCValueAccelerator>(current2);
float openTarget = value.OpenTarget;
if (componentData._acceleratorValue != openTarget || componentData._targetValue != openTarget)
{
componentData._acceleratorValue = openTarget;
componentData._targetValue = openTarget;
((EntityManager)(ref entityManager)).SetComponentData<SCValueAccelerator>(current2, componentData);
}
}
else
{
if (!flag2 || !flag3)
{
continue;
}
SCElectricPower componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<SCElectricPower>(current2);
if (!componentData2._isElectricityInterrupted && (int)componentData2._suppliedState == 2)
{
continue;
}
LocalToWorld componentData3 = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(current2);
float3 val6 = ((LocalToWorld)(ref componentData3)).Position - val;
float num2 = math.length(val6);
((float3)(ref val7))..ctor(val6.x, 0f, val6.z);
((float3)(ref val8))..ctor(val2.x, 0f, val2.z);
if (!(num2 <= 4f) || !(math.lengthsq(val7) > 0.001f) || !(math.lengthsq(val8) > 0.001f))
{
continue;
}
float num3 = math.dot(math.normalize(val8), math.normalize(val7));
if (num3 > 0.45f)
{
float num4 = num3 - num2 * 0.1f;
if (num4 > num)
{
num = num4;
val4 = current2;
}
}
}
}
if (val4 != Entity.Null)
{
SCValueAccelerator componentData4 = ((EntityManager)(ref entityManager)).GetComponentData<SCValueAccelerator>(val4);
SCTypeElectricGate componentData5 = ((EntityManager)(ref entityManager)).GetComponentData<SCTypeElectricGate>(val4);
LocalToWorld componentData6 = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(val4);
float num5 = ((componentData5._doorRendererMinScale.x < 0.5f || componentData5._doorRendererMinScale.y < 0.5f || componentData5._doorRendererMinScale.z < 0.5f) ? 0f : 1f);
float3 val9 = math.normalizesafe(((LocalToWorld)(ref componentData6)).Position - val, val2);
val9.y = 0.25f;
val9 = math.normalize(val9);
LaunchDoorLeaves(entityManager, val4, ((LocalToWorld)(ref componentData6)).Position, val9);
_blownDoors[(val4.Index, val4.Version)] = new BlownDoorState
{
OpenTarget = num5,
BlownTime = Time.time
};
componentData4._acceleratorValue = num5;
componentData4._targetValue = num5;
((EntityManager)(ref entityManager)).SetComponentData<SCValueAccelerator>(val4, componentData4);
PlayBlowExplosionSound(((LocalToWorld)(ref componentData6)).Position);
}
}
finally
{
val5.Dispose();
}
}
private void LaunchDoorLeaves(EntityManager em, Entity doorEntity, float3 doorCenter, float3 blastDir)
{
//IL_0003: 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_002f: 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_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_0072: 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_008b: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_00f6: 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_010f: 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)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: 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_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
if (!((EntityManager)(ref em)).HasBuffer<Child>(doorEntity))
{
return;
}
DynamicBuffer<Child> buffer = ((EntityManager)(ref em)).GetBuffer<Child>(doorEntity, false);
List<Entity> list = new List<Entity>();
for (int i = 0; i < buffer.Length; i++)
{
list.Add(buffer[i].Value);
}
int num = 0;
float3 angularVelocity = default(float3);
foreach (Entity item in list)
{
if (!(item == Entity.Null) && ((EntityManager)(ref em)).Exists(item) && ((EntityManager)(ref em)).HasComponent<LocalToWorld>(item) && (((EntityManager)(ref em)).HasComponent<PostTransformMatrix>(item) || list.Count <= 1))
{
LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData<LocalToWorld>(item);
Entity val = ((EntityManager)(ref em)).Instantiate(item);
if (((EntityManager)(ref em)).HasComponent<Parent>(val))
{
((EntityManager)(ref em)).RemoveComponent<Parent>(val);
}
if (((EntityManager)(ref em)).HasComponent<PreviousParent>(val))
{
((EntityManager)(ref em)).RemoveComponent<PreviousParent>(val);
}
if (((EntityManager)(ref em)).HasComponent<PostTransformMatrix>(val))
{
((EntityManager)(ref em)).RemoveComponent<PostTransformMatrix>(val);
}
float num2 = ((num % 2 == 0) ? (-1f) : 1f);
float3 val2 = math.cross(new float3(0f, 1f, 0f), blastDir);
float3 val3 = ((math.distance(((LocalToWorld)(ref componentData)).Position, doorCenter) > 1.35f) ? (doorCenter + val2 * (num2 * 0.45f)) : ((LocalToWorld)(ref componentData)).Position);
float3 val4 = val3 + blastDir * 0.65f;
LocalTransform val5 = LocalTransform.FromPositionRotationScale(val4, ((LocalToWorld)(ref componentData)).Rotation, 1f);
if (((EntityManager)(ref em)).HasComponent<LocalTransform>(val))
{
((EntityManager)(ref em)).SetComponentData<LocalTransform>(val, val5);
}
else
{
((EntityManager)(ref em)).AddComponentData<LocalTransform>(val, val5);
}
float3 velocity = blastDir * 10.5f + val2 * (num2 * 1.8f) + new float3(0f, 2.2f, 0f);
((float3)(ref angularVelocity))..ctor(2.8f, num2 * 2.4f, 1.9f);
_launchedDebris.Add(new LaunchedDebrisItem
{
VisualEntity = val,
Velocity = velocity,
AngularVelocity = angularVelocity,
SpawnTime = Time.time,
Bounces = 0,
Settled = false
});
num++;
}
}
}
}
}