using System;
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.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ZeroDestroyedCables")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Resets destroyed cable data readings to zero")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ZeroDestroyedCables")]
[assembly: AssemblyTitle("ZeroDestroyedCables")]
[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 ZeroDestroyedCables
{
[BepInPlugin("com.wyatt.zerodestroyedcables", "Zero Destroyed Cables", "1.0.0")]
public class Plugin : BasePlugin
{
public override void Load()
{
//IL_000a: 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_0015: Expected O, but got Unknown
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
ClassInjector.RegisterTypeInIl2Cpp<CableResetUpdater>();
GameObject val = new GameObject("ZeroDestroyedCablesUpdater");
Object.DontDestroyOnLoad((Object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<CableResetUpdater>();
((BasePlugin)this).Log.LogInfo((object)"Zero Destroyed Cables loaded!");
}
}
public class CableResetUpdater : MonoBehaviour
{
private EntityQuery _portQuery;
private bool _queryInitialized;
public void Update()
{
ResetDisconnectedPorts();
}
public void LateUpdate()
{
ResetDisconnectedPorts();
}
private void ResetDisconnectedPorts()
{
//IL_001a: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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_0082: 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_0089: 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_009c: 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_00a3: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Invalid comparison between Unknown and I4
//IL_00b1: 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_00c1: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: 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)
World defaultGameObjectInjectionWorld = World.DefaultGameObjectInjectionWorld;
if (defaultGameObjectInjectionWorld == null || !defaultGameObjectInjectionWorld.IsCreated)
{
_queryInitialized = false;
return;
}
EntityManager entityManager = defaultGameObjectInjectionWorld.EntityManager;
if (!_queryInitialized)
{
_portQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<SpaceshipElectricPort>() });
_queryInitialized = true;
}
if (((EntityQuery)(ref _portQuery)).IsEmptyIgnoreFilter)
{
return;
}
NativeArray<Entity> val = ((EntityQuery)(ref _portQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
try
{
for (int i = 0; i < val.Length; i++)
{
Entity val2 = val[i];
SpaceshipElectricPort componentData = ((EntityManager)(ref entityManager)).GetComponentData<SpaceshipElectricPort>(val2);
if (((int)componentData._runtimeType == 0 || (int)componentData._runtimeType == 3) && (!(componentData._runtimeEndEntity != Entity.Null) || !((EntityManager)(ref entityManager)).Exists(componentData._runtimeEndEntity) || !((EntityManager)(ref entityManager)).HasComponent<SpaceshipElectricPort>(componentData._runtimeEndEntity)) && componentData._portValue != 0f)
{
componentData._portValue = 0f;
((EntityManager)(ref entityManager)).SetComponentData<SpaceshipElectricPort>(val2, componentData);
}
}
}
finally
{
val.Dispose();
}
}
}
}