using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.RegularExpressions;
using BHCamera;
using BHCamera.Patches;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LC_API.BundleAPI;
using LethalLib.Modules;
using Unity.Collections;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
internal class <Module>
{
static <Module>()
{
}
}
public class CameraPluginConfig : SyncedInstance<CameraPluginConfig>
{
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct ImageSettings
{
public TextureFormat ImageFormat => (TextureFormat)3;
public int ImageResolution => 256;
}
private static ConfigEntry<string> _configImageFormat;
private static ConfigEntry<int> _configPhotoResolution;
private static ConfigEntry<string> _configRateLimit;
private static ConfigEntry<int> _configCameraPrice;
public ImageSettings imageSettings;
private string rateLimit;
public int cameraPrice => 50;
public float RateLimit
{
get
{
string input = NormalizeConfigValue(rateLimit);
string s = Regex.Replace(input, "[0-9]*", "");
string text = Regex.Replace(input, "[^0-9]*", "").ToLower();
int num = int.Parse(s);
int num2 = 1;
switch (text)
{
case "mb":
num2 = 1000000;
break;
case "kb":
num2 = 1000;
break;
default:
CameraPlugin.Log.LogError((object)("Invalid Suffix for Rate Limit Given: " + text + " Defaulting to b"));
break;
case "b":
break;
}
return num * num2;
}
}
public CameraPluginConfig()
{
InitInstance(this);
}
public void SetUp(CameraPlugin instance)
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
_configImageFormat = ((BaseUnityPlugin)instance).Config.Bind<string>("Image Settings", "ImageFormat", "RGB24", "Use Unity's built-in TextureFormat for potential values. This will have heavy effects on the performance");
_configPhotoResolution = ((BaseUnityPlugin)instance).Config.Bind<int>("Image Settings", "ImageResolution", 64, "The resolution of the images taken by a camera. Changing this will break all existing images");
_configRateLimit = ((BaseUnityPlugin)instance).Config.Bind<string>("Network Settings", "RateLimit", "", "WIP. Unused. use b (bytes), kb (kilobytes), or mb (megabytes). Leaving it blank will leave the rate limit unbounded");
_configCameraPrice = ((BaseUnityPlugin)instance).Config.Bind<int>("General Settings", "CameraPrice", 50, "The price that shows up on the store");
if (!Enum.TryParse<TextureFormat>(NormalizeConfigValue(_configImageFormat.Value), out TextureFormat result))
{
CameraPlugin.Log.LogError((object)"Invalid Setting for Image Format. Defaulting to R8.");
result = (TextureFormat)63;
}
rateLimit = _configRateLimit.Value;
}
private static string NormalizeConfigValue(string value)
{
return value.Trim();
}
public static void RequestSync()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if (!SyncedInstance<CameraPluginConfig>.IsClient)
{
return;
}
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(SyncedInstance<CameraPluginConfig>.IntSize, (Allocator)2, -1);
try
{
SyncedInstance<CameraPluginConfig>.MessageManager.SendNamedMessage("PolaroidCamera_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
}
finally
{
((IDisposable)(FastBufferWriter)(ref val)).Dispose();
}
}
public static void OnRequestSync(ulong clientId, FastBufferReader _)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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 (!SyncedInstance<CameraPluginConfig>.IsHost)
{
return;
}
CameraPlugin.Log.LogInfo((object)$"Config sync request received from client: {clientId}");
byte[] array = SyncedInstance<CameraPluginConfig>.SerializeToBytes(SyncedInstance<CameraPluginConfig>.Instance);
int num = array.Length;
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<CameraPluginConfig>.IntSize, (Allocator)2, -1);
try
{
((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
SyncedInstance<CameraPluginConfig>.MessageManager.SendNamedMessage("PolaroidCamera_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
}
catch (Exception arg)
{
CameraPlugin.Log.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
}
finally
{
((IDisposable)(FastBufferWriter)(ref val)).Dispose();
}
}
public static void OnReceiveSync(ulong _, FastBufferReader reader)
{
//IL_0024: 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)
if (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<CameraPluginConfig>.IntSize))
{
CameraPlugin.Log.LogError((object)"Config sync error: Could not begin reading buffer.");
return;
}
int num = default(int);
((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
{
CameraPlugin.Log.LogError((object)"Config sync error: Host could not sync.");
return;
}
byte[] data = new byte[num];
((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
SyncedInstance<CameraPluginConfig>.SyncInstance(data);
CameraPlugin.Log.LogInfo((object)"Successfully synced config with host.");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
public static void InitializeLocalPlayer()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
if (SyncedInstance<CameraPluginConfig>.IsHost)
{
SyncedInstance<CameraPluginConfig>.MessageManager.RegisterNamedMessageHandler("PolaroidCamera_OnRequestConfigSync", new HandleNamedMessageDelegate(OnRequestSync));
SyncedInstance<CameraPluginConfig>.Synced = true;
}
else
{
SyncedInstance<CameraPluginConfig>.Synced = false;
SyncedInstance<CameraPluginConfig>.MessageManager.RegisterNamedMessageHandler("PolaroidCamera_OnReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveSync));
RequestSync();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
public static void PlayerLeave()
{
SyncedInstance<CameraPluginConfig>.RevertSync();
CameraImageRegistry.GetInstance().Reset();
}
}
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
private struct MonoScriptData
{
public byte[] FilePathsData;
public byte[] TypesData;
public int TotalTypes;
public int TotalFiles;
public bool IsEditorOnly;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static MonoScriptData Get()
{
MonoScriptData result = default(MonoScriptData);
result.FilePathsData = new byte[522]
{
0, 0, 0, 1, 0, 0, 0, 59, 92, 65,
115, 115, 101, 116, 115, 92, 67, 97, 109, 101,
114, 97, 92, 65, 115, 115, 101, 109, 98, 108,
105, 101, 115, 92, 67, 97, 109, 101, 114, 97,
67, 111, 114, 101, 92, 67, 97, 109, 101, 114,
97, 73, 109, 97, 103, 101, 82, 101, 103, 105,
115, 116, 114, 121, 46, 99, 115, 0, 0, 0,
1, 0, 0, 0, 50, 92, 65, 115, 115, 101,
116, 115, 92, 67, 97, 109, 101, 114, 97, 92,
65, 115, 115, 101, 109, 98, 108, 105, 101, 115,
92, 67, 97, 109, 101, 114, 97, 67, 111, 114,
101, 92, 67, 97, 109, 101, 114, 97, 73, 116,
101, 109, 46, 99, 115, 0, 0, 0, 3, 0,
0, 0, 52, 92, 65, 115, 115, 101, 116, 115,
92, 67, 97, 109, 101, 114, 97, 92, 65, 115,
115, 101, 109, 98, 108, 105, 101, 115, 92, 67,
97, 109, 101, 114, 97, 67, 111, 114, 101, 92,
67, 97, 109, 101, 114, 97, 80, 108, 117, 103,
105, 110, 46, 99, 115, 0, 0, 0, 1, 0,
0, 0, 72, 92, 65, 115, 115, 101, 116, 115,
92, 67, 97, 109, 101, 114, 97, 92, 65, 115,
115, 101, 109, 98, 108, 105, 101, 115, 92, 67,
97, 109, 101, 114, 97, 67, 111, 114, 101, 92,
80, 97, 116, 99, 104, 101, 115, 92, 71, 97,
109, 101, 78, 101, 116, 119, 111, 114, 107, 77,
97, 110, 97, 103, 101, 114, 95, 80, 97, 116,
99, 104, 46, 99, 115, 0, 0, 0, 1, 0,
0, 0, 71, 92, 65, 115, 115, 101, 116, 115,
92, 67, 97, 109, 101, 114, 97, 92, 65, 115,
115, 101, 109, 98, 108, 105, 101, 115, 92, 67,
97, 109, 101, 114, 97, 67, 111, 114, 101, 92,
80, 97, 116, 99, 104, 101, 115, 92, 80, 108,
97, 121, 101, 114, 67, 111, 110, 116, 114, 111,
108, 108, 101, 114, 66, 95, 80, 97, 116, 99,
104, 46, 99, 115, 0, 0, 0, 1, 0, 0,
0, 49, 92, 65, 115, 115, 101, 116, 115, 92,
67, 97, 109, 101, 114, 97, 92, 65, 115, 115,
101, 109, 98, 108, 105, 101, 115, 92, 67, 97,
109, 101, 114, 97, 67, 111, 114, 101, 92, 80,
104, 111, 116, 111, 73, 116, 101, 109, 46, 99,
115, 0, 0, 0, 1, 0, 0, 0, 51, 92,
65, 115, 115, 101, 116, 115, 92, 67, 97, 109,
101, 114, 97, 92, 65, 115, 115, 101, 109, 98,
108, 105, 101, 115, 92, 67, 97, 109, 101, 114,
97, 67, 111, 114, 101, 92, 83, 99, 114, 97,
112, 76, 111, 97, 100, 101, 114, 46, 99, 115,
0, 0, 0, 1, 0, 0, 0, 54, 92, 65,
115, 115, 101, 116, 115, 92, 67, 97, 109, 101,
114, 97, 92, 65, 115, 115, 101, 109, 98, 108,
105, 101, 115, 92, 67, 97, 109, 101, 114, 97,
67, 111, 114, 101, 92, 83, 121, 110, 99, 101,
100, 73, 110, 115, 116, 97, 110, 99, 101, 46,
99, 115
};
result.TypesData = new byte[311]
{
0, 0, 0, 0, 28, 66, 72, 67, 97, 109,
101, 114, 97, 124, 67, 97, 109, 101, 114, 97,
73, 109, 97, 103, 101, 82, 101, 103, 105, 115,
116, 114, 121, 0, 0, 0, 0, 19, 66, 72,
67, 97, 109, 101, 114, 97, 124, 67, 97, 109,
101, 114, 97, 73, 116, 101, 109, 0, 0, 0,
0, 21, 66, 72, 67, 97, 109, 101, 114, 97,
124, 67, 97, 109, 101, 114, 97, 80, 108, 117,
103, 105, 110, 0, 0, 0, 0, 19, 124, 67,
97, 109, 101, 114, 97, 80, 108, 117, 103, 105,
110, 67, 111, 110, 102, 105, 103, 0, 0, 0,
0, 32, 67, 97, 109, 101, 114, 97, 80, 108,
117, 103, 105, 110, 67, 111, 110, 102, 105, 103,
124, 73, 109, 97, 103, 101, 83, 101, 116, 116,
105, 110, 103, 115, 0, 0, 0, 0, 41, 66,
72, 67, 97, 109, 101, 114, 97, 46, 80, 97,
116, 99, 104, 101, 115, 124, 71, 97, 109, 101,
78, 101, 116, 119, 111, 114, 107, 77, 97, 110,
97, 103, 101, 114, 95, 80, 97, 116, 99, 104,
0, 0, 0, 0, 40, 66, 72, 67, 97, 109,
101, 114, 97, 46, 80, 97, 116, 99, 104, 101,
115, 124, 80, 108, 97, 121, 101, 114, 67, 111,
110, 116, 114, 111, 108, 108, 101, 114, 66, 95,
80, 97, 116, 99, 104, 0, 0, 0, 0, 18,
66, 72, 67, 97, 109, 101, 114, 97, 124, 80,
104, 111, 116, 111, 73, 116, 101, 109, 0, 0,
0, 0, 20, 66, 72, 67, 97, 109, 101, 114,
97, 124, 83, 99, 114, 97, 112, 76, 111, 97,
100, 101, 114, 0, 0, 0, 0, 23, 66, 72,
67, 97, 109, 101, 114, 97, 124, 83, 121, 110,
99, 101, 100, 73, 110, 115, 116, 97, 110, 99,
101
};
result.TotalFiles = 8;
result.TotalTypes = 10;
result.IsEditorOnly = false;
return result;
}
}
namespace BHCamera
{
public class CameraImageRegistry
{
private static CameraImageRegistry instance;
private int _nextId = 1;
private readonly Dictionary<int, byte[]> _imageRegistry;
public byte[] this[int index]
{
get
{
return _imageRegistry[index];
}
set
{
RegisterImage(value, index);
}
}
public static CameraImageRegistry GetInstance()
{
return instance ?? (instance = new CameraImageRegistry());
}
private CameraImageRegistry()
{
_imageRegistry = new Dictionary<int, byte[]>();
Reset();
}
public void Reset()
{
_imageRegistry.Clear();
_nextId = 1;
}
public void LoadImagesFromSave()
{
string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
string[] files = ES3.GetFiles("photos/" + currentSaveFileName);
int num = 0;
string[] array = files;
foreach (string text in array)
{
int num2 = int.Parse(Regex.Replace(text, "[^0-9]", ""));
num = Math.Max(num, num2);
int imageResolution = CameraPlugin.CameraConfig.imageSettings.ImageResolution;
byte[] value = new byte[imageResolution * imageResolution];
try
{
value = ES3.LoadImage("photos/" + text).GetRawTextureData();
}
catch (Exception ex)
{
string text2 = "Failed to load " + text;
CameraPlugin.Log.LogError((object)text2);
CameraPlugin.Log.LogError((object)ex);
}
_imageRegistry[num2] = value;
}
_nextId = num + 1;
}
public void LoadImageFromSave(int id)
{
string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
int imageResolution = CameraPlugin.CameraConfig.imageSettings.ImageResolution;
byte[] value = new byte[imageResolution * imageResolution];
string text = "photos/" + currentSaveFileName + "/Photo_" + id + ".raw";
try
{
value = ES3.LoadRawBytes(text);
}
catch (Exception ex)
{
string text2 = "Failed to load " + text;
CameraPlugin.Log.LogError((object)text2);
CameraPlugin.Log.LogError((object)ex);
}
_imageRegistry[id] = value;
}
public void SaveImages()
{
foreach (KeyValuePair<int, byte[]> item in _imageRegistry)
{
ES3.SaveRaw(item.Value, "photos/" + GameNetworkManager.Instance.currentSaveFileName + "/Photo_" + item.Key + ".raw");
}
}
public void SaveImage(int id)
{
ES3.SaveRaw(_imageRegistry[id], "photos/" + GameNetworkManager.Instance.currentSaveFileName + "/Photo_" + id + ".raw");
}
public int RegisterImage(byte[] imageData, int? index = null)
{
int result;
if (index.HasValue)
{
result = index.Value;
_imageRegistry[index.Value] = imageData;
}
else
{
while (_imageRegistry.ContainsKey(_nextId))
{
_nextId++;
}
result = _nextId;
_imageRegistry[_nextId] = imageData;
}
return result;
}
public bool has(int index)
{
return _imageRegistry.ContainsKey(index);
}
}
public class CameraItem : GrabbableObject
{
public float renderDistance;
private RenderTexture _cameraViewTexture;
private Camera camera;
private Light flashBulb;
private static readonly int MainTexture = Shader.PropertyToID("MainTex");
private static CameraPluginConfig.ImageSettings _imageSettings = CameraPlugin.CameraConfig.imageSettings;
private float flashTimeout = 1f;
public float[] flashSequence = new float[3] { 0.1f, 0.1f, 0.5f };
private bool dropFlash;
public MeshRenderer flashIndicator;
private PlayerControllerB previousPlayerHeldBy;
private AudioClip photoClick;
private AudioSource cameraAudio;
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
_ = ((NetworkBehaviour)this).IsServer;
int imageResolution = _imageSettings.ImageResolution;
_cameraViewTexture = new RenderTexture(imageResolution, imageResolution, 24);
((Texture)_cameraViewTexture).filterMode = (FilterMode)0;
camera = ((Component)this).GetComponentInChildren<Camera>();
flashBulb = ((Component)this).GetComponentInChildren<Light>();
((Behaviour)flashBulb).enabled = false;
photoClick = ScrapLoader.loadedAudio["cameraClick"];
cameraAudio = ((Component)this).GetComponent<AudioSource>();
}
public override void GrabItem()
{
((GrabbableObject)this).GrabItem();
previousPlayerHeldBy = base.playerHeldBy;
}
public override void Start()
{
((GrabbableObject)this).Start();
camera.Render();
if (!_cameraViewTexture.IsCreated())
{
_cameraViewTexture.Create();
}
((Renderer)((Component)((Component)this).transform.Find("Screen")).GetComponent<MeshRenderer>()).material.SetTexture(MainTexture, (Texture)(object)_cameraViewTexture);
((Renderer)((Component)((Component)this).transform.Find("Screen")).GetComponent<MeshRenderer>()).material.mainTexture = (Texture)(object)_cameraViewTexture;
camera.targetTexture = _cameraViewTexture;
camera.cullingMask = 20649983;
camera.farClipPlane = renderDistance;
camera.nearClipPlane = 0.55f;
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (buttonDown && base.insertedBattery.charge > 0f)
{
dropFlash = true;
((MonoBehaviour)this).StartCoroutine(flashLight());
((MonoBehaviour)this).StartCoroutine(doNextFrame(TakePicture));
}
}
public override void Update()
{
((GrabbableObject)this).Update();
if (base.isHeld && !base.isHeldByEnemy)
{
camera.Render();
}
}
public override void OnDestroy()
{
((NetworkBehaviour)this).OnDestroy();
}
private void TakePicture()
{
//IL_0010: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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)
int imageResolution = _imageSettings.ImageResolution;
Texture2D val = new Texture2D(imageResolution, imageResolution, _imageSettings.ImageFormat, false)
{
filterMode = (FilterMode)0
};
RenderTexture active = RenderTexture.active;
RenderTexture.active = _cameraViewTexture;
val.ReadPixels(new Rect(0f, 0f, (float)((Texture)_cameraViewTexture).width, (float)((Texture)_cameraViewTexture).height), 0, 0);
val.Apply();
RenderTexture.active = active;
byte[] rawTextureData = val.GetRawTextureData();
CameraPlugin.Log.LogInfo((object)("Number of Bytes: " + rawTextureData.Length));
TakePicture_ServerRpc(rawTextureData);
}
[ServerRpc(RequireOwnership = false)]
private void TakePicture_ServerRpc(byte[] imageData)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Invalid comparison between Unknown and I4
//IL_005f: 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)
//IL_006d: 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_008e: 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_00ac: 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_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3286540989u, val, (RpcDelivery)0);
bool flag = imageData != null;
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(imageData, default(ForPrimitives));
}
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3286540989u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ((NetworkBehaviour)this).IsHost)
{
int num = CameraImageRegistry.GetInstance().RegisterImage(imageData);
CameraImageRegistry.GetInstance().SaveImage(num);
CameraPlugin.Log.LogInfo((object)("Uploaded Image to Server: " + num));
CameraPlugin.Log.LogInfo((object)("Number of Bytes: " + imageData.Length));
Vector3 val3 = ((Component)this).transform.position + Vector3.up * 0.25f;
Transform val4 = ((((!((Object)(object)base.playerHeldBy != (Object)null) || !base.playerHeldBy.isInElevator) && !StartOfRound.Instance.inShipPhase) || !((Object)(object)RoundManager.Instance.spawnedScrapContainer != (Object)null)) ? StartOfRound.Instance.elevatorTransform : StartOfRound.Instance.elevatorTransform);
GameObject obj = Object.Instantiate<GameObject>(ScrapLoader.loadedItems["photo"].spawnPrefab, val3, Quaternion.identity, val4);
PhotoItem component = obj.GetComponent<PhotoItem>();
((GrabbableObject)component).hasHitGround = false;
GrabbableObject component2 = obj.GetComponent<GrabbableObject>();
component2.startFallingPosition = val3;
component2.targetFloorPosition = component2.GetItemFloorPosition(((Component)this).transform.position);
if ((Object)(object)previousPlayerHeldBy != (Object)null && previousPlayerHeldBy.isInHangarShipRoom)
{
previousPlayerHeldBy.SetItemInElevator(true, true, component2);
}
((NetworkBehaviour)component2).NetworkObject.Spawn(false);
component.photoID.Value = num;
SpawnPhotoClientRpc(NetworkObjectReference.op_Implicit(((Component)this).gameObject.GetComponent<NetworkObject>()), val3);
FlashCamera_ClientRpc(Time.time);
}
}
[ClientRpc]
public void SpawnPhotoClientRpc(NetworkObjectReference netObjectRef, Vector3 startFallingPos)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Invalid comparison between Unknown and I4
//IL_005f: 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)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3765346262u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
((FastBufferWriter)(ref val2)).WriteValueSafe(ref startFallingPos);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3765346262u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
if ((Object)(object)base.playerHeldBy != (Object)null)
{
base.playerHeldBy.activatingItem = false;
}
if (!((NetworkBehaviour)this).IsServer)
{
cameraAudio.PlayOneShot(photoClick);
((MonoBehaviour)this).StartCoroutine(waitForPhotoToSpawnOnClient(netObjectRef, startFallingPos));
}
}
}
private IEnumerator waitForPhotoToSpawnOnClient(NetworkObjectReference netObjectRef, Vector3 startFallingPos)
{
//IL_000e: 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: 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)
NetworkObject netObject = null;
float startTime = Time.realtimeSinceStartup;
while ((double)Time.realtimeSinceStartup - (double)startTime < 8.0 && !((NetworkObjectReference)(ref netObjectRef)).TryGet(ref netObject, (NetworkManager)null))
{
yield return (object)new WaitForSeconds(0.03f);
}
if ((Object)(object)netObject == (Object)null)
{
Debug.Log((object)"No network object found");
yield break;
}
yield return (object)new WaitForEndOfFrame();
GrabbableObject component = ((Component)netObject).GetComponent<GrabbableObject>();
component.startFallingPosition = startFallingPos;
component.fallTime = 0f;
component.hasHitGround = false;
component.reachedFloorTarget = false;
if ((Object)(object)previousPlayerHeldBy != (Object)null && previousPlayerHeldBy.isInHangarShipRoom)
{
previousPlayerHeldBy.SetItemInElevator(true, true, component);
}
}
[ClientRpc]
private void FlashCamera_ClientRpc(float time)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Invalid comparison between Unknown and I4
//IL_005f: 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)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4245448909u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref time, default(ForPrimitives));
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4245448909u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && Time.time < time + flashTimeout && !dropFlash)
{
((MonoBehaviour)this).StartCoroutine(flashLight());
}
}
}
private IEnumerator flashLight()
{
dropFlash = false;
toggleFlash(true);
float[] array = flashSequence;
foreach (float num in array)
{
yield return (object)new WaitForSeconds(num);
toggleFlash();
}
toggleFlash(false);
}
private void toggleFlash(bool? isOn = null)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
bool enabled = ((Behaviour)flashBulb).enabled;
enabled = isOn ?? (!enabled);
((Behaviour)flashBulb).enabled = enabled;
((Renderer)flashIndicator).material.color = (enabled ? Color.yellow : Color.black);
}
private IEnumerator doNextFrame(Action action)
{
yield return null;
action();
}
protected override void __initializeVariables()
{
((GrabbableObject)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_CameraItem()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(3286540989u, new RpcReceiveHandler(__rpc_handler_3286540989));
NetworkManager.__rpc_func_table.Add(3765346262u, new RpcReceiveHandler(__rpc_handler_3765346262));
NetworkManager.__rpc_func_table.Add(4245448909u, new RpcReceiveHandler(__rpc_handler_4245448909));
}
private static void __rpc_handler_3286540989(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_0088: 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_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
byte[] imageData = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref imageData, default(ForPrimitives));
}
target.__rpc_exec_stage = (__RpcExecStage)1;
((CameraItem)(object)target).TakePicture_ServerRpc(imageData);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_3765346262(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkObjectReference netObjectRef = default(NetworkObjectReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
Vector3 startFallingPos = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref startFallingPos);
target.__rpc_exec_stage = (__RpcExecStage)2;
((CameraItem)(object)target).SpawnPhotoClientRpc(netObjectRef, startFallingPos);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_4245448909(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
float time = default(float);
((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref time, default(ForPrimitives));
target.__rpc_exec_stage = (__RpcExecStage)2;
((CameraItem)(object)target).FlashCamera_ClientRpc(time);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "CameraItem";
}
}
[BepInPlugin("itbeblockhead.lethalcompany.cameraitem", "Camera Item", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class CameraPlugin : BaseUnityPlugin
{
private static readonly Harmony Harmony = new Harmony("CameraPlugin");
public static readonly Dictionary<string, string> CONFIG = new Dictionary<string, string>
{
{ "PLUGIN_ID", "Camera-Mod" },
{ "AUTHOR", "BlockHead" },
{ "CAMERA_BUNDLE_PATH", "bundles/camera.assetbundle" }
};
public static ScrapLoader ScrapLoader;
public static ManualLogSource Log;
public static CameraPluginConfig CameraConfig = new CameraPluginConfig();
private void Awake()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
for (int i = 0; i < types.Length; i++)
{
MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
Log = ((BaseUnityPlugin)this).Logger;
CameraConfig.SetUp(this);
ScrapLoader = new ScrapLoader();
ScrapLoader.setup();
Item val = ScrapLoader.loadedItems["camera"];
if ((Object)(object)val.spawnPrefab.GetComponent<NetworkTransform>() == (Object)null)
{
NetworkTransform obj = val.spawnPrefab.AddComponent<NetworkTransform>();
obj.SlerpPosition = false;
obj.Interpolate = false;
obj.SyncPositionX = false;
obj.SyncPositionY = false;
obj.SyncPositionZ = false;
obj.SyncScaleX = false;
obj.SyncScaleY = false;
obj.SyncScaleZ = false;
obj.UseHalfFloatPrecision = true;
}
val = ScrapLoader.loadedItems["photo"];
if ((Object)(object)val.spawnPrefab.GetComponent<NetworkTransform>() == (Object)null)
{
NetworkTransform obj2 = val.spawnPrefab.AddComponent<NetworkTransform>();
obj2.SlerpPosition = false;
obj2.Interpolate = false;
obj2.SyncPositionX = false;
obj2.SyncPositionY = false;
obj2.SyncPositionZ = false;
obj2.SyncScaleX = false;
obj2.SyncScaleY = false;
obj2.SyncScaleZ = false;
obj2.UseHalfFloatPrecision = true;
}
Items.RegisterShopItem(ScrapLoader.loadedItems["camera"], CameraConfig.cameraPrice);
Items.RegisterItem(ScrapLoader.loadedItems["photo"]);
Harmony.PatchAll(typeof(GameNetworkManager_Patch));
Harmony.PatchAll(typeof(CameraPluginConfig));
}
}
public class PhotoItem : GrabbableObject
{
public NetworkVariable<int> photoID = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private bool _photoDeveloped;
private bool _developingPhoto;
private float _developed;
public float developmentSpeed = 0.2f;
private readonly Dictionary<ulong, ClientRpcParams> _idCache = new Dictionary<ulong, ClientRpcParams>();
private Material _filmMaterial;
private static readonly int DevelopProgress = Shader.PropertyToID("_developProgress");
private static CameraPluginConfig.ImageSettings _imageSettings = CameraPlugin.CameraConfig.imageSettings;
public override void Start()
{
((GrabbableObject)this).Start();
developmentSpeed = 0.2f;
if (((NetworkBehaviour)this).IsServer)
{
_imageSettings = CameraPlugin.CameraConfig.imageSettings;
}
_filmMaterial = ((Renderer)((Component)((Component)this).transform.Find("Film")).GetComponent<MeshRenderer>()).material;
}
public override void GrabItem()
{
((GrabbableObject)this).GrabItem();
if (_photoDeveloped || _developingPhoto)
{
return;
}
if (photoID.Value >= 0)
{
if (CameraImageRegistry.GetInstance().has(photoID.Value))
{
DevelopPhoto();
return;
}
_developingPhoto = true;
RequestImage_ServerRpc(NetworkManager.Singleton.LocalClientId, photoID.Value);
}
else
{
CameraPlugin.Log.LogError((object)("Item has Invalid photoID: " + photoID.Value));
}
}
private void DevelopPhoto()
{
//IL_0026: 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_0032: Expected O, but got Unknown
byte[] array = CameraImageRegistry.GetInstance()[photoID.Value];
try
{
int imageResolution = _imageSettings.ImageResolution;
Texture2D val = new Texture2D(imageResolution, imageResolution, _imageSettings.ImageFormat, false);
((Texture)val).filterMode = (FilterMode)0;
val.LoadRawTextureData(array);
val.Apply();
_filmMaterial.mainTexture = (Texture)(object)val;
}
catch (Exception ex)
{
CameraPlugin.Log.LogError((object)"Failed to load image onto photo item");
CameraPlugin.Log.LogError((object)ex);
}
_photoDeveloped = true;
}
public override void Update()
{
((GrabbableObject)this).Update();
if (_photoDeveloped)
{
_developed += Time.deltaTime * developmentSpeed;
_developed = Mathf.Min(_developed, 1f);
_filmMaterial.SetFloat(DevelopProgress, _developed);
}
}
[ServerRpc(RequireOwnership = false)]
public void RequestImage_ServerRpc(ulong returnId, int id)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Invalid comparison between Unknown and I4
//IL_005f: 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)
//IL_006d: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3945644824u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, returnId);
BytePacker.WriteValueBitPacked(val2, id);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3945644824u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
if (((NetworkBehaviour)this).IsServer)
{
_developingPhoto = false;
_photoDeveloped = true;
}
if (!CameraImageRegistry.GetInstance().has(id))
{
CameraImageRegistry.GetInstance().LoadImageFromSave(id);
if (!CameraImageRegistry.GetInstance().has(id))
{
CameraPlugin.Log.LogError((object)("Requested Image ID " + id + " Does not have a registered image"));
}
}
if (!_idCache.ContainsKey(returnId))
{
_idCache[returnId] = new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIds = new ulong[1] { returnId }
}
};
}
ClientRpcParams clientRpcParams = _idCache[returnId];
RegisterImage_ClientRpc(id, CameraImageRegistry.GetInstance()[id], clientRpcParams);
}
[ClientRpc]
public void RegisterImage_ClientRpc(int id, byte[] imageData, ClientRpcParams clientRpcParams = default(ClientRpcParams))
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Invalid comparison between Unknown and I4
//IL_005f: 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)
//IL_006d: 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_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(4062700602u, clientRpcParams, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val, id);
bool flag = imageData != null;
((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val)).WriteValueSafe<byte>(imageData, default(ForPrimitives));
}
((NetworkBehaviour)this).__endSendClientRpc(ref val, 4062700602u, clientRpcParams, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
CameraImageRegistry.GetInstance()[id] = imageData;
_developingPhoto = false;
DevelopPhoto();
}
}
public override int GetItemDataToSave()
{
return photoID.Value;
}
public override void LoadItemSaveData(int saveData)
{
photoID.Value = saveData;
}
protected override void __initializeVariables()
{
if (photoID == null)
{
throw new Exception("PhotoItem.photoID cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)photoID).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)photoID, "photoID");
((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)photoID);
((GrabbableObject)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_PhotoItem()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(3945644824u, new RpcReceiveHandler(__rpc_handler_3945644824));
NetworkManager.__rpc_func_table.Add(4062700602u, new RpcReceiveHandler(__rpc_handler_4062700602));
}
private static void __rpc_handler_3945644824(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_0061: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong returnId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref returnId);
int id = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref id);
target.__rpc_exec_stage = (__RpcExecStage)1;
((PhotoItem)(object)target).RequestImage_ServerRpc(returnId, id);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_4062700602(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0042: 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_0076: 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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int id = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref id);
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
byte[] imageData = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref imageData, default(ForPrimitives));
}
ClientRpcParams client = rpcParams.Client;
target.__rpc_exec_stage = (__RpcExecStage)2;
((PhotoItem)(object)target).RegisterImage_ClientRpc(id, imageData, client);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "PhotoItem";
}
}
public class ScrapLoader
{
public static Dictionary<string, Item> loadedItems = new Dictionary<string, Item>();
public static Dictionary<string, AudioClip> loadedAudio = new Dictionary<string, AudioClip>();
public static bool loaded = false;
public void setup()
{
CameraPlugin.Log.LogInfo((object)"Adding ScrapLoader Event");
load();
}
public void load()
{
//IL_0083: 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_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Expected O, but got Unknown
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0404: Unknown result type (might be due to invalid IL or missing references)
//IL_041a: Unknown result type (might be due to invalid IL or missing references)
//IL_041f: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_043a: Unknown result type (might be due to invalid IL or missing references)
LoadedAssetBundle val = BundleLoader.LoadAssetBundle(Path.Combine(Paths.PluginPath, CameraPlugin.CONFIG["AUTHOR"] + "-PolaroidCamera", CameraPlugin.CONFIG["PLUGIN_ID"] + "/" + CameraPlugin.CONFIG["CAMERA_BUNDLE_PATH"]), true);
GameObject asset = val.GetAsset<GameObject>("Assets/Camera/Assets/ViewFinder.prefab");
Texture2D asset2 = val.GetAsset<Texture2D>("Assets/Camera/Assets/camera.png");
Sprite itemIcon = Sprite.Create(asset2, new Rect(0f, 0f, (float)((Texture)asset2).width, (float)((Texture)asset2).height), new Vector2(0.5f, 0.5f), 100f);
CameraPlugin.Log.LogInfo((object)"Loading Camera Item");
Item val2 = ScriptableObject.CreateInstance<Item>();
((Object)val2).name = "PolaroidCamera";
val2.itemName = "Polaroid Camera";
val2.canBeGrabbedBeforeGameStart = true;
val2.isScrap = false;
val2.minValue = 20;
val2.maxValue = 80;
val2.creditsWorth = CameraPlugin.CameraConfig.cameraPrice;
val2.weight = 1.05f;
val2.spawnPrefab = asset;
val2.twoHanded = false;
val2.twoHandedAnimation = false;
val2.requiresBattery = true;
val2.isConductiveMetal = true;
val2.itemIcon = itemIcon;
val2.syncGrabFunction = false;
val2.syncUseFunction = false;
val2.syncDiscardFunction = false;
val2.syncInteractLRFunction = false;
val2.verticalOffset = 0.1f;
val2.restingRotation = new Vector3(0f, 0f, 0f);
val2.positionOffset = new Vector3(0f, 0.25f, -0.125f);
val2.rotationOffset = new Vector3(-90f, -90f, 0f);
val2.meshOffset = false;
val2.meshVariants = Array.Empty<Mesh>();
val2.materialVariants = Array.Empty<Material>();
val2.canBeInspected = true;
val2.itemIsTrigger = true;
val2.batteryUsage = 0.1f;
CameraItem cameraItem = asset.AddComponent<CameraItem>();
((GrabbableObject)cameraItem).insertedBattery = new Battery(false, 1f);
((GrabbableObject)cameraItem).useCooldown = 1f;
((GrabbableObject)cameraItem).grabbable = true;
((GrabbableObject)cameraItem).itemProperties = val2;
((GrabbableObject)cameraItem).mainObjectRenderer = asset.GetComponent<MeshRenderer>();
cameraItem.renderDistance = 1000f;
cameraItem.flashSequence = new float[3] { 0.1f, 0.1f, 0.5f };
cameraItem.flashIndicator = ((Component)((Component)cameraItem).transform.Find("PolaroidCameraModel").Find("Lens")).GetComponent<MeshRenderer>();
Transform val3 = asset.transform.Find("ScanNode");
if ((Object)(object)val3 != (Object)null)
{
ScanNodeProperties obj = ((Component)val3).gameObject.AddComponent<ScanNodeProperties>();
obj.maxRange = 13;
obj.minRange = 1;
obj.headerText = val2.itemName;
obj.subText = "Value: ";
obj.nodeType = 2;
}
loadedItems["camera"] = val2;
GameObject asset3 = val.GetAsset<GameObject>("Assets/Camera/Assets/Photo.prefab");
Texture2D asset4 = val.GetAsset<Texture2D>("Assets/Camera/Assets/photo.png");
Sprite itemIcon2 = Sprite.Create(asset4, new Rect(0f, 0f, (float)((Texture)asset4).width, (float)((Texture)asset4).height), new Vector2(0.5f, 0.5f), 100f);
Item val4 = ScriptableObject.CreateInstance<Item>();
((Object)val4).name = "Photo";
val4.itemName = "Photo";
val4.canBeGrabbedBeforeGameStart = true;
val4.isScrap = true;
val4.minValue = 20;
val4.maxValue = 80;
val4.weight = 1.05f;
val4.spawnPrefab = asset3;
val4.twoHanded = false;
val4.twoHandedAnimation = false;
val4.requiresBattery = false;
val4.isConductiveMetal = false;
val4.itemIcon = itemIcon2;
val4.syncGrabFunction = false;
val4.syncUseFunction = false;
val4.syncDiscardFunction = false;
val4.syncInteractLRFunction = false;
val4.verticalOffset = 0.01f;
val4.restingRotation = new Vector3(90f, 0f, 0f);
val4.positionOffset = new Vector3(0.25f, 0f, -0.125f);
val4.rotationOffset = new Vector3(-90f, -90f, 0f);
val4.meshOffset = false;
val4.meshVariants = Array.Empty<Mesh>();
val4.materialVariants = Array.Empty<Material>();
val4.canBeInspected = true;
val4.saveItemVariable = true;
PhotoItem photoItem = asset3.AddComponent<PhotoItem>();
((GrabbableObject)photoItem).grabbable = true;
((GrabbableObject)photoItem).itemProperties = val4;
((GrabbableObject)photoItem).mainObjectRenderer = asset3.GetComponent<MeshRenderer>();
AudioSource obj2 = asset3.AddComponent<AudioSource>();
obj2.playOnAwake = false;
obj2.spatialBlend = 1f;
Transform val5 = asset3.transform.Find("ScanNode");
if ((Object)(object)val5 != (Object)null)
{
ScanNodeProperties obj3 = ((Component)val5).gameObject.AddComponent<ScanNodeProperties>();
obj3.maxRange = 13;
obj3.minRange = 1;
obj3.headerText = val4.itemName;
obj3.subText = "Value: ";
obj3.nodeType = 2;
}
loadedItems["photo"] = val4;
loadedAudio["cameraClick"] = val.GetAsset<AudioClip>("Assets/Camera/Assets/click.mp3");
loaded = true;
}
}
[Serializable]
public class SyncedInstance<T>
{
[NonSerialized]
protected static int IntSize = 4;
internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;
internal static bool IsClient => NetworkManager.Singleton.IsClient;
internal static bool IsHost => NetworkManager.Singleton.IsHost;
public static T Default { get; private set; }
public static T Instance { get; private set; }
public static bool Synced { get; internal set; }
protected void InitInstance(T instance)
{
Default = instance;
Instance = instance;
IntSize = 4;
}
internal static void SyncInstance(byte[] data)
{
Instance = DeserializeFromBytes(data);
Synced = true;
}
internal static void RevertSync()
{
Instance = Default;
Synced = false;
}
public static byte[] SerializeToBytes(T val)
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
using MemoryStream memoryStream = new MemoryStream();
try
{
binaryFormatter.Serialize(memoryStream, val);
return memoryStream.ToArray();
}
catch (Exception arg)
{
CameraPlugin.Log.LogError((object)$"Error serializing instance: {arg}");
return null;
}
}
public static T DeserializeFromBytes(byte[] data)
{
BinaryFormatter binaryFormatter = new BinaryFormatter();
using MemoryStream serializationStream = new MemoryStream(data);
try
{
return (T)binaryFormatter.Deserialize(serializationStream);
}
catch (Exception arg)
{
CameraPlugin.Log.LogError((object)$"Error deserializing instance: {arg}");
return default(T);
}
}
}
}
namespace BHCamera.Patches
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal class GameNetworkManager_Patch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void Start_Prefix(GameNetworkManager __instance)
{
CameraPlugin.Log.LogInfo((object)"Registering Camera Prefab");
Item val = ScrapLoader.loadedItems["camera"];
((Component)__instance).GetComponent<NetworkManager>().PrefabHandler.AddNetworkPrefab(val.spawnPrefab);
CameraPlugin.Log.LogInfo((object)"Registering Photo Prefab");
Item val2 = ScrapLoader.loadedItems["photo"];
((Component)__instance).GetComponent<NetworkManager>().PrefabHandler.AddNetworkPrefab(val2.spawnPrefab);
}
}
public class PlayerControllerB_Patch
{
}
}