using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ShipExpander.Builder;
using ShipExpander.Core;
using ShipExpander.Helper;
using ShipExpander.MonoBehaviour;
using ShipExpander.Patch;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine")]
[assembly: AssemblyCompany("JBriggs.ShipExpander")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A plugin for Lethal Company which expands the size of the ship")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+de8f5fae99353085bbb23cd83d56e56848e1b62b")]
[assembly: AssemblyProduct("Ship Expander")]
[assembly: AssemblyTitle("JBriggs.ShipExpander")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ShipExpander
{
[BepInPlugin("JBriggs.ShipExpander", "Ship Expander", "1.0.0")]
public class ShipExpanderModBase : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("JBriggs.ShipExpander");
private static ShipExpanderModBase _instance;
public static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
if ((Object)(object)_instance == (Object)null)
{
_instance = this;
}
SELogger.Log(((Component)this).gameObject, "Plugin JBriggs.ShipExpander is loaded by jbriggs.dev", (LogLevel)8);
_harmony.PatchAll(typeof(CopyShipPatch));
_harmony.PatchAll(typeof(AutoParentToShipPatch));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "JBriggs.ShipExpander";
public const string PLUGIN_NAME = "Ship Expander";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace ShipExpander.Patch
{
[HarmonyDebug]
[HarmonyPatch(typeof(AutoParentToShip))]
public class AutoParentToShipPatch
{
[HarmonyPostfix]
[HarmonyPatch("MoveToOffset")]
private static void HarmonyPostFixMoveToOffset(ref AutoParentToShip __instance)
{
//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_0010: 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_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_001d: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)__instance).transform;
Vector3 localPosition = transform.localPosition;
localPosition += ConstantVariables.InsideShipOffset;
transform.localPosition = localPosition;
}
}
[HarmonyDebug]
[HarmonyPatch(typeof(StartOfRound))]
public class CopyShipPatch
{
private const string HangarShipGameObjectName = "HangarShip";
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void HarmonyPostFixAwake()
{
SELogger.Log("CopyShipPatch", "Adding ExpandShipComponent to hangarShip", (LogLevel)8);
GameObject val = GameObjectHelper.FindObjectByName("HangarShip");
ExpandShipComponent expandShipComponent = val.AddComponent<ExpandShipComponent>();
SELogger.Log("CopyShipPatch", "ExpandShipComponent added", (LogLevel)8);
}
}
}
namespace ShipExpander.MonoBehaviour
{
public class CameraFollowComponent : MonoBehaviour
{
public Transform playerCamera;
public Transform portal;
public Transform otherPortal;
private void LateUpdate()
{
//IL_0007: 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_001c: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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_0057: 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_0061: 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_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_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)
Vector3 val = playerCamera.position - otherPortal.position;
((Component)this).transform.position = portal.position + val;
float num = Quaternion.Angle(portal.rotation, otherPortal.rotation);
Quaternion val2 = Quaternion.AngleAxis(num, Vector3.up);
Vector3 val3 = val2 * playerCamera.forward;
((Component)this).transform.rotation = Quaternion.LookRotation(val3, Vector3.up);
}
}
public class ExpandShipComponent : MonoBehaviour
{
private NetworkObject _thisNetworkObject;
private GameObject _insideShip;
private NetworkObject _insideShipNetworkObject;
private GameObject _outsideShip;
private NetworkObject _outsideShipNetworkObject;
private List<string> _toIgnore = new List<string> { "Player", "InsideTeleporter", "OutsideTeleporter" };
private List<string> _toBeCopiedOutside = new List<string> { "WallInsulator", "ShipModels2b", "ShipInside", "ShipElectricLights" };
private List<string> _toIgnoreInside = new List<string>
{
"Cameras", "Cube.004", "Cube.005", "Cube.006", "Cube.007", "Cube.008", "ThrusterBackRight", "ThrusterBackLeft", "ThrusterFrontRight", "ThrusterFrontLeft",
"ShipSupportBeams", "ShipRails", "ShipRailPosts", "CatwalkRailLining", "CatwalkShip", "CatwalkUnderneathSupports", "ClimbOntoCatwalkHelper", "CatwalkRailLiningB", "Ladder", "LadderShort",
"LadderShort (1)", "LargePipe (1)"
};
private void Start()
{
//IL_00c3: 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_0100: 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)
SELogger.Log(((Component)this).gameObject, "############### Updated scripts", (LogLevel)8);
_thisNetworkObject = ((Component)this).GetComponent<NetworkObject>();
SELogger.Log(((Component)this).gameObject, "Creating container for insideShip", (LogLevel)8);
_insideShip = new GameObjectBuilder().WithName("insideShip").WithParent(((Component)this).gameObject).WithNetworkObjectComponent(ref _insideShipNetworkObject)
.WithNetworkTransformComponent()
.GetGameObject();
SELogger.Log(((Component)this).gameObject, "Creating container for outsideShip", (LogLevel)8);
_outsideShip = new GameObjectBuilder().WithName("outsideShip").WithParent(((Component)this).gameObject).WithNetworkObjectComponent(ref _outsideShipNetworkObject)
.WithNetworkTransformComponent()
.GetGameObject();
SELogger.Log(((Component)this).gameObject, $"outsideShip spawned with local position of {_outsideShip.transform.localPosition}", (LogLevel)8);
TransformHelper.MoveObject(_insideShip, ConstantVariables.InsideShipOffset);
SELogger.Log(((Component)this).gameObject, $"insideShip updated with local position of {_insideShip.transform.localPosition}", (LogLevel)8);
List<string> list = new List<string> { "StartGameLever" };
foreach (string item in list)
{
GameObject val = GameObjectHelper.FindObjectByName(item);
SELogger.Log(((Component)this).gameObject, "Moving niche object " + ((Object)val).name, (LogLevel)8);
TransformHelper.MoveObject(val, ConstantVariables.InsideShipOffset);
}
SELogger.Log(((Component)this).gameObject, "Setting up teleport", (LogLevel)8);
((MonoBehaviour)this).StartCoroutine(SetupTeleport());
}
private void LateUpdate()
{
FixInsideShipHierarchy();
FixLightingForInsideShip();
FixVolumetricEffectsForInsideShip();
CopyObjectsForOutside();
}
private void FixVolumetricEffectsForInsideShip()
{
LocalVolumetricFog[] array = Object.FindObjectsByType<LocalVolumetricFog>((FindObjectsSortMode)0);
foreach (LocalVolumetricFog val in array)
{
}
}
private void FixLightingForInsideShip()
{
Light[] array = Object.FindObjectsByType<Light>((FindObjectsSortMode)0);
foreach (Light light in array)
{
if (!light.LayerCullingIncludes(1 << ConstantVariables.InsideShipLayer))
{
light.LayerCullingShow(1 << ConstantVariables.InsideShipLayer);
}
}
}
private void FixInsideShipHierarchy()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
foreach (Transform item in ((Component)this).gameObject.transform)
{
Transform val = item;
GameObject gameObject = ((Component)val).gameObject;
if (_toIgnoreInside.Contains(((Object)gameObject).name) || _toIgnore.Contains(((Object)gameObject).name) || (Object)(object)gameObject == (Object)(object)_insideShip || (Object)(object)gameObject == (Object)(object)_outsideShip || (Object)(object)val == (Object)null)
{
continue;
}
NetworkObject component = gameObject.GetComponent<NetworkObject>();
_insideShip.AddComponent<InsideShipLayerToggleComponent>();
if ((Object)(object)((Component)val).GetComponent<PhysicsProp>() != (Object)null)
{
continue;
}
if ((Object)(object)component != (Object)null)
{
if (component.TrySetParent(((Component)_insideShipNetworkObject).transform, true))
{
continue;
}
((Component)val).transform.parent = ((Component)_insideShipNetworkObject).transform;
}
else
{
((Component)val).transform.parent = _insideShip.transform;
}
if ((Object)(object)gameObject.GetComponent<InsideShipComponent>() == (Object)null)
{
gameObject.AddComponent<InsideShipComponent>();
}
}
List<string> source = new List<string> { "ChangableSuit(Clone)" };
foreach (GameObject item2 in source.Select(GameObjectHelper.FindObjectByName))
{
if ((Object)(object)item2.transform.parent != (Object)(object)_insideShip.transform)
{
item2.transform.parent = _insideShip.transform;
}
}
}
private void CopyObjectsForOutside()
{
//IL_00a0: 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_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
while (_toBeCopiedOutside.Count > 0)
{
List<string> partsCopied = new List<string>();
SELogger.Log(((Component)this).gameObject, $"Copying {_toBeCopiedOutside.Count} object outside", (LogLevel)8);
foreach (string item in _toBeCopiedOutside)
{
GameObject val = GameObjectHelper.FindObjectByName(item);
SELogger.Log(((Component)this).gameObject, "Copying object to outsideShip " + item, (LogLevel)32);
GameObject val2 = Object.Instantiate<GameObject>(val, _outsideShip.transform, true);
SELogger.Log(((Component)this).gameObject, $"Copied object transforms: T({val2.transform.position}) - LT({val2.transform.localPosition})", (LogLevel)32);
SELogger.Log(((Component)this).gameObject, $"Copied object transforms: T({val2.transform.position}) - LT({val2.transform.localPosition})", (LogLevel)32);
InsideShipComponent component = val2.GetComponent<InsideShipComponent>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
partsCopied.Add(item);
}
_toBeCopiedOutside.RemoveAll((string x) => partsCopied.Contains(x));
}
}
private IEnumerator SetupTeleport()
{
bool foundMainCamera = false;
Transform playerContainer = null;
Transform cameraContainer = null;
while (!foundMainCamera)
{
try
{
SELogger.Log(((Component)this).gameObject, "Finding Player", (LogLevel)32);
playerContainer = ((Component)this).gameObject.transform.Find("Player");
SELogger.Log(((Component)this).gameObject, "Found Player: " + ((Object)playerContainer).name, (LogLevel)32);
SELogger.Log(((Component)this).gameObject, "Finding ScavengerModel", (LogLevel)32);
Transform scavModel = playerContainer.Find("ScavengerModel");
SELogger.Log(((Component)this).gameObject, "Found ScavengerModel: " + ((Object)scavModel).name, (LogLevel)32);
SELogger.Log(((Component)this).gameObject, "Finding metarig", (LogLevel)32);
Transform metaRig = scavModel.Find("metarig");
SELogger.Log(((Component)this).gameObject, "Found metarig: " + ((Object)metaRig).name, (LogLevel)32);
SELogger.Log(((Component)this).gameObject, "Finding CameraContainer", (LogLevel)32);
cameraContainer = metaRig.Find("CameraContainer");
SELogger.Log(((Component)this).gameObject, "Found CameraContainer: " + ((Object)cameraContainer).name, (LogLevel)32);
foundMainCamera = true;
}
catch (Exception e)
{
SELogger.Log(((Component)this).gameObject, "Couldn't find camera, will re-attempt: " + e.Message, (LogLevel)8);
}
yield return (object)new WaitForFixedUpdate();
}
TeleportCreatorComponent teleportComponent = ((Component)cameraContainer).gameObject.AddComponent<TeleportCreatorComponent>();
teleportComponent.Initialize(_insideShip, _outsideShip, playerContainer);
}
private void OnDestroy()
{
SELogger.Log(((Component)this).gameObject, "Removing ExpandShipComponent", (LogLevel)8);
}
}
public class InsideShipComponent : MonoBehaviour
{
private int initialLayerValue;
private void Start()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//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)
Transform transform = ((Component)this).transform;
transform.localPosition += ConstantVariables.InsideShipOffset;
}
private void OnDestroy()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//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)
Transform transform = ((Component)this).transform;
transform.localPosition -= ConstantVariables.InsideShipOffset;
}
}
public class InsideShipLayerToggleComponent : MonoBehaviour
{
private int initialLayerValue;
public bool neverDestroy;
public List<int> layersToIgnore = new List<int>
{
LayerMask.NameToLayer("Triggers"),
LayerMask.NameToLayer("Colliders"),
LayerMask.NameToLayer("ScanNode")
};
private void Start()
{
initialLayerValue = ((Component)this).gameObject.layer;
}
private void Update()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
foreach (Transform item in ((Component)this).transform)
{
Transform val = item;
if ((Object)(object)((Component)val).gameObject.GetComponent<InsideShipLayerToggleComponent>() == (Object)null)
{
((Component)val).gameObject.AddComponent<InsideShipLayerToggleComponent>();
}
}
if (!neverDestroy && (Object)(object)((Component)((Component)this).transform.parent).gameObject.GetComponent<InsideShipLayerToggleComponent>() == (Object)null)
{
Object.Destroy((Object)(object)this);
}
}
private void OnDestroy()
{
((Component)this).gameObject.layer = initialLayerValue;
}
public void EnableLayer()
{
if (!layersToIgnore.Contains(initialLayerValue))
{
((Component)this).gameObject.layer = ConstantVariables.InsideShipLayer;
}
}
public void DisableLayer()
{
if (!layersToIgnore.Contains(initialLayerValue))
{
((Component)this).gameObject.layer = initialLayerValue;
}
}
}
[RequireComponent(typeof(BoxCollider))]
public class TeleportComponent : MonoBehaviour
{
private bool _playerIsOverlapping = false;
private Transform _player;
private Transform _receiver;
private bool _isGoingOutside;
public void Initialize(Transform player, Transform receiver, bool shouldHideInsideShip)
{
_player = player;
_receiver = receiver;
_isGoingOutside = shouldHideInsideShip;
}
private void Update()
{
//IL_0015: 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_0025: 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_0036: 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_0053: 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)
if (_playerIsOverlapping)
{
Vector3 val = _player.position - ((Component)this).transform.position;
SELogger.Log(((Component)this).gameObject, $"Player is overlapping with collider component. portalToPlayer: {val}", (LogLevel)8);
float num = Vector3.Dot(((Component)this).transform.up, val);
if (num < 0f)
{
MovePlayer(val);
HandleHidingInsideShip();
}
SELogger.Log(((Component)this).gameObject, $"Player is overlapping with collider component. Dot product: {num}", (LogLevel)8);
}
}
private void HandleHidingInsideShip()
{
InsideShipLayerToggleComponent[] array = Object.FindObjectsByType<InsideShipLayerToggleComponent>((FindObjectsSortMode)0);
InsideShipLayerToggleComponent[] array2 = array;
foreach (InsideShipLayerToggleComponent insideShipLayerToggleComponent in array2)
{
if (_isGoingOutside)
{
insideShipLayerToggleComponent.EnableLayer();
}
else
{
insideShipLayerToggleComponent.DisableLayer();
}
}
}
private void MovePlayer(Vector3 portalToPlayer)
{
//IL_0007: 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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_0061: Unknown result type (might be due to invalid IL or missing references)
float num = 0f - Quaternion.Angle(((Component)this).transform.rotation, _receiver.rotation);
num += 180f;
_player.Rotate(Vector3.up, num);
Vector3 val = Quaternion.Euler(0f, num, 0f) * portalToPlayer;
_player.position = _receiver.position + val;
_playerIsOverlapping = false;
}
private void OnTriggerEnter(Collider other)
{
if (((Component)other).tag == "Player")
{
_playerIsOverlapping = true;
}
}
private void OnTriggerExit(Collider other)
{
if (((Component)other).tag == "Player")
{
_playerIsOverlapping = false;
}
}
}
public class TeleportCreatorComponent : MonoBehaviour
{
private readonly bool shouldRenderColliderInDebug = false;
private static readonly Vector3 ShipDoorOffset = new Vector3(-5.75f, 2f, -14f);
private static readonly Vector3 RenderPlaneOffset = new Vector3(0.4f, 0f, 0f);
private Transform _player;
private Camera _playerCamera;
private Camera _cameraInside;
private GameObject _insideShipTeleporter;
private TeleportComponent _insideColliderBox;
private Camera _cameraOutside;
private GameObject _outsideShipTeleporter;
private TeleportComponent _outsideColliderBox;
public void Initialize(GameObject insideShip, GameObject outsideShip, Transform player)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
_player = player;
_insideShipTeleporter = new GameObjectBuilder().WithNetworkObjectComponent().WithName("InsideTeleporter").WithParent(insideShip)
.GetGameObject();
_outsideShipTeleporter = new GameObjectBuilder().WithNetworkObjectComponent().WithName("OutsideTeleporter").WithParent(outsideShip)
.GetGameObject();
TransformHelper.MoveObject(_insideShipTeleporter.gameObject, new Vector3(-7.2f, 0f, -14f));
TransformHelper.MoveObject(_outsideShipTeleporter.gameObject, new Vector3(-7.2f, 0f, -14f));
_playerCamera = ((Component)this).GetComponentInChildren<Camera>();
_playerCamera.LayerCullingShow(1 << ConstantVariables.RenderLayer);
SELogger.Log(((Component)this).gameObject, "Creating inside camera name", (LogLevel)8);
_cameraInside = Object.Instantiate<Camera>(_playerCamera, ((Component)this).transform, true);
((Object)_cameraInside).name = "MainCameraInside";
((Component)_cameraInside).tag = "Untagged";
_cameraInside.aspect = _playerCamera.aspect;
_cameraInside.LayerCullingShow(1 << ConstantVariables.InsideShipLayer);
_cameraInside.LayerCullingShow(1 << ConstantVariables.RenderLayer);
SELogger.Log(((Component)this).gameObject, "Adding TempFollowComponent to insideCamera", (LogLevel)8);
CameraFollowComponent cameraFollowComponent = ((Component)_cameraInside).gameObject.AddComponent<CameraFollowComponent>();
SELogger.Log(((Component)this).gameObject, "Setting variables to tempFollowComponent on inside camera", (LogLevel)8);
cameraFollowComponent.portal = _insideShipTeleporter.transform;
cameraFollowComponent.otherPortal = _outsideShipTeleporter.transform;
cameraFollowComponent.playerCamera = ((Component)_playerCamera).transform;
SELogger.Log(((Component)this).gameObject, "Creating outside camera", (LogLevel)8);
_cameraOutside = Object.Instantiate<Camera>(_playerCamera, ((Component)this).transform, true);
((Object)_cameraOutside).name = "MainCameraOutside";
((Component)_cameraOutside).tag = "Untagged";
_cameraOutside.aspect = _playerCamera.aspect;
_cameraOutside.LayerCullingShow(1 << ConstantVariables.InsideShipLayer);
_cameraOutside.LayerCullingShow(1 << ConstantVariables.RenderLayer);
SELogger.Log(((Component)this).gameObject, "Adding TempFollowComponent to outsideCamera", (LogLevel)8);
CameraFollowComponent cameraFollowComponent2 = ((Component)_cameraOutside).gameObject.AddComponent<CameraFollowComponent>();
SELogger.Log(((Component)this).gameObject, "Setting variables to tempFollowComponent on outside camera", (LogLevel)8);
cameraFollowComponent2.portal = _outsideShipTeleporter.transform;
cameraFollowComponent2.otherPortal = _insideShipTeleporter.transform;
cameraFollowComponent2.playerCamera = ((Component)_playerCamera).transform;
SELogger.Log(((Component)this).gameObject, "Creating insideRenderPlane", (LogLevel)8);
GameObject val = CreateRenderPlane(_cameraOutside, _insideShipTeleporter.transform, "RenderPlane");
SELogger.Log(((Component)this).gameObject, "Moving insideRenderPlane up", (LogLevel)8);
TransformHelper.MoveObject(val.gameObject, ConstantVariables.InsideShipOffset);
SELogger.Log(((Component)this).gameObject, "Creating insideColliderBox", (LogLevel)8);
_insideColliderBox = CreateColliderPlane(_insideShipTeleporter.transform, "ColliderPlane");
SELogger.Log(((Component)this).gameObject, "Moving insideColliderBox up", (LogLevel)8);
TransformHelper.MoveObject(((Component)_insideColliderBox).gameObject, ConstantVariables.InsideShipOffset);
CreateRenderPlane(_cameraInside, _outsideShipTeleporter.transform, "RenderPlane", flipped: true);
_outsideColliderBox = CreateColliderPlane(_outsideShipTeleporter.transform, "ColliderPlane", flipped: true);
SELogger.Log(((Component)this).gameObject, "Initializing colliderBoxes up", (LogLevel)8);
_insideColliderBox.Initialize(_player, ((Component)_outsideColliderBox).transform, shouldHideInsideShip: true);
_outsideColliderBox.Initialize(_player, ((Component)_insideColliderBox).transform, shouldHideInsideShip: false);
}
private GameObject CreateRenderPlane(Camera camera, Transform parentTransform, string planeName, bool flipped = false)
{
//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_001a: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: 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_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_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Expected O, but got Unknown
float width = 2.25f;
float height = 2.25f;
GameObject val = new GameObject
{
name = planeName
};
val.transform.parent = parentTransform;
val.transform.localEulerAngles = new Vector3(270f, 270f, flipped ? 180f : 0f);
val.layer = ConstantVariables.RenderLayer;
GameObject val2 = val;
if (flipped)
{
TransformHelper.MoveObject(val2, ShipDoorOffset + RenderPlaneOffset);
}
else
{
TransformHelper.MoveObject(val2, ShipDoorOffset + -RenderPlaneOffset);
}
val2.AddComponent<MeshFilter>();
val2.AddComponent<MeshRenderer>();
val2.GetComponent<MeshFilter>().mesh = CreatePlaneMesh(width, height);
Shader screenCutoutShader = UnityBundleHelper.GetScreenCutoutShader();
Material val3 = new Material(screenCutoutShader);
((Object)val3).name = planeName + "_material";
Renderer component = val2.GetComponent<Renderer>();
component.material = val3;
if ((Object)(object)camera.targetTexture != (Object)null)
{
camera.targetTexture.Release();
}
camera.targetTexture = new RenderTexture(Screen.width, Screen.height, 24);
component.material.mainTexture = (Texture)(object)camera.targetTexture;
component.lightProbeUsage = (LightProbeUsage)1;
component.reflectionProbeUsage = (ReflectionProbeUsage)1;
component.shadowCastingMode = (ShadowCastingMode)1;
component.receiveShadows = true;
component.motionVectorGenerationMode = (MotionVectorGenerationMode)1;
return val2;
}
private Mesh CreatePlaneMesh(float width, float height)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//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_002a: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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_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_0086: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
Mesh val = new Mesh();
Vector3[] vertices = (Vector3[])(object)new Vector3[4]
{
new Vector3(width, 0f, height),
new Vector3(width, 0f, 0f - height),
new Vector3(0f - width, 0f, height),
new Vector3(0f - width, 0f, 0f - height)
};
Vector2[] uv = (Vector2[])(object)new Vector2[4]
{
new Vector2(1f, 1f),
new Vector2(1f, 0f),
new Vector2(0f, 1f),
new Vector2(0f, 0f)
};
int[] triangles = new int[6] { 0, 1, 2, 2, 1, 3 };
val.vertices = vertices;
val.uv = uv;
val.triangles = triangles;
val.RecalculateNormals();
val.RecalculateBounds();
return val;
}
private TeleportComponent CreateColliderPlane(Transform parentTransform, string colliderName, bool flipped = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0017: 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_005f: 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_0089: 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_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Expected O, but got Unknown
GameObject val = new GameObject();
((Object)val).name = colliderName;
val.transform.position = default(Vector3);
val.transform.parent = parentTransform;
val.transform.localEulerAngles = (flipped ? new Vector3(270f, 0f, 90f) : new Vector3(270f, 0f, -90f));
BoxCollider val2 = val.AddComponent<BoxCollider>();
((Collider)val2).isTrigger = true;
val2.size = new Vector3(2f, 0f, 3f);
if (shouldRenderColliderInDebug)
{
SELogger.Log(((Component)this).gameObject, "Doing DEBUG step", (LogLevel)4);
SELogger.Log(((Component)this).gameObject, "Adding MeshFilter", (LogLevel)8);
val.AddComponent<MeshFilter>();
SELogger.Log(((Component)this).gameObject, "Adding MeshRenderer", (LogLevel)8);
val.AddComponent<MeshRenderer>();
SELogger.Log(((Component)this).gameObject, "Adding MeshFilter", (LogLevel)8);
val.GetComponent<MeshFilter>().mesh = CreatePlaneMesh(5f, 5f);
SELogger.Log(((Component)this).gameObject, "Creating shader", (LogLevel)8);
Shader debugShader = UnityBundleHelper.GetDebugShader();
SELogger.Log(((Component)this).gameObject, "Creating material", (LogLevel)8);
Material val3 = new Material(debugShader);
((Object)val3).name = ((Object)this).name + "_material";
SELogger.Log(((Component)this).gameObject, "Getting renderer", (LogLevel)8);
Renderer component = val.GetComponent<Renderer>();
SELogger.Log(((Component)this).gameObject, "Assigning material to renderer", (LogLevel)8);
component.material = val3;
}
TransformHelper.MoveObject(val, ShipDoorOffset);
return val.AddComponent<TeleportComponent>();
}
}
public class TempFollowComponent : MonoBehaviour
{
public Transform playerCamera;
public Transform portal;
public Transform otherPortal;
private void Update()
{
//IL_0007: 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_001c: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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_0057: 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_0061: 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_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_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)
Vector3 val = playerCamera.position - otherPortal.position;
((Component)this).transform.position = portal.position + val;
float num = Quaternion.Angle(portal.rotation, otherPortal.rotation);
Quaternion val2 = Quaternion.AngleAxis(num, Vector3.up);
Vector3 val3 = val2 * playerCamera.forward;
((Component)this).transform.rotation = Quaternion.LookRotation(val3, Vector3.up);
}
}
}
namespace ShipExpander.Helper
{
public static class CameraLayerHelper
{
public static void LayerCullingShow(this Camera camera, int layerMask)
{
camera.cullingMask |= layerMask;
}
public static void LayerCullingHide(this Camera camera, int layerMask)
{
camera.cullingMask &= ~layerMask;
}
public static void LayerCullingToggle(this Camera camera, int layerMask)
{
camera.cullingMask ^= layerMask;
}
public static bool LayerCullingIncludes(this Camera camera, int layerMask)
{
return (camera.cullingMask & layerMask) > 0;
}
public static void LayerCullingToggle(this Camera camera, int layerMask, bool isOn)
{
bool flag = camera.LayerCullingIncludes(layerMask);
if (isOn && !flag)
{
camera.LayerCullingShow(layerMask);
}
else if (!isOn && flag)
{
camera.LayerCullingHide(layerMask);
}
}
}
public abstract class GameObjectHelper
{
public static GameObject FindObjectByName(string name)
{
GameObject val = GameObject.Find(name);
if ((Object)(object)val != (Object)null)
{
return val;
}
SELogger.Log("GameObjectHelper", "Could not find " + name, (LogLevel)4);
return null;
}
}
public static class LightLayerHelper
{
public static void LayerCullingShow(this Light light, int layerMask)
{
light.cullingMask |= layerMask;
}
public static void LayerCullingHide(this Light light, int layerMask)
{
light.cullingMask &= ~layerMask;
}
public static void LayerCullingToggle(this Light light, int layerMask)
{
light.cullingMask ^= layerMask;
}
public static bool LayerCullingIncludes(this Light light, int layerMask)
{
return (light.cullingMask & layerMask) > 0;
}
public static void LayerCullingToggle(this Light light, int layerMask, bool isOn)
{
bool flag = light.LayerCullingIncludes(layerMask);
if (isOn && !flag)
{
light.LayerCullingShow(layerMask);
}
else if (!isOn && flag)
{
light.LayerCullingHide(layerMask);
}
}
}
public abstract class ParentHelper
{
public static void SetParent(GameObject child, GameObject parent)
{
NetworkObject component = child.gameObject.GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null)
{
if (!component.TrySetParent(parent.transform, true))
{
child.transform.parent = parent.transform;
}
}
else
{
child.transform.parent = parent.transform;
}
}
}
public class PlaneBuilder : GameObjectBuilder
{
public Mesh _mesh;
public PlaneBuilder()
{
Reset();
}
private void Reset()
{
}
}
public abstract class TransformHelper
{
public static void MoveObject(GameObject gameObject, Vector3 distance)
{
//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_003d: 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_0021: Unknown result type (might be due to invalid IL or missing references)
NetworkObject component = gameObject.GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null)
{
Transform transform = gameObject.transform;
transform.localPosition += distance;
}
else
{
Transform transform2 = gameObject.transform;
transform2.localPosition += distance;
}
}
}
public abstract class UnityBundleHelper
{
private static AssetBundle _shaderBundle;
private static AssetBundle _prefabBundle;
private static readonly string ScreenCutoutShaderName = "assets/shader/screencutoutshader.shader";
private static readonly string DebugShaderName = "assets/shader/debugshader.shader";
private static readonly string CameraContainerPrefabName = "assets/prefabs/othercameracontainer.prefab";
private static AssetBundle LoadResource(string unityPackageName)
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, unityPackageName));
if ((Object)(object)val == (Object)null)
{
SELogger.Log("UnityBundleHelper", "Failed to load custom assets.", (LogLevel)2);
}
string[] allAssetNames = val.GetAllAssetNames();
foreach (string text in allAssetNames)
{
SELogger.Log("UnityBundleHelper", $"Loaded asset: {text} of type {((object)val.LoadAsset(text)).GetType()}", (LogLevel)8);
}
return val;
}
private static Shader GetShader(string name)
{
if ((Object)(object)_shaderBundle == (Object)null)
{
_shaderBundle = LoadResource("additionalshaders");
}
Shader val = _shaderBundle.LoadAsset<Shader>(name);
if ((Object)(object)val == (Object)null)
{
SELogger.Log("UnityBundleHelper", "Failed to load asset " + name + " from additionalshaders", (LogLevel)8);
}
return val;
}
private static GameObject GetPrefab(string name)
{
if ((Object)(object)_shaderBundle == (Object)null)
{
_prefabBundle = LoadResource("additionalprefabs");
}
GameObject val = _prefabBundle.LoadAsset<GameObject>(name);
if ((Object)(object)val == (Object)null)
{
SELogger.Log("UnityBundleHelper", "Failed to load asset " + name + " from additionalprefabs", (LogLevel)8);
}
return val;
}
public static Shader GetScreenCutoutShader()
{
return GetShader(ScreenCutoutShaderName);
}
public static Shader GetDebugShader()
{
return GetShader(DebugShaderName);
}
public static GameObject GetCameraContainerPrefab()
{
return GetPrefab(CameraContainerPrefabName);
}
}
}
namespace ShipExpander.Core
{
public abstract class ConstantVariables
{
public static readonly Vector3 InsideShipOffset = new Vector3(0f, 20f, 0f);
public static readonly int InsideShipLayer = 7;
public static readonly int RenderLayer = 30;
}
public abstract class SELogger
{
private static void Log(string message, LogLevel logLevel = 8)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ShipExpanderModBase.Log.Log(logLevel, (object)message);
}
public static void Log(string source, string message, LogLevel logLevel = 8)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
Log("(" + source + ") -> " + message, logLevel);
}
public static void Log(GameObject gameObject, string message, LogLevel logLevel = 8)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
Log(((Object)gameObject).name, message, logLevel);
}
public static void LogInfo(string source, string message)
{
Log("(" + source + ") -> " + message, (LogLevel)16);
}
public static void LogError(string source, string message)
{
Log("(" + source + ") -> " + message, (LogLevel)2);
}
}
[Serializable]
public class ShipExpanderException : Exception
{
public ShipExpanderException()
{
}
public ShipExpanderException(string message)
: base(message)
{
}
public ShipExpanderException(string message, Exception inner)
: base(message, inner)
{
}
}
}
namespace ShipExpander.Builder
{
public class GameObjectBuilder
{
protected GameObject GameObject;
protected GameObject Parent;
protected bool IsNetworkObject;
public GameObjectBuilder()
{
Reset();
}
private void Reset()
{
//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_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
GameObject val = new GameObject();
val.transform.localPosition = Vector3.zero;
GameObject = val;
}
public GameObjectBuilder WithName(string name)
{
((Object)GameObject).name = name;
return this;
}
public GameObjectBuilder WithNetworkObjectComponent()
{
IsNetworkObject = true;
GameObject.AddComponent<NetworkObject>();
return this;
}
public GameObjectBuilder WithNetworkObjectComponent(ref NetworkObject networkObject)
{
IsNetworkObject = true;
networkObject = GameObject.AddComponent<NetworkObject>();
return this;
}
public GameObjectBuilder WithNetworkTransformComponent()
{
IsNetworkObject = true;
GameObject.AddComponent<NetworkTransform>();
return this;
}
public GameObjectBuilder WithParent(GameObject parent)
{
//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_0024: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = GameObject.transform.position;
Parent = parent;
GameObject.transform.position = position;
return this;
}
public GameObjectBuilder WithPlane(Plane plane)
{
GameObject.AddComponent<MeshRenderer>();
return this;
}
public GameObject GetGameObject()
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Parent != (Object)null)
{
if (IsNetworkObject)
{
NetworkObject component = GameObject.GetComponent<NetworkObject>();
NetworkObject component2 = Parent.GetComponent<NetworkObject>();
if (!((Object)(object)component != (Object)null) || !((Object)(object)component2 != (Object)null))
{
throw new ShipExpanderException("Parent is not an Network Object");
}
component.TrySetParent(component2, true);
component.SpawnWithOwnership(component2.NetworkObjectId, false);
}
GameObject.transform.parent = Parent.transform;
}
GameObject.transform.localPosition = Vector3.zero;
return GameObject;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}