using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Olecheck.Scripts;
using Olecheck.Utils;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Olecheck")]
[assembly: AssemblyDescription("Lethal Company plugin for BepInEx")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Fantastic Studio")]
[assembly: AssemblyProduct("Olecheck")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bdf41c6a-c4e6-470c-80b0-05a5c42ed6d0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Olecheck
{
[BepInPlugin("fantasticstudio.brauncompany", "Braun Company", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private static readonly Harmony harmony = new Harmony("fantasticstudio.brauncompany");
public static ManualLogSource CLog;
private void Awake()
{
CLog = ((BaseUnityPlugin)this).Logger;
CLog.LogInfo((object)"Plugin Braun Company is loaded!");
harmony.PatchAll();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "fantasticstudio.brauncompany";
public const string PLUGIN_NAME = "Braun Company";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace Olecheck.Utils
{
public static class Console
{
public static bool DebugState;
public static void Log(string message)
{
SendLog(message, "Log");
}
public static void LogInfo(string message)
{
SendLog(message, "LogInfo");
}
public static void LogError(string message)
{
SendLog(message, "LogError");
}
public static void LogWarning(string message)
{
SendLog(message, "LogWarning");
}
public static void LogDebug(string message)
{
SendLog(message, "LogDebug");
}
public static void LogFatal(string message)
{
SendLog(message, "LogFatal");
}
public static void LogMessage(string message)
{
SendLog(message, "LogMessage");
}
private static void SendLog(string message, string level = null)
{
if (!DebugState)
{
return;
}
switch (level)
{
case "LogInfo":
Plugin.CLog.LogInfo((object)message);
return;
case "LogError":
Plugin.CLog.LogError((object)message);
return;
case "LogWarning":
Plugin.CLog.LogWarning((object)message);
return;
case "LogDebug":
Plugin.CLog.LogDebug((object)message);
return;
case "LogFatal":
Plugin.CLog.LogFatal((object)message);
return;
case "LogMessage":
Plugin.CLog.LogMessage((object)message);
return;
}
if (level != "Log")
{
Debug.Log((object)("[" + level + "]: " + message));
}
else
{
Debug.Log((object)message);
}
}
}
}
namespace Olecheck.Scripts
{
public class PompaTrigger : MonoBehaviour
{
public ParticleSystem snowParticleSystem;
public float emissionDuration = 4f;
public void Pompa()
{
if (Random.Range(0f, 1f) <= 0.25f)
{
((MonoBehaviour)this).StartCoroutine(EmitSnow());
}
}
private void Start()
{
Transform transform = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/MonitorDoorPanel/BraunCharacter/Armature/mixamorig:Hips/mixamorig:Spine/mixamorig:Spine1/mixamorig:Spine2/mixamorig:RightShoulder/mixamorig:RightArm/mixamorig:RightForeArm/mixamorig:RightHand/Particle System").transform;
snowParticleSystem = ((Component)transform).GetComponent<ParticleSystem>();
if ((Object)(object)transform != (Object)null)
{
snowParticleSystem = ((Component)transform).GetComponent<ParticleSystem>();
}
else
{
Debug.LogError((object)"PompaTrigger: Nie znaleziono systemu cząsteczek na postaci");
}
if (snowParticleSystem.isPlaying)
{
snowParticleSystem.Stop();
}
}
private IEnumerator EmitSnow()
{
snowParticleSystem.Play();
yield return (object)new WaitForSeconds(emissionDuration);
snowParticleSystem.Stop();
}
}
public class RopePhysics : MonoBehaviour
{
public Transform startPoint;
public Transform endPoint;
public SkinnedMeshRenderer skinnedMeshRenderer;
public float jointSpring = 20f;
public float jointDamper = 5f;
private void Start()
{
startPoint = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/MonitorDoorPanel/BraunCharacter/Armature/mixamorig:Hips/mixamorig:Spine/mixamorig:Spine1/mixamorig:Spine2/mixamorig:LeftShoulder/mixamorig:LeftArm/mixamorig:LeftForeArm/mixamorig:LeftHand/p1").transform;
endPoint = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/MonitorDoorPanel/BraunCharacter/Armature/mixamorig:Hips/mixamorig:Spine/mixamorig:Spine1/mixamorig:Spine2/mixamorig:RightShoulder/mixamorig:RightArm/mixamorig:RightForeArm/mixamorig:RightHand/p2").transform;
Transform transform = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/MonitorDoorPanel/rope/Rope").transform;
if ((Object)(object)transform != (Object)null)
{
skinnedMeshRenderer = ((Component)transform).GetComponent<SkinnedMeshRenderer>();
}
else
{
Console.LogError("SkinnedMeshRenderer, startPoint lub endPoint nie zostały przypisane.(1)");
}
if ((Object)(object)skinnedMeshRenderer != (Object)null && (Object)(object)startPoint != (Object)null && (Object)(object)endPoint != (Object)null)
{
int boneCount = CountBones(skinnedMeshRenderer.rootBone);
SetupPhysics(skinnedMeshRenderer.rootBone, boneCount);
}
else
{
Console.LogError("SkinnedMeshRenderer, startPoint lub endPoint nie zostały przypisane.(2)");
}
}
private void SetupPhysics(Transform currentBone, int boneCount)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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_0083: Unknown result type (might be due to invalid IL or missing references)
Rigidbody val = ((Component)startPoint).GetComponent<Rigidbody>();
if ((Object)(object)val == (Object)null)
{
val = ((Component)startPoint).gameObject.AddComponent<Rigidbody>();
val.isKinematic = true;
}
float num = Vector3.Distance(startPoint.position, endPoint.position);
float boneLength = num / (float)boneCount;
int num2 = 0;
Transform val2 = null;
while ((Object)(object)currentBone != (Object)null)
{
float num3 = (float)num2 / (float)(boneCount - 1);
currentBone.position = Vector3.Lerp(startPoint.position, endPoint.position, num3);
Rigidbody val3 = ((Component)currentBone).gameObject.AddComponent<Rigidbody>();
val3.mass = 1f;
val3.collisionDetectionMode = (CollisionDetectionMode)2;
ConfigurableJoint val4 = ((Component)currentBone).gameObject.AddComponent<ConfigurableJoint>();
((Joint)val4).connectedBody = val;
ConfigureJoint(val4, boneLength);
val = val3;
val2 = currentBone;
currentBone = ((currentBone.childCount > 0) ? currentBone.GetChild(0) : null);
num2++;
}
if ((Object)(object)val2 != (Object)null)
{
Rigidbody val5 = ((Component)endPoint).GetComponent<Rigidbody>();
if ((Object)(object)val5 == (Object)null)
{
val5 = ((Component)endPoint).gameObject.AddComponent<Rigidbody>();
val5.isKinematic = true;
}
FixedJoint val6 = ((Component)val2).gameObject.AddComponent<FixedJoint>();
((Joint)val6).connectedBody = val5;
}
}
private void ConfigureJoint(ConfigurableJoint joint, float boneLength)
{
//IL_0034: 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_004c: 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_007c: 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)
joint.xMotion = (ConfigurableJointMotion)0;
joint.yMotion = (ConfigurableJointMotion)0;
joint.zMotion = (ConfigurableJointMotion)0;
joint.angularXMotion = (ConfigurableJointMotion)2;
joint.angularYMotion = (ConfigurableJointMotion)2;
joint.angularZMotion = (ConfigurableJointMotion)2;
SoftJointLimit linearLimit = default(SoftJointLimit);
((SoftJointLimit)(ref linearLimit)).limit = boneLength;
joint.linearLimit = linearLimit;
JointDrive val = default(JointDrive);
((JointDrive)(ref val)).positionSpring = jointSpring;
((JointDrive)(ref val)).positionDamper = jointDamper;
((JointDrive)(ref val)).maximumForce = float.PositiveInfinity;
JointDrive slerpDrive = val;
joint.slerpDrive = slerpDrive;
joint.rotationDriveMode = (RotationDriveMode)1;
}
private int CountBones(Transform bone)
{
int num = 0;
Transform val = bone;
while ((Object)(object)val != (Object)null)
{
num++;
val = ((val.childCount > 0) ? val.GetChild(0) : null);
}
return num;
}
}
public class RuraTrigger : MonoBehaviour
{
[SerializeField]
public AudioClip clip;
[SerializeField]
public AudioSource audioSource;
private void Awake()
{
if ((Object)(object)audioSource != (Object)null && (Object)(object)clip != (Object)null)
{
audioSource.clip = clip;
}
}
private void Rura()
{
audioSource.Stop();
audioSource.Play();
}
}
}
namespace Olecheck.Patches
{
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
private static AssetBundle assetBundle;
private static Transform MonitorWall;
private static Transform DoorPanel;
public static Transform MonitorDoorPanel;
private static Transform MonitorStartButton;
private static Transform MonitorStopButton;
private static InteractTrigger MonitorStartButtonTrigger;
private static InteractTrigger MonitorStopButtonTrigger;
private static GameObject CharacterPrefab;
private static GameObject RackPrefab;
private static GameObject RopePrefab;
private static Texture[] Textures;
private static Texture2D RackTexture;
private static Material[] Materials;
private static AnimationClip DancingAnimation;
private static RuntimeAnimatorController AnimatorController;
private static AudioClip RuraClip;
private static AudioClip ClickClip;
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void StartPatch()
{
LoadAssetBundle("model.braun");
GetObjectReferences();
if (!((Object)(object)MonitorWall == (Object)null) && !((Object)(object)DoorPanel == (Object)null))
{
CreateBraunCorner();
}
}
private static void GetObjectReferences()
{
MonitorWall = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall").transform;
if ((Object)(object)MonitorWall == (Object)null)
{
Console.LogError("Could not find MonitorWall");
}
else
{
DoorPanel = GameObject.Find("Environment/HangarShip/AnimatedShipDoor/HangarDoorButtonPanel").transform;
}
}
private static void LoadAssetBundle(string bundleName)
{
if ((Object)(object)assetBundle != (Object)null)
{
Console.LogInfo("Asset bundle already loaded!");
return;
}
assetBundle = AssetBundle.LoadFromFile(Path.Combine(Paths.PluginPath, bundleName));
CharacterPrefab = assetBundle.LoadAsset<GameObject>("Assets/braun.prefab");
RackPrefab = assetBundle.LoadAsset<GameObject>("Assets/rack.prefab");
RopePrefab = assetBundle.LoadAsset<GameObject>("Assets/rope.prefab");
AnimatorController = assetBundle.LoadAsset<RuntimeAnimatorController>("Assets/BraunAnimatorController.controller");
RackTexture = assetBundle.LoadAsset<Texture2D>("Assets/export.png");
Textures = (Texture[])(object)new Texture[10]
{
assetBundle.LoadAsset<Texture>("Assets/braunFace.png"),
assetBundle.LoadAsset<Texture>("Assets/Ch23_Body_Color_image.png"),
assetBundle.LoadAsset<Texture>("Assets/Ch23_Body_Color_image 1.png"),
assetBundle.LoadAsset<Texture>("Assets/Ch23_Body_Normal_image.png"),
assetBundle.LoadAsset<Texture>("Assets/Ch23_Body_Normal_image 1.png"),
assetBundle.LoadAsset<Texture>("Assets/Ch23_hair_Base_color_image.png"),
assetBundle.LoadAsset<Texture>("Assets/Ch23_hair_Base_color_image 1.png"),
assetBundle.LoadAsset<Texture>("Assets/export.png"),
assetBundle.LoadAsset<Texture>("Assets/FireExtinguisher_D.png"),
assetBundle.LoadAsset<Texture>("Assets/FireExtinguisher_N.png")
};
Materials = (Material[])(object)new Material[5]
{
assetBundle.LoadAsset<Material>("Assets/BraunMaterial.mat"),
assetBundle.LoadAsset<Material>("Assets/Ch23_body.mat"),
assetBundle.LoadAsset<Material>("Assets/Ch23_hair.mat"),
assetBundle.LoadAsset<Material>("Assets/GasnicaHandle.mat"),
assetBundle.LoadAsset<Material>("Assets/GasnicaMaterial.mat")
};
DancingAnimation = assetBundle.LoadAsset<AnimationClip>("Assets/DancingBraun.anim");
RuraClip = assetBundle.LoadAsset<AudioClip>("Assets/rura.mp3");
ClickClip = assetBundle.LoadAsset<AudioClip>("Assets/click.mp3");
}
private static void CreateBraunCorner()
{
//IL_006b: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: 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_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: 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_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)MonitorWall.Find("MonitorDoorPanel") != (Object)null)
{
Console.LogError("MonitorDoorPanel already exists");
return;
}
MonitorDoorPanel = Object.Instantiate<Transform>(DoorPanel, MonitorWall);
((Object)MonitorDoorPanel).name = "MonitorDoorPanel";
MonitorDoorPanel.localPosition = new Vector3(-0.05f, -1.71f, 0.18f);
MonitorDoorPanel.localEulerAngles = new Vector3(90f, 81f, 0f);
Transform val = MonitorDoorPanel.Find("StartButton");
Transform val2 = MonitorDoorPanel.Find("StopButton");
val.position = new Vector3(10.25f, 2.16f, -13f);
val.localPosition = new Vector3(0.39f, 0.47f, -0.55f);
val.localScale = new Vector3(-0.78f, -0.78f, -0.81f);
val2.position = new Vector3(10.25f, 2.16f, -13.17f);
val2.localPosition = new Vector3(0.25f, 0.47f, -0.55f);
val2.localScale = new Vector3(-0.78f, -0.78f, -0.81f);
MeshRenderer component = ((Component)MonitorDoorPanel).GetComponent<MeshRenderer>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
Animator component2 = ((Component)MonitorDoorPanel).GetComponent<Animator>();
if ((Object)(object)component2 != (Object)null)
{
((Behaviour)component2).enabled = false;
}
Transform val3 = MonitorDoorPanel.Find("ElevatorPanelScreen");
if ((Object)(object)val3 != (Object)null)
{
Object.Destroy((Object)(object)((Component)val3).gameObject);
}
GameObject characterInstance = Object.Instantiate<GameObject>(CharacterPrefab, ((Component)MonitorDoorPanel).transform);
((Object)characterInstance).name = "BraunCharacter";
characterInstance.transform.localPosition = new Vector3(0.3f, 0.2f, -0.38f);
characterInstance.transform.eulerAngles = new Vector3(0f, 90f, 180f);
RuraTrigger ruraTrigger = characterInstance.AddComponent<RuraTrigger>();
ruraTrigger.clip = RuraClip;
ruraTrigger.audioSource = characterInstance.GetComponent<AudioSource>();
PompaTrigger pompaTrigger = characterInstance.AddComponent<PompaTrigger>();
Animator characterAnimator = characterInstance.GetComponent<Animator>();
characterAnimator.speed = 0f;
GameObject val4 = Object.Instantiate<GameObject>(RopePrefab, ((Component)MonitorDoorPanel).transform);
((Object)val4).name = "rope";
val4.transform.localPosition = new Vector3(0.3f, 0.2f, -0.38f);
val4.transform.eulerAngles = new Vector3(0f, 90f, 180f);
RopePhysics ropePhysics = characterInstance.AddComponent<RopePhysics>();
GameObject val5 = Object.Instantiate<GameObject>(RackPrefab, ((Component)MonitorDoorPanel).transform);
((Object)val5).name = "BraunRack";
val5.transform.localPosition = new Vector3(0.32f, 0.23f, -0.5f);
val5.transform.eulerAngles = new Vector3(90f, 270f, 0f);
MeshRenderer component3 = val5.GetComponent<MeshRenderer>();
if ((Object)(object)component3 != (Object)null && (Object)(object)((Renderer)component3).material != (Object)null && (Object)(object)RackTexture != (Object)null)
{
((Renderer)component3).material.mainTexture = (Texture)(object)RackTexture;
}
else
{
Console.LogError("MeshRenderer or Material or Texture not found on rackInstance");
}
MonitorStartButton = MonitorDoorPanel.Find("StartButton").Find("Cube (2)");
MonitorStopButton = MonitorDoorPanel.Find("StopButton").Find("Cube (3)");
MonitorStartButtonTrigger = ((Component)MonitorStartButton).GetComponent<InteractTrigger>();
MonitorStopButtonTrigger = ((Component)MonitorStopButton).GetComponent<InteractTrigger>();
MonitorStartButtonTrigger.hoverTip = "Go! : [E]";
MonitorStartButtonTrigger.holdTip = "Go! : [E]";
MonitorStopButtonTrigger.hoverTip = "Hold up! : [E]";
MonitorStopButtonTrigger.holdTip = "Hold up! : [E]";
((UnityEvent<PlayerControllerB>)(object)MonitorStartButtonTrigger.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate
{
HUDManager.Instance.UIAudio.PlayOneShot(ClickClip);
AudioSource component5 = characterInstance.GetComponent<AudioSource>();
if ((Object)(object)component5 != (Object)null && !component5.isPlaying)
{
component5.Play();
}
if ((Object)(object)characterAnimator != (Object)null)
{
characterAnimator.speed = 1f;
}
});
((UnityEvent<PlayerControllerB>)(object)MonitorStopButtonTrigger.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate
{
HUDManager.Instance.UIAudio.PlayOneShot(ClickClip);
AudioSource component4 = characterInstance.GetComponent<AudioSource>();
if ((Object)(object)component4 != (Object)null && component4.isPlaying)
{
component4.Pause();
}
if ((Object)(object)characterAnimator != (Object)null)
{
characterAnimator.speed = 0f;
}
});
}
}
}