using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CG.Game;
using CG.Ship.Repair;
using CG.Space;
using Gameplay.Atmosphere;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using VoidManager;
using VoidManager.MPModChecks;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("ThinHull")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2+8b918966fefc6ead58b196e8802f015cd5adacc4")]
[assembly: AssemblyProduct("ThinHull")]
[assembly: AssemblyTitle("Makes hull breaches leak air from the ship. Host side.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ThinHull
{
[HarmonyPatch(typeof(Atmosphere))]
internal class AtmospherePatch
{
internal static Dictionary<HullBreach, Room> nearestRoom;
private static readonly FieldInfo breachesField = AccessTools.Field(typeof(HullDamageController), "breaches");
private const float airLeakRate = 0.4f;
private const float heatLeakRate = 0.3f;
[HarmonyPostfix]
[HarmonyPatch("RoomsInitialize")]
private static void RoomsInitialize()
{
CreateDictionary();
}
[HarmonyPostfix]
[HarmonyPatch("RoomsShutdown")]
private static void RoomsShutdown()
{
nearestRoom = null;
}
[HarmonyPrefix]
[HarmonyPatch("LateUpdate")]
private static void LateUpdate(Atmosphere __instance)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Invalid comparison between Unknown and I4
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
if (!PhotonNetwork.IsMasterClient || nearestRoom == null)
{
return;
}
foreach (HullBreach key in nearestRoom.Keys)
{
if ((int)key.State.condition != 0)
{
Room val = nearestRoom[key];
AtmosphereValues elementAt = __instance.Atmospheres.GetElementAt(val.RoomIndex);
elementAt.Oxygen *= 1f - 0.4f / val.Volume * (float)key.State.condition;
elementAt.Pressure = elementAt.Oxygen;
float num = elementAt.Temperature + 273f;
num *= 1f - 0.3f / val.Volume * (float)key.State.condition;
elementAt.Temperature = num - 273f;
__instance.Atmospheres.SetElement(val, elementAt);
}
}
}
internal static void CreateDictionary()
{
//IL_009e: 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_00bb: 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)
nearestRoom = new Dictionary<HullBreach, Room>();
AbstractPlayerControlledShip playerShip = ClientGame.Current.PlayerShip;
HullDamageController val = ((playerShip != null) ? ((Component)playerShip).GetComponentInChildren<HullDamageController>() : null);
if ((Object)(object)val == (Object)null)
{
return;
}
Vector3 val3 = default(Vector3);
foreach (HullBreach item in (List<HullBreach>)breachesField.GetValue(val))
{
float num = float.MaxValue;
Room value = null;
foreach (RoomCollection s_roomCollection in RoomCollection.s_roomCollections)
{
Room[] rooms = s_roomCollection.Rooms;
foreach (Room val2 in rooms)
{
s_roomCollection.RoomSphereIntersect(val2, ((Component)item).transform.position, 1000f, ref val3);
Vector3 val4 = ((Component)item).transform.position - val3;
float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
value = val2;
}
}
}
nearestRoom.Add(item, value);
}
}
}
[BepInPlugin("18107.ThinHull", "Thin Hull", "0.0.2")]
[BepInProcess("Void Crew.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BepinPlugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "18107.ThinHull");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 18107.ThinHull is loaded!");
}
}
public class MyPluginInfo
{
public const string PLUGIN_GUID = "18107.ThinHull";
public const string PLUGIN_NAME = "ThinHull";
public const string USERS_PLUGIN_NAME = "Thin Hull";
public const string PLUGIN_VERSION = "0.0.2";
public const string PLUGIN_DESCRIPTION = "Makes hull breaches leak air from the ship. Host side.";
public const string PLUGIN_ORIGINAL_AUTHOR = "18107";
public const string PLUGIN_AUTHORS = "18107";
public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Thin_Hull";
}
public class VoidManagerPlugin : VoidPlugin
{
public override MultiplayerType MPType => (MultiplayerType)14;
public override string Author => "18107";
public override string Description => "Makes hull breaches leak air from the ship. Host side.";
public override string ThunderstoreID => "VoidCrewModdingTeam/Thin_Hull";
public override SessionChangedReturn OnSessionChange(SessionChangedInput input)
{
//IL_0003: 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_0012: 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)
SessionChangedReturn result = default(SessionChangedReturn);
result.SetMod_Session = true;
return result;
}
}
}