using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using CWSurfaceCameraRescue.Hooks;
using Microsoft.CodeAnalysis;
using On;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;
[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: AssemblyCompany("com.yourname.cw.surfacecamerarescue")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("com.yourname.cw.surfacecamerarescue")]
[assembly: AssemblyTitle("com.yourname.cw.surfacecamerarescue")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 CWSurfaceCameraRescue
{
internal static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.yourname.cw.surfacecamerarescue";
public const string PLUGIN_NAME = "CW Surface Camera Rescue";
public const string PLUGIN_VERSION = "0.1.0";
}
[ContentWarningPlugin("com.yourname.cw.surfacecamerarescue", "CW Surface Camera Rescue", false)]
[BepInPlugin("com.yourname.cw.surfacecamerarescue", "CW Surface Camera Rescue", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <SpawnRecoveredCamerasRoutine>d__20 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private int <total>5__1;
private int <index>5__2;
private float <waited>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SpawnRecoveredCamerasRoutine>d__20(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
goto IL_00be;
}
<>1__state = -1;
<total>5__1 = <>4__this.PreservedCameras.Count;
Log.LogInfo((object)$"SpawnRecoveredCamerasRoutine: Spawne {<total>5__1} Kamera(s)");
<index>5__2 = <total>5__1;
goto IL_00fb;
IL_00be:
if (<>4__this.PreservedCameras.Count == <index>5__2 && <waited>5__3 < 10f)
{
<waited>5__3 += 0.5f;
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
}
<index>5__2--;
goto IL_00fb;
IL_00fb:
if (<index>5__2 > 0)
{
<>4__this.SpawnSingleRecoveredCamera(<index>5__2);
<waited>5__3 = 0f;
goto IL_00be;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <TrySpawnOnSurfaceAfterDelay>d__13 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TrySpawnOnSurfaceAfterDelay>d__13(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Invalid comparison between Unknown and I4
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Log.LogInfo((object)$"TrySpawnOnSurfaceAfterDelay: TimeOfDay={TimeOfDayHandler.TimeOfDay} Queue={<>4__this.PreservedCameras.Count}");
if ((int)TimeOfDayHandler.TimeOfDay == 10 && <>4__this.HasPreservedCameras())
{
<>4__this.SpawnRecoveredCameras();
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
internal static ManualLogSource Log = null;
internal const byte VideoCameraItemId = 1;
internal static readonly Vector3 BaseSpawnPosition = new Vector3(-14.805f, 2.418f, 8.896f);
internal static readonly Quaternion BaseSpawnRotation = Quaternion.Euler(0f, 315f, 0f);
internal const float SpawnOffsetPerCamera = 0.487f;
internal readonly Queue<ItemInstanceData> PreservedCameras = new Queue<ItemInstanceData>();
internal static Plugin Instance { get; private set; } = null;
private void Awake()
{
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
PlayerPatch.Init();
VideoCameraPatch.Init();
SceneManager.sceneLoaded += OnSceneLoaded;
Log.LogInfo((object)"[CW Surface Camera Rescue] loaded");
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
Log.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name));
if (((Scene)(ref scene)).name == "SurfaceScene")
{
((MonoBehaviour)this).StartCoroutine(TrySpawnOnSurfaceAfterDelay());
}
}
[IteratorStateMachine(typeof(<TrySpawnOnSurfaceAfterDelay>d__13))]
private IEnumerator TrySpawnOnSurfaceAfterDelay()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TrySpawnOnSurfaceAfterDelay>d__13(0)
{
<>4__this = this
};
}
internal void PreserveCamera(ItemInstanceData instanceData)
{
VideoInfoEntry val = default(VideoInfoEntry);
if (!instanceData.TryGetEntry<VideoInfoEntry>(ref val))
{
Log.LogInfo((object)"PreserveCamera: Kamera hat keinen VideoInfoEntry");
return;
}
Log.LogInfo((object)$"PreserveCamera: VideoID={val.videoID.id}");
PreservedCameras.Enqueue(instanceData);
}
internal bool HasPreservedCameras()
{
return PreservedCameras.Count > 0;
}
internal ItemInstanceData? PeekPreservedCamera()
{
return (PreservedCameras.Count > 0) ? PreservedCameras.Peek() : null;
}
internal void ConsumePreservedCamera()
{
if (PreservedCameras.Count > 0)
{
PreservedCameras.Dequeue();
}
}
internal void ClearPreservedCameras()
{
Log.LogInfo((object)"ClearPreservedCameras");
PreservedCameras.Clear();
}
internal void SpawnRecoveredCameras()
{
if (!HasPreservedCameras())
{
Log.LogInfo((object)"SpawnRecoveredCameras: Queue leer");
}
else
{
((MonoBehaviour)this).StartCoroutine(SpawnRecoveredCamerasRoutine());
}
}
[IteratorStateMachine(typeof(<SpawnRecoveredCamerasRoutine>d__20))]
private IEnumerator SpawnRecoveredCamerasRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SpawnRecoveredCamerasRoutine>d__20(0)
{
<>4__this = this
};
}
private void SpawnSingleRecoveredCamera(int cameraNumber)
{
//IL_003d: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
float num = (float)cameraNumber * 0.487f;
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(BaseSpawnPosition.x - num, BaseSpawnPosition.y, BaseSpawnPosition.z - num);
Log.LogInfo((object)$"SpawnSingleRecoveredCamera: {val}");
PickupHandler.CreatePickup((byte)1, new ItemInstanceData(Guid.NewGuid()), val, BaseSpawnRotation);
}
}
}
namespace CWSurfaceCameraRescue.Hooks
{
internal static class PlayerPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_RPCA_PlayerDie <0>__OnPlayerDie;
}
internal static void Init()
{
//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_001c: Expected O, but got Unknown
object obj = <>O.<0>__OnPlayerDie;
if (obj == null)
{
hook_RPCA_PlayerDie val = OnPlayerDie;
<>O.<0>__OnPlayerDie = val;
obj = (object)val;
}
Player.RPCA_PlayerDie += (hook_RPCA_PlayerDie)obj;
}
private static void OnPlayerDie(orig_RPCA_PlayerDie orig, Player self)
{
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: 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)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
Plugin.Log.LogInfo((object)"HOOK: RPCA_PlayerDie wurde aufgerufen");
try
{
if ((Object)(object)self != (Object)null && self.refs != null && (Object)(object)self.refs.view != (Object)null && self.refs.view.IsMine)
{
Plugin.Log.LogInfo((object)"RPCA_PlayerDie: lokaler Spieler gestorben");
PlayerInventory val = default(PlayerInventory);
if (self.TryGetInventory(ref val))
{
List<ItemDescriptor> items = val.GetItems();
Plugin.Log.LogInfo((object)$"RPCA_PlayerDie: Inventar hat {items.Count} Item(s)");
foreach (ItemDescriptor item in items)
{
string text = (((Object)(object)item.item != (Object)null) ? ((Object)item.item).name : "NULL");
Plugin.Log.LogInfo((object)("RPCA_PlayerDie: Inventar-Item = " + text));
if ((Object)(object)item.item != (Object)null && ((Object)item.item).name != null && ((Object)item.item).name.ToLower().Contains("camera"))
{
Plugin.Log.LogInfo((object)"RPCA_PlayerDie: Kamera im Inventar gefunden -> retten");
Plugin.Instance.PreserveCamera(item.data);
}
}
}
else
{
Plugin.Log.LogInfo((object)"RPCA_PlayerDie: Kein Inventory gefunden");
}
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("RPCA_PlayerDie Hook Fehler: " + ex));
}
orig.Invoke(self);
}
}
internal static class VideoCameraPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_ConfigItem <0>__OnConfigItem;
}
internal static void Init()
{
//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_001c: Expected O, but got Unknown
object obj = <>O.<0>__OnConfigItem;
if (obj == null)
{
hook_ConfigItem val = OnConfigItem;
<>O.<0>__OnConfigItem = val;
obj = (object)val;
}
VideoCamera.ConfigItem += (hook_ConfigItem)obj;
}
private static void OnConfigItem(orig_ConfigItem orig, VideoCamera self, ItemInstanceData data, PhotonView playerView)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
bool flag = (int)TimeOfDayHandler.TimeOfDay == 10;
VideoInfoEntry val = default(VideoInfoEntry);
bool flag2 = data.TryGetEntry<VideoInfoEntry>(ref val);
bool flag3 = flag2 && val.videoID.id != Guid.Empty;
Plugin.Log.LogInfo((object)$"HOOK: OnConfigItem | isEvening={flag} | hasVideoInfo={flag2} | hasValidFootage={flag3} | queue={Plugin.Instance.PreservedCameras.Count}");
if (flag && !flag3 && Plugin.Instance.HasPreservedCameras())
{
ItemInstanceData val2 = Plugin.Instance.PeekPreservedCamera();
VideoInfoEntry val3 = default(VideoInfoEntry);
if (val2 != null && val2.TryGetEntry<VideoInfoEntry>(ref val3) && val3.videoID.id != Guid.Empty)
{
data.AddDataEntry((ItemDataEntry)(object)val3);
Plugin.Instance.ConsumePreservedCamera();
Plugin.Log.LogInfo((object)$"Restored footage {val3.videoID.id} onto spawned surface camera");
}
}
orig.Invoke(self, data, playerView);
}
}
}