

using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using API;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GameData;
using Globals;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Player;
using ReplayRecorder.API;
using ReplayRecorder.API.Attributes;
using ReplayRecorder.BepInEx;
using ReplayRecorder.Core;
using ReplayRecorder.Exceptions;
using ReplayRecorder.Net;
using ReplayRecorder.SNetUtils;
using ReplayRecorder.Snapshot;
using ReplayRecorder.Snapshot.Exceptions;
using ReplayRecorder.Snapshot.Types;
using ReplayRecorder.Steam;
using SNetwork;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.Analytics;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ReplayRecorder")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b2152aa675e7c59f4573437f7c3dd474ba06922c")]
[assembly: AssemblyProduct("ReplayRecorder")]
[assembly: AssemblyTitle("ReplayRecorder")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace API
{
[HarmonyPatch(typeof(GameDataInit))]
internal class GameDataInit_Patches
{
[HarmonyPatch("Initialize")]
[HarmonyWrapSafe]
[HarmonyPostfix]
public static void Initialize_Postfix()
{
Analytics.enabled = false;
}
}
internal static class APILogger
{
private static readonly ManualLogSource logger;
static APILogger()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
logger = new ManualLogSource("Rand-API");
Logger.Sources.Add((ILogSource)(object)logger);
}
private static string Format(string module, object msg)
{
return $"[{module}]: {msg}";
}
public static void Info(string module, object data)
{
logger.LogMessage((object)Format(module, data));
}
public static void Verbose(string module, object data)
{
}
public static void Log(object data)
{
logger.LogDebug((object)Format("ReplayRecorder", data));
}
public static void Debug(object data)
{
if (ConfigManager.Debug)
{
Log(data);
}
}
public static void Warn(object data)
{
logger.LogWarning((object)Format("ReplayRecorder", data));
}
public static void Error(object data)
{
logger.LogError((object)Format("ReplayRecorder", data));
}
}
}
namespace ReplayRecorder
{
internal class BufferPool
{
private Stack<ByteBuffer> pool = new Stack<ByteBuffer>();
private readonly object lockObj = new object();
private int size;
private int inUse;
public int Size => size;
public int InUse => inUse;
public void Shrink(int count)
{
while (pool.Count > count)
{
pool.Pop();
size--;
}
}
public ByteBuffer Checkout()
{
lock (lockObj)
{
inUse++;
if (pool.Count == 0)
{
size++;
return new ByteBuffer();
}
ByteBuffer byteBuffer = pool.Pop();
byteBuffer.Clear();
return byteBuffer;
}
}
public void Release(ByteBuffer buffer)
{
lock (lockObj)
{
if (inUse != 0)
{
inUse--;
}
else
{
size++;
}
pool.Push(buffer);
}
}
}
public class MainThread : MonoBehaviour
{
private static MainThread? _instance;
private ConcurrentQueue<Action> queue = new ConcurrentQueue<Action>();
private static MainThread Instance
{
get
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_instance == (Object)null)
{
_instance = new GameObject().AddComponent<MainThread>();
}
return _instance;
}
}
public static void Run(Action action)
{
Instance.queue.Enqueue(action);
}
private void Update()
{
Action result;
while (queue.TryDequeue(out result))
{
result?.Invoke();
}
}
}
public static class RNet
{
private class EventInfo
{
public string name;
public Action<ulong, ArraySegment<byte>>? onReceive;
public byte[] header;
public EventInfo(string name, byte[] header, Action<ulong, ArraySegment<byte>>? onReceive = null)
{
this.name = name;
this.header = header;
this.onReceive = onReceive;
}
}
private static Dictionary<string, EventInfo> eventMap;
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void Init()
{
}
static RNet()
{
eventMap = new Dictionary<string, EventInfo>();
ReplayRecorder.SNetUtils.SNetUtils.OnReceive = (Action<ArraySegment<byte>, ulong>)Delegate.Combine(ReplayRecorder.SNetUtils.SNetUtils.OnReceive, new Action<ArraySegment<byte>, ulong>(Receive));
}
[HideFromIl2Cpp]
private static void Receive(ArraySegment<byte> packet, ulong from)
{
int index = 0;
if (BitHelper.ReadByte(packet, ref index) == 1)
{
string text = BitHelper.ReadString(packet, ref index);
if (!eventMap.ContainsKey(text))
{
APILogger.Warn("Received unknown RNet event, '" + text + "'.");
return;
}
int count = BitHelper.ReadInt(packet, ref index);
eventMap[text].onReceive?.Invoke(from, new ArraySegment<byte>(packet.Array, packet.Offset + index, count));
}
}
[HideFromIl2Cpp]
public static void Register(string eventName, Action<ulong, ArraySegment<byte>> callback)
{
if (!eventMap.ContainsKey(eventName))
{
ByteBuffer byteBuffer = new ByteBuffer();
BitHelper.WriteBytes((byte)1, byteBuffer);
BitHelper.WriteBytes(eventName, byteBuffer);
byte[] array = new byte[byteBuffer.Count];
Array.Copy(byteBuffer.Array.Array, byteBuffer.Array.Offset, array, 0, byteBuffer.Count);
eventMap.Add(eventName, new EventInfo(eventName, array, callback));
}
else
{
EventInfo eventInfo = eventMap[eventName];
eventInfo.onReceive = (Action<ulong, ArraySegment<byte>>)Delegate.Combine(eventInfo.onReceive, callback);
}
}
[HideFromIl2Cpp]
public static void Trigger(string eventName, ByteBuffer bytes)
{
Trigger(eventName, bytes.Array);
}
[HideFromIl2Cpp]
public static void Trigger(string eventName, ArraySegment<byte> bytes)
{
if (!eventMap.ContainsKey(eventName))
{
throw new Exception("Event '" + eventName + "' does not exist.");
}
EventInfo eventInfo = eventMap[eventName];
byte[] array = new byte[eventInfo.header.Length + 4 + bytes.Count];
Array.Copy(eventInfo.header, array, eventInfo.header.Length);
int index = eventInfo.header.Length;
BitHelper.WriteBytes(bytes, (ArraySegment<byte>)array, ref index);
ReplayRecorder.SNetUtils.SNetUtils.SendBytes(array, ReplayPlayerManager.playersWithReplayMod);
}
}
internal class TCPServer : IDisposable
{
public delegate void OnAccept(EndPoint endpoint);
public delegate void OnReceive(ArraySegment<byte> buffer, EndPoint endpoint);
public delegate void OnDisconnect(EndPoint endpoint);
public delegate void OnClose();
private class Connection : IDisposable
{
public enum State
{
waiting,
reading
}
public Socket socket;
public readonly EndPoint remoteEP;
public byte[] recvBuffer;
public byte[] sendBuffer;
public byte[] messageBuffer;
public SemaphoreSlim semaphoreSend = new SemaphoreSlim(1);
public State state;
public int messageSize;
public int bytesWritten;
public Connection(Socket socket, int bufferSize)
{
this.socket = socket;
remoteEP = socket.RemoteEndPoint;
messageBuffer = new byte[bufferSize];
recvBuffer = new byte[bufferSize];
sendBuffer = new byte[bufferSize];
}
public void Dispose()
{
semaphoreSend.Dispose();
socket.Dispose();
}
}
private readonly int bufferSize;
private Socket? socket;
public OnAccept? onAccept;
public OnReceive? onReceive;
public OnDisconnect? onDisconnect;
public OnClose? onClose;
private ConcurrentDictionary<EndPoint, Connection> acceptedConnections = new ConcurrentDictionary<EndPoint, Connection>();
public ICollection<EndPoint> Connections => acceptedConnections.Keys;
public TCPServer(int bufferSize = 8192)
{
if (bufferSize < 4)
{
throw new ArgumentException("Buffer size cannot be smaller than a message header [sizeof(int)].");
}
this.bufferSize = bufferSize;
}
private void Open()
{
if (socket != null)
{
Dispose();
}
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.ReuseAddress, optionValue: true);
}
public EndPoint Bind(EndPoint remoteEP, int backlog = 5)
{
Open();
socket.Bind(remoteEP);
socket.Listen(backlog);
Listen();
return socket.LocalEndPoint;
}
private async Task Listen()
{
if (socket == null)
{
return;
}
Socket incoming = await socket.AcceptAsync().ConfigureAwait(continueOnCapturedContext: false);
EndPoint remoteEndPoint = incoming.RemoteEndPoint;
if (remoteEndPoint != null)
{
Connection connection = new Connection(incoming, bufferSize);
acceptedConnections.AddOrUpdate(remoteEndPoint, connection, delegate(EndPoint key, Connection old)
{
incoming.Dispose();
return old;
});
onAccept?.Invoke(remoteEndPoint);
ListenTo(connection);
}
else
{
incoming.Dispose();
}
Listen();
}
private async Task ListenTo(Connection connection)
{
try
{
int num = await connection.socket.ReceiveAsync(connection.recvBuffer, SocketFlags.None).ConfigureAwait(continueOnCapturedContext: false);
if (num > 0)
{
int num2 = num;
int index = 0;
do
{
switch (connection.state)
{
case Connection.State.waiting:
connection.messageSize = BitHelper.ReadInt(connection.recvBuffer, ref index);
connection.bytesWritten = 0;
if (connection.messageSize > 0)
{
connection.state = Connection.State.reading;
}
break;
case Connection.State.reading:
{
int num3 = num2;
if (connection.bytesWritten + num2 > connection.messageSize)
{
num3 = connection.messageSize - connection.bytesWritten;
}
Array.Copy(connection.recvBuffer, index, connection.messageBuffer, connection.bytesWritten, num3);
connection.bytesWritten += num3;
index += num3;
if (connection.bytesWritten == connection.messageSize)
{
connection.state = Connection.State.waiting;
onReceive?.Invoke(new ArraySegment<byte>(connection.messageBuffer, 0, connection.messageSize), connection.remoteEP);
}
break;
}
}
num2 = num - index;
}
while (num2 > 0);
ListenTo(connection);
}
else
{
Dispose(connection);
onDisconnect?.Invoke(connection.remoteEP);
}
}
catch (ObjectDisposedException)
{
Dispose(connection);
onDisconnect?.Invoke(connection.remoteEP);
}
}
private void Dispose(Connection connection)
{
acceptedConnections.Remove(connection.socket.RemoteEndPoint, out var _);
connection.Dispose();
}
public async Task Send(ArraySegment<byte> data)
{
List<Task> list = new List<Task>();
foreach (EndPoint key in acceptedConnections.Keys)
{
list.Add(SendTo(data, key));
}
await Task.WhenAll(list).ConfigureAwait(continueOnCapturedContext: false);
}
public async Task RawSendTo(ArraySegment<byte> data, EndPoint remoteEP)
{
if (!acceptedConnections.TryGetValue(remoteEP, out Connection connection))
{
return;
}
await connection.semaphoreSend.WaitAsync().ConfigureAwait(continueOnCapturedContext: false);
try
{
int num = await connection.socket.SendAsync(data, SocketFlags.None).ConfigureAwait(continueOnCapturedContext: false);
while (num < data.Count)
{
int num2 = num;
num = num2 + await connection.socket.SendAsync(new ArraySegment<byte>(data.Array, data.Offset + num, data.Count - num), SocketFlags.None).ConfigureAwait(continueOnCapturedContext: false);
}
}
catch (SocketException)
{
}
finally
{
connection.semaphoreSend.Release();
}
}
public async Task SendTo(ArraySegment<byte> data, EndPoint remoteEP)
{
if (!acceptedConnections.TryGetValue(remoteEP, out Connection connection))
{
return;
}
await connection.semaphoreSend.WaitAsync().ConfigureAwait(continueOnCapturedContext: false);
try
{
if (data.Count <= int.MaxValue)
{
int size = 4 + data.Count;
int num;
for (num = connection.sendBuffer.Length; num < size; num *= 2)
{
}
if (num > connection.sendBuffer.Length)
{
connection.sendBuffer = new byte[num];
}
int index = 0;
BitHelper.WriteBytes(data.Count, (ArraySegment<byte>)connection.sendBuffer, ref index);
Array.Copy(data.Array, data.Offset, connection.sendBuffer, index, data.Count);
int num2 = await connection.socket.SendAsync(new ArraySegment<byte>(connection.sendBuffer, 0, size), SocketFlags.None).ConfigureAwait(continueOnCapturedContext: false);
while (num2 < size)
{
int num3 = num2;
num2 = num3 + await connection.socket.SendAsync(new ArraySegment<byte>(connection.sendBuffer, num2, size - num2), SocketFlags.None).ConfigureAwait(continueOnCapturedContext: false);
}
}
}
catch (SocketException)
{
}
finally
{
connection.semaphoreSend.Release();
}
}
public void Disconnect()
{
Dispose();
}
public void DisconnectClients()
{
foreach (Connection value in acceptedConnections.Values)
{
value.Dispose();
}
acceptedConnections.Clear();
}
public void Dispose()
{
if (socket != null)
{
DisconnectClients();
socket.Dispose();
socket = null;
onClose?.Invoke();
}
}
}
[HarmonyPatch]
internal class GameEventManager
{
private static bool initialized;
[HarmonyPatch(typeof(SteamManager), "PostSetup")]
[HarmonyPrefix]
private static void SteamSetup()
{
if (!initialized)
{
initialized = true;
Replay.OnPluginLoad?.Invoke();
}
}
[HarmonyPatch(typeof(ElevatorRide), "StartElevatorRide")]
[HarmonyPostfix]
private static void StartElevatorRide()
{
APILogger.Debug("Entered elevator!");
SnapshotManager.OnElevatorStart();
Replay.OnExpeditionStart?.Invoke();
}
[HarmonyPatch(typeof(RundownManager), "EndGameSession")]
[HarmonyPrefix]
private static void EndGameSession()
{
APILogger.Debug("Level ended!");
SnapshotManager.OnExpeditionEnd();
}
[HarmonyPatch(typeof(SNet_SessionHub), "LeaveHub")]
[HarmonyPrefix]
private static void LeaveHub()
{
APILogger.Debug("Level ended!");
SnapshotManager.OnExpeditionEnd();
}
[HarmonyPatch(typeof(GS_ReadyToStopElevatorRide), "Enter")]
[HarmonyPostfix]
private static void StopElevatorRide()
{
APILogger.Debug("Stop elevator!");
Replay.OnElevatorStop?.Invoke();
}
[HarmonyPatch(typeof(PUI_LocalPlayerStatus), "UpdateBPM")]
[HarmonyWrapSafe]
[HarmonyPostfix]
public static void Initialize_Postfix(PUI_LocalPlayerStatus __instance)
{
if (ConfigManager.PerformanceDebug)
{
SnapshotInstance instance = SnapshotManager.GetInstance();
TextMeshPro pulseText = __instance.m_pulseText;
((TMP_Text)pulseText).text = ((TMP_Text)pulseText).text + $" | ({instance.pool.InUse}/{instance.pool.Size}) {Mathf.RoundToInt(instance.tickTime)}({Mathf.RoundToInt(instance.waitForWrite)})ms";
}
}
}
public static class Raudy
{
public static long Now => ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds();
}
public class BitHelperBufferTooLarge : Exception
{
public BitHelperBufferTooLarge(string message)
: base(message)
{
}
}
public class ByteBuffer
{
internal ArraySegment<byte> _array = new byte[1024];
internal int count;
internal ArraySegment<byte> Array => new ArraySegment<byte>(_array.Array, _array.Offset, count);
internal byte this[int index]
{
get
{
return _array[index];
}
set
{
_array[index] = value;
}
}
public int Count => count;
public ByteBuffer()
{
_array = new byte[1024];
}
public ByteBuffer(ArraySegment<byte> array)
{
_array = array;
}
public void Clear()
{
count = 0;
}
internal void Copy(ByteBuffer other)
{
_array = new byte[other.count];
System.Array.Copy(other._array.Array, other._array.Offset, _array.Array, _array.Offset, other.count);
}
internal void Reserve(int size, bool increment = false)
{
if (_array.Count - count < size)
{
byte[] array = new byte[Mathf.Max(_array.Count * 2, count + size)];
System.Array.Copy(_array.Array, _array.Offset, array, 0, _array.Count);
_array = array;
}
if (increment)
{
count += size;
}
}
internal async Task AsyncFlush(FileStream fs)
{
if (ConfigManager.DebugTicks)
{
APILogger.Debug($"Async Flushed snapshot: {count} bytes.");
}
await fs.WriteAsync(Array).ConfigureAwait(continueOnCapturedContext: false);
}
internal void Shrink()
{
_array = new byte[1024];
GC.Collect();
}
}
public interface BufferWriteable
{
void Write(ByteBuffer buffer);
}
public static class BitHelper
{
public const int SizeOfHalf = 2;
public const int SizeOfVector3 = 12;
public const int SizeOfQuaternion = 13;
public const int SizeOfHalfVector3 = 6;
public const int SizeOfHalfQuaternion = 7;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint RotateLeft(uint value, int offset)
{
return (value << offset) | (value >> 32 - offset);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint RotateRight(uint value, int offset)
{
return (value >> offset) | (value << 32 - offset);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static long ReverseEndianness(long value)
{
return (long)ReverseEndianness((ulong)value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int ReverseEndianness(int value)
{
return (int)ReverseEndianness((uint)value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static short ReverseEndianness(short value)
{
return (short)ReverseEndianness((ushort)value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ushort ReverseEndianness(ushort value)
{
return (ushort)((value >> 8) + (value << 8));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint ReverseEndianness(uint value)
{
return RotateRight(value & 0xFF00FFu, 8) + RotateLeft(value & 0xFF00FF00u, 8);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ulong ReverseEndianness(ulong value)
{
return ((ulong)ReverseEndianness((uint)value) << 32) + ReverseEndianness((uint)(value >> 32));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe static void _WriteBytes(byte* source, int size, ArraySegment<byte> destination, ref int index)
{
int num = 0;
while (num < size)
{
destination[index++] = source[num++];
}
}
public static void WriteBytes(byte value, ArraySegment<byte> destination, ref int index)
{
destination[index++] = value;
}
public static void WriteBytes(bool value, ArraySegment<byte> destination, ref int index)
{
WriteBytes(value ? ((byte)1) : ((byte)0), destination, ref index);
}
public unsafe static void WriteBytes(ulong value, ArraySegment<byte> destination, ref int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 8, destination, ref index);
}
public unsafe static void WriteBytes(uint value, ArraySegment<byte> destination, ref int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 4, destination, ref index);
}
public unsafe static void WriteBytes(ushort value, ArraySegment<byte> destination, ref int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 2, destination, ref index);
}
public unsafe static void WriteBytes(long value, ArraySegment<byte> destination, ref int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 8, destination, ref index);
}
public unsafe static void WriteBytes(int value, ArraySegment<byte> destination, ref int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 4, destination, ref index);
}
public unsafe static void WriteBytes(short value, ArraySegment<byte> destination, ref int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 2, destination, ref index);
}
public unsafe static void WriteBytes(float value, ArraySegment<byte> destination, ref int index)
{
int value2 = *(int*)(&value);
if (!BitConverter.IsLittleEndian)
{
value2 = ReverseEndianness(value2);
}
_WriteBytes((byte*)(&value2), 4, destination, ref index);
}
public static void WriteBytes(string value, ArraySegment<byte> destination, ref int index)
{
byte[] bytes = Encoding.UTF8.GetBytes(value);
if (bytes.Length > 65535)
{
throw new BitHelperBufferTooLarge($"String value is too large, byte length must be smaller than {65535}.");
}
WriteBytes((ushort)bytes.Length, destination, ref index);
Array.Copy(bytes, 0, destination.Array, destination.Offset + index, bytes.Length);
index += bytes.Length;
}
public static int SizeOfString(string value)
{
return 2 + Encoding.UTF8.GetBytes(value).Length;
}
public static void WriteBytes(ArraySegment<byte> buffer, ArraySegment<byte> destination, ref int index)
{
WriteBytes(buffer.Count, destination, ref index);
Array.Copy(buffer.Array, buffer.Offset, destination.Array, destination.Offset + index, buffer.Count);
index += buffer.Count;
}
public static void WriteHalf(float value, ArraySegment<byte> destination, ref int index)
{
WriteBytes(FloatToHalf(value), destination, ref index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe static void _WriteBytes(byte* source, int size, ArraySegment<byte> destination, int index)
{
int num = 0;
while (num < size)
{
destination[index++] = source[num++];
}
}
public static void WriteBytes(byte value, ArraySegment<byte> destination, int index)
{
destination[index++] = value;
}
public static void WriteBytes(bool value, ArraySegment<byte> destination, int index)
{
WriteBytes(value ? ((byte)1) : ((byte)0), destination, index);
}
public unsafe static void WriteBytes(ulong value, ArraySegment<byte> destination, int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 8, destination, index);
}
public unsafe static void WriteBytes(uint value, ArraySegment<byte> destination, int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 4, destination, index);
}
public unsafe static void WriteBytes(ushort value, ArraySegment<byte> destination, int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 2, destination, index);
}
public unsafe static void WriteBytes(long value, ArraySegment<byte> destination, int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 8, destination, index);
}
public unsafe static void WriteBytes(int value, ArraySegment<byte> destination, int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 4, destination, index);
}
public unsafe static void WriteBytes(short value, ArraySegment<byte> destination, int index)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 2, destination, index);
}
public unsafe static void WriteBytes(float value, ArraySegment<byte> destination, int index)
{
int value2 = *(int*)(&value);
if (!BitConverter.IsLittleEndian)
{
value2 = ReverseEndianness(value2);
}
_WriteBytes((byte*)(&value2), 4, destination, index);
}
public static void WriteBytes(string value, ArraySegment<byte> destination, int index)
{
byte[] bytes = Encoding.UTF8.GetBytes(value);
if (bytes.Length > 65535)
{
throw new BitHelperBufferTooLarge($"String value is too large, byte length must be smaller than {65535}.");
}
WriteBytes((ushort)bytes.Length, destination, index);
Array.Copy(bytes, 0, destination.Array, destination.Offset + index, bytes.Length);
index += bytes.Length;
}
public static void WriteBytes(ArraySegment<byte> buffer, ArraySegment<byte> destination, int index)
{
WriteBytes(buffer.Count, destination, index);
Array.Copy(buffer.Array, buffer.Offset, destination.Array, destination.Offset + index, buffer.Count);
index += buffer.Count;
}
public static void WriteHalf(float value, ArraySegment<byte> destination, int index)
{
WriteBytes(FloatToHalf(value), destination, index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe static void _WriteBytes(byte* bytes, int size, ByteBuffer buffer)
{
buffer.Reserve(size);
for (int i = 0; i < size; i++)
{
buffer[buffer.count++] = bytes[i];
}
}
public static void WriteBytes(byte value, ByteBuffer buffer)
{
buffer.Reserve(1);
buffer[buffer.count++] = value;
}
public static void WriteBytes(bool value, ByteBuffer buffer)
{
WriteBytes(value ? ((byte)1) : ((byte)0), buffer);
}
public unsafe static void WriteBytes(ulong value, ByteBuffer buffer)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 8, buffer);
}
public unsafe static void WriteBytes(uint value, ByteBuffer buffer)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 4, buffer);
}
public unsafe static void WriteBytes(ushort value, ByteBuffer buffer)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 2, buffer);
}
public unsafe static void WriteBytes(long value, ByteBuffer buffer)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 8, buffer);
}
public unsafe static void WriteBytes(int value, ByteBuffer buffer)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 4, buffer);
}
public unsafe static void WriteBytes(short value, ByteBuffer buffer)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 2, buffer);
}
public unsafe static void WriteBytes(float value, ByteBuffer buffer)
{
int value2 = *(int*)(&value);
if (!BitConverter.IsLittleEndian)
{
value2 = ReverseEndianness(value2);
}
_WriteBytes((byte*)(&value2), 4, buffer);
}
public static void WriteBytes(string value, ByteBuffer buffer)
{
byte[] bytes = Encoding.UTF8.GetBytes(value);
if (value.Length > 65535)
{
throw new BitHelperBufferTooLarge($"String value is too large, length must be smaller than {65535}.");
}
WriteBytes((ushort)bytes.Length, buffer);
buffer.Reserve(bytes.Length);
Array.Copy(bytes, 0, buffer._array.Array, buffer._array.Offset + buffer.count, bytes.Length);
buffer.count += bytes.Length;
}
public static void WriteBytes(ArraySegment<byte> bytes, ByteBuffer buffer, bool includeCount = true)
{
if (includeCount)
{
WriteBytes(bytes.Count, buffer);
}
buffer.Reserve(bytes.Count);
Array.Copy(bytes.Array, bytes.Offset, buffer._array.Array, buffer._array.Offset + buffer.count, bytes.Count);
buffer.count += bytes.Count;
}
public static void WriteBytes(BufferWriteable writeable, ByteBuffer buffer)
{
writeable.Write(buffer);
}
public static void WriteHalf(float value, ByteBuffer buffer)
{
WriteBytes(FloatToHalf(value), buffer);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe static void _WriteBytes(byte* bytes, int size, FileStream fs)
{
for (int i = 0; i < size; i++)
{
fs.WriteByte(bytes[i]);
}
}
public static void WriteBytes(byte value, FileStream fs)
{
fs.WriteByte(value);
}
public static void WriteBytes(bool value, FileStream fs)
{
WriteBytes(value ? ((byte)1) : ((byte)0), fs);
}
public unsafe static void WriteBytes(ulong value, FileStream fs)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 8, fs);
}
public unsafe static void WriteBytes(uint value, FileStream fs)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 4, fs);
}
public unsafe static void WriteBytes(ushort value, FileStream fs)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 2, fs);
}
public unsafe static void WriteBytes(long value, FileStream fs)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 8, fs);
}
public unsafe static void WriteBytes(int value, FileStream fs)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 4, fs);
}
public unsafe static void WriteBytes(short value, FileStream fs)
{
if (!BitConverter.IsLittleEndian)
{
value = ReverseEndianness(value);
}
_WriteBytes((byte*)(&value), 2, fs);
}
public unsafe static void WriteBytes(float value, FileStream fs)
{
int value2 = *(int*)(&value);
if (!BitConverter.IsLittleEndian)
{
value2 = ReverseEndianness(value2);
}
_WriteBytes((byte*)(&value2), 4, fs);
}
public static void WriteBytes(string value, FileStream fs)
{
byte[] bytes = Encoding.UTF8.GetBytes(value);
if (value.Length > 65535)
{
throw new BitHelperBufferTooLarge($"String value is too large, length must be smaller than {65535}.");
}
WriteBytes((ushort)bytes.Length, fs);
fs.Write(bytes);
}
public static void WriteBytes(byte[] buffer, FileStream fs)
{
WriteBytes(buffer.Length, fs);
fs.Write(buffer);
}
public static void WriteHalf(float value, FileStream fs)
{
WriteBytes(FloatToHalf(value), fs);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe static uint AsUInt(float x)
{
return *(uint*)(&x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe static float AsFloat(uint x)
{
return *(float*)(&x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static float HalfToFloat(ushort x)
{
int num = (x & 0x7C00) >> 10;
int num2 = (x & 0x3FF) << 13;
int num3 = (int)(AsUInt(num2) >> 23);
return AsFloat((uint)(((x & 0x8000) << 16) | (Convert.ToInt32(num != 0) * ((num + 112 << 23) | num2)) | ((Convert.ToInt32(num == 0) & Convert.ToInt32(num2 != 0)) * ((num3 - 37 << 23) | ((num2 << 150 - num3) & 0x7FE000)))));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ushort FloatToHalf(float x)
{
uint num = AsUInt(x) + 4096;
uint num2 = (num & 0x7F800000) >> 23;
uint num3 = num & 0x7FFFFFu;
return (ushort)(((num & 0x80000000u) >> 16) | (Convert.ToInt32(num2 > 112) * (((num2 - 112 << 10) & 0x7C00) | (num3 >> 13))) | ((Convert.ToInt32(num2 < 113) & Convert.ToInt32(num2 > 101)) * ((8384512 + num3 >> (int)(125 - num2)) + 1 >> 1)) | (Convert.ToUInt32(num2 > 143) * 32767));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Quantize(float x)
{
return HalfToFloat(FloatToHalf(x));
}
public static byte ReadByte(ArraySegment<byte> source, ref int index)
{
return source[index++];
}
public static bool ReadBool(ArraySegment<byte> source, ref int index)
{
return ReadByte(source, ref index) != 0;
}
public unsafe static ulong ReadULong(ArraySegment<byte> source, ref int index)
{
fixed (byte* ptr = source.Array)
{
byte* num = ptr + source.Offset + index;
index += 8;
ulong num2 = *(ulong*)num;
if (!BitConverter.IsLittleEndian)
{
num2 = ReverseEndianness(num2);
}
return num2;
}
}
public unsafe static long ReadLong(ArraySegment<byte> source, ref int index)
{
fixed (byte* ptr = source.Array)
{
byte* num = ptr + source.Offset + index;
index += 8;
long num2 = *(long*)num;
if (!BitConverter.IsLittleEndian)
{
num2 = ReverseEndianness(num2);
}
return num2;
}
}
public unsafe static uint ReadUInt(ArraySegment<byte> source, ref int index)
{
fixed (byte* ptr = source.Array)
{
byte* num = ptr + source.Offset + index;
index += 4;
uint num2 = *(uint*)num;
if (!BitConverter.IsLittleEndian)
{
num2 = ReverseEndianness(num2);
}
return num2;
}
}
public unsafe static int ReadInt(ArraySegment<byte> source, ref int index)
{
fixed (byte* ptr = source.Array)
{
byte* num = ptr + source.Offset + index;
index += 4;
int num2 = *(int*)num;
if (!BitConverter.IsLittleEndian)
{
num2 = ReverseEndianness(num2);
}
return num2;
}
}
public unsafe static ushort ReadUShort(ArraySegment<byte> source, ref int index)
{
fixed (byte* ptr = source.Array)
{
byte* num = ptr + source.Offset + index;
index += 2;
ushort num2 = *(ushort*)num;
if (!BitConverter.IsLittleEndian)
{
num2 = ReverseEndianness(num2);
}
return num2;
}
}
public unsafe static short ReadShort(ArraySegment<byte> source, ref int index)
{
fixed (byte* ptr = source.Array)
{
byte* num = ptr + source.Offset + index;
index += 2;
short num2 = *(short*)num;
if (!BitConverter.IsLittleEndian)
{
num2 = ReverseEndianness(num2);
}
return num2;
}
}
public static float ReadHalf(ArraySegment<byte> source, ref int index)
{
return HalfToFloat(ReadUShort(source, ref index));
}
public unsafe static float ReadFloat(ArraySegment<byte> source, ref int index)
{
fixed (byte* ptr = source.Array)
{
byte* ptr2 = ptr + source.Offset + index;
index += 4;
if (!BitConverter.IsLittleEndian)
{
int num = ReverseEndianness(*(int*)ptr2);
return *(float*)(&num);
}
return *(float*)ptr2;
}
}
public static string ReadString(ArraySegment<byte> source, ref int index)
{
int num = ReadUShort(source, ref index);
string @string = Encoding.UTF8.GetString(source.Array, source.Offset + index, num);
index += num;
return @string;
}
public static string ReadString(ArraySegment<byte> source, int length, ref int index)
{
string @string = Encoding.UTF8.GetString(source.Array, source.Offset + index, length);
index += length;
return @string;
}
public static void WriteBytes(Vector3 value, byte[] destination, ref int index)
{
//IL_0000: 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_0024: Unknown result type (might be due to invalid IL or missing references)
WriteBytes(value.x, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.y, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.z, (ArraySegment<byte>)destination, ref index);
}
public static void WriteBytes(Quaternion value, byte[] destination, ref int index)
{
//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_0009: 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_0024: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_01e6: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
value = ((Quaternion)(ref value)).normalized;
float num = value.x;
byte b = 0;
if (value.y > num)
{
num = value.y;
b = 1;
}
if (value.z > num)
{
num = value.z;
b = 2;
}
if (value.w > num)
{
num = value.w;
b = 3;
}
WriteBytes(b, (ArraySegment<byte>)destination, ref index);
switch (b)
{
case 0:
if (value.x >= 0f)
{
WriteBytes(value.y, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.z, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.w, (ArraySegment<byte>)destination, ref index);
}
else
{
WriteBytes(0f - value.y, (ArraySegment<byte>)destination, ref index);
WriteBytes(0f - value.z, (ArraySegment<byte>)destination, ref index);
WriteBytes(0f - value.w, (ArraySegment<byte>)destination, ref index);
}
break;
case 1:
if (value.y >= 0f)
{
WriteBytes(value.x, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.z, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.w, (ArraySegment<byte>)destination, ref index);
}
else
{
WriteBytes(0f - value.x, (ArraySegment<byte>)destination, ref index);
WriteBytes(0f - value.z, (ArraySegment<byte>)destination, ref index);
WriteBytes(0f - value.w, (ArraySegment<byte>)destination, ref index);
}
break;
case 2:
if (value.z >= 0f)
{
WriteBytes(value.x, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.y, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.w, (ArraySegment<byte>)destination, ref index);
}
else
{
WriteBytes(0f - value.x, (ArraySegment<byte>)destination, ref index);
WriteBytes(0f - value.y, (ArraySegment<byte>)destination, ref index);
WriteBytes(0f - value.w, (ArraySegment<byte>)destination, ref index);
}
break;
case 3:
if (value.w >= 0f)
{
WriteBytes(value.x, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.y, (ArraySegment<byte>)destination, ref index);
WriteBytes(value.z, (ArraySegment<byte>)destination, ref index);
}
else
{
WriteBytes(0f - value.x, (ArraySegment<byte>)destination, ref index);
WriteBytes(0f - value.y, (ArraySegment<byte>)destination, ref index);
WriteBytes(0f - value.z, (ArraySegment<byte>)destination, ref index);
}
break;
}
}
public static void WriteBytes(Vector3 value, ByteBuffer buffer)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
WriteBytes(value.x, buffer);
WriteBytes(value.y, buffer);
WriteBytes(value.z, buffer);
}
public static void WriteBytes(Quaternion value, ByteBuffer buffer)
{
//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_0009: 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_0024: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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)
//IL_0174: 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_00a5: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: 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_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
value = ((Quaternion)(ref value)).normalized;
float num = value.x;
byte b = 0;
if (value.y > num)
{
num = value.y;
b = 1;
}
if (value.z > num)
{
num = value.z;
b = 2;
}
if (value.w > num)
{
num = value.w;
b = 3;
}
WriteBytes(b, buffer);
switch (b)
{
case 0:
if (value.x >= 0f)
{
WriteBytes(value.y, buffer);
WriteBytes(value.z, buffer);
WriteBytes(value.w, buffer);
}
else
{
WriteBytes(0f - value.y, buffer);
WriteBytes(0f - value.z, buffer);
WriteBytes(0f - value.w, buffer);
}
break;
case 1:
if (value.y >= 0f)
{
WriteBytes(value.x, buffer);
WriteBytes(value.z, buffer);
WriteBytes(value.w, buffer);
}
else
{
WriteBytes(0f - value.x, buffer);
WriteBytes(0f - value.z, buffer);
WriteBytes(0f - value.w, buffer);
}
break;
case 2:
if (value.z >= 0f)
{
WriteBytes(value.x, buffer);
WriteBytes(value.y, buffer);
WriteBytes(value.w, buffer);
}
else
{
WriteBytes(0f - value.x, buffer);
WriteBytes(0f - value.y, buffer);
WriteBytes(0f - value.w, buffer);
}
break;
case 3:
if (value.w >= 0f)
{
WriteBytes(value.x, buffer);
WriteBytes(value.y, buffer);
WriteBytes(value.z, buffer);
}
else
{
WriteBytes(0f - value.x, buffer);
WriteBytes(0f - value.y, buffer);
WriteBytes(0f - value.z, buffer);
}
break;
}
}
public static void WriteBytes(Vector3 value, FileStream fs)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
WriteBytes(value.x, fs);
WriteBytes(value.y, fs);
WriteBytes(value.z, fs);
}
public static void WriteBytes(Quaternion value, FileStream fs)
{
//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_0009: 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_0024: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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)
//IL_0174: 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_00a5: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: 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_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
value = ((Quaternion)(ref value)).normalized;
float num = value.x;
byte b = 0;
if (value.y > num)
{
num = value.y;
b = 1;
}
if (value.z > num)
{
num = value.z;
b = 2;
}
if (value.w > num)
{
num = value.w;
b = 3;
}
WriteBytes(b, fs);
switch (b)
{
case 0:
if (value.x >= 0f)
{
WriteBytes(value.y, fs);
WriteBytes(value.z, fs);
WriteBytes(value.w, fs);
}
else
{
WriteBytes(0f - value.y, fs);
WriteBytes(0f - value.z, fs);
WriteBytes(0f - value.w, fs);
}
break;
case 1:
if (value.y >= 0f)
{
WriteBytes(value.x, fs);
WriteBytes(value.z, fs);
WriteBytes(value.w, fs);
}
else
{
WriteBytes(0f - value.x, fs);
WriteBytes(0f - value.z, fs);
WriteBytes(0f - value.w, fs);
}
break;
case 2:
if (value.z >= 0f)
{
WriteBytes(value.x, fs);
WriteBytes(value.y, fs);
WriteBytes(value.w, fs);
}
else
{
WriteBytes(0f - value.x, fs);
WriteBytes(0f - value.y, fs);
WriteBytes(0f - value.w, fs);
}
break;
case 3:
if (value.w >= 0f)
{
WriteBytes(value.x, fs);
WriteBytes(value.y, fs);
WriteBytes(value.z, fs);
}
else
{
WriteBytes(0f - value.x, fs);
WriteBytes(0f - value.y, fs);
WriteBytes(0f - value.z, fs);
}
break;
}
}
public static Vector3 ReadVector3(ArraySegment<byte> source, ref int index)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(ReadFloat(source, ref index), ReadFloat(source, ref index), ReadFloat(source, ref index));
}
public static Quaternion ReadQuaternion(ArraySegment<byte> source, ref int index)
{
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
byte b = ReadByte(source, ref index);
float num = 0f;
float num2 = 0f;
float num3 = 0f;
float num4 = 0f;
switch (b)
{
case 0:
num2 = ReadFloat(source, ref index);
num3 = ReadFloat(source, ref index);
num4 = ReadFloat(source, ref index);
num = Mathf.Sqrt(Mathf.Clamp01(1f - num2 * num2 - num3 * num3 - num4 * num4));
break;
case 1:
num = ReadFloat(source, ref index);
num3 = ReadFloat(source, ref index);
num4 = ReadFloat(source, ref index);
num2 = Mathf.Sqrt(Mathf.Clamp01(1f - num * num - num3 * num3 - num4 * num4));
break;
case 2:
num = ReadFloat(source, ref index);
num2 = ReadFloat(source, ref index);
num4 = ReadFloat(source, ref index);
num3 = Mathf.Sqrt(Mathf.Clamp01(1f - num * num - num2 * num2 - num4 * num4));
break;
case 3:
num = ReadFloat(source, ref index);
num2 = ReadFloat(source, ref index);
num3 = ReadFloat(source, ref index);
num4 = Mathf.Sqrt(Mathf.Clamp01(1f - num * num - num2 * num2 - num3 * num3));
break;
}
return new Quaternion(num, num2, num3, num4);
}
public static void WriteHalf(Vector3 value, ArraySegment<byte> destination, ref int index)
{
//IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references)
WriteHalf(value.x, destination, ref index);
WriteHalf(value.y, destination, ref index);
WriteHalf(value.z, destination, ref index);
}
public static void WriteHalf(Quaternion value, ArraySegment<byte> destination, ref int index)
{
//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_0009: 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_0024: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
//IL_0067: 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_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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_0081: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
value = ((Quaternion)(ref value)).normalized;
float num = value.x;
byte b = 0;
if (value.y > num)
{
num = value.y;
b = 1;
}
if (value.z > num)
{
num = value.z;
b = 2;
}
if (value.w > num)
{
num = value.w;
b = 3;
}
WriteBytes(b, destination, ref index);
switch (b)
{
case 0:
if (value.x >= 0f)
{
WriteHalf(value.y, destination, ref index);
WriteHalf(value.z, destination, ref index);
WriteHalf(value.w, destination, ref index);
}
else
{
WriteHalf(0f - value.y, destination, ref index);
WriteHalf(0f - value.z, destination, ref index);
WriteHalf(0f - value.w, destination, ref index);
}
break;
case 1:
if (value.y >= 0f)
{
WriteHalf(value.x, destination, ref index);
WriteHalf(value.z, destination, ref index);
WriteHalf(value.w, destination, ref index);
}
else
{
WriteHalf(0f - value.x, destination, ref index);
WriteHalf(0f - value.z, destination, ref index);
WriteHalf(0f - value.w, destination, ref index);
}
break;
case 2:
if (value.z >= 0f)
{
WriteHalf(value.x, destination, ref index);
WriteHalf(value.y, destination, ref index);
WriteHalf(value.w, destination, ref index);
}
else
{
WriteHalf(0f - value.x, destination, ref index);
WriteHalf(0f - value.y, destination, ref index);
WriteHalf(0f - value.w, destination, ref index);
}
break;
case 3:
if (value.w >= 0f)
{
WriteHalf(value.x, destination, ref index);
WriteHalf(value.y, destination, ref index);
WriteHalf(value.z, destination, ref index);
}
else
{
WriteHalf(0f - value.x, destination, ref index);
WriteHalf(0f - value.y, destination, ref index);
WriteHalf(0f - value.z, destination, ref index);
}
break;
}
}
public static void WriteHalf(Vector3 value, ByteBuffer buffer)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
WriteHalf(value.x, buffer);
WriteHalf(value.y, buffer);
WriteHalf(value.z, buffer);
}
public static void WriteHalf(Quaternion value, ByteBuffer buffer)
{
//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_0009: 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_0024: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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)
//IL_0174: 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_00a5: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: 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_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
value = ((Quaternion)(ref value)).normalized;
float num = value.x;
byte b = 0;
if (value.y > num)
{
num = value.y;
b = 1;
}
if (value.z > num)
{
num = value.z;
b = 2;
}
if (value.w > num)
{
num = value.w;
b = 3;
}
WriteBytes(b, buffer);
switch (b)
{
case 0:
if (value.x >= 0f)
{
WriteHalf(value.y, buffer);
WriteHalf(value.z, buffer);
WriteHalf(value.w, buffer);
}
else
{
WriteHalf(0f - value.y, buffer);
WriteHalf(0f - value.z, buffer);
WriteHalf(0f - value.w, buffer);
}
break;
case 1:
if (value.y >= 0f)
{
WriteHalf(value.x, buffer);
WriteHalf(value.z, buffer);
WriteHalf(value.w, buffer);
}
else
{
WriteHalf(0f - value.x, buffer);
WriteHalf(0f - value.z, buffer);
WriteHalf(0f - value.w, buffer);
}
break;
case 2:
if (value.z >= 0f)
{
WriteHalf(value.x, buffer);
WriteHalf(value.y, buffer);
WriteHalf(value.w, buffer);
}
else
{
WriteHalf(0f - value.x, buffer);
WriteHalf(0f - value.y, buffer);
WriteHalf(0f - value.w, buffer);
}
break;
case 3:
if (value.w >= 0f)
{
WriteHalf(value.x, buffer);
WriteHalf(value.y, buffer);
WriteHalf(value.z, buffer);
}
else
{
WriteHalf(0f - value.x, buffer);
WriteHalf(0f - value.y, buffer);
WriteHalf(0f - value.z, buffer);
}
break;
}
}
public static void WriteHalf(Vector3 value, FileStream fs)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
WriteHalf(value.x, fs);
WriteHalf(value.y, fs);
WriteHalf(value.z, fs);
}
public static void WriteHalf(Quaternion value, FileStream fs)
{
//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_0009: 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_0024: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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)
//IL_0174: 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_00a5: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: 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_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
value = ((Quaternion)(ref value)).normalized;
float num = value.x;
byte b = 0;
if (value.y > num)
{
num = value.y;
b = 1;
}
if (value.z > num)
{
num = value.z;
b = 2;
}
if (value.w > num)
{
num = value.w;
b = 3;
}
WriteBytes(b, fs);
switch (b)
{
case 0:
if (value.x >= 0f)
{
WriteHalf(value.y, fs);
WriteHalf(value.z, fs);
WriteHalf(value.w, fs);
}
else
{
WriteHalf(0f - value.y, fs);
WriteHalf(0f - value.z, fs);
WriteHalf(0f - value.w, fs);
}
break;
case 1:
if (value.y >= 0f)
{
WriteHalf(value.x, fs);
WriteHalf(value.z, fs);
WriteHalf(value.w, fs);
}
else
{
WriteHalf(0f - value.x, fs);
WriteHalf(0f - value.z, fs);
WriteHalf(0f - value.w, fs);
}
break;
case 2:
if (value.z >= 0f)
{
WriteHalf(value.x, fs);
WriteHalf(value.y, fs);
WriteHalf(value.w, fs);
}
else
{
WriteHalf(0f - value.x, fs);
WriteHalf(0f - value.y, fs);
WriteHalf(0f - value.w, fs);
}
break;
case 3:
if (value.w >= 0f)
{
WriteHalf(value.x, fs);
WriteHalf(value.y, fs);
WriteHalf(value.z, fs);
}
else
{
WriteHalf(0f - value.x, fs);
WriteHalf(0f - value.y, fs);
WriteHalf(0f - value.z, fs);
}
break;
}
}
public static Vector3 ReadHalfVector3(ArraySegment<byte> source, ref int index)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(ReadHalf(source, ref index), ReadHalf(source, ref index), ReadHalf(source, ref index));
}
public static Quaternion ReadHalfQuaternion(ArraySegment<byte> source, ref int index)
{
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
byte b = ReadByte(source, ref index);
float num = 0f;
float num2 = 0f;
float num3 = 0f;
float num4 = 0f;
switch (b)
{
case 0:
num2 = ReadHalf(source, ref index);
num3 = ReadHalf(source, ref index);
num4 = ReadHalf(source, ref index);
num = Mathf.Sqrt(Mathf.Clamp01(1f - num2 * num2 - num3 * num3 - num4 * num4));
break;
case 1:
num = ReadHalf(source, ref index);
num3 = ReadHalf(source, ref index);
num4 = ReadHalf(source, ref index);
num2 = Mathf.Sqrt(Mathf.Clamp01(1f - num * num - num3 * num3 - num4 * num4));
break;
case 2:
num = ReadHalf(source, ref index);
num2 = ReadHalf(source, ref index);
num4 = ReadHalf(source, ref index);
num3 = Mathf.Sqrt(Mathf.Clamp01(1f - num * num - num2 * num2 - num4 * num4));
break;
case 3:
num = ReadHalf(source, ref index);
num2 = ReadHalf(source, ref index);
num3 = ReadHalf(source, ref index);
num4 = Mathf.Sqrt(Mathf.Clamp01(1f - num * num - num2 * num2 - num3 * num3));
break;
}
return new Quaternion(num, num2, num3, num4);
}
}
public static class Replay
{
public static Action? OnExpeditionEnd;
public static Action? OnExpeditionStart;
public static Action? OnElevatorStop;
public static Action? OnGameplayStart;
public static Action? OnHeaderCompletion;
public static Action? OnTick;
public static Action? OnPluginLoad;
public static Dictionary<Type, Action<long, ReplayEvent>?> EventHooks = new Dictionary<Type, Action<long, ReplayEvent>>();
public static Dictionary<Type, Action<long, ReplayDynamic>?> SpawnHooks = new Dictionary<Type, Action<long, ReplayDynamic>>();
public static Dictionary<Type, Action<long, ReplayDynamic>?> DespawnHooks = new Dictionary<Type, Action<long, ReplayDynamic>>();
public static Dictionary<Type, Action<long, ReplayDynamic>?> DynamicHooks = new Dictionary<Type, Action<long, ReplayDynamic>>();
public static Dictionary<Type, Action<long, ReplayDynamic>?> DirtyDynamicHooks = new Dictionary<Type, Action<long, ReplayDynamic>>();
public static float tickRate => SnapshotManager.GetInstance().tickRate;
public static bool Ready => SnapshotManager.Ready;
public static bool Active => SnapshotManager.Active;
private static Delegate CreateCompatibleDelegate(MethodInfo methodInfo, Type delegateType)
{
ParameterInfo[] parameters2 = methodInfo.GetParameters();
ParameterInfo[] parameters3 = delegateType.GetMethod("Invoke").GetParameters();
ParameterExpression[] parameters = parameters3.Select((ParameterInfo p) => Expression.Parameter(p.ParameterType, p.Name)).ToArray();
UnaryExpression[] array = parameters2.Select((ParameterInfo mp, int i) => Expression.Convert(parameters[i], mp.ParameterType)).ToArray();
Expression[] arguments = array;
MethodCallExpression body = Expression.Call(null, methodInfo, arguments);
return Expression.Lambda(delegateType, body, parameters).Compile();
}
private static void RegisterMethods(Type t)
{
foreach (MethodInfo item in from m in t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
where m.GetCustomAttribute<ReplayOnExpeditionEnd>() != null || m.GetCustomAttribute<ReplayInit>() != null || m.GetCustomAttribute<ReplayTick>() != null || m.GetCustomAttribute<ReplayOnHeaderCompletion>() != null || m.GetCustomAttribute<ReplayOnGameplayStart>() != null || m.GetCustomAttribute<ReplayOnElevatorStop>() != null || m.GetCustomAttribute<ReplayHook>() != null || m.GetCustomAttribute<ReplaySpawnHook>() != null || m.GetCustomAttribute<ReplayDespawnHook>() != null || m.GetCustomAttribute<ReplayOnPlayerSpawn>() != null || m.GetCustomAttribute<ReplayOnPlayerDespawn>() != null || m.GetCustomAttribute<ReplayPluginLoad>() != null
select m)
{
if (item.IsStatic)
{
try
{
string value = "ReplayOnExpeditionEnd";
ReplayHook customAttribute = item.GetCustomAttribute<ReplayHook>();
ReplaySpawnHook customAttribute2 = item.GetCustomAttribute<ReplaySpawnHook>();
ReplayDespawnHook customAttribute3 = item.GetCustomAttribute<ReplayDespawnHook>();
if (customAttribute != null)
{
value = "ReplayHook";
if (customAttribute.type.IsAssignableTo(typeof(ReplayEvent)))
{
Action<long, ReplayEvent> action = (Action<long, ReplayEvent>)CreateCompatibleDelegate(item, typeof(Action<long, ReplayEvent>));
if (!EventHooks.ContainsKey(customAttribute.type))
{
EventHooks.Add(customAttribute.type, action);
}
else
{
Dictionary<Type, Action<long, ReplayEvent>> eventHooks = EventHooks;
Type type = customAttribute.type;
eventHooks[type] = (Action<long, ReplayEvent>)Delegate.Combine(eventHooks[type], action);
}
}
else if (customAttribute.type.IsAssignableTo(typeof(ReplayDynamic)))
{
Action<long, ReplayDynamic> action2 = (Action<long, ReplayDynamic>)CreateCompatibleDelegate(item, typeof(Action<long, ReplayDynamic>));
if (customAttribute.triggerOnlyWhenDirty)
{
if (!DirtyDynamicHooks.ContainsKey(customAttribute.type))
{
DirtyDynamicHooks.Add(customAttribute.type, action2);
}
else
{
Dictionary<Type, Action<long, ReplayDynamic>> dirtyDynamicHooks = DirtyDynamicHooks;
Type type = customAttribute.type;
dirtyDynamicHooks[type] = (Action<long, ReplayDynamic>)Delegate.Combine(dirtyDynamicHooks[type], action2);
}
}
else if (!DynamicHooks.ContainsKey(customAttribute.type))
{
DynamicHooks.Add(customAttribute.type, action2);
}
else
{
Dictionary<Type, Action<long, ReplayDynamic>> dirtyDynamicHooks = DynamicHooks;
Type type = customAttribute.type;
dirtyDynamicHooks[type] = (Action<long, ReplayDynamic>)Delegate.Combine(dirtyDynamicHooks[type], action2);
}
}
else
{
APILogger.Error($"Failed to register method '{item}': Type '{customAttribute.type}' is not a valid ReplayDynamic / ReplayEvent.");
}
}
else if (customAttribute2 != null)
{
value = "ReplaySpawnHook";
if (customAttribute2.type.IsAssignableTo(typeof(ReplayDynamic)))
{
Action<long, ReplayDynamic> action3 = (Action<long, ReplayDynamic>)CreateCompatibleDelegate(item, typeof(Action<long, ReplayDynamic>));
if (!SpawnHooks.ContainsKey(customAttribute2.type))
{
SpawnHooks.Add(customAttribute2.type, action3);
}
else
{
Dictionary<Type, Action<long, ReplayDynamic>> dirtyDynamicHooks = SpawnHooks;
Type type = customAttribute2.type;
dirtyDynamicHooks[type] = (Action<long, ReplayDynamic>)Delegate.Combine(dirtyDynamicHooks[type], action3);
}
}
else
{
APILogger.Error($"Failed to register method '{item}': Type '{customAttribute2.type}' is not a valid ReplayDynamic.");
}
}
else if (customAttribute3 != null)
{
value = "ReplayDespawnHook";
if (customAttribute3.type.IsAssignableTo(typeof(ReplayDynamic)))
{
Action<long, ReplayDynamic> action4 = (Action<long, ReplayDynamic>)CreateCompatibleDelegate(item, typeof(Action<long, ReplayDynamic>));
if (!DespawnHooks.ContainsKey(customAttribute3.type))
{
DespawnHooks.Add(customAttribute3.type, action4);
}
else
{
Dictionary<Type, Action<long, ReplayDynamic>> dirtyDynamicHooks = DespawnHooks;
Type type = customAttribute3.type;
dirtyDynamicHooks[type] = (Action<long, ReplayDynamic>)Delegate.Combine(dirtyDynamicHooks[type], action4);
}
}
else
{
APILogger.Error($"Failed to register method '{item}': Type '{customAttribute3.type}' is not a valid ReplayDynamic.");
}
}
else if (item.GetCustomAttribute<ReplayInit>() != null)
{
value = "ReplayInit";
OnExpeditionStart = (Action)Delegate.Combine(OnExpeditionStart, (Action)item.CreateDelegate(typeof(Action)));
}
else if (item.GetCustomAttribute<ReplayOnHeaderCompletion>() != null)
{
value = "ReplayOnHeaderCompletion";
OnHeaderCompletion = (Action)Delegate.Combine(OnHeaderCompletion, (Action)item.CreateDelegate(typeof(Action)));
}
else if (item.GetCustomAttribute<ReplayOnGameplayStart>() != null)
{
value = "ReplayOnGameplayStart";
OnGameplayStart = (Action)Delegate.Combine(OnGameplayStart, (Action)item.CreateDelegate(typeof(Action)));
}
else if (item.GetCustomAttribute<ReplayTick>() != null)
{
value = "ReplayTick";
OnTick = (Action)Delegate.Combine(OnTick, (Action)item.CreateDelegate(typeof(Action)));
}
else if (item.GetCustomAttribute<ReplayOnElevatorStop>() != null)
{
value = "ReplayOnElevatorStop";
OnElevatorStop = (Action)Delegate.Combine(OnElevatorStop, (Action)item.CreateDelegate(typeof(Action)));
}
else if (item.GetCustomAttribute<ReplayOnPlayerSpawn>() != null)
{
value = "ReplayOnPlayerSpawn";
ReplayPlayerManager.OnPlayerSpawn = (Action<PlayerAgent>)Delegate.Combine(ReplayPlayerManager.OnPlayerSpawn, (Action<PlayerAgent>)CreateCompatibleDelegate(item, typeof(Action<PlayerAgent>)));
}
else if (item.GetCustomAttribute<ReplayOnPlayerDespawn>() != null)
{
value = "ReplayOnPlayerDespawn";
ReplayPlayerManager.OnPlayerDespawn = (Action<int>)Delegate.Combine(ReplayPlayerManager.OnPlayerDespawn, (Action<int>)CreateCompatibleDelegate(item, typeof(Action<int>)));
}
else if (item.GetCustomAttribute<ReplayPluginLoad>() != null)
{
value = "ReplayPluginLoad";
OnPluginLoad = (Action)Delegate.Combine(OnPluginLoad, (Action)item.CreateDelegate(typeof(Action)));
}
else
{
OnExpeditionEnd = (Action)Delegate.Combine(OnExpeditionEnd, (Action)item.CreateDelegate(typeof(Action)));
}
APILogger.Debug($"Registered {value}: '{t.FullName}.{item.Name}'");
}
catch (Exception value2)
{
APILogger.Error($"Failed to register method '{item}': {value2}");
}
}
else
{
APILogger.Error($"Replay attributes can only be applied to static methods. '{item}' is not static.");
}
}
}
public static void RegisterAll()
{
Assembly obj = new StackTrace()?.GetFrame(1)?.GetMethod()?.ReflectedType?.Assembly;
if (obj == null)
{
throw new Exception("Unable to find assembly.");
}
CollectionExtensions.Do<Type>((IEnumerable<Type>)AccessTools.GetTypesFromAssembly(obj), (Action<Type>)delegate(Type t)
{
if (t.GetCustomAttribute<ReplayData>() != null)
{
RegisterType(t);
}
RegisterMethods(t);
});
}
public static void RegisterAll(Type type)
{
Type[] nestedTypes = type.GetNestedTypes(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (Type type2 in nestedTypes)
{
if (type.GetCustomAttribute<ReplayData>() != null)
{
RegisterType(type2);
}
RegisterMethods(type2);
RegisterAll(type2);
}
}
public static void RegisterType(Type type)
{
ReplayData customAttribute = type.GetCustomAttribute<ReplayData>();
if (customAttribute == null)
{
throw new ReplayTypeNotCompatible($"Type '{type}' is not a valid ReplayData type.");
}
SnapshotManager.types.RegisterType(customAttribute, type);
}
[HideFromIl2Cpp]
public static void Configure<T>(int tickRate = 1, int max = int.MaxValue) where T : ReplayDynamic
{
SnapshotManager.GetInstance().Configure<T>(tickRate, max);
}
[HideFromIl2Cpp]
public static bool Trigger(ReplayEvent e)
{
return SnapshotManager.GetInstance().Trigger(e);
}
[HideFromIl2Cpp]
public static void Trigger(ReplayHeader header)
{
SnapshotManager.GetInstance().Trigger(header);
}
[HideFromIl2Cpp]
public static bool Has(ReplayDynamic dynamic)
{
return SnapshotManager.GetInstance().Has(dynamic);
}
[HideFromIl2Cpp]
public static bool Has<T>(int id) where T : ReplayDynamic
{
return SnapshotManager.GetInstance().Has(typeof(T), id);
}
[HideFromIl2Cpp]
public static T Get<T>(int id) where T : ReplayDynamic
{
return (T)SnapshotManager.GetInstance().Get(typeof(T), id);
}
[HideFromIl2Cpp]
public static bool TryGet<T>(int id, [NotNullWhen(true)] out T dynamic) where T : ReplayDynamic
{
if (Has<T>(id))
{
dynamic = Get<T>(id);
return true;
}
dynamic = null;
return false;
}
[HideFromIl2Cpp]
public static void Clear<T>() where T : ReplayDynamic
{
SnapshotManager.GetInstance().Clear(typeof(T));
}
[HideFromIl2Cpp]
public static void Spawn(ReplayDynamic dynamic, bool errorOnDuplicate = true)
{
SnapshotManager.GetInstance().Spawn(dynamic, errorOnDuplicate);
}
[HideFromIl2Cpp]
public static void Despawn(ReplayDynamic dynamic, bool errorOnNotFound = true)
{
SnapshotManager.GetInstance().Despawn(dynamic, errorOnNotFound);
}
[HideFromIl2Cpp]
public static bool TryDespawn<T>(int id) where T : ReplayDynamic
{
if (Has<T>(id))
{
Despawn(Get<T>(id));
return true;
}
return false;
}
}
public class ConcurrentHashSet<T> : ConcurrentDictionary<T, byte> where T : notnull
{
private const byte DummyByte = 0;
public bool Contains(T item)
{
return ContainsKey(item);
}
public bool Add(T item)
{
return TryAdd(item, 0);
}
public bool Remove(T item)
{
byte value;
return TryRemove(item, out value);
}
}
public static class Utils
{
public const BindingFlags AnyBindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
public static string RemoveHTMLTags(string content)
{
return Regex.Replace(content, "<[^>]*>", "");
}
public static string RemoveInvalidCharacters(string content, char replace = '_', bool isFullPath = true)
{
if (string.IsNullOrEmpty(content))
{
return content;
}
char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
int num = content.IndexOfAny(invalidFileNameChars);
if (num >= 0)
{
StringBuilder stringBuilder = new StringBuilder(content);
while (num >= 0)
{
if (!isFullPath || (stringBuilder[num] != ':' && stringBuilder[num] != '\\' && stringBuilder[num] != '/'))
{
stringBuilder[num] = replace;
}
num = content.IndexOfAny(invalidFileNameChars, num + 1);
}
return stringBuilder.ToString();
}
return content;
}
}
}
namespace ReplayRecorder.Steam
{
internal class rSteamClient : IDisposable
{
public delegate void OnAccept(rSteamClient connection);
public delegate void OnReceive(ArraySegment<byte> buffer, rSteamClient connection);
public delegate void OnClose(rSteamClient connection);
public delegate void OnFail(rSteamClient connection);
public OnAccept? onAccept;
public OnReceive? onReceive;
public OnClose? onClose;
public OnFail? onFail;
internal static HashSet<HSteamNetConnection> localClients = new HashSet<HSteamNetConnection>();
private bool running = true;
private Task? receiveTask;
private HSteamNetConnection connection;
private SteamNetworkingIdentity identity;
private Callback<SteamNetConnectionStatusChangedCallback_t> cb_OnConnectionStatusChanged;
private bool connected;
private readonly string debugName;
private ConcurrentQueue<rSteamServer.ResendRequest> resendQueue = new ConcurrentQueue<rSteamServer.ResendRequest>();
private List<rSteamServer.ResendRequest> resendQueueBuffer = new List<rSteamServer.ResendRequest>();
public rSteamClient(ulong steamid, int virtualPort, SteamNetworkingConfigValue_t[]? options = null, string debugName = "Client")
{
//IL_0031: 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_005a: 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_006a: Unknown result type (might be due to invalid IL or missing references)
this.debugName = debugName;
identity = default(SteamNetworkingIdentity);
((SteamNetworkingIdentity)(ref identity)).SetSteamID(new CSteamID(steamid));
connection = SteamNetworkingSockets.ConnectP2P(ref identity, virtualPort, (options != null) ? options.Length : 0, options);
localClients.Add(connection);
cb_OnConnectionStatusChanged = Callback<SteamNetConnectionStatusChangedCallback_t>.Create((DispatchDelegate<SteamNetConnectionStatusChangedCallback_t>)OnConnectionStatusChanged);
}
public bool Send(ArraySegment<byte> data, bool dequeue = false)
{
//IL_0091: 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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
if (!dequeue && !resendQueue.IsEmpty)
{
resendQueue.Enqueue(new rSteamServer.ResendRequest
{
bytes = data
});
return true;
}
if (data.Count > 81920)
{
APILogger.Error("Failed to send packet, packet was larger than maximum message send size.");
throw new Exception("Failed to send packet, packet was larger than maximum message send size.");
}
IntPtr[] array = new IntPtr[1];
ArraySegment<byte>[] array2 = new ArraySegment<byte>[1];
long[] array3 = new long[1];
int num = 0;
int num2 = 0;
while (num < data.Count)
{
int num3 = Mathf.Min(data.Count - num, 81920);
IntPtr intPtr = SteamGameServerNetworkingUtils.AllocateMessage(num3);
SteamNetworkingMessage_t val = SteamNetworkingMessage_t.FromIntPtr(intPtr);
val.m_conn = connection;
val.m_nFlags = 9;
Marshal.Copy(data.Array, data.Offset + num, val.m_pData, num3);
array2[num2] = new ArraySegment<byte>(data.Array, data.Offset + num, num3);
num += num3;
array[num2] = intPtr;
num2++;
Marshal.StructureToPtr<SteamNetworkingMessage_t>(val, intPtr, fDeleteOld: true);
APILogger.Debug($"[{debugName}] Sent packet({dequeue}): {num}/{data.Count}");
}
SteamNetworkingSockets.SendMessages(1, array, array3);
bool result = true;
for (int i = 0; i < array3.Length; i++)
{
if (array3[i] < 0)
{
APILogger.Debug($"[{debugName}] Failed to send packet, Error Code: {array3[i]}");
if (-array3[i] == 25)
{
resendQueue.Enqueue(new rSteamServer.ResendRequest
{
bytes = array2[i]
});
APILogger.Debug("[" + debugName + "] Requeued packet.");
result = false;
}
else
{
APILogger.Error($"[{debugName}] Failed to send packet, Error Code: {array3[i]}");
}
}
}
return result;
}
private async Task ReceiveMessages()
{
IntPtr[] messageBuffer = new IntPtr[50];
while (true)
{
int num;
int numMessages = (num = SteamNetworkingSockets.ReceiveMessagesOnConnection(connection, messageBuffer, messageBuffer.Length));
if (num > 0)
{
for (int i = 0; i < numMessages; i++)
{
SteamNetworkingMessage_t val = SteamNetworkingMessage_t.FromIntPtr(messageBuffer[i]);
byte[] array = new byte[val.m_cbSize];
Marshal.Copy(val.m_pData, array, 0, array.Length);
onReceive?.Invoke(array, this);
SteamNetworkingMessage_t.Release(messageBuffer[i]);
}
continue;
}
if (!resendQueue.IsEmpty)
{
SteamNetConnectionRealTimeStatus_t val2 = default(SteamNetConnectionRealTimeStatus_t);
SteamNetConnectionRealTimeLaneStatus_t val3 = default(SteamNetConnectionRealTimeLaneStatus_t);
if ((int)SteamNetworkingSockets.GetConnectionRealTimeStatus(connection, ref val2, 0, ref val3) == 1 && val2.m_cbPendingReliable + val2.m_cbSentUnackedReliable == 0)
{
rSteamServer.ResendRequest result;
while (resendQueue.TryDequeue(out result))
{
resendQueueBuffer.Add(result);
}
int j;
for (j = 0; j < resendQueueBuffer.Count && Send(resendQueueBuffer[j].bytes, dequeue: true); j++)
{
}
for (; j < resendQueueBuffer.Count; j++)
{
resendQueue.Enqueue(resendQueueBuffer[j]);
}
resendQueueBuffer.Clear();
}
}
await Task.Delay(16);
if (numMessages < 0 || !running)
{
break;
}
}
}
private void OnConnectionStatusChanged(SteamNetConnectionStatusChangedCallback_t callbackData)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//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_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected I4, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
HSteamNetConnection hConn = callbackData.m_hConn;
if (connection != hConn)
{
return;
}
SteamNetConnectionInfo_t info = callbackData.m_info;
ESteamNetworkingConnectionState eState = info.m_eState;
switch (eState - 1)
{
case 0:
APILogger.Warn($"[{debugName}] {hConn.m_HSteamNetConnection} Connecting to: {((SteamNetConnectionInfo_t)(ref info)).m_szConnectionDescription}");
connected = false;
break;
case 2:
APILogger.Warn($"[{debugName}] {hConn.m_HSteamNetConnection} Connection established: {((SteamNetConnectionInfo_t)(ref info)).m_szConnectionDescription}");
onAccept?.Invoke(this);
connected = true;
receiveTask = ReceiveMessages();
break;
case 3:
case 4:
APILogger.Warn($"[{debugName}] {hConn.m_HSteamNetConnection} Connection closed: {((SteamNetConnectionInfo_t)(ref info)).m_szEndDebug}, established: {connected}");
if (!connected)
{
onFail?.Invoke(this);
}
Dispose();
break;
case 1:
break;
}
}
public void Dispose()
{
//IL_0048: 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)
running = false;
receiveTask?.Wait();
receiveTask?.Dispose();
receiveTask = null;
onClose?.Invoke(this);
localClients.Remove(connection);
SteamNetworkingSockets.CloseConnection(connection, 0, "Disconnect", false);
cb_OnConnectionStatusChanged.Dispose();
}
}
internal class rSteamServer : IDisposable
{
public delegate void OnAccept(HSteamNetConnection connection);
public delegate void OnReceive(ArraySegment<byte> buffer, HSteamNetConnection connection);
public delegate void OnDisconnect(HSteamNetConnection connection);
public delegate void OnClose();
public struct ResendRequest
{
public ArraySegment<byte> bytes;
}
public class Connection
{
public ConcurrentQueue<ResendRequest> resendQueue = new ConcurrentQueue<ResendRequest>();
public List<ResendRequest> resendQueueBuffer = new List<ResendRequest>();
public readonly HSteamNetConnection connection;
private rSteamServer server;
public bool running = true;
public string name = "Unknown";
public Connection(rSteamServer server, HSteamNetConnection connection)
{
//IL_002f: 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)
this.connection = connection;
this.server = server;
ReceiveMessages();
}
public void Dispose()
{
running = false;
}
public async Task ReceiveMessages()
{
IntPtr[] messageBuffer = new IntPtr[50];
while (true)
{
int num;
int numMessages = (num = SteamNetworkingSockets.ReceiveMessagesOnConnection(connection, messageBuffer, messageBuffer.Length));
if (num > 0)
{
for (int i = 0; i < numMessages; i++)
{
SteamNetworkingMessage_t val = SteamNetworkingMessage_t.FromIntPtr(messageBuffer[i]);
byte[] array = new byte[val.m_cbSize];
Marshal.Copy(val.m_pData, array, 0, array.Length);
server.onReceive?.Invoke(array, connection);
SteamNetworkingMessage_t.Release(messageBuffer[i]);
}
continue;
}
if (!resendQueue.IsEmpty)
{
SteamNetConnectionRealTimeStatus_t val2 = default(SteamNetConnectionRealTimeStatus_t);
SteamNetConnectionRealTimeLaneStatus_t val3 = default(SteamNetConnectionRealTimeLaneStatus_t);
if ((int)SteamNetworkingSockets.GetConnectionRealTimeStatus(connection, ref val2, 0, ref val3) == 1 && val2.m_cbPendingReliable + val2.m_cbSentUnackedReliable == 0)
{
ResendRequest result;
while (resendQueue.TryDequeue(out result))
{
resendQueueBuffer.Add(result);
}
int j;
for (j = 0; j < resendQueueBuffer.Count && server.SendTo(connection, resendQueueBuffer[j].bytes, dequeue: true); j++)
{
}
for (; j < resendQueueBuffer.Count; j++)
{
resendQueue.Enqueue(resendQueueBuffer[j]);
}
resendQueueBuffer.Clear();
}
}
await Task.Delay(16);
if (numMessages < 0 || !running)
{
break;
}
}
}
}
public const int maxPacketSize = 81920;
public OnAccept? onAccept;
public OnReceive? onReceive;
public OnDisconnect? onDisconnect;
public OnClose? onClose;
private HSteamListenSocket server;
private Task? receiveTask;
private Callback<SteamNetConnectionStatusChangedCallback_t> cb_OnConnectionStatusChanged;
private readonly string debugName;
public ConcurrentDictionary<HSteamNetConnection, Connection> currentConnections = new ConcurrentDictionary<HSteamNetConnection, Connection>();
public rSteamServer(int virtualPort, SteamNetworkingConfigValue_t[]? options = null, string debugName = "Server")
{
//IL_0024: 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)
this.debugName = debugName;
server = SteamNetworkingSockets.CreateListenSocketP2P(virtualPort, (options != null) ? options.Length : 0, options);
cb_OnConnectionStatusChanged = Callback<SteamNetConnectionStatusChangedCallback_t>.Create((DispatchDelegate<SteamNetConnectionStatusChangedCallback_t>)OnConnectionStatusChanged);
}
public void Send(ArraySegment<byte> data)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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)
foreach (HSteamNetConnection key in currentConnections.Keys)
{
SendTo(key, data);
}
}
public bool SendTo(HSteamNetConnection connection, ArraySegment<byte> data, bool dequeue = false)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
Connection connection2 = currentConnections[connection];
if (!dequeue && !connection2.resendQueue.IsEmpty)
{
connection2.resendQueue.Enqueue(new ResendRequest
{
bytes = data
});
return true;
}
if (data.Count > 81920)
{
APILogger.Error("Failed to send packet, packet was larger than maximum message send size.");
throw new Exception("Failed to send packet, packet was larger than maximum message send size.");
}
IntPtr[] array = new IntPtr[1];
ArraySegment<byte>[] array2 = new ArraySegment<byte>[1];
long[] array3 = new long[1];
int num = 0;
int num2 = 0;
while (num < data.Count)
{
int num3 = Mathf.Min(data.Count - num, 81920);
IntPtr intPtr = SteamGameServerNetworkingUtils.AllocateMessage(num3);
SteamNetworkingMessage_t val = SteamNetworkingMessage_t.FromIntPtr(intPtr);
val.m_conn = connection;
val.m_nFlags = 9;
Marshal.Copy(data.Array, data.Offset + num, val.m_pData, num3);
array2[num2] = new ArraySegment<byte>(data.Array, data.Offset + num, num3);
num += num3;
array[num2] = intPtr;
num2++;
Marshal.StructureToPtr<SteamNetworkingMessage_t>(val, intPtr, fDeleteOld: true);
}
SteamNetworkingSockets.SendMessages(1, array, array3);
bool result = true;
for (int i = 0; i < array3.Length; i++)
{
if (array3[i] < 0)
{
APILogger.Debug($"Failed to send packet, Error Code: {array3[i]}");
if (-array3[i] == 25)
{
connection2.resend
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Text;
using Microsoft.Win32.SafeHandles;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Steamworks.NET")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Riley Labrecque")]
[assembly: AssemblyProduct("Steamworks.NET")]
[assembly: AssemblyCopyright("Copyright © Riley Labrecque 2013-2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("316ab144-2a2a-4847-857b-63317c980dda")]
[assembly: AssemblyFileVersion("2024.8.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]
[assembly: AssemblyVersion("2024.8.0.0")]
namespace Steamworks;
public static class SteamApps
{
public static bool BIsSubscribed()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsSubscribed(CSteamAPIContext.GetSteamApps());
}
public static bool BIsLowViolence()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsLowViolence(CSteamAPIContext.GetSteamApps());
}
public static bool BIsCybercafe()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsCybercafe(CSteamAPIContext.GetSteamApps());
}
public static bool BIsVACBanned()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsVACBanned(CSteamAPIContext.GetSteamApps());
}
public static string GetCurrentGameLanguage()
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamApps_GetCurrentGameLanguage(CSteamAPIContext.GetSteamApps()));
}
public static string GetAvailableGameLanguages()
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamApps_GetAvailableGameLanguages(CSteamAPIContext.GetSteamApps()));
}
public static bool BIsSubscribedApp(AppId_t appID)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsSubscribedApp(CSteamAPIContext.GetSteamApps(), appID);
}
public static bool BIsDlcInstalled(AppId_t appID)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsDlcInstalled(CSteamAPIContext.GetSteamApps(), appID);
}
public static uint GetEarliestPurchaseUnixTime(AppId_t nAppID)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_GetEarliestPurchaseUnixTime(CSteamAPIContext.GetSteamApps(), nAppID);
}
public static bool BIsSubscribedFromFreeWeekend()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsSubscribedFromFreeWeekend(CSteamAPIContext.GetSteamApps());
}
public static int GetDLCCount()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_GetDLCCount(CSteamAPIContext.GetSteamApps());
}
public static bool BGetDLCDataByIndex(int iDLC, out AppId_t pAppID, out bool pbAvailable, out string pchName, int cchNameBufferSize)
{
InteropHelp.TestIfAvailableClient();
IntPtr intPtr = Marshal.AllocHGlobal(cchNameBufferSize);
bool flag = NativeMethods.ISteamApps_BGetDLCDataByIndex(CSteamAPIContext.GetSteamApps(), iDLC, out pAppID, out pbAvailable, intPtr, cchNameBufferSize);
pchName = (flag ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
return flag;
}
public static void InstallDLC(AppId_t nAppID)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamApps_InstallDLC(CSteamAPIContext.GetSteamApps(), nAppID);
}
public static void UninstallDLC(AppId_t nAppID)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamApps_UninstallDLC(CSteamAPIContext.GetSteamApps(), nAppID);
}
public static void RequestAppProofOfPurchaseKey(AppId_t nAppID)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamApps_RequestAppProofOfPurchaseKey(CSteamAPIContext.GetSteamApps(), nAppID);
}
public static bool GetCurrentBetaName(out string pchName, int cchNameBufferSize)
{
InteropHelp.TestIfAvailableClient();
IntPtr intPtr = Marshal.AllocHGlobal(cchNameBufferSize);
bool flag = NativeMethods.ISteamApps_GetCurrentBetaName(CSteamAPIContext.GetSteamApps(), intPtr, cchNameBufferSize);
pchName = (flag ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
return flag;
}
public static bool MarkContentCorrupt(bool bMissingFilesOnly)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_MarkContentCorrupt(CSteamAPIContext.GetSteamApps(), bMissingFilesOnly);
}
public static uint GetInstalledDepots(AppId_t appID, DepotId_t[] pvecDepots, uint cMaxDepots)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_GetInstalledDepots(CSteamAPIContext.GetSteamApps(), appID, pvecDepots, cMaxDepots);
}
public static uint GetAppInstallDir(AppId_t appID, out string pchFolder, uint cchFolderBufferSize)
{
InteropHelp.TestIfAvailableClient();
IntPtr intPtr = Marshal.AllocHGlobal((int)cchFolderBufferSize);
uint num = NativeMethods.ISteamApps_GetAppInstallDir(CSteamAPIContext.GetSteamApps(), appID, intPtr, cchFolderBufferSize);
pchFolder = ((num != 0) ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
return num;
}
public static bool BIsAppInstalled(AppId_t appID)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsAppInstalled(CSteamAPIContext.GetSteamApps(), appID);
}
public static CSteamID GetAppOwner()
{
InteropHelp.TestIfAvailableClient();
return (CSteamID)NativeMethods.ISteamApps_GetAppOwner(CSteamAPIContext.GetSteamApps());
}
public static string GetLaunchQueryParam(string pchKey)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchKey2 = new InteropHelp.UTF8StringHandle(pchKey);
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamApps_GetLaunchQueryParam(CSteamAPIContext.GetSteamApps(), pchKey2));
}
public static bool GetDlcDownloadProgress(AppId_t nAppID, out ulong punBytesDownloaded, out ulong punBytesTotal)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_GetDlcDownloadProgress(CSteamAPIContext.GetSteamApps(), nAppID, out punBytesDownloaded, out punBytesTotal);
}
public static int GetAppBuildId()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_GetAppBuildId(CSteamAPIContext.GetSteamApps());
}
public static void RequestAllProofOfPurchaseKeys()
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamApps_RequestAllProofOfPurchaseKeys(CSteamAPIContext.GetSteamApps());
}
public static SteamAPICall_t GetFileDetails(string pszFileName)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pszFileName2 = new InteropHelp.UTF8StringHandle(pszFileName);
return (SteamAPICall_t)NativeMethods.ISteamApps_GetFileDetails(CSteamAPIContext.GetSteamApps(), pszFileName2);
}
public static int GetLaunchCommandLine(out string pszCommandLine, int cubCommandLine)
{
InteropHelp.TestIfAvailableClient();
IntPtr intPtr = Marshal.AllocHGlobal(cubCommandLine);
int num = NativeMethods.ISteamApps_GetLaunchCommandLine(CSteamAPIContext.GetSteamApps(), intPtr, cubCommandLine);
pszCommandLine = ((num != -1) ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
return num;
}
public static bool BIsSubscribedFromFamilySharing()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsSubscribedFromFamilySharing(CSteamAPIContext.GetSteamApps());
}
public static bool BIsTimedTrial(out uint punSecondsAllowed, out uint punSecondsPlayed)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_BIsTimedTrial(CSteamAPIContext.GetSteamApps(), out punSecondsAllowed, out punSecondsPlayed);
}
public static bool SetDlcContext(AppId_t nAppID)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_SetDlcContext(CSteamAPIContext.GetSteamApps(), nAppID);
}
public static int GetNumBetas(out int pnAvailable, out int pnPrivate)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamApps_GetNumBetas(CSteamAPIContext.GetSteamApps(), out pnAvailable, out pnPrivate);
}
public static bool GetBetaInfo(int iBetaIndex, out uint punFlags, out uint punBuildID, out string pchBetaName, int cchBetaName, out string pchDescription, int cchDescription)
{
InteropHelp.TestIfAvailableClient();
IntPtr intPtr = Marshal.AllocHGlobal(cchBetaName);
IntPtr intPtr2 = Marshal.AllocHGlobal(cchDescription);
bool flag = NativeMethods.ISteamApps_GetBetaInfo(CSteamAPIContext.GetSteamApps(), iBetaIndex, out punFlags, out punBuildID, intPtr, cchBetaName, intPtr2, cchDescription);
pchBetaName = (flag ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
pchDescription = (flag ? InteropHelp.PtrToStringUTF8(intPtr2) : null);
Marshal.FreeHGlobal(intPtr2);
return flag;
}
public static bool SetActiveBeta(string pchBetaName)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchBetaName2 = new InteropHelp.UTF8StringHandle(pchBetaName);
return NativeMethods.ISteamApps_SetActiveBeta(CSteamAPIContext.GetSteamApps(), pchBetaName2);
}
}
public static class SteamClient
{
public static HSteamPipe CreateSteamPipe()
{
InteropHelp.TestIfAvailableClient();
return (HSteamPipe)NativeMethods.ISteamClient_CreateSteamPipe(CSteamAPIContext.GetSteamClient());
}
public static bool BReleaseSteamPipe(HSteamPipe hSteamPipe)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamClient_BReleaseSteamPipe(CSteamAPIContext.GetSteamClient(), hSteamPipe);
}
public static HSteamUser ConnectToGlobalUser(HSteamPipe hSteamPipe)
{
InteropHelp.TestIfAvailableClient();
return (HSteamUser)NativeMethods.ISteamClient_ConnectToGlobalUser(CSteamAPIContext.GetSteamClient(), hSteamPipe);
}
public static HSteamUser CreateLocalUser(out HSteamPipe phSteamPipe, EAccountType eAccountType)
{
InteropHelp.TestIfAvailableClient();
return (HSteamUser)NativeMethods.ISteamClient_CreateLocalUser(CSteamAPIContext.GetSteamClient(), out phSteamPipe, eAccountType);
}
public static void ReleaseUser(HSteamPipe hSteamPipe, HSteamUser hUser)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamClient_ReleaseUser(CSteamAPIContext.GetSteamClient(), hSteamPipe, hUser);
}
public static IntPtr GetISteamUser(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamUser(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamGameServer(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamGameServer(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static void SetLocalIPBinding(ref SteamIPAddress_t unIP, ushort usPort)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamClient_SetLocalIPBinding(CSteamAPIContext.GetSteamClient(), ref unIP, usPort);
}
public static IntPtr GetISteamFriends(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamFriends(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamUtils(HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamUtils(CSteamAPIContext.GetSteamClient(), hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamMatchmaking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamMatchmaking(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamMatchmakingServers(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamMatchmakingServers(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamGenericInterface(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamGenericInterface(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamUserStats(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamUserStats(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamGameServerStats(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamGameServerStats(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamApps(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamApps(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamNetworking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamNetworking(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamRemoteStorage(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamRemoteStorage(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamScreenshots(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamScreenshots(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamGameSearch(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamGameSearch(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static uint GetIPCCallCount()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamClient_GetIPCCallCount(CSteamAPIContext.GetSteamClient());
}
public static void SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamClient_SetWarningMessageHook(CSteamAPIContext.GetSteamClient(), pFunction);
}
public static bool BShutdownIfAllPipesClosed()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamClient_BShutdownIfAllPipesClosed(CSteamAPIContext.GetSteamClient());
}
public static IntPtr GetISteamHTTP(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamHTTP(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamController(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamController(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamUGC(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamUGC(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamMusic(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamMusic(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamMusicRemote(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamMusicRemote(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamHTMLSurface(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamHTMLSurface(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamInventory(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamInventory(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamVideo(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamVideo(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamParentalSettings(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamParentalSettings(CSteamAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamInput(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamInput(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamParties(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamParties(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamRemotePlay(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamRemotePlay(CSteamAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
}
public static class SteamFriends
{
public static string GetPersonaName()
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetPersonaName(CSteamAPIContext.GetSteamFriends()));
}
public static SteamAPICall_t SetPersonaName(string pchPersonaName)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchPersonaName2 = new InteropHelp.UTF8StringHandle(pchPersonaName);
return (SteamAPICall_t)NativeMethods.ISteamFriends_SetPersonaName(CSteamAPIContext.GetSteamFriends(), pchPersonaName2);
}
public static EPersonaState GetPersonaState()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetPersonaState(CSteamAPIContext.GetSteamFriends());
}
public static int GetFriendCount(EFriendFlags iFriendFlags)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendCount(CSteamAPIContext.GetSteamFriends(), iFriendFlags);
}
public static CSteamID GetFriendByIndex(int iFriend, EFriendFlags iFriendFlags)
{
InteropHelp.TestIfAvailableClient();
return (CSteamID)NativeMethods.ISteamFriends_GetFriendByIndex(CSteamAPIContext.GetSteamFriends(), iFriend, iFriendFlags);
}
public static EFriendRelationship GetFriendRelationship(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendRelationship(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static EPersonaState GetFriendPersonaState(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendPersonaState(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static string GetFriendPersonaName(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendPersonaName(CSteamAPIContext.GetSteamFriends(), steamIDFriend));
}
public static bool GetFriendGamePlayed(CSteamID steamIDFriend, out FriendGameInfo_t pFriendGameInfo)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendGamePlayed(CSteamAPIContext.GetSteamFriends(), steamIDFriend, out pFriendGameInfo);
}
public static string GetFriendPersonaNameHistory(CSteamID steamIDFriend, int iPersonaName)
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendPersonaNameHistory(CSteamAPIContext.GetSteamFriends(), steamIDFriend, iPersonaName));
}
public static int GetFriendSteamLevel(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendSteamLevel(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static string GetPlayerNickname(CSteamID steamIDPlayer)
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetPlayerNickname(CSteamAPIContext.GetSteamFriends(), steamIDPlayer));
}
public static int GetFriendsGroupCount()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendsGroupCount(CSteamAPIContext.GetSteamFriends());
}
public static FriendsGroupID_t GetFriendsGroupIDByIndex(int iFG)
{
InteropHelp.TestIfAvailableClient();
return (FriendsGroupID_t)NativeMethods.ISteamFriends_GetFriendsGroupIDByIndex(CSteamAPIContext.GetSteamFriends(), iFG);
}
public static string GetFriendsGroupName(FriendsGroupID_t friendsGroupID)
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendsGroupName(CSteamAPIContext.GetSteamFriends(), friendsGroupID));
}
public static int GetFriendsGroupMembersCount(FriendsGroupID_t friendsGroupID)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendsGroupMembersCount(CSteamAPIContext.GetSteamFriends(), friendsGroupID);
}
public static void GetFriendsGroupMembersList(FriendsGroupID_t friendsGroupID, CSteamID[] pOutSteamIDMembers, int nMembersCount)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamFriends_GetFriendsGroupMembersList(CSteamAPIContext.GetSteamFriends(), friendsGroupID, pOutSteamIDMembers, nMembersCount);
}
public static bool HasFriend(CSteamID steamIDFriend, EFriendFlags iFriendFlags)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_HasFriend(CSteamAPIContext.GetSteamFriends(), steamIDFriend, iFriendFlags);
}
public static int GetClanCount()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetClanCount(CSteamAPIContext.GetSteamFriends());
}
public static CSteamID GetClanByIndex(int iClan)
{
InteropHelp.TestIfAvailableClient();
return (CSteamID)NativeMethods.ISteamFriends_GetClanByIndex(CSteamAPIContext.GetSteamFriends(), iClan);
}
public static string GetClanName(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetClanName(CSteamAPIContext.GetSteamFriends(), steamIDClan));
}
public static string GetClanTag(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetClanTag(CSteamAPIContext.GetSteamFriends(), steamIDClan));
}
public static bool GetClanActivityCounts(CSteamID steamIDClan, out int pnOnline, out int pnInGame, out int pnChatting)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetClanActivityCounts(CSteamAPIContext.GetSteamFriends(), steamIDClan, out pnOnline, out pnInGame, out pnChatting);
}
public static SteamAPICall_t DownloadClanActivityCounts(CSteamID[] psteamIDClans, int cClansToRequest)
{
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_DownloadClanActivityCounts(CSteamAPIContext.GetSteamFriends(), psteamIDClans, cClansToRequest);
}
public static int GetFriendCountFromSource(CSteamID steamIDSource)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendCountFromSource(CSteamAPIContext.GetSteamFriends(), steamIDSource);
}
public static CSteamID GetFriendFromSourceByIndex(CSteamID steamIDSource, int iFriend)
{
InteropHelp.TestIfAvailableClient();
return (CSteamID)NativeMethods.ISteamFriends_GetFriendFromSourceByIndex(CSteamAPIContext.GetSteamFriends(), steamIDSource, iFriend);
}
public static bool IsUserInSource(CSteamID steamIDUser, CSteamID steamIDSource)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_IsUserInSource(CSteamAPIContext.GetSteamFriends(), steamIDUser, steamIDSource);
}
public static void SetInGameVoiceSpeaking(CSteamID steamIDUser, bool bSpeaking)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamFriends_SetInGameVoiceSpeaking(CSteamAPIContext.GetSteamFriends(), steamIDUser, bSpeaking);
}
public static void ActivateGameOverlay(string pchDialog)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchDialog2 = new InteropHelp.UTF8StringHandle(pchDialog);
NativeMethods.ISteamFriends_ActivateGameOverlay(CSteamAPIContext.GetSteamFriends(), pchDialog2);
}
public static void ActivateGameOverlayToUser(string pchDialog, CSteamID steamID)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchDialog2 = new InteropHelp.UTF8StringHandle(pchDialog);
NativeMethods.ISteamFriends_ActivateGameOverlayToUser(CSteamAPIContext.GetSteamFriends(), pchDialog2, steamID);
}
public static void ActivateGameOverlayToWebPage(string pchURL, EActivateGameOverlayToWebPageMode eMode = EActivateGameOverlayToWebPageMode.k_EActivateGameOverlayToWebPageMode_Default)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchURL2 = new InteropHelp.UTF8StringHandle(pchURL);
NativeMethods.ISteamFriends_ActivateGameOverlayToWebPage(CSteamAPIContext.GetSteamFriends(), pchURL2, eMode);
}
public static void ActivateGameOverlayToStore(AppId_t nAppID, EOverlayToStoreFlag eFlag)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamFriends_ActivateGameOverlayToStore(CSteamAPIContext.GetSteamFriends(), nAppID, eFlag);
}
public static void SetPlayedWith(CSteamID steamIDUserPlayedWith)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamFriends_SetPlayedWith(CSteamAPIContext.GetSteamFriends(), steamIDUserPlayedWith);
}
public static void ActivateGameOverlayInviteDialog(CSteamID steamIDLobby)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamFriends_ActivateGameOverlayInviteDialog(CSteamAPIContext.GetSteamFriends(), steamIDLobby);
}
public static int GetSmallFriendAvatar(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetSmallFriendAvatar(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static int GetMediumFriendAvatar(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetMediumFriendAvatar(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static int GetLargeFriendAvatar(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetLargeFriendAvatar(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static bool RequestUserInformation(CSteamID steamIDUser, bool bRequireNameOnly)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_RequestUserInformation(CSteamAPIContext.GetSteamFriends(), steamIDUser, bRequireNameOnly);
}
public static SteamAPICall_t RequestClanOfficerList(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_RequestClanOfficerList(CSteamAPIContext.GetSteamFriends(), steamIDClan);
}
public static CSteamID GetClanOwner(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return (CSteamID)NativeMethods.ISteamFriends_GetClanOwner(CSteamAPIContext.GetSteamFriends(), steamIDClan);
}
public static int GetClanOfficerCount(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetClanOfficerCount(CSteamAPIContext.GetSteamFriends(), steamIDClan);
}
public static CSteamID GetClanOfficerByIndex(CSteamID steamIDClan, int iOfficer)
{
InteropHelp.TestIfAvailableClient();
return (CSteamID)NativeMethods.ISteamFriends_GetClanOfficerByIndex(CSteamAPIContext.GetSteamFriends(), steamIDClan, iOfficer);
}
public static uint GetUserRestrictions()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetUserRestrictions(CSteamAPIContext.GetSteamFriends());
}
public static bool SetRichPresence(string pchKey, string pchValue)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchKey2 = new InteropHelp.UTF8StringHandle(pchKey);
using InteropHelp.UTF8StringHandle pchValue2 = new InteropHelp.UTF8StringHandle(pchValue);
return NativeMethods.ISteamFriends_SetRichPresence(CSteamAPIContext.GetSteamFriends(), pchKey2, pchValue2);
}
public static void ClearRichPresence()
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamFriends_ClearRichPresence(CSteamAPIContext.GetSteamFriends());
}
public static string GetFriendRichPresence(CSteamID steamIDFriend, string pchKey)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchKey2 = new InteropHelp.UTF8StringHandle(pchKey);
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendRichPresence(CSteamAPIContext.GetSteamFriends(), steamIDFriend, pchKey2));
}
public static int GetFriendRichPresenceKeyCount(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendRichPresenceKeyCount(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static string GetFriendRichPresenceKeyByIndex(CSteamID steamIDFriend, int iKey)
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendRichPresenceKeyByIndex(CSteamAPIContext.GetSteamFriends(), steamIDFriend, iKey));
}
public static void RequestFriendRichPresence(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamFriends_RequestFriendRichPresence(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static bool InviteUserToGame(CSteamID steamIDFriend, string pchConnectString)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchConnectString2 = new InteropHelp.UTF8StringHandle(pchConnectString);
return NativeMethods.ISteamFriends_InviteUserToGame(CSteamAPIContext.GetSteamFriends(), steamIDFriend, pchConnectString2);
}
public static int GetCoplayFriendCount()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetCoplayFriendCount(CSteamAPIContext.GetSteamFriends());
}
public static CSteamID GetCoplayFriend(int iCoplayFriend)
{
InteropHelp.TestIfAvailableClient();
return (CSteamID)NativeMethods.ISteamFriends_GetCoplayFriend(CSteamAPIContext.GetSteamFriends(), iCoplayFriend);
}
public static int GetFriendCoplayTime(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetFriendCoplayTime(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static AppId_t GetFriendCoplayGame(CSteamID steamIDFriend)
{
InteropHelp.TestIfAvailableClient();
return (AppId_t)NativeMethods.ISteamFriends_GetFriendCoplayGame(CSteamAPIContext.GetSteamFriends(), steamIDFriend);
}
public static SteamAPICall_t JoinClanChatRoom(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_JoinClanChatRoom(CSteamAPIContext.GetSteamFriends(), steamIDClan);
}
public static bool LeaveClanChatRoom(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_LeaveClanChatRoom(CSteamAPIContext.GetSteamFriends(), steamIDClan);
}
public static int GetClanChatMemberCount(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetClanChatMemberCount(CSteamAPIContext.GetSteamFriends(), steamIDClan);
}
public static CSteamID GetChatMemberByIndex(CSteamID steamIDClan, int iUser)
{
InteropHelp.TestIfAvailableClient();
return (CSteamID)NativeMethods.ISteamFriends_GetChatMemberByIndex(CSteamAPIContext.GetSteamFriends(), steamIDClan, iUser);
}
public static bool SendClanChatMessage(CSteamID steamIDClanChat, string pchText)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchText2 = new InteropHelp.UTF8StringHandle(pchText);
return NativeMethods.ISteamFriends_SendClanChatMessage(CSteamAPIContext.GetSteamFriends(), steamIDClanChat, pchText2);
}
public static int GetClanChatMessage(CSteamID steamIDClanChat, int iMessage, out string prgchText, int cchTextMax, out EChatEntryType peChatEntryType, out CSteamID psteamidChatter)
{
InteropHelp.TestIfAvailableClient();
IntPtr intPtr = Marshal.AllocHGlobal(cchTextMax);
int num = NativeMethods.ISteamFriends_GetClanChatMessage(CSteamAPIContext.GetSteamFriends(), steamIDClanChat, iMessage, intPtr, cchTextMax, out peChatEntryType, out psteamidChatter);
prgchText = ((num != 0) ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
return num;
}
public static bool IsClanChatAdmin(CSteamID steamIDClanChat, CSteamID steamIDUser)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_IsClanChatAdmin(CSteamAPIContext.GetSteamFriends(), steamIDClanChat, steamIDUser);
}
public static bool IsClanChatWindowOpenInSteam(CSteamID steamIDClanChat)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_IsClanChatWindowOpenInSteam(CSteamAPIContext.GetSteamFriends(), steamIDClanChat);
}
public static bool OpenClanChatWindowInSteam(CSteamID steamIDClanChat)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_OpenClanChatWindowInSteam(CSteamAPIContext.GetSteamFriends(), steamIDClanChat);
}
public static bool CloseClanChatWindowInSteam(CSteamID steamIDClanChat)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_CloseClanChatWindowInSteam(CSteamAPIContext.GetSteamFriends(), steamIDClanChat);
}
public static bool SetListenForFriendsMessages(bool bInterceptEnabled)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_SetListenForFriendsMessages(CSteamAPIContext.GetSteamFriends(), bInterceptEnabled);
}
public static bool ReplyToFriendMessage(CSteamID steamIDFriend, string pchMsgToSend)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchMsgToSend2 = new InteropHelp.UTF8StringHandle(pchMsgToSend);
return NativeMethods.ISteamFriends_ReplyToFriendMessage(CSteamAPIContext.GetSteamFriends(), steamIDFriend, pchMsgToSend2);
}
public static int GetFriendMessage(CSteamID steamIDFriend, int iMessageID, out string pvData, int cubData, out EChatEntryType peChatEntryType)
{
InteropHelp.TestIfAvailableClient();
IntPtr intPtr = Marshal.AllocHGlobal(cubData);
int num = NativeMethods.ISteamFriends_GetFriendMessage(CSteamAPIContext.GetSteamFriends(), steamIDFriend, iMessageID, intPtr, cubData, out peChatEntryType);
pvData = ((num != 0) ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
return num;
}
public static SteamAPICall_t GetFollowerCount(CSteamID steamID)
{
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_GetFollowerCount(CSteamAPIContext.GetSteamFriends(), steamID);
}
public static SteamAPICall_t IsFollowing(CSteamID steamID)
{
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_IsFollowing(CSteamAPIContext.GetSteamFriends(), steamID);
}
public static SteamAPICall_t EnumerateFollowingList(uint unStartIndex)
{
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_EnumerateFollowingList(CSteamAPIContext.GetSteamFriends(), unStartIndex);
}
public static bool IsClanPublic(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_IsClanPublic(CSteamAPIContext.GetSteamFriends(), steamIDClan);
}
public static bool IsClanOfficialGameGroup(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_IsClanOfficialGameGroup(CSteamAPIContext.GetSteamFriends(), steamIDClan);
}
public static int GetNumChatsWithUnreadPriorityMessages()
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetNumChatsWithUnreadPriorityMessages(CSteamAPIContext.GetSteamFriends());
}
public static void ActivateGameOverlayRemotePlayTogetherInviteDialog(CSteamID steamIDLobby)
{
InteropHelp.TestIfAvailableClient();
NativeMethods.ISteamFriends_ActivateGameOverlayRemotePlayTogetherInviteDialog(CSteamAPIContext.GetSteamFriends(), steamIDLobby);
}
public static bool RegisterProtocolInOverlayBrowser(string pchProtocol)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchProtocol2 = new InteropHelp.UTF8StringHandle(pchProtocol);
return NativeMethods.ISteamFriends_RegisterProtocolInOverlayBrowser(CSteamAPIContext.GetSteamFriends(), pchProtocol2);
}
public static void ActivateGameOverlayInviteDialogConnectString(string pchConnectString)
{
InteropHelp.TestIfAvailableClient();
using InteropHelp.UTF8StringHandle pchConnectString2 = new InteropHelp.UTF8StringHandle(pchConnectString);
NativeMethods.ISteamFriends_ActivateGameOverlayInviteDialogConnectString(CSteamAPIContext.GetSteamFriends(), pchConnectString2);
}
public static SteamAPICall_t RequestEquippedProfileItems(CSteamID steamID)
{
InteropHelp.TestIfAvailableClient();
return (SteamAPICall_t)NativeMethods.ISteamFriends_RequestEquippedProfileItems(CSteamAPIContext.GetSteamFriends(), steamID);
}
public static bool BHasEquippedProfileItem(CSteamID steamID, ECommunityProfileItemType itemType)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_BHasEquippedProfileItem(CSteamAPIContext.GetSteamFriends(), steamID, itemType);
}
public static string GetProfileItemPropertyString(CSteamID steamID, ECommunityProfileItemType itemType, ECommunityProfileItemProperty prop)
{
InteropHelp.TestIfAvailableClient();
return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetProfileItemPropertyString(CSteamAPIContext.GetSteamFriends(), steamID, itemType, prop));
}
public static uint GetProfileItemPropertyUint(CSteamID steamID, ECommunityProfileItemType itemType, ECommunityProfileItemProperty prop)
{
InteropHelp.TestIfAvailableClient();
return NativeMethods.ISteamFriends_GetProfileItemPropertyUint(CSteamAPIContext.GetSteamFriends(), steamID, itemType, prop);
}
}
public static class SteamGameServer
{
public static void SetProduct(string pszProduct)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszProduct2 = new InteropHelp.UTF8StringHandle(pszProduct);
NativeMethods.ISteamGameServer_SetProduct(CSteamGameServerAPIContext.GetSteamGameServer(), pszProduct2);
}
public static void SetGameDescription(string pszGameDescription)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszGameDescription2 = new InteropHelp.UTF8StringHandle(pszGameDescription);
NativeMethods.ISteamGameServer_SetGameDescription(CSteamGameServerAPIContext.GetSteamGameServer(), pszGameDescription2);
}
public static void SetModDir(string pszModDir)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszModDir2 = new InteropHelp.UTF8StringHandle(pszModDir);
NativeMethods.ISteamGameServer_SetModDir(CSteamGameServerAPIContext.GetSteamGameServer(), pszModDir2);
}
public static void SetDedicatedServer(bool bDedicated)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_SetDedicatedServer(CSteamGameServerAPIContext.GetSteamGameServer(), bDedicated);
}
public static void LogOn(string pszToken)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszToken2 = new InteropHelp.UTF8StringHandle(pszToken);
NativeMethods.ISteamGameServer_LogOn(CSteamGameServerAPIContext.GetSteamGameServer(), pszToken2);
}
public static void LogOnAnonymous()
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_LogOnAnonymous(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static void LogOff()
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_LogOff(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static bool BLoggedOn()
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_BLoggedOn(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static bool BSecure()
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_BSecure(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static CSteamID GetSteamID()
{
InteropHelp.TestIfAvailableGameServer();
return (CSteamID)NativeMethods.ISteamGameServer_GetSteamID(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static bool WasRestartRequested()
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_WasRestartRequested(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static void SetMaxPlayerCount(int cPlayersMax)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_SetMaxPlayerCount(CSteamGameServerAPIContext.GetSteamGameServer(), cPlayersMax);
}
public static void SetBotPlayerCount(int cBotplayers)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_SetBotPlayerCount(CSteamGameServerAPIContext.GetSteamGameServer(), cBotplayers);
}
public static void SetServerName(string pszServerName)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszServerName2 = new InteropHelp.UTF8StringHandle(pszServerName);
NativeMethods.ISteamGameServer_SetServerName(CSteamGameServerAPIContext.GetSteamGameServer(), pszServerName2);
}
public static void SetMapName(string pszMapName)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszMapName2 = new InteropHelp.UTF8StringHandle(pszMapName);
NativeMethods.ISteamGameServer_SetMapName(CSteamGameServerAPIContext.GetSteamGameServer(), pszMapName2);
}
public static void SetPasswordProtected(bool bPasswordProtected)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_SetPasswordProtected(CSteamGameServerAPIContext.GetSteamGameServer(), bPasswordProtected);
}
public static void SetSpectatorPort(ushort unSpectatorPort)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_SetSpectatorPort(CSteamGameServerAPIContext.GetSteamGameServer(), unSpectatorPort);
}
public static void SetSpectatorServerName(string pszSpectatorServerName)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszSpectatorServerName2 = new InteropHelp.UTF8StringHandle(pszSpectatorServerName);
NativeMethods.ISteamGameServer_SetSpectatorServerName(CSteamGameServerAPIContext.GetSteamGameServer(), pszSpectatorServerName2);
}
public static void ClearAllKeyValues()
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_ClearAllKeyValues(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static void SetKeyValue(string pKey, string pValue)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pKey2 = new InteropHelp.UTF8StringHandle(pKey);
using InteropHelp.UTF8StringHandle pValue2 = new InteropHelp.UTF8StringHandle(pValue);
NativeMethods.ISteamGameServer_SetKeyValue(CSteamGameServerAPIContext.GetSteamGameServer(), pKey2, pValue2);
}
public static void SetGameTags(string pchGameTags)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchGameTags2 = new InteropHelp.UTF8StringHandle(pchGameTags);
NativeMethods.ISteamGameServer_SetGameTags(CSteamGameServerAPIContext.GetSteamGameServer(), pchGameTags2);
}
public static void SetGameData(string pchGameData)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchGameData2 = new InteropHelp.UTF8StringHandle(pchGameData);
NativeMethods.ISteamGameServer_SetGameData(CSteamGameServerAPIContext.GetSteamGameServer(), pchGameData2);
}
public static void SetRegion(string pszRegion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszRegion2 = new InteropHelp.UTF8StringHandle(pszRegion);
NativeMethods.ISteamGameServer_SetRegion(CSteamGameServerAPIContext.GetSteamGameServer(), pszRegion2);
}
public static void SetAdvertiseServerActive(bool bActive)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_SetAdvertiseServerActive(CSteamGameServerAPIContext.GetSteamGameServer(), bActive);
}
public static HAuthTicket GetAuthSessionTicket(byte[] pTicket, int cbMaxTicket, out uint pcbTicket, ref SteamNetworkingIdentity pSnid)
{
InteropHelp.TestIfAvailableGameServer();
return (HAuthTicket)NativeMethods.ISteamGameServer_GetAuthSessionTicket(CSteamGameServerAPIContext.GetSteamGameServer(), pTicket, cbMaxTicket, out pcbTicket, ref pSnid);
}
public static EBeginAuthSessionResult BeginAuthSession(byte[] pAuthTicket, int cbAuthTicket, CSteamID steamID)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_BeginAuthSession(CSteamGameServerAPIContext.GetSteamGameServer(), pAuthTicket, cbAuthTicket, steamID);
}
public static void EndAuthSession(CSteamID steamID)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_EndAuthSession(CSteamGameServerAPIContext.GetSteamGameServer(), steamID);
}
public static void CancelAuthTicket(HAuthTicket hAuthTicket)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_CancelAuthTicket(CSteamGameServerAPIContext.GetSteamGameServer(), hAuthTicket);
}
public static EUserHasLicenseForAppResult UserHasLicenseForApp(CSteamID steamID, AppId_t appID)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_UserHasLicenseForApp(CSteamGameServerAPIContext.GetSteamGameServer(), steamID, appID);
}
public static bool RequestUserGroupStatus(CSteamID steamIDUser, CSteamID steamIDGroup)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_RequestUserGroupStatus(CSteamGameServerAPIContext.GetSteamGameServer(), steamIDUser, steamIDGroup);
}
public static void GetGameplayStats()
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_GetGameplayStats(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static SteamAPICall_t GetServerReputation()
{
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamGameServer_GetServerReputation(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static SteamIPAddress_t GetPublicIP()
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_GetPublicIP(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static bool HandleIncomingPacket(byte[] pData, int cbData, uint srcIP, ushort srcPort)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_HandleIncomingPacket(CSteamGameServerAPIContext.GetSteamGameServer(), pData, cbData, srcIP, srcPort);
}
public static int GetNextOutgoingPacket(byte[] pOut, int cbMaxOut, out uint pNetAdr, out ushort pPort)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_GetNextOutgoingPacket(CSteamGameServerAPIContext.GetSteamGameServer(), pOut, cbMaxOut, out pNetAdr, out pPort);
}
public static SteamAPICall_t AssociateWithClan(CSteamID steamIDClan)
{
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamGameServer_AssociateWithClan(CSteamGameServerAPIContext.GetSteamGameServer(), steamIDClan);
}
public static SteamAPICall_t ComputeNewPlayerCompatibility(CSteamID steamIDNewPlayer)
{
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamGameServer_ComputeNewPlayerCompatibility(CSteamGameServerAPIContext.GetSteamGameServer(), steamIDNewPlayer);
}
public static bool SendUserConnectAndAuthenticate_DEPRECATED(uint unIPClient, byte[] pvAuthBlob, uint cubAuthBlobSize, out CSteamID pSteamIDUser)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamGameServer_SendUserConnectAndAuthenticate_DEPRECATED(CSteamGameServerAPIContext.GetSteamGameServer(), unIPClient, pvAuthBlob, cubAuthBlobSize, out pSteamIDUser);
}
public static CSteamID CreateUnauthenticatedUserConnection()
{
InteropHelp.TestIfAvailableGameServer();
return (CSteamID)NativeMethods.ISteamGameServer_CreateUnauthenticatedUserConnection(CSteamGameServerAPIContext.GetSteamGameServer());
}
public static void SendUserDisconnect_DEPRECATED(CSteamID steamIDUser)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamGameServer_SendUserDisconnect_DEPRECATED(CSteamGameServerAPIContext.GetSteamGameServer(), steamIDUser);
}
public static bool BUpdateUserData(CSteamID steamIDUser, string pchPlayerName, uint uScore)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchPlayerName2 = new InteropHelp.UTF8StringHandle(pchPlayerName);
return NativeMethods.ISteamGameServer_BUpdateUserData(CSteamGameServerAPIContext.GetSteamGameServer(), steamIDUser, pchPlayerName2, uScore);
}
}
public static class SteamGameServerClient
{
public static HSteamPipe CreateSteamPipe()
{
InteropHelp.TestIfAvailableGameServer();
return (HSteamPipe)NativeMethods.ISteamClient_CreateSteamPipe(CSteamGameServerAPIContext.GetSteamClient());
}
public static bool BReleaseSteamPipe(HSteamPipe hSteamPipe)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamClient_BReleaseSteamPipe(CSteamGameServerAPIContext.GetSteamClient(), hSteamPipe);
}
public static HSteamUser ConnectToGlobalUser(HSteamPipe hSteamPipe)
{
InteropHelp.TestIfAvailableGameServer();
return (HSteamUser)NativeMethods.ISteamClient_ConnectToGlobalUser(CSteamGameServerAPIContext.GetSteamClient(), hSteamPipe);
}
public static HSteamUser CreateLocalUser(out HSteamPipe phSteamPipe, EAccountType eAccountType)
{
InteropHelp.TestIfAvailableGameServer();
return (HSteamUser)NativeMethods.ISteamClient_CreateLocalUser(CSteamGameServerAPIContext.GetSteamClient(), out phSteamPipe, eAccountType);
}
public static void ReleaseUser(HSteamPipe hSteamPipe, HSteamUser hUser)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamClient_ReleaseUser(CSteamGameServerAPIContext.GetSteamClient(), hSteamPipe, hUser);
}
public static IntPtr GetISteamUser(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamUser(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamGameServer(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamGameServer(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static void SetLocalIPBinding(ref SteamIPAddress_t unIP, ushort usPort)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamClient_SetLocalIPBinding(CSteamGameServerAPIContext.GetSteamClient(), ref unIP, usPort);
}
public static IntPtr GetISteamFriends(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamFriends(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamUtils(HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamUtils(CSteamGameServerAPIContext.GetSteamClient(), hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamMatchmaking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamMatchmaking(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamMatchmakingServers(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamMatchmakingServers(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamGenericInterface(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamGenericInterface(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamUserStats(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamUserStats(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamGameServerStats(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamGameServerStats(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamApps(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamApps(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamNetworking(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamNetworking(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamRemoteStorage(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamRemoteStorage(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamScreenshots(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamScreenshots(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamGameSearch(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamGameSearch(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static uint GetIPCCallCount()
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamClient_GetIPCCallCount(CSteamGameServerAPIContext.GetSteamClient());
}
public static void SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamClient_SetWarningMessageHook(CSteamGameServerAPIContext.GetSteamClient(), pFunction);
}
public static bool BShutdownIfAllPipesClosed()
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamClient_BShutdownIfAllPipesClosed(CSteamGameServerAPIContext.GetSteamClient());
}
public static IntPtr GetISteamHTTP(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamHTTP(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamController(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamController(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamUGC(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamUGC(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamMusic(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamMusic(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamMusicRemote(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamMusicRemote(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamHTMLSurface(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamHTMLSurface(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamInventory(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamInventory(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamVideo(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamVideo(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamParentalSettings(HSteamUser hSteamuser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamParentalSettings(CSteamGameServerAPIContext.GetSteamClient(), hSteamuser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamInput(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamInput(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamParties(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamParties(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
public static IntPtr GetISteamRemotePlay(HSteamUser hSteamUser, HSteamPipe hSteamPipe, string pchVersion)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchVersion2 = new InteropHelp.UTF8StringHandle(pchVersion);
return NativeMethods.ISteamClient_GetISteamRemotePlay(CSteamGameServerAPIContext.GetSteamClient(), hSteamUser, hSteamPipe, pchVersion2);
}
}
public static class SteamGameServerHTTP
{
public static HTTPRequestHandle CreateHTTPRequest(EHTTPMethod eHTTPRequestMethod, string pchAbsoluteURL)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchAbsoluteURL2 = new InteropHelp.UTF8StringHandle(pchAbsoluteURL);
return (HTTPRequestHandle)NativeMethods.ISteamHTTP_CreateHTTPRequest(CSteamGameServerAPIContext.GetSteamHTTP(), eHTTPRequestMethod, pchAbsoluteURL2);
}
public static bool SetHTTPRequestContextValue(HTTPRequestHandle hRequest, ulong ulContextValue)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_SetHTTPRequestContextValue(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, ulContextValue);
}
public static bool SetHTTPRequestNetworkActivityTimeout(HTTPRequestHandle hRequest, uint unTimeoutSeconds)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_SetHTTPRequestNetworkActivityTimeout(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, unTimeoutSeconds);
}
public static bool SetHTTPRequestHeaderValue(HTTPRequestHandle hRequest, string pchHeaderName, string pchHeaderValue)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchHeaderName2 = new InteropHelp.UTF8StringHandle(pchHeaderName);
using InteropHelp.UTF8StringHandle pchHeaderValue2 = new InteropHelp.UTF8StringHandle(pchHeaderValue);
return NativeMethods.ISteamHTTP_SetHTTPRequestHeaderValue(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, pchHeaderName2, pchHeaderValue2);
}
public static bool SetHTTPRequestGetOrPostParameter(HTTPRequestHandle hRequest, string pchParamName, string pchParamValue)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchParamName2 = new InteropHelp.UTF8StringHandle(pchParamName);
using InteropHelp.UTF8StringHandle pchParamValue2 = new InteropHelp.UTF8StringHandle(pchParamValue);
return NativeMethods.ISteamHTTP_SetHTTPRequestGetOrPostParameter(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, pchParamName2, pchParamValue2);
}
public static bool SendHTTPRequest(HTTPRequestHandle hRequest, out SteamAPICall_t pCallHandle)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_SendHTTPRequest(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, out pCallHandle);
}
public static bool SendHTTPRequestAndStreamResponse(HTTPRequestHandle hRequest, out SteamAPICall_t pCallHandle)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_SendHTTPRequestAndStreamResponse(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, out pCallHandle);
}
public static bool DeferHTTPRequest(HTTPRequestHandle hRequest)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_DeferHTTPRequest(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest);
}
public static bool PrioritizeHTTPRequest(HTTPRequestHandle hRequest)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_PrioritizeHTTPRequest(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest);
}
public static bool GetHTTPResponseHeaderSize(HTTPRequestHandle hRequest, string pchHeaderName, out uint unResponseHeaderSize)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchHeaderName2 = new InteropHelp.UTF8StringHandle(pchHeaderName);
return NativeMethods.ISteamHTTP_GetHTTPResponseHeaderSize(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, pchHeaderName2, out unResponseHeaderSize);
}
public static bool GetHTTPResponseHeaderValue(HTTPRequestHandle hRequest, string pchHeaderName, byte[] pHeaderValueBuffer, uint unBufferSize)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchHeaderName2 = new InteropHelp.UTF8StringHandle(pchHeaderName);
return NativeMethods.ISteamHTTP_GetHTTPResponseHeaderValue(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, pchHeaderName2, pHeaderValueBuffer, unBufferSize);
}
public static bool GetHTTPResponseBodySize(HTTPRequestHandle hRequest, out uint unBodySize)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_GetHTTPResponseBodySize(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, out unBodySize);
}
public static bool GetHTTPResponseBodyData(HTTPRequestHandle hRequest, byte[] pBodyDataBuffer, uint unBufferSize)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_GetHTTPResponseBodyData(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, pBodyDataBuffer, unBufferSize);
}
public static bool GetHTTPStreamingResponseBodyData(HTTPRequestHandle hRequest, uint cOffset, byte[] pBodyDataBuffer, uint unBufferSize)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_GetHTTPStreamingResponseBodyData(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, cOffset, pBodyDataBuffer, unBufferSize);
}
public static bool ReleaseHTTPRequest(HTTPRequestHandle hRequest)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_ReleaseHTTPRequest(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest);
}
public static bool GetHTTPDownloadProgressPct(HTTPRequestHandle hRequest, out float pflPercentOut)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_GetHTTPDownloadProgressPct(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, out pflPercentOut);
}
public static bool SetHTTPRequestRawPostBody(HTTPRequestHandle hRequest, string pchContentType, byte[] pubBody, uint unBodyLen)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchContentType2 = new InteropHelp.UTF8StringHandle(pchContentType);
return NativeMethods.ISteamHTTP_SetHTTPRequestRawPostBody(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, pchContentType2, pubBody, unBodyLen);
}
public static HTTPCookieContainerHandle CreateCookieContainer(bool bAllowResponsesToModify)
{
InteropHelp.TestIfAvailableGameServer();
return (HTTPCookieContainerHandle)NativeMethods.ISteamHTTP_CreateCookieContainer(CSteamGameServerAPIContext.GetSteamHTTP(), bAllowResponsesToModify);
}
public static bool ReleaseCookieContainer(HTTPCookieContainerHandle hCookieContainer)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_ReleaseCookieContainer(CSteamGameServerAPIContext.GetSteamHTTP(), hCookieContainer);
}
public static bool SetCookie(HTTPCookieContainerHandle hCookieContainer, string pchHost, string pchUrl, string pchCookie)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchHost2 = new InteropHelp.UTF8StringHandle(pchHost);
using InteropHelp.UTF8StringHandle pchUrl2 = new InteropHelp.UTF8StringHandle(pchUrl);
using InteropHelp.UTF8StringHandle pchCookie2 = new InteropHelp.UTF8StringHandle(pchCookie);
return NativeMethods.ISteamHTTP_SetCookie(CSteamGameServerAPIContext.GetSteamHTTP(), hCookieContainer, pchHost2, pchUrl2, pchCookie2);
}
public static bool SetHTTPRequestCookieContainer(HTTPRequestHandle hRequest, HTTPCookieContainerHandle hCookieContainer)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_SetHTTPRequestCookieContainer(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, hCookieContainer);
}
public static bool SetHTTPRequestUserAgentInfo(HTTPRequestHandle hRequest, string pchUserAgentInfo)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchUserAgentInfo2 = new InteropHelp.UTF8StringHandle(pchUserAgentInfo);
return NativeMethods.ISteamHTTP_SetHTTPRequestUserAgentInfo(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, pchUserAgentInfo2);
}
public static bool SetHTTPRequestRequiresVerifiedCertificate(HTTPRequestHandle hRequest, bool bRequireVerifiedCertificate)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_SetHTTPRequestRequiresVerifiedCertificate(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, bRequireVerifiedCertificate);
}
public static bool SetHTTPRequestAbsoluteTimeoutMS(HTTPRequestHandle hRequest, uint unMilliseconds)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_SetHTTPRequestAbsoluteTimeoutMS(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, unMilliseconds);
}
public static bool GetHTTPRequestWasTimedOut(HTTPRequestHandle hRequest, out bool pbWasTimedOut)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamHTTP_GetHTTPRequestWasTimedOut(CSteamGameServerAPIContext.GetSteamHTTP(), hRequest, out pbWasTimedOut);
}
}
public static class SteamGameServerInventory
{
public static EResult GetResultStatus(SteamInventoryResult_t resultHandle)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_GetResultStatus(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle);
}
public static bool GetResultItems(SteamInventoryResult_t resultHandle, SteamItemDetails_t[] pOutItemsArray, ref uint punOutItemsArraySize)
{
InteropHelp.TestIfAvailableGameServer();
if (pOutItemsArray != null && pOutItemsArray.Length != punOutItemsArraySize)
{
throw new ArgumentException("pOutItemsArray must be the same size as punOutItemsArraySize!");
}
return NativeMethods.ISteamInventory_GetResultItems(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle, pOutItemsArray, ref punOutItemsArraySize);
}
public static bool GetResultItemProperty(SteamInventoryResult_t resultHandle, uint unItemIndex, string pchPropertyName, out string pchValueBuffer, ref uint punValueBufferSizeOut)
{
InteropHelp.TestIfAvailableGameServer();
IntPtr intPtr = Marshal.AllocHGlobal((int)punValueBufferSizeOut);
using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
bool flag = NativeMethods.ISteamInventory_GetResultItemProperty(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle, unItemIndex, pchPropertyName2, intPtr, ref punValueBufferSizeOut);
pchValueBuffer = (flag ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
return flag;
}
public static uint GetResultTimestamp(SteamInventoryResult_t resultHandle)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_GetResultTimestamp(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle);
}
public static bool CheckResultSteamID(SteamInventoryResult_t resultHandle, CSteamID steamIDExpected)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_CheckResultSteamID(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle, steamIDExpected);
}
public static void DestroyResult(SteamInventoryResult_t resultHandle)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamInventory_DestroyResult(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle);
}
public static bool GetAllItems(out SteamInventoryResult_t pResultHandle)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_GetAllItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle);
}
public static bool GetItemsByID(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t[] pInstanceIDs, uint unCountInstanceIDs)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_GetItemsByID(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, pInstanceIDs, unCountInstanceIDs);
}
public static bool SerializeResult(SteamInventoryResult_t resultHandle, byte[] pOutBuffer, out uint punOutBufferSize)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_SerializeResult(CSteamGameServerAPIContext.GetSteamInventory(), resultHandle, pOutBuffer, out punOutBufferSize);
}
public static bool DeserializeResult(out SteamInventoryResult_t pOutResultHandle, byte[] pBuffer, uint unBufferSize, bool bRESERVED_MUST_BE_FALSE = false)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_DeserializeResult(CSteamGameServerAPIContext.GetSteamInventory(), out pOutResultHandle, pBuffer, unBufferSize, bRESERVED_MUST_BE_FALSE);
}
public static bool GenerateItems(out SteamInventoryResult_t pResultHandle, SteamItemDef_t[] pArrayItemDefs, uint[] punArrayQuantity, uint unArrayLength)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_GenerateItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, pArrayItemDefs, punArrayQuantity, unArrayLength);
}
public static bool GrantPromoItems(out SteamInventoryResult_t pResultHandle)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_GrantPromoItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle);
}
public static bool AddPromoItem(out SteamInventoryResult_t pResultHandle, SteamItemDef_t itemDef)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_AddPromoItem(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, itemDef);
}
public static bool AddPromoItems(out SteamInventoryResult_t pResultHandle, SteamItemDef_t[] pArrayItemDefs, uint unArrayLength)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_AddPromoItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, pArrayItemDefs, unArrayLength);
}
public static bool ConsumeItem(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemConsume, uint unQuantity)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_ConsumeItem(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, itemConsume, unQuantity);
}
public static bool ExchangeItems(out SteamInventoryResult_t pResultHandle, SteamItemDef_t[] pArrayGenerate, uint[] punArrayGenerateQuantity, uint unArrayGenerateLength, SteamItemInstanceID_t[] pArrayDestroy, uint[] punArrayDestroyQuantity, uint unArrayDestroyLength)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_ExchangeItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, pArrayGenerate, punArrayGenerateQuantity, unArrayGenerateLength, pArrayDestroy, punArrayDestroyQuantity, unArrayDestroyLength);
}
public static bool TransferItemQuantity(out SteamInventoryResult_t pResultHandle, SteamItemInstanceID_t itemIdSource, uint unQuantity, SteamItemInstanceID_t itemIdDest)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_TransferItemQuantity(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, itemIdSource, unQuantity, itemIdDest);
}
public static void SendItemDropHeartbeat()
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamInventory_SendItemDropHeartbeat(CSteamGameServerAPIContext.GetSteamInventory());
}
public static bool TriggerItemDrop(out SteamInventoryResult_t pResultHandle, SteamItemDef_t dropListDefinition)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_TriggerItemDrop(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, dropListDefinition);
}
public static bool TradeItems(out SteamInventoryResult_t pResultHandle, CSteamID steamIDTradePartner, SteamItemInstanceID_t[] pArrayGive, uint[] pArrayGiveQuantity, uint nArrayGiveLength, SteamItemInstanceID_t[] pArrayGet, uint[] pArrayGetQuantity, uint nArrayGetLength)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_TradeItems(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, steamIDTradePartner, pArrayGive, pArrayGiveQuantity, nArrayGiveLength, pArrayGet, pArrayGetQuantity, nArrayGetLength);
}
public static bool LoadItemDefinitions()
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_LoadItemDefinitions(CSteamGameServerAPIContext.GetSteamInventory());
}
public static bool GetItemDefinitionIDs(SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize)
{
InteropHelp.TestIfAvailableGameServer();
if (pItemDefIDs != null && pItemDefIDs.Length != punItemDefIDsArraySize)
{
throw new ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!");
}
return NativeMethods.ISteamInventory_GetItemDefinitionIDs(CSteamGameServerAPIContext.GetSteamInventory(), pItemDefIDs, ref punItemDefIDsArraySize);
}
public static bool GetItemDefinitionProperty(SteamItemDef_t iDefinition, string pchPropertyName, out string pchValueBuffer, ref uint punValueBufferSizeOut)
{
InteropHelp.TestIfAvailableGameServer();
IntPtr intPtr = Marshal.AllocHGlobal((int)punValueBufferSizeOut);
using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
bool flag = NativeMethods.ISteamInventory_GetItemDefinitionProperty(CSteamGameServerAPIContext.GetSteamInventory(), iDefinition, pchPropertyName2, intPtr, ref punValueBufferSizeOut);
pchValueBuffer = (flag ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
return flag;
}
public static SteamAPICall_t RequestEligiblePromoItemDefinitionsIDs(CSteamID steamID)
{
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamInventory_RequestEligiblePromoItemDefinitionsIDs(CSteamGameServerAPIContext.GetSteamInventory(), steamID);
}
public static bool GetEligiblePromoItemDefinitionIDs(CSteamID steamID, SteamItemDef_t[] pItemDefIDs, ref uint punItemDefIDsArraySize)
{
InteropHelp.TestIfAvailableGameServer();
if (pItemDefIDs != null && pItemDefIDs.Length != punItemDefIDsArraySize)
{
throw new ArgumentException("pItemDefIDs must be the same size as punItemDefIDsArraySize!");
}
return NativeMethods.ISteamInventory_GetEligiblePromoItemDefinitionIDs(CSteamGameServerAPIContext.GetSteamInventory(), steamID, pItemDefIDs, ref punItemDefIDsArraySize);
}
public static SteamAPICall_t StartPurchase(SteamItemDef_t[] pArrayItemDefs, uint[] punArrayQuantity, uint unArrayLength)
{
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamInventory_StartPurchase(CSteamGameServerAPIContext.GetSteamInventory(), pArrayItemDefs, punArrayQuantity, unArrayLength);
}
public static SteamAPICall_t RequestPrices()
{
InteropHelp.TestIfAvailableGameServer();
return (SteamAPICall_t)NativeMethods.ISteamInventory_RequestPrices(CSteamGameServerAPIContext.GetSteamInventory());
}
public static uint GetNumItemsWithPrices()
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_GetNumItemsWithPrices(CSteamGameServerAPIContext.GetSteamInventory());
}
public static bool GetItemsWithPrices(SteamItemDef_t[] pArrayItemDefs, ulong[] pCurrentPrices, ulong[] pBasePrices, uint unArrayLength)
{
InteropHelp.TestIfAvailableGameServer();
if (pArrayItemDefs != null && pArrayItemDefs.Length != unArrayLength)
{
throw new ArgumentException("pArrayItemDefs must be the same size as unArrayLength!");
}
if (pCurrentPrices != null && pCurrentPrices.Length != unArrayLength)
{
throw new ArgumentException("pCurrentPrices must be the same size as unArrayLength!");
}
if (pBasePrices != null && pBasePrices.Length != unArrayLength)
{
throw new ArgumentException("pBasePrices must be the same size as unArrayLength!");
}
return NativeMethods.ISteamInventory_GetItemsWithPrices(CSteamGameServerAPIContext.GetSteamInventory(), pArrayItemDefs, pCurrentPrices, pBasePrices, unArrayLength);
}
public static bool GetItemPrice(SteamItemDef_t iDefinition, out ulong pCurrentPrice, out ulong pBasePrice)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_GetItemPrice(CSteamGameServerAPIContext.GetSteamInventory(), iDefinition, out pCurrentPrice, out pBasePrice);
}
public static SteamInventoryUpdateHandle_t StartUpdateProperties()
{
InteropHelp.TestIfAvailableGameServer();
return (SteamInventoryUpdateHandle_t)NativeMethods.ISteamInventory_StartUpdateProperties(CSteamGameServerAPIContext.GetSteamInventory());
}
public static bool RemoveProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
return NativeMethods.ISteamInventory_RemoveProperty(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2);
}
public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, string pchPropertyValue)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
using InteropHelp.UTF8StringHandle pchPropertyValue2 = new InteropHelp.UTF8StringHandle(pchPropertyValue);
return NativeMethods.ISteamInventory_SetPropertyString(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, pchPropertyValue2);
}
public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, bool bValue)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
return NativeMethods.ISteamInventory_SetPropertyBool(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, bValue);
}
public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, long nValue)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
return NativeMethods.ISteamInventory_SetPropertyInt64(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, nValue);
}
public static bool SetProperty(SteamInventoryUpdateHandle_t handle, SteamItemInstanceID_t nItemID, string pchPropertyName, float flValue)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchPropertyName2 = new InteropHelp.UTF8StringHandle(pchPropertyName);
return NativeMethods.ISteamInventory_SetPropertyFloat(CSteamGameServerAPIContext.GetSteamInventory(), handle, nItemID, pchPropertyName2, flValue);
}
public static bool SubmitUpdateProperties(SteamInventoryUpdateHandle_t handle, out SteamInventoryResult_t pResultHandle)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamInventory_SubmitUpdateProperties(CSteamGameServerAPIContext.GetSteamInventory(), handle, out pResultHandle);
}
public static bool InspectItem(out SteamInventoryResult_t pResultHandle, string pchItemToken)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pchItemToken2 = new InteropHelp.UTF8StringHandle(pchItemToken);
return NativeMethods.ISteamInventory_InspectItem(CSteamGameServerAPIContext.GetSteamInventory(), out pResultHandle, pchItemToken2);
}
}
public static class SteamGameServerNetworking
{
public static bool SendP2PPacket(CSteamID steamIDRemote, byte[] pubData, uint cubData, EP2PSend eP2PSendType, int nChannel = 0)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_SendP2PPacket(CSteamGameServerAPIContext.GetSteamNetworking(), steamIDRemote, pubData, cubData, eP2PSendType, nChannel);
}
public static bool IsP2PPacketAvailable(out uint pcubMsgSize, int nChannel = 0)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_IsP2PPacketAvailable(CSteamGameServerAPIContext.GetSteamNetworking(), out pcubMsgSize, nChannel);
}
public static bool ReadP2PPacket(byte[] pubDest, uint cubDest, out uint pcubMsgSize, out CSteamID psteamIDRemote, int nChannel = 0)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_ReadP2PPacket(CSteamGameServerAPIContext.GetSteamNetworking(), pubDest, cubDest, out pcubMsgSize, out psteamIDRemote, nChannel);
}
public static bool AcceptP2PSessionWithUser(CSteamID steamIDRemote)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_AcceptP2PSessionWithUser(CSteamGameServerAPIContext.GetSteamNetworking(), steamIDRemote);
}
public static bool CloseP2PSessionWithUser(CSteamID steamIDRemote)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_CloseP2PSessionWithUser(CSteamGameServerAPIContext.GetSteamNetworking(), steamIDRemote);
}
public static bool CloseP2PChannelWithUser(CSteamID steamIDRemote, int nChannel)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_CloseP2PChannelWithUser(CSteamGameServerAPIContext.GetSteamNetworking(), steamIDRemote, nChannel);
}
public static bool GetP2PSessionState(CSteamID steamIDRemote, out P2PSessionState_t pConnectionState)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_GetP2PSessionState(CSteamGameServerAPIContext.GetSteamNetworking(), steamIDRemote, out pConnectionState);
}
public static bool AllowP2PPacketRelay(bool bAllow)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_AllowP2PPacketRelay(CSteamGameServerAPIContext.GetSteamNetworking(), bAllow);
}
public static SNetListenSocket_t CreateListenSocket(int nVirtualP2PPort, SteamIPAddress_t nIP, ushort nPort, bool bAllowUseOfPacketRelay)
{
InteropHelp.TestIfAvailableGameServer();
return (SNetListenSocket_t)NativeMethods.ISteamNetworking_CreateListenSocket(CSteamGameServerAPIContext.GetSteamNetworking(), nVirtualP2PPort, nIP, nPort, bAllowUseOfPacketRelay);
}
public static SNetSocket_t CreateP2PConnectionSocket(CSteamID steamIDTarget, int nVirtualPort, int nTimeoutSec, bool bAllowUseOfPacketRelay)
{
InteropHelp.TestIfAvailableGameServer();
return (SNetSocket_t)NativeMethods.ISteamNetworking_CreateP2PConnectionSocket(CSteamGameServerAPIContext.GetSteamNetworking(), steamIDTarget, nVirtualPort, nTimeoutSec, bAllowUseOfPacketRelay);
}
public static SNetSocket_t CreateConnectionSocket(SteamIPAddress_t nIP, ushort nPort, int nTimeoutSec)
{
InteropHelp.TestIfAvailableGameServer();
return (SNetSocket_t)NativeMethods.ISteamNetworking_CreateConnectionSocket(CSteamGameServerAPIContext.GetSteamNetworking(), nIP, nPort, nTimeoutSec);
}
public static bool DestroySocket(SNetSocket_t hSocket, bool bNotifyRemoteEnd)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_DestroySocket(CSteamGameServerAPIContext.GetSteamNetworking(), hSocket, bNotifyRemoteEnd);
}
public static bool DestroyListenSocket(SNetListenSocket_t hSocket, bool bNotifyRemoteEnd)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_DestroyListenSocket(CSteamGameServerAPIContext.GetSteamNetworking(), hSocket, bNotifyRemoteEnd);
}
public static bool SendDataOnSocket(SNetSocket_t hSocket, byte[] pubData, uint cubData, bool bReliable)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_SendDataOnSocket(CSteamGameServerAPIContext.GetSteamNetworking(), hSocket, pubData, cubData, bReliable);
}
public static bool IsDataAvailableOnSocket(SNetSocket_t hSocket, out uint pcubMsgSize)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_IsDataAvailableOnSocket(CSteamGameServerAPIContext.GetSteamNetworking(), hSocket, out pcubMsgSize);
}
public static bool RetrieveDataFromSocket(SNetSocket_t hSocket, byte[] pubDest, uint cubDest, out uint pcubMsgSize)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_RetrieveDataFromSocket(CSteamGameServerAPIContext.GetSteamNetworking(), hSocket, pubDest, cubDest, out pcubMsgSize);
}
public static bool IsDataAvailable(SNetListenSocket_t hListenSocket, out uint pcubMsgSize, out SNetSocket_t phSocket)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_IsDataAvailable(CSteamGameServerAPIContext.GetSteamNetworking(), hListenSocket, out pcubMsgSize, out phSocket);
}
public static bool RetrieveData(SNetListenSocket_t hListenSocket, byte[] pubDest, uint cubDest, out uint pcubMsgSize, out SNetSocket_t phSocket)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_RetrieveData(CSteamGameServerAPIContext.GetSteamNetworking(), hListenSocket, pubDest, cubDest, out pcubMsgSize, out phSocket);
}
public static bool GetSocketInfo(SNetSocket_t hSocket, out CSteamID pSteamIDRemote, out int peSocketStatus, out SteamIPAddress_t punIPRemote, out ushort punPortRemote)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_GetSocketInfo(CSteamGameServerAPIContext.GetSteamNetworking(), hSocket, out pSteamIDRemote, out peSocketStatus, out punIPRemote, out punPortRemote);
}
public static bool GetListenSocketInfo(SNetListenSocket_t hListenSocket, out SteamIPAddress_t pnIP, out ushort pnPort)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_GetListenSocketInfo(CSteamGameServerAPIContext.GetSteamNetworking(), hListenSocket, out pnIP, out pnPort);
}
public static ESNetSocketConnectionType GetSocketConnectionType(SNetSocket_t hSocket)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_GetSocketConnectionType(CSteamGameServerAPIContext.GetSteamNetworking(), hSocket);
}
public static int GetMaxPacketSize(SNetSocket_t hSocket)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworking_GetMaxPacketSize(CSteamGameServerAPIContext.GetSteamNetworking(), hSocket);
}
}
public static class SteamGameServerNetworkingMessages
{
public static EResult SendMessageToUser(ref SteamNetworkingIdentity identityRemote, IntPtr pubData, uint cubData, int nSendFlags, int nRemoteChannel)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingMessages_SendMessageToUser(CSteamGameServerAPIContext.GetSteamNetworkingMessages(), ref identityRemote, pubData, cubData, nSendFlags, nRemoteChannel);
}
public static int ReceiveMessagesOnChannel(int nLocalChannel, IntPtr[] ppOutMessages, int nMaxMessages)
{
InteropHelp.TestIfAvailableGameServer();
if (ppOutMessages != null && ppOutMessages.Length != nMaxMessages)
{
throw new ArgumentException("ppOutMessages must be the same size as nMaxMessages!");
}
return NativeMethods.ISteamNetworkingMessages_ReceiveMessagesOnChannel(CSteamGameServerAPIContext.GetSteamNetworkingMessages(), nLocalChannel, ppOutMessages, nMaxMessages);
}
public static bool AcceptSessionWithUser(ref SteamNetworkingIdentity identityRemote)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingMessages_AcceptSessionWithUser(CSteamGameServerAPIContext.GetSteamNetworkingMessages(), ref identityRemote);
}
public static bool CloseSessionWithUser(ref SteamNetworkingIdentity identityRemote)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingMessages_CloseSessionWithUser(CSteamGameServerAPIContext.GetSteamNetworkingMessages(), ref identityRemote);
}
public static bool CloseChannelWithUser(ref SteamNetworkingIdentity identityRemote, int nLocalChannel)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingMessages_CloseChannelWithUser(CSteamGameServerAPIContext.GetSteamNetworkingMessages(), ref identityRemote, nLocalChannel);
}
public static ESteamNetworkingConnectionState GetSessionConnectionInfo(ref SteamNetworkingIdentity identityRemote, out SteamNetConnectionInfo_t pConnectionInfo, out SteamNetConnectionRealTimeStatus_t pQuickStatus)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingMessages_GetSessionConnectionInfo(CSteamGameServerAPIContext.GetSteamNetworkingMessages(), ref identityRemote, out pConnectionInfo, out pQuickStatus);
}
}
public static class SteamGameServerNetworkingSockets
{
public static HSteamListenSocket CreateListenSocketIP(ref SteamNetworkingIPAddr localAddress, int nOptions, SteamNetworkingConfigValue_t[] pOptions)
{
InteropHelp.TestIfAvailableGameServer();
return (HSteamListenSocket)NativeMethods.ISteamNetworkingSockets_CreateListenSocketIP(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), ref localAddress, nOptions, pOptions);
}
public static HSteamNetConnection ConnectByIPAddress(ref SteamNetworkingIPAddr address, int nOptions, SteamNetworkingConfigValue_t[] pOptions)
{
InteropHelp.TestIfAvailableGameServer();
return (HSteamNetConnection)NativeMethods.ISteamNetworkingSockets_ConnectByIPAddress(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), ref address, nOptions, pOptions);
}
public static HSteamListenSocket CreateListenSocketP2P(int nLocalVirtualPort, int nOptions, SteamNetworkingConfigValue_t[] pOptions)
{
InteropHelp.TestIfAvailableGameServer();
return (HSteamListenSocket)NativeMethods.ISteamNetworkingSockets_CreateListenSocketP2P(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), nLocalVirtualPort, nOptions, pOptions);
}
public static HSteamNetConnection ConnectP2P(ref SteamNetworkingIdentity identityRemote, int nRemoteVirtualPort, int nOptions, SteamNetworkingConfigValue_t[] pOptions)
{
InteropHelp.TestIfAvailableGameServer();
return (HSteamNetConnection)NativeMethods.ISteamNetworkingSockets_ConnectP2P(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), ref identityRemote, nRemoteVirtualPort, nOptions, pOptions);
}
public static EResult AcceptConnection(HSteamNetConnection hConn)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingSockets_AcceptConnection(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), hConn);
}
public static bool CloseConnection(HSteamNetConnection hPeer, int nReason, string pszDebug, bool bEnableLinger)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszDebug2 = new InteropHelp.UTF8StringHandle(pszDebug);
return NativeMethods.ISteamNetworkingSockets_CloseConnection(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), hPeer, nReason, pszDebug2, bEnableLinger);
}
public static bool CloseListenSocket(HSteamListenSocket hSocket)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingSockets_CloseListenSocket(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), hSocket);
}
public static bool SetConnectionUserData(HSteamNetConnection hPeer, long nUserData)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingSockets_SetConnectionUserData(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), hPeer, nUserData);
}
public static long GetConnectionUserData(HSteamNetConnection hPeer)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingSockets_GetConnectionUserData(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), hPeer);
}
public static void SetConnectionName(HSteamNetConnection hPeer, string pszName)
{
InteropHelp.TestIfAvailableGameServer();
using InteropHelp.UTF8StringHandle pszName2 = new InteropHelp.UTF8StringHandle(pszName);
NativeMethods.ISteamNetworkingSockets_SetConnectionName(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), hPeer, pszName2);
}
public static bool GetConnectionName(HSteamNetConnection hPeer, out string pszName, int nMaxLen)
{
InteropHelp.TestIfAvailableGameServer();
IntPtr intPtr = Marshal.AllocHGlobal(nMaxLen);
bool flag = NativeMethods.ISteamNetworkingSockets_GetConnectionName(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), hPeer, intPtr, nMaxLen);
pszName = (flag ? InteropHelp.PtrToStringUTF8(intPtr) : null);
Marshal.FreeHGlobal(intPtr);
return flag;
}
public static EResult SendMessageToConnection(HSteamNetConnection hConn, IntPtr pData, uint cbData, int nSendFlags, out long pOutMessageNumber)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingSockets_SendMessageToConnection(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), hConn, pData, cbData, nSendFlags, out pOutMessageNumber);
}
public static void SendMessages(int nMessages, IntPtr[] pMessages, long[] pOutMessageNumberOrResult)
{
InteropHelp.TestIfAvailableGameServer();
NativeMethods.ISteamNetworkingSockets_SendMessages(CSteamGameServerAPIContext.GetSteamNetworkingSockets(), nMessages, pMessages, pOutMessageNumberOrResult);
}
public static EResult FlushMessagesOnConnection(HSteamNetConnection hConn)
{
InteropHelp.TestIfAvailableGameServer();
return NativeMethods.ISteamNetworkingSockets_FlushMessagesOnConnection(CSteamGameSe
using System;
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 AIGraph;
using API;
using Agents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BoosterImplants;
using ChainedPuzzles;
using Enemies;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using ReplayRecorder;
using ReplayRecorder.API;
using ReplayRecorder.API.Attributes;
using ReplayRecorder.Core;
using ReplayRecorder.SNetUtils;
using SNetwork;
using StateMachines;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Analytics;
using Vanilla.BepInEx;
using Vanilla.Enemy;
using Vanilla.Events;
using Vanilla.Map;
using Vanilla.Metadata;
using Vanilla.Mines;
using Vanilla.Noises;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Vanilla")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b2152aa675e7c59f4573437f7c3dd474ba06922c")]
[assembly: AssemblyProduct("Vanilla")]
[assembly: AssemblyTitle("Vanilla")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace API
{
[HarmonyPatch(typeof(GameDataInit))]
internal class GameDataInit_Patches
{
[HarmonyPatch("Initialize")]
[HarmonyWrapSafe]
[HarmonyPostfix]
public static void Initialize_Postfix()
{
Analytics.enabled = false;
}
}
internal static class APILogger
{
private static readonly ManualLogSource logger;
static APILogger()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
logger = new ManualLogSource("Rand-API");
Logger.Sources.Add((ILogSource)(object)logger);
}
private static string Format(string module, object msg)
{
return $"[{module}]: {msg}";
}
public static void Info(string module, object data)
{
logger.LogMessage((object)Format(module, data));
}
public static void Verbose(string module, object data)
{
}
public static void Log(object data)
{
logger.LogDebug((object)Format("ReplayRecorder.Vanilla", data));
}
public static void Debug(object data)
{
if (ConfigManager.Debug)
{
Log(data);
}
}
public static void Warn(object data)
{
logger.LogWarning((object)Format("ReplayRecorder.Vanilla", data));
}
public static void Error(object data)
{
logger.LogError((object)Format("ReplayRecorder.Vanilla", data));
}
}
}
namespace Vanilla
{
public struct Identifier : BufferWriteable, IEquatable<Identifier>
{
private enum Type
{
Unknown,
Gear,
Alias_Gear,
Item,
Enemy,
Vanity
}
private static Dictionary<int, string> GearCache = new Dictionary<int, string>();
private static Dictionary<string, ushort> GearTable = new Dictionary<string, ushort>();
private static HashSet<ushort> WrittenGears = new HashSet<ushort>();
public static Identifier unknown = new Identifier
{
type = Type.Unknown
};
private static ushort _id = 0;
private string stringKey;
private ushort id;
private Type type;
[ReplayInit]
private static void Init()
{
_id = 0;
GearTable.Clear();
GearCache.Clear();
WrittenGears.Clear();
}
public override string ToString()
{
return $"{stringKey}({id})[{type}]";
}
private static ushort AssignId()
{
return _id++;
}
public static void WriteToRNetPacket(Identifier identifier, ByteBuffer buffer)
{
Type type = identifier.type;
if (type == Type.Alias_Gear)
{
type = Type.Gear;
}
BitHelper.WriteBytes((byte)type, buffer);
BitHelper.WriteBytes(identifier.id, buffer);
BitHelper.WriteBytes((identifier.stringKey == null) ? string.Empty : identifier.stringKey, buffer);
}
public static Identifier ReadFromRNetPacket(ArraySegment<byte> bytes, ref int index)
{
Type type = (Type)BitHelper.ReadByte(bytes, ref index);
ushort num = BitHelper.ReadUShort(bytes, ref index);
string key = BitHelper.ReadString(bytes, ref index);
switch (type)
{
case Type.Unknown:
return unknown;
case Type.Gear:
{
if (GearTable.ContainsKey(key))
{
num = GearTable[key];
}
else
{
num = AssignId();
GearTable.Add(key, num);
}
Identifier result = default(Identifier);
result.type = Type.Alias_Gear;
result.stringKey = key;
result.id = num;
return result;
}
case Type.Alias_Gear:
throw new Exception("Should not receive identifier type Alias_Gear from network.");
case Type.Item:
case Type.Enemy:
case Type.Vanity:
{
Identifier result = default(Identifier);
result.type = type;
result.id = num;
return result;
}
default:
throw new NotImplementedException();
}
}
public void Write(ByteBuffer buffer)
{
switch (type)
{
case Type.Gear:
throw new Exception("GearKey is an internal type that gets written when a new Gear Alias is created. Should not be written directly.");
case Type.Alias_Gear:
if (WrittenGears.Contains(id))
{
BitHelper.WriteBytes((byte)2, buffer);
BitHelper.WriteBytes(id, buffer);
break;
}
WrittenGears.Add(id);
BitHelper.WriteBytes((byte)1, buffer);
BitHelper.WriteBytes(stringKey, buffer);
BitHelper.WriteBytes(id, buffer);
break;
case Type.Item:
case Type.Enemy:
case Type.Vanity:
BitHelper.WriteBytes((byte)type, buffer);
BitHelper.WriteBytes(id, buffer);
break;
case Type.Unknown:
BitHelper.WriteBytes((byte)0, buffer);
break;
default:
throw new NotImplementedException();
}
}
public static bool operator ==(Identifier lhs, Identifier rhs)
{
return lhs.Equals(rhs);
}
public static bool operator !=(Identifier lhs, Identifier rhs)
{
return !(lhs == rhs);
}
public override bool Equals(object? obj)
{
if (obj != null && obj is Identifier)
{
return Equals(obj);
}
return false;
}
public bool Equals(Identifier other)
{
switch (type)
{
case Type.Unknown:
return other.type == Type.Unknown;
case Type.Gear:
if (other.type == Type.Gear)
{
return stringKey == other.stringKey;
}
if (stringKey != null && GearTable.ContainsKey(stringKey))
{
return other.id == GearTable[stringKey];
}
return false;
case Type.Alias_Gear:
if (other.type == Type.Alias_Gear)
{
return id == other.id;
}
if (other.stringKey != null && GearTable.ContainsKey(other.stringKey))
{
return id == GearTable[other.stringKey];
}
return false;
case Type.Item:
case Type.Enemy:
case Type.Vanity:
if (type == other.type)
{
return id == other.id;
}
return false;
default:
throw new NotImplementedException();
}
}
public override int GetHashCode()
{
if (type == Type.Unknown)
{
return type.GetHashCode();
}
return HashCode.Combine(type, stringKey, id);
}
private static void From(GearIDRange gear, ref Identifier identifier)
{
int hashCode = ((Object)gear).GetHashCode();
if (GearCache.ContainsKey(hashCode))
{
identifier.stringKey = GearCache[hashCode];
}
else
{
identifier.stringKey = gear.ToJSON();
GearCache.Add(hashCode, identifier.stringKey);
}
identifier.type = Type.Alias_Gear;
if (GearTable.ContainsKey(identifier.stringKey))
{
identifier.id = GearTable[identifier.stringKey];
return;
}
identifier.id = AssignId();
GearTable.Add(identifier.stringKey, identifier.id);
}
public static Identifier From(ItemEquippable? item)
{
Identifier identifier = default(Identifier);
identifier.type = Type.Unknown;
if ((Object)(object)item != (Object)null)
{
if (item.GearIDRange != null)
{
From(item.GearIDRange, ref identifier);
}
else if (((Item)item).ItemDataBlock != null)
{
identifier.type = Type.Item;
identifier.id = (ushort)((GameDataBlockBase<ItemDataBlock>)(object)((Item)item).ItemDataBlock).persistentID;
}
}
return identifier;
}
public static Identifier From(BackpackItem? item)
{
Identifier identifier = default(Identifier);
identifier.type = Type.Unknown;
if (item != null && item.GearIDRange != null)
{
From(item.GearIDRange, ref identifier);
}
return identifier;
}
public static Identifier From(Item? item)
{
Identifier result = default(Identifier);
result.type = Type.Unknown;
if ((Object)(object)item != (Object)null && item.ItemDataBlock != null)
{
result.type = Type.Item;
result.id = (ushort)((GameDataBlockBase<ItemDataBlock>)(object)item.ItemDataBlock).persistentID;
}
return result;
}
public static Identifier From(pItemData item)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
Identifier result = default(Identifier);
result.type = Type.Item;
result.id = (ushort)item.itemID_gearCRC;
return result;
}
public static Identifier From(EnemyAgent enemy)
{
Identifier result = default(Identifier);
result.type = Type.Enemy;
result.id = (ushort)((GameDataBlockBase<EnemyDataBlock>)(object)enemy.EnemyData).persistentID;
return result;
}
public static Identifier Vanity(uint id)
{
Identifier result = default(Identifier);
result.type = Type.Vanity;
result.id = (ushort)id;
return result;
}
public static Identifier Item(uint id)
{
Identifier result = default(Identifier);
result.type = Type.Item;
result.id = (ushort)id;
return result;
}
}
}
namespace Vanilla.StatTracker
{
[HarmonyPatch]
[ReplayData("Vanilla.Player.Gunshots.Info", "0.0.1")]
public class rGunshotInfo : Id
{
[HarmonyPatch]
public static class Patches
{
public struct BulletInfo
{
public int hits;
public int crits;
}
private static Vector3? lastHit = null;
private static Identifier currentWeapon = Identifier.unknown;
public static PlayerAgent? currentPlayer = null;
public static BulletInfo currentBullet = new BulletInfo
{
hits = 0,
crits = 0
};
private static void TriggerBullet()
{
if (!((Object)(object)currentPlayer == (Object)null))
{
if (currentBullet.hits > 255 || currentBullet.crits > 255)
{
APILogger.Warn($"Number of enemies hit / crit for this bullet exceeded maximum value of {255}.");
}
Sync.Trigger(new rGunshotInfo(currentPlayer, currentWeapon, (byte)currentBullet.hits, (byte)currentBullet.crits));
lastHit = null;
currentBullet.crits = 0;
currentBullet.hits = 0;
}
}
private static void PrepareWeapon(BulletWeapon weapon)
{
if (!((Object)(object)((Item)weapon).Owner == (Object)null) && (SNet.IsMaster || !((Item)weapon).Owner.Owner.IsBot) && (((Item)weapon).Owner.Owner.IsBot || ((Agent)((Item)weapon).Owner).IsLocallyOwned) && !rGunshot.CancelSyncedShot(weapon))
{
lastHit = null;
currentPlayer = ((Item)weapon).Owner;
ItemEquippable wieldedItem = currentPlayer.Inventory.WieldedItem;
if (wieldedItem.IsWeapon && (Object)(object)((Il2CppObjectBase)wieldedItem).TryCast<BulletWeapon>() != (Object)null)
{
currentWeapon = Identifier.From(wieldedItem);
}
}
}
private static void ResetWeapon()
{
TriggerBullet();
currentPlayer = null;
currentWeapon = Identifier.unknown;
}
[HarmonyPatch(typeof(BulletWeapon), "Fire")]
[HarmonyPrefix]
private static void Prefix_BulletWeaponFire(BulletWeapon __instance)
{
PrepareWeapon(__instance);
}
[HarmonyPatch(typeof(BulletWeapon), "Fire")]
[HarmonyPostfix]
private static void Postfix_BulletWeaponFire(BulletWeapon __instance)
{
ResetWeapon();
}
[HarmonyPatch(typeof(Shotgun), "Fire")]
[HarmonyPrefix]
private static void Prefix_ShotgunFire(Shotgun __instance)
{
PrepareWeapon((BulletWeapon)(object)__instance);
}
[HarmonyPatch(typeof(Shotgun), "Fire")]
[HarmonyPostfix]
private static void Postfix_ShotgunFire(Shotgun __instance)
{
ResetWeapon();
}
[HarmonyPatch(typeof(BulletWeaponSynced), "Fire")]
[HarmonyPrefix]
private static void Prefix_BulletWeaponSyncFire(BulletWeaponSynced __instance)
{
if (!((Object)(object)((Item)__instance).Owner == (Object)null) && ((Item)__instance).Owner.Owner.IsBot)
{
PrepareWeapon((BulletWeapon)(object)__instance);
}
}
[HarmonyPatch(typeof(BulletWeaponSynced), "Fire")]
[HarmonyPostfix]
private static void Postfix_BulletWeaponSyncFire()
{
ResetWeapon();
}
[HarmonyPatch(typeof(ShotgunSynced), "Fire")]
[HarmonyPrefix]
private static void Prefix_ShotgunSyncFire(ShotgunSynced __instance)
{
if (!((Object)(object)((Item)__instance).Owner == (Object)null) && ((Item)__instance).Owner.Owner.IsBot)
{
PrepareWeapon((BulletWeapon)(object)__instance);
}
}
[HarmonyPatch(typeof(ShotgunSynced), "Fire")]
[HarmonyPostfix]
private static void Postfix_ShotgunSyncFire()
{
ResetWeapon();
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void Postfix_CastWeaponRay(bool __result, Transform alignTransform, WeaponHitData weaponRayData, Vector3 originPos)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0048: 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_0057: 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_0020: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)currentPlayer == (Object)null))
{
if (lastHit.HasValue && originPos != lastHit.Value)
{
TriggerBullet();
}
RaycastHit rayHit = Weapon.s_weaponRayData.rayHit;
lastHit = ((RaycastHit)(ref rayHit)).point + Weapon.s_weaponRayData.fireDir * 0.1f;
}
}
[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "BulletDamage")]
[HarmonyPrefix]
public static void Prefix_EnemyLimbBulletDamage(Dam_EnemyDamageLimb __instance, Agent sourceAgent)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Invalid comparison between Unknown and I4
if (!((Object)(object)currentPlayer == (Object)null))
{
currentBullet.hits++;
if ((int)__instance.m_type == 1)
{
currentBullet.crits++;
}
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageLimb), "BulletDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerLimbBulletDamage(Dam_PlayerDamageLimb __instance, Agent sourceAgent)
{
if (!((Object)(object)currentPlayer == (Object)null))
{
currentBullet.hits++;
}
}
[HarmonyPatch(typeof(GenericDamageComponent), "BulletDamage")]
[HarmonyPrefix]
public static void Prefix_GenericBulletDamage(GenericDamageComponent __instance, Agent sourceAgent)
{
if (!((Object)(object)currentPlayer == (Object)null))
{
currentBullet.hits++;
}
}
[HarmonyPatch(typeof(LG_WeakLockDamage), "BulletDamage")]
[HarmonyPrefix]
public static void Prefix_LockBulletDamage(LG_WeakLockDamage __instance, Agent sourceAgent)
{
if (!(__instance.Health <= 0f) && !((Object)(object)currentPlayer == (Object)null))
{
currentBullet.hits++;
}
}
}
public static class Sync
{
private const string eventName = "Vanilla.Player.Gunshots.Info";
private static ByteBuffer packet = new ByteBuffer();
[ReplayPluginLoad]
private static void Load()
{
RNet.Register("Vanilla.Player.Gunshots.Info", (Action<ulong, ArraySegment<byte>>)OnReceive);
}
public static void Trigger(rGunshotInfo info)
{
Replay.Trigger((ReplayEvent)(object)info);
ByteBuffer val = packet;
val.Clear();
BitHelper.WriteBytes((ushort)((Id)info).id, val);
Identifier.WriteToRNetPacket(info.gear, val);
BitHelper.WriteBytes(info.numHits, val);
BitHelper.WriteBytes(info.numCrits, val);
RNet.Trigger("Vanilla.Player.Gunshots.Info", val);
}
private static void OnReceive(ulong sender, ArraySegment<byte> packet)
{
int index = 0;
ushort id = BitHelper.ReadUShort(packet, ref index);
Identifier gear = Identifier.ReadFromRNetPacket(packet, ref index);
byte numHits = BitHelper.ReadByte(packet, ref index);
byte numCrits = BitHelper.ReadByte(packet, ref index);
Replay.Trigger((ReplayEvent)(object)new rGunshotInfo(id, gear, numHits, numCrits));
}
}
public Identifier gear;
public byte numHits;
public byte numCrits;
public rGunshotInfo(PlayerAgent owner, Identifier gear, byte numHits, byte numCrits)
: base((int)((Agent)owner).GlobalID)
{
this.gear = gear;
this.numHits = numHits;
this.numCrits = numCrits;
}
public rGunshotInfo(ushort id, Identifier gear, byte numHits, byte numCrits)
: base((int)id)
{
this.gear = gear;
this.numHits = numHits;
this.numCrits = numCrits;
}
public override void Write(ByteBuffer buffer)
{
((Id)this).Write(buffer);
BitHelper.WriteBytes((BufferWriteable)(object)gear, buffer);
BitHelper.WriteBytes(numHits, buffer);
BitHelper.WriteBytes(numCrits, buffer);
}
}
[HarmonyPatch]
[ReplayData("Vanilla.StatTracker.Damage", "0.0.1")]
public class rDamage : ReplayEvent
{
[HarmonyPatch]
private static class Patches
{
private static bool sentry;
[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "FireBullet")]
[HarmonyPrefix]
private static void Prefix_SentryGunFire(SentryGunInstance_Firing_Bullets __instance, bool doDamage, bool targetIsTagged)
{
sentry = true;
}
[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "FireBullet")]
[HarmonyPostfix]
private static void Postfix_SentryGunFire()
{
sentry = false;
}
[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateFireShotgunSemi")]
[HarmonyPrefix]
private static void Prefix_SentryShotgunFire(SentryGunInstance_Firing_Bullets __instance, bool isMaster, bool targetIsTagged)
{
sentry = true;
}
[HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateFireShotgunSemi")]
[HarmonyPostfix]
private static void Postfix_SentryShotgunFire()
{
sentry = false;
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveFallDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerReceiveFallDamage(Dam_PlayerDamageBase __instance, pMiniDamageData data)
{
if (SNet.IsMaster)
{
float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, (Agent)(object)__instance.Owner, Type.Fall, Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num)));
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveTentacleAttackDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerReceiveTentacleAttackDamage(Dam_PlayerDamageBase __instance, pMediumDamageData data)
{
if (SNet.IsMaster && ((Agent)__instance.Owner).Alive)
{
float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
Agent val = default(Agent);
if (((pAgent)(ref data.source)).TryGet(ref val))
{
num = AgentModifierManager.ApplyModifier(val, (AgentModifier)200, num);
}
num = AgentModifierManager.ApplyModifier((Agent)(object)__instance.Owner, (AgentModifier)6, num);
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, val, Type.Tongue, Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num)));
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveShooterProjectileDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerReceiveShooterProjectileDamage(Dam_PlayerDamageBase __instance, pMediumDamageData data)
{
if (SNet.IsMaster && ((Agent)__instance.Owner).Alive)
{
float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
Agent val = default(Agent);
if (((pAgent)(ref data.source)).TryGet(ref val))
{
num = AgentModifierManager.ApplyModifier(val, (AgentModifier)70, num);
}
num = AgentModifierManager.ApplyModifier((Agent)(object)__instance.Owner, (AgentModifier)7, num);
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, (Agent)(object)__instance.Owner, Type.Projectile, Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num)));
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveExplosionDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerReceiveExplosionDamage(Dam_PlayerDamageBase __instance, pExplosionDamageData data)
{
if (SNet.IsMaster && ((Agent)__instance.Owner).Alive && MineManager.currentDetonateEvent != null)
{
float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, ((Id)MineManager.currentDetonateEvent).id, Type.Explosive, Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num)));
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveMeleeDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerReceiveMeleeDamage(Dam_PlayerDamageBase __instance, pFullDamageData data)
{
Agent val = default(Agent);
if (SNet.IsMaster && ((Agent)__instance.Owner).Alive && ((pAgent)(ref data.source)).TryGet(ref val))
{
float num = AgentModifierManager.ApplyModifier(val, (AgentModifier)200, ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).DamageMax));
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, val, Type.Melee, Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num)));
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveBulletDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerReceiveBulletDamage(Dam_PlayerDamageBase __instance, pBulletDamageData data)
{
Agent val = default(Agent);
if (!SNet.IsMaster || !((Agent)__instance.Owner).Alive || !((pAgent)(ref data.source)).TryGet(ref val))
{
return;
}
Identifier gear = Identifier.unknown;
PlayerAgent val2 = ((Il2CppObjectBase)val).TryCast<PlayerAgent>();
if ((Object)(object)val2 != (Object)null)
{
if (!sentry)
{
ItemEquippable wieldedItem = val2.Inventory.WieldedItem;
if (wieldedItem.IsWeapon && (Object)(object)((Il2CppObjectBase)wieldedItem).TryCast<BulletWeapon>() != (Object)null)
{
gear = Identifier.From(wieldedItem);
}
}
else
{
gear = Identifier.From(PlayerBackpackManager.GetItem(val2.Owner, (InventorySlot)3));
}
}
float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
APILogger.Debug($"{__instance.Owner.Owner.NickName} was hit by {((Il2CppObjectBase)val).Cast<PlayerAgent>().Owner.NickName} -> {num}");
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, val, Type.Bullet, Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num), gear, sentry));
}
[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveBulletDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerLocalReceiveBulletDamage(Dam_PlayerDamageBase __instance, pBulletDamageData data)
{
Agent val = default(Agent);
if (!SNet.IsMaster || !((Agent)__instance.Owner).Alive || !((pAgent)(ref data.source)).TryGet(ref val))
{
return;
}
Identifier gear = Identifier.unknown;
PlayerAgent val2 = ((Il2CppObjectBase)val).TryCast<PlayerAgent>();
if ((Object)(object)val2 != (Object)null)
{
if (!sentry)
{
ItemEquippable wieldedItem = val2.Inventory.WieldedItem;
if ((Object)(object)wieldedItem != (Object)null && wieldedItem.IsWeapon && (Object)(object)((Il2CppObjectBase)wieldedItem).TryCast<BulletWeapon>() != (Object)null)
{
gear = Identifier.From(wieldedItem);
}
}
else
{
gear = Identifier.From(PlayerBackpackManager.GetItem(val2.Owner, (InventorySlot)3));
}
}
float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
APILogger.Debug($"{__instance.Owner.Owner.NickName} was hit by {((Il2CppObjectBase)val).Cast<PlayerAgent>().Owner.NickName} -> {num}");
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, val, Type.Bullet, Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num), gear, sentry));
}
[HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveExplosionDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerLocalReceiveExplosionDamage(Dam_PlayerDamageBase __instance, pExplosionDamageData data)
{
if (SNet.IsMaster && ((Agent)__instance.Owner).Alive)
{
APILogger.Debug("local explosive");
if (MineManager.currentDetonateEvent != null)
{
float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, ((Id)MineManager.currentDetonateEvent).id, Type.Explosive, Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num)));
}
}
}
[HarmonyPatch(typeof(Dam_EnemyDamageBase), "ReceiveExplosionDamage")]
[HarmonyPrefix]
public static void Prefix_EnemyReceiveExplosionDamage(Dam_EnemyDamageBase __instance, pExplosionDamageData data)
{
if (!SNet.IsMaster || !((Agent)__instance.Owner).Alive)
{
return;
}
if (MineManager.currentDetonateEvent != null)
{
float num = ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
float num2 = num;
float num3 = __instance.Owner.EnemyBalancingData.Health.DamageUntilHitreact - __instance.m_damBuildToHitreact;
if (num3 < 0f)
{
num3 = 0f;
}
num = Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num);
num2 = HandlePouncerStagger(__instance, num, Mathf.Min(num3, num2));
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, ((Id)MineManager.currentDetonateEvent).id, Type.Explosive, num, sentry: false, num2));
}
else
{
APILogger.Error("Unable to find detonation event. This should not happen.");
}
}
[HarmonyPatch(typeof(Dam_EnemyDamageBase), "ReceiveMeleeDamage")]
[HarmonyPrefix]
public static void Prefix_EnemyReceiveMeleeDamage(Dam_EnemyDamageBase __instance, pFullDamageData data)
{
Agent val = default(Agent);
if (!SNet.IsMaster || !((Agent)__instance.Owner).Alive || !((pAgent)(ref data.source)).TryGet(ref val))
{
return;
}
Identifier gear = Identifier.unknown;
PlayerAgent val2 = ((Il2CppObjectBase)val).TryCast<PlayerAgent>();
if ((Object)(object)val2 != (Object)null)
{
ItemEquippable wieldedItem = val2.Inventory.WieldedItem;
if ((Object)(object)wieldedItem != (Object)null && wieldedItem.IsWeapon && (Object)(object)((Il2CppObjectBase)wieldedItem).TryCast<BulletWeapon>() != (Object)null)
{
gear = Identifier.From(wieldedItem);
}
}
float num = AgentModifierManager.ApplyModifier(val, (AgentModifier)200, ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).DamageMax));
float num2 = num * ((UFloat16)(ref data.staggerMulti)).Get(10f);
float num3 = __instance.Owner.EnemyBalancingData.Health.DamageUntilHitreact - __instance.m_damBuildToHitreact;
if (num3 < 0f)
{
num3 = 0f;
}
num = Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num);
num2 = HandlePouncerStagger(__instance, num, Mathf.Min(num3, num2));
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, val, Type.Melee, num, gear, sentry: false, num2));
}
[HarmonyPatch(typeof(Dam_EnemyDamageBase), "ReceiveBulletDamage")]
[HarmonyPrefix]
public static void Prefix_EnemyReceiveBulletDamage(Dam_EnemyDamageBase __instance, pBulletDamageData data)
{
Agent val = default(Agent);
if (!SNet.IsMaster || !((Agent)__instance.Owner).Alive || !((pAgent)(ref data.source)).TryGet(ref val))
{
return;
}
Identifier gear = Identifier.unknown;
PlayerAgent val2 = ((Il2CppObjectBase)val).TryCast<PlayerAgent>();
if ((Object)(object)val2 != (Object)null)
{
if (!sentry)
{
ItemEquippable wieldedItem = val2.Inventory.WieldedItem;
if (wieldedItem.IsWeapon && (Object)(object)((Il2CppObjectBase)wieldedItem).TryCast<BulletWeapon>() != (Object)null)
{
gear = Identifier.From(wieldedItem);
}
}
else
{
gear = Identifier.From(PlayerBackpackManager.GetItem(val2.Owner, (InventorySlot)3));
}
}
float num = AgentModifierManager.ApplyModifier((Agent)(object)__instance.Owner, (AgentModifier)7, ((UFloat16)(ref data.damage)).Get(((Dam_SyncedDamageBase)__instance).HealthMax));
float num2 = num * ((UFloat16)(ref data.staggerMulti)).Get(10f);
float num3 = __instance.Owner.EnemyBalancingData.Health.DamageUntilHitreact - __instance.m_damBuildToHitreact;
if (num3 < 0f)
{
num3 = 0f;
}
num = Mathf.Min(((Dam_SyncedDamageBase)__instance).Health, num);
num2 = HandlePouncerStagger(__instance, num, Mathf.Min(num3, num2));
Sync.Trigger(new rDamage((Agent)(object)__instance.Owner, val, Type.Bullet, num, gear, sentry, num2));
}
private static float HandlePouncerStagger(Dam_EnemyDamageBase __instance, float damage, float stagger)
{
PouncerBehaviour component = ((Component)__instance.Owner).GetComponent<PouncerBehaviour>();
if ((Object)(object)component == (Object)null)
{
return stagger;
}
if (((MachineState<EB_StateBase>)(object)((StateMachine<EB_StateBase>)(object)component).CurrentState).ENUM_ID == ((MachineState<EB_StateBase>)(object)component.Dash).ENUM_ID)
{
return Mathf.Min(damage + component.Dash.m_damageReceivedDuringState, component.m_data.DashStaggerDamageThreshold) - component.Dash.m_damageReceivedDuringState;
}
if (((MachineState<EB_StateBase>)(object)((StateMachine<EB_StateBase>)(object)component).CurrentState).ENUM_ID == ((MachineState<EB_StateBase>)(object)component.Charge).ENUM_ID)
{
return Mathf.Min(damage + component.Charge.m_damageReceivedDuringState, component.m_data.ChargeStaggerDamageThreshold) - component.Charge.m_damageReceivedDuringState;
}
return 0f;
}
}
public enum Type
{
Bullet,
Explosive,
Melee,
Projectile,
Tongue,
Fall
}
private static class Sync
{
private const string eventName = "Vanilla.StatTracker.Damage";
private static ByteBuffer packet = new ByteBuffer();
[ReplayPluginLoad]
private static void Load()
{
RNet.Register("Vanilla.StatTracker.Damage", (Action<ulong, ArraySegment<byte>>)OnReceive);
}
public static void Trigger(rDamage damage)
{
Replay.Trigger((ReplayEvent)(object)damage);
ByteBuffer val = packet;
val.Clear();
BitHelper.WriteBytes((byte)damage.type, val);
BitHelper.WriteBytes(damage.source, val);
BitHelper.WriteBytes(damage.target, val);
BitHelper.WriteHalf(damage.damage, val);
Identifier.WriteToRNetPacket(damage.gear, val);
BitHelper.WriteBytes(damage.sentry, val);
BitHelper.WriteHalf(damage.staggerDamage, val);
RNet.Trigger("Vanilla.StatTracker.Damage", val);
}
private static void OnReceive(ulong sender, ArraySegment<byte> packet)
{
int index = 0;
Type type = (Type)BitHelper.ReadByte(packet, ref index);
int source = BitHelper.ReadInt(packet, ref index);
ushort target = BitHelper.ReadUShort(packet, ref index);
float damage = BitHelper.ReadHalf(packet, ref index);
Identifier gear = Identifier.ReadFromRNetPacket(packet, ref index);
bool sentry = BitHelper.ReadBool(packet, ref index);
float staggerMulti = BitHelper.ReadHalf(packet, ref index);
Replay.Trigger((ReplayEvent)(object)new rDamage(target, source, type, damage, gear, sentry, staggerMulti));
}
}
public Type type;
public int source;
public ushort target;
public Identifier gear;
public bool sentry;
public float damage;
public float staggerDamage;
public rDamage(Agent target, Agent source, Type type, float damage, Identifier gear, bool sentry = false, float staggerMulti = 0f)
{
this.type = type;
this.source = source.GlobalID;
this.target = target.GlobalID;
this.gear = gear;
this.damage = damage;
staggerDamage = staggerMulti;
this.sentry = sentry;
}
public rDamage(Agent target, int source, Type type, float damage, Identifier gear, bool sentry = false, float staggerMulti = 0f)
{
this.type = type;
this.source = source;
this.target = target.GlobalID;
this.gear = gear;
this.damage = damage;
staggerDamage = staggerMulti;
this.sentry = sentry;
}
public rDamage(ushort target, int source, Type type, float damage, Identifier gear, bool sentry = false, float staggerMulti = 0f)
{
this.type = type;
this.source = source;
this.target = target;
this.gear = gear;
this.damage = damage;
staggerDamage = staggerMulti;
this.sentry = sentry;
}
public rDamage(Agent target, Agent source, Type type, float damage, bool sentry = false, float staggerMulti = 0f)
{
this.type = type;
this.source = source.GlobalID;
this.target = target.GlobalID;
gear = Identifier.unknown;
this.damage = damage;
staggerDamage = staggerMulti;
this.sentry = sentry;
}
public rDamage(Agent target, int source, Type type, float damage, bool sentry = false, float staggerMulti = 0f)
{
this.type = type;
this.source = source;
this.target = target.GlobalID;
gear = Identifier.unknown;
this.damage = damage;
staggerDamage = staggerMulti;
this.sentry = sentry;
}
public rDamage(ushort target, int source, Type type, float damage, bool sentry = false, float staggerMulti = 0f)
{
this.type = type;
this.source = source;
this.target = target;
gear = Identifier.unknown;
this.damage = damage;
staggerDamage = staggerMulti;
this.sentry = sentry;
}
public override void Write(ByteBuffer buffer)
{
BitHelper.WriteBytes((byte)type, buffer);
BitHelper.WriteBytes(source, buffer);
BitHelper.WriteBytes(target, buffer);
BitHelper.WriteHalf(damage, buffer);
BitHelper.WriteBytes((BufferWriteable)(object)gear, buffer);
BitHelper.WriteBytes(sentry, buffer);
BitHelper.WriteHalf(staggerDamage, buffer);
}
}
[HarmonyPatch]
[ReplayData("Vanilla.StatTracker.Revive", "0.0.1")]
public class rRevive : ReplayEvent
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(AgentReplicatedActions), "DoPlayerRevive")]
[HarmonyPostfix]
public static void DoPlayerRevive(pPlayerReviveAction data)
{
PlayerAgent val = default(PlayerAgent);
PlayerAgent val2 = default(PlayerAgent);
if (((pPlayerAgent)(ref data.TargetPlayer)).TryGet(ref val) && !((Agent)val).Alive && ((pPlayerAgent)(ref data.SourcePlayer)).TryGet(ref val2))
{
APILogger.Debug($"Player {val.Owner.NickName} was revived by {val2.Owner.NickName}.");
Replay.Trigger((ReplayEvent)(object)new rRevive(val, val2));
}
}
}
private ushort source;
private ushort target;
public rRevive(PlayerAgent target, PlayerAgent source)
{
this.source = ((Agent)source).GlobalID;
this.target = ((Agent)target).GlobalID;
}
public override void Write(ByteBuffer buffer)
{
BitHelper.WriteBytes(source, buffer);
BitHelper.WriteBytes(target, buffer);
}
}
}
namespace Vanilla.StatTracker.Dodges
{
[HarmonyPatch]
[ReplayData("Vanilla.StatTracker.TongueDodge", "0.0.1")]
public class rTongueDodge : ReplayEvent
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(MovingEnemyTentacleBase), "AttackIn")]
[HarmonyPrefix]
private static void AttackIn(MovingEnemyTentacleBase __instance)
{
int instanceID = ((Object)__instance).GetInstanceID();
if (Replay.Has<rEnemyTongue>(instanceID))
{
rEnemyTongue rEnemyTongue = Replay.Get<rEnemyTongue>(instanceID);
if (!rEnemyTongue.attackOut && (Object)(object)rEnemyTongue.target != (Object)null)
{
Replay.Trigger((ReplayEvent)(object)new rTongueDodge(__instance.m_owner, rEnemyTongue.target));
}
rEnemyTongue.attackOut = false;
}
}
[HarmonyPatch(typeof(MovingEnemyTentacleBase), "OnAttackIsOut")]
[HarmonyPrefix]
private static void OnAttackIsOut(MovingEnemyTentacleBase __instance)
{
//IL_005f: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
if (!SNet.IsMaster)
{
return;
}
int instanceID = ((Object)__instance).GetInstanceID();
if (!Replay.Has<rEnemyTongue>(instanceID))
{
return;
}
rEnemyTongue rEnemyTongue = Replay.Get<rEnemyTongue>(instanceID);
rEnemyTongue.attackOut = true;
PlayerAgent val = __instance.PlayerTarget;
if ((Object)(object)val == (Object)null)
{
val = rEnemyTongue.target;
}
if ((Object)(object)val == (Object)null)
{
return;
}
bool flag = __instance.CheckTargetInAttackTunnel();
bool flag2 = false;
if (__instance.m_hasStaticTargetPos)
{
RaycastHit val2 = default(RaycastHit);
if (Physics.Linecast(((Agent)__instance.m_owner).EyePosition, __instance.m_staticTargetPos, ref val2, LayerManager.MASK_DEFAULT) && ((Component)((RaycastHit)(ref val2)).collider).GetComponent<IDamageable>() != null)
{
flag2 = true;
}
}
else if ((Object)(object)__instance.PlayerTarget != (Object)null && ((Dam_SyncedDamageBase)__instance.PlayerTarget.Damage).IsSetup)
{
bool flag3;
if (__instance.m_owner.EnemyBalancingData.UseTentacleTunnelCheck)
{
flag3 = flag;
}
else
{
Vector3 tipPos = __instance.GetTipPos();
Vector3 val3 = ((Agent)__instance.PlayerTarget).TentacleTarget.position - tipPos;
flag3 = ((Vector3)(ref val3)).magnitude < __instance.m_owner.EnemyBalancingData.TentacleAttackDamageRadiusIfNoTunnelCheck;
}
if (flag3)
{
flag2 = true;
}
}
if (!flag2)
{
Replay.Trigger((ReplayEvent)(object)new rTongueDodge(__instance.m_owner, val));
}
}
}
public ushort source;
public ushort target;
public rTongueDodge(EnemyAgent source, PlayerAgent target)
{
this.source = ((Agent)source).GlobalID;
this.target = ((Agent)target).GlobalID;
}
public override void Write(ByteBuffer buffer)
{
BitHelper.WriteBytes(source, buffer);
BitHelper.WriteBytes(target, buffer);
}
}
}
namespace Vanilla.StatTracker.Consumable
{
[HarmonyPatch]
[ReplayData("Vanilla.StatTracker.Pack", "0.0.1")]
public class rPack : ReplayEvent
{
[HarmonyPatch]
private class Patches
{
private static PlayerAgent? sourcePackUser;
[HarmonyPatch(typeof(ResourcePackFirstPerson), "ApplyPackBot")]
[HarmonyPrefix]
public static void ApplyPackBot(PlayerAgent ownerAgent, PlayerAgent receiverAgent, ItemEquippable resourceItem)
{
if (SNet.IsMaster)
{
uint persistentID = ((GameDataBlockBase<ItemDataBlock>)(object)((Item)resourceItem).ItemDataBlock).persistentID;
if (persistentID - 101 <= 1 || persistentID == 127 || persistentID == 132)
{
sourcePackUser = ownerAgent;
}
}
}
[HarmonyPatch(typeof(ResourcePackFirstPerson), "ApplyPack")]
[HarmonyPrefix]
public static void ApplyPackFirstPerson(ResourcePackFirstPerson __instance)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//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_0011: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
if (SNet.IsMaster)
{
eResourceContainerSpawnType packType = __instance.m_packType;
if ((int)packType <= 2 || (int)packType == 9)
{
sourcePackUser = ((Item)__instance).Owner;
}
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveAddHealth")]
[HarmonyPrefix]
public static void Postfix_ReceiveAddHealth(Dam_PlayerDamageBase __instance, pAddHealthData data)
{
if (!SNet.IsMaster)
{
return;
}
float num = ((SFloat16)(ref data.health)).Get(((Dam_SyncedDamageBase)__instance).HealthMax);
if (Mathf.Min(((Dam_SyncedDamageBase)__instance).Health + num, ((Dam_SyncedDamageBase)__instance).HealthMax) - ((Dam_SyncedDamageBase)__instance).Health > 0f)
{
Agent val = default(Agent);
if ((Object)(object)sourcePackUser == (Object)null)
{
((pAgent)(ref data.source)).TryGet(ref val);
}
else
{
val = (Agent)(object)sourcePackUser;
}
if ((Object)(object)val != (Object)null)
{
PlayerAgent val2 = ((Il2CppObjectBase)val).TryCast<PlayerAgent>();
if ((Object)(object)val2 != (Object)null)
{
APILogger.Debug($"Player {val2.Owner.NickName} used healing item on {__instance.Owner.Owner.NickName}.");
Sync.Trigger(new rPack(Type.HealingItem, val, (Agent)(object)__instance.Owner));
}
}
}
sourcePackUser = null;
}
[HarmonyPatch(typeof(PlayerBackpackManager), "ReceiveAmmoGive")]
[HarmonyPostfix]
public static void ReceiveAmmoGive(PlayerBackpackManager __instance, pAmmoGive data)
{
//IL_0022: 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)
if (!SNet.IsMaster)
{
return;
}
SNet_Player val = default(SNet_Player);
if (((pPlayer)(ref data.targetPlayer)).TryGetPlayer(ref val))
{
PlayerDataBlock block = GameDataBlockBase<PlayerDataBlock>.GetBlock(1u);
float num = data.ammoStandardRel * (float)block.AmmoStandardResourcePackMaxCap;
float num2 = data.ammoSpecialRel * (float)block.AmmoSpecialResourcePackMaxCap;
Type type = ((!(num > 0f) || !(num2 > 0f)) ? Type.Tool : Type.Ammo);
PlayerAgent val2 = ((Il2CppObjectBase)val.PlayerAgent).Cast<PlayerAgent>();
SNet_Player val3 = default(SNet_Player);
if ((Object)(object)sourcePackUser != (Object)null)
{
APILogger.Debug($"Player {sourcePackUser.Owner.NickName} used {type} on {val2.Owner.NickName}.");
Sync.Trigger(new rPack(type, (Agent)(object)sourcePackUser, (Agent)(object)val2));
}
else if (SNetUtils.TryGetSender((SNet_Packet)(object)((SNet_SyncedAction<pAmmoGive>)(object)__instance.m_giveAmmoPacket).m_packet, ref val3))
{
APILogger.Debug($"Player {val3.NickName} used {type} on {val2.Owner.NickName}.");
Sync.Trigger(new rPack(type, (Agent)(object)((Il2CppObjectBase)val3.PlayerAgent).Cast<PlayerAgent>(), (Agent)(object)val2));
}
else
{
APILogger.Debug($"Player {val2.Owner.NickName} used {type}.");
Sync.Trigger(new rPack(type, (Agent)(object)val2, (Agent)(object)val2));
}
}
sourcePackUser = null;
}
[HarmonyPatch(typeof(Dam_PlayerDamageBase), "ModifyInfection")]
[HarmonyPostfix]
public static void ModifyInfection(Dam_PlayerDamageBase __instance, pInfection data, bool sync, bool updatePageMap)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
if (!SNet.IsMaster)
{
return;
}
if ((int)data.effect == 1)
{
PlayerAgent owner = __instance.Owner;
SNet_Player val = default(SNet_Player);
if ((Object)(object)sourcePackUser != (Object)null)
{
APILogger.Debug($"Player {sourcePackUser.Owner.NickName} used disinfect pack on {owner.Owner.NickName}.");
Sync.Trigger(new rPack(Type.Disinfect, (Agent)(object)sourcePackUser, (Agent)(object)owner));
}
else if (SNetUtils.TryGetSender((SNet_Packet)(object)__instance.m_receiveModifyInfectionPacket, ref val))
{
APILogger.Debug($"Player {val.NickName} used disinfect pack on {owner.Owner.NickName}.");
Sync.Trigger(new rPack(Type.Disinfect, (Agent)(object)((Il2CppObjectBase)val.PlayerAgent).Cast<PlayerAgent>(), (Agent)(object)owner));
}
else
{
APILogger.Debug("Player " + owner.Owner.NickName + " used disinfect pack.");
Sync.Trigger(new rPack(Type.Disinfect, (Agent)(object)owner, (Agent)(object)owner));
}
}
sourcePackUser = null;
}
}
public enum Type
{
Ammo,
Tool,
HealingItem,
Disinfect
}
private static class Sync
{
private const string eventName = "Vanilla.StatTracker.Pack";
private static ByteBuffer packet = new ByteBuffer();
[ReplayPluginLoad]
private static void Load()
{
RNet.Register("Vanilla.StatTracker.Pack", (Action<ulong, ArraySegment<byte>>)OnReceive);
}
public static void Trigger(rPack pack)
{
Replay.Trigger((ReplayEvent)(object)pack);
ByteBuffer val = packet;
val.Clear();
BitHelper.WriteBytes((byte)pack.type, val);
BitHelper.WriteBytes(pack.source, val);
BitHelper.WriteBytes(pack.target, val);
RNet.Trigger("Vanilla.StatTracker.Pack", val);
}
private static void OnReceive(ulong sender, ArraySegment<byte> packet)
{
int num = 0;
byte type = BitHelper.ReadByte(packet, ref num);
ushort source = BitHelper.ReadUShort(packet, ref num);
ushort target = BitHelper.ReadUShort(packet, ref num);
Replay.Trigger((ReplayEvent)(object)new rPack((Type)type, source, target));
}
}
public Type type;
public ushort source;
public ushort target;
public rPack(Type type, Agent source, Agent target)
{
this.type = type;
this.source = source.GlobalID;
this.target = target.GlobalID;
}
public rPack(Type type, ushort source, ushort target)
{
this.type = type;
this.source = source;
this.target = target;
}
public override void Write(ByteBuffer buffer)
{
BitHelper.WriteBytes((byte)type, buffer);
BitHelper.WriteBytes(source, buffer);
BitHelper.WriteBytes(target, buffer);
}
}
}
namespace Vanilla.StaticItems
{
internal class rBulkheadController
{
public LG_BulkheadDoorController_Core core;
public int id;
public Vector3 position => ((Component)core).transform.position;
public Quaternion rotation => ((Component)core).transform.rotation;
public byte dimensionIndex => (byte)core.SpawnNode.m_dimension.DimensionIndex;
public ushort serialNumber => (ushort)core.m_serialNumber;
public rBulkheadController(LG_BulkheadDoorController_Core controller)
{
id = ((Object)controller).GetInstanceID();
core = controller;
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.BulkheadControllers", "0.0.1")]
internal class rBulkheadControllers : ReplayHeader
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(LG_BulkheadDoorController_Core), "Setup")]
[HarmonyPostfix]
private static void Setup(LG_BulkheadDoorController_Core __instance)
{
rBulkheadController rBulkheadController2 = new rBulkheadController(__instance);
bulkheadControllers.Add(rBulkheadController2.id, rBulkheadController2);
}
}
internal static Dictionary<int, rBulkheadController> bulkheadControllers = new Dictionary<int, rBulkheadController>();
private static LG_LayerType[] layers = (LG_LayerType[])(object)new LG_LayerType[3]
{
default(LG_LayerType),
(LG_LayerType)1,
(LG_LayerType)2
};
[ReplayOnElevatorStop]
private static void Trigger()
{
int[] array = bulkheadControllers.Keys.ToArray();
foreach (int key in array)
{
if (bulkheadControllers.ContainsKey(key) && (Object)(object)bulkheadControllers[key].core == (Object)null)
{
bulkheadControllers.Remove(key);
}
}
Replay.Trigger((ReplayHeader)(object)new rBulkheadControllers());
bulkheadControllers.Clear();
}
[ReplayInit]
private static void Init()
{
bulkheadControllers.Clear();
}
public override void Write(ByteBuffer buffer)
{
//IL_0046: 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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: 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)
BitHelper.WriteBytes((ushort)bulkheadControllers.Count, buffer);
foreach (rBulkheadController value in bulkheadControllers.Values)
{
BitHelper.WriteBytes(value.id, buffer);
BitHelper.WriteBytes(value.dimensionIndex, buffer);
BitHelper.WriteBytes(value.position, buffer);
BitHelper.WriteHalf(value.rotation, buffer);
BitHelper.WriteBytes(value.serialNumber, buffer);
Dictionary<LG_LayerType, LG_SecurityDoor> connectedBulkheadDoors = value.core.m_connectedBulkheadDoors;
LG_LayerType[] array = layers;
foreach (LG_LayerType val in array)
{
if (connectedBulkheadDoors.ContainsKey(val))
{
BitHelper.WriteBytes(true, buffer);
BitHelper.WriteBytes(((Object)connectedBulkheadDoors[val].Gate).GetInstanceID(), buffer);
}
else
{
BitHelper.WriteBytes(false, buffer);
}
}
}
}
}
internal class rDisinfectStation
{
public LG_DisinfectionStation core;
public int id;
public Vector3 position => ((Component)core).transform.position;
public Quaternion rotation => ((Component)core).transform.rotation;
public byte dimensionIndex => (byte)core.SpawnNode.m_dimension.DimensionIndex;
public ushort serialNumber => (ushort)core.m_serialNumber;
public rDisinfectStation(LG_DisinfectionStation disinfectStation)
{
id = ((Object)disinfectStation).GetInstanceID();
core = disinfectStation;
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.DisinfectStations", "0.0.1")]
internal class rDisinfectStations : ReplayHeader
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(LG_DisinfectionStation), "Setup")]
[HarmonyPostfix]
private static void Setup(LG_DisinfectionStation __instance)
{
rDisinfectStation rDisinfectStation2 = new rDisinfectStation(__instance);
disinfectStations.Add(rDisinfectStation2.id, rDisinfectStation2);
}
}
internal static Dictionary<int, rDisinfectStation> disinfectStations = new Dictionary<int, rDisinfectStation>();
[ReplayOnElevatorStop]
private static void Trigger()
{
int[] array = disinfectStations.Keys.ToArray();
foreach (int key in array)
{
if (disinfectStations.ContainsKey(key) && (Object)(object)disinfectStations[key].core == (Object)null)
{
disinfectStations.Remove(key);
}
}
Replay.Trigger((ReplayHeader)(object)new rDisinfectStations());
disinfectStations.Clear();
}
[ReplayInit]
private static void Init()
{
disinfectStations.Clear();
}
public override void Write(ByteBuffer buffer)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
BitHelper.WriteBytes((ushort)disinfectStations.Count, buffer);
foreach (rDisinfectStation value in disinfectStations.Values)
{
BitHelper.WriteBytes(value.id, buffer);
BitHelper.WriteBytes(value.dimensionIndex, buffer);
BitHelper.WriteBytes(value.position, buffer);
BitHelper.WriteHalf(value.rotation, buffer);
BitHelper.WriteBytes(value.serialNumber, buffer);
}
}
}
internal class rDoor
{
public enum Type
{
WeakDoor,
SecurityDoor,
BulkheadDoor,
BulkheadDoorMain,
ApexDoor
}
private int id;
public LG_Gate gate;
private MonoBehaviourExtended mono;
private ushort serialNumber;
private bool isCheckpoint;
private Type type;
private byte size;
public rDoor(Type type, LG_Door_Sync sync, LG_Gate gate, MonoBehaviourExtended mono, int serialNumber, bool isCheckpoint = false)
{
//IL_007e: 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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Invalid comparison between Unknown and I4
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Invalid comparison between Unknown and I4
id = sync.m_stateReplicator.Replicator.Key;
this.gate = gate;
this.mono = mono;
this.serialNumber = (ushort)serialNumber;
this.type = type;
this.isCheckpoint = isCheckpoint;
if (this.type == Type.SecurityDoor)
{
if (gate.ForceApexGate)
{
this.type = Type.ApexDoor;
}
else if (gate.ForceBulkheadGate)
{
this.type = Type.BulkheadDoor;
}
else if (gate.ForceBulkheadGateMainPath)
{
this.type = Type.BulkheadDoorMain;
}
}
LG_GateType val = gate.Type;
if ((int)val != 1)
{
if ((int)val == 2)
{
size = 2;
}
else
{
size = 0;
}
}
else
{
size = 1;
}
}
public void Write(ByteBuffer buffer)
{
//IL_0017: 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)
//IL_0038: 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)
BitHelper.WriteBytes(id, buffer);
BitHelper.WriteBytes((byte)Dimension.GetDimensionFromPos(((Component)mono).transform.position).DimensionIndex, buffer);
BitHelper.WriteBytes(((Component)mono).transform.position, buffer);
BitHelper.WriteHalf(((Component)mono).transform.rotation, buffer);
BitHelper.WriteBytes(serialNumber, buffer);
BitHelper.WriteBytes(isCheckpoint, buffer);
BitHelper.WriteBytes((byte)type, buffer);
BitHelper.WriteBytes(size, buffer);
}
}
[ReplayData("Vanilla.Map.Doors", "0.0.1")]
internal class rDoors : ReplayHeader
{
private List<rDoor> doors;
public rDoors(List<rDoor> doors)
{
this.doors = doors;
}
public override void Write(ByteBuffer buffer)
{
if (doors.Count > 65535)
{
throw new TooManyDoors($"There were too many doors! {doors.Count} doors were found.");
}
BitHelper.WriteBytes((ushort)doors.Count, buffer);
foreach (rDoor door in doors)
{
door.Write(buffer);
}
}
}
public class NoDoorDestructionComp : Exception
{
public NoDoorDestructionComp(string message)
: base(message)
{
}
}
public class TooManyDoors : Exception
{
public TooManyDoors(string message)
: base(message)
{
}
}
internal static class DoorReplayManager
{
internal static List<rDoor> doors = new List<rDoor>();
internal static List<rWeakDoor> weakDoors = new List<rWeakDoor>();
[ReplayInit]
private static void Init()
{
doors.Clear();
weakDoors.Clear();
}
[ReplayOnHeaderCompletion]
private static void WriteWeakDoors()
{
rWeakDoor[] array = weakDoors.ToArray();
weakDoors.Clear();
rWeakDoor[] array2 = array;
foreach (rWeakDoor rWeakDoor2 in array2)
{
if ((Object)(object)rWeakDoor2.door != (Object)null)
{
weakDoors.Add(rWeakDoor2);
}
}
foreach (rWeakDoor weakDoor in weakDoors)
{
Replay.Spawn((ReplayDynamic)(object)weakDoor, true);
}
}
public static byte doorStatus(eDoorStatus status)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected I4, but got Unknown
return (status - 10) switch
{
0 => 1,
2 => 2,
1 => 3,
_ => 0,
};
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.DoorStatusChange", "0.0.1")]
internal class rDoorStatusChange : Id
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(LG_WeakDoor), "OnSyncDoorStateChange")]
[HarmonyPrefix]
private static void Weak_DoorStateChange(LG_WeakDoor __instance, pDoorState state)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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)
if (DoorReplayManager.doorStatus(__instance.LastStatus) != DoorReplayManager.doorStatus(state.status))
{
Replay.Trigger((ReplayEvent)(object)new rDoorStatusChange(((Il2CppObjectBase)__instance.m_sync).Cast<LG_Door_Sync>().m_stateReplicator.Replicator.Key, state.status));
}
}
[HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")]
[HarmonyPrefix]
private static void Security_DoorStateChange(LG_SecurityDoor __instance, pDoorState state)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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)
if (DoorReplayManager.doorStatus(__instance.LastStatus) != DoorReplayManager.doorStatus(state.status))
{
Replay.Trigger((ReplayEvent)(object)new rDoorStatusChange(((Il2CppObjectBase)__instance.m_sync).Cast<LG_Door_Sync>().m_stateReplicator.Replicator.Key, state.status));
}
}
}
private byte status;
public rDoorStatusChange(int id, eDoorStatus status)
: base(id)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
this.status = DoorReplayManager.doorStatus(status);
}
public override void Write(ByteBuffer buffer)
{
((Id)this).Write(buffer);
BitHelper.WriteBytes(status, buffer);
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.WeakDoor.Punch", "0.0.1")]
internal class rDoorPunch : Id
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(LG_WeakDoor_Destruction), "TriggerPunchEffect")]
[HarmonyPostfix]
private static void WeakDoor_Punch(LG_WeakDoor_Destruction __instance)
{
LG_WeakDoor val = ((Il2CppObjectBase)__instance.m_core).TryCast<LG_WeakDoor>();
if (!((Object)(object)val == (Object)null))
{
Replay.Trigger((ReplayEvent)(object)new rDoorPunch(((Il2CppObjectBase)val.m_sync).Cast<LG_Door_Sync>().m_stateReplicator.Replicator.Key));
}
}
}
public rDoorPunch(int id)
: base(id)
{
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.WeakDoor", "0.0.1")]
internal class rWeakDoor : ReplayDynamic
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(LG_WeakDoor), "Setup")]
[HarmonyPostfix]
private static void WeakDoor_Setup(LG_WeakDoor __instance, LG_Gate gate)
{
DoorReplayManager.doors.Add(new rDoor(rDoor.Type.WeakDoor, ((Il2CppObjectBase)__instance.m_sync).Cast<LG_Door_Sync>(), gate, (MonoBehaviourExtended)(object)__instance, __instance.m_serialNumber, __instance.IsCheckpointDoor));
DoorReplayManager.weakDoors.Add(new rWeakDoor(__instance));
}
[HarmonyPatch(typeof(LG_SecurityDoor), "Setup")]
[HarmonyPostfix]
private static void SecurityDoor_Setup(LG_SecurityDoor __instance, LG_Gate gate)
{
DoorReplayManager.doors.Add(new rDoor(rDoor.Type.SecurityDoor, ((Il2CppObjectBase)__instance.m_sync).Cast<LG_Door_Sync>(), gate, (MonoBehaviourExtended)(object)__instance, __instance.m_serialNumber, __instance.IsCheckpointDoor));
}
[HarmonyPatch(typeof(GS_ReadyToStopElevatorRide), "Enter")]
[HarmonyPostfix]
private static void StopElevatorRide()
{
rDoor[] array = DoorReplayManager.doors.ToArray();
DoorReplayManager.doors.Clear();
rDoor[] array2 = array;
foreach (rDoor rDoor2 in array2)
{
if ((Object)(object)rDoor2.gate != (Object)null)
{
DoorReplayManager.doors.Add(rDoor2);
}
}
Replay.Trigger((ReplayHeader)(object)new rDoors(DoorReplayManager.doors));
}
}
private enum LockType
{
None,
Melee,
Hackable
}
private static class Sync
{
private const string eventName = "Vanilla.Map.WeakDoor";
private static ByteBuffer packet = new ByteBuffer();
[ReplayPluginLoad]
private static void Load()
{
RNet.Register("Vanilla.Map.WeakDoor", (Action<ulong, ArraySegment<byte>>)OnReceive);
}
public static void Trigger(int id, byte health)
{
ByteBuffer val = packet;
val.Clear();
BitHelper.WriteBytes(id, val);
BitHelper.WriteBytes(health, val);
RNet.Trigger("Vanilla.Map.WeakDoor", val);
}
private static void OnReceive(ulong sender, ArraySegment<byte> packet)
{
int num = 0;
int num2 = BitHelper.ReadInt(packet, ref num);
byte health = BitHelper.ReadByte(packet, ref num);
rWeakDoor rWeakDoor2 = default(rWeakDoor);
if (Replay.TryGet<rWeakDoor>(num2, ref rWeakDoor2))
{
rWeakDoor2._health = health;
}
}
}
public LG_WeakDoor door;
private LG_WeakDoor_Destruction destruction;
private float damageTaken;
private byte _health = byte.MaxValue;
private byte prevHealth = byte.MaxValue;
private byte _lock0;
private byte _lock1;
public override string? Debug => $"{base.id} - {destruction.m_health}/{door.m_healthMax}";
public override bool Active => (Object)(object)door != (Object)null;
public override bool IsDirty
{
get
{
if (health == prevHealth && _lock0 == lock0)
{
return _lock1 != lock1;
}
return true;
}
}
private byte health
{
get
{
if (SNet.IsMaster)
{
return (byte)(255f * destruction.m_health / door.m_healthMax);
}
return _health;
}
}
private byte lock0 => (byte)GetLockType(0);
private byte lock1 => (byte)GetLockType(1);
private LockType GetLockType(int slot)
{
//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_0054: Invalid comparison between Unknown and I4
//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_0067: Invalid comparison between Unknown and I4
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Invalid comparison between Unknown and I4
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Invalid comparison between Unknown and I4
if (door.m_weakLocks == null || slot < 0 || slot >= ((Il2CppArrayBase<LG_WeakLock>)(object)door.m_weakLocks).Length)
{
return LockType.None;
}
LG_WeakLock val = ((Il2CppArrayBase<LG_WeakLock>)(object)door.m_weakLocks)[slot];
LockType result = LockType.None;
if ((Object)(object)val != (Object)null && (int)val.m_stateReplicator.State.status != 3 && (int)val.m_stateReplicator.State.status != 2)
{
eWeakLockType lockType = val.m_lockType;
if ((int)lockType != 1)
{
if ((int)lockType == 2)
{
result = LockType.Hackable;
}
}
else
{
result = LockType.Melee;
}
}
return result;
}
public rWeakDoor(LG_WeakDoor door)
: base((int)((Il2CppObjectBase)door.m_sync).Cast<LG_Door_Sync>().m_stateReplicator.Replicator.Key)
{
this.door = door;
damageTaken = door.m_healthMax;
LG_WeakDoor_Destruction val = ((Il2CppObjectBase)door.m_destruction).TryCast<LG_WeakDoor_Destruction>();
if ((Object)(object)val == (Object)null)
{
throw new NoDoorDestructionComp("Failed to get 'LG_WeakDoor_Destruction'.");
}
destruction = val;
}
public override void Write(ByteBuffer buffer)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
prevHealth = health;
_lock0 = lock0;
_lock1 = lock1;
BitHelper.WriteBytes(prevHealth, buffer);
if (((Component)((Il2CppArrayBase<Transform>)(object)door.m_buttonAligns)[0]).transform.localPosition.z < 0f)
{
BitHelper.WriteBytes(_lock0, buffer);
BitHelper.WriteBytes(_lock1, buffer);
}
else
{
BitHelper.WriteBytes(_lock1, buffer);
BitHelper.WriteBytes(_lock0, buffer);
}
if (SNet.IsMaster)
{
Sync.Trigger(base.id, health);
}
}
public override void Spawn(ByteBuffer buffer)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
_lock0 = lock0;
_lock1 = lock1;
BitHelper.WriteHalf(door.m_healthMax, buffer);
if (((Component)((Il2CppArrayBase<Transform>)(object)door.m_buttonAligns)[0]).transform.localPosition.z < 0f)
{
BitHelper.WriteBytes(_lock0, buffer);
BitHelper.WriteBytes(_lock1, buffer);
}
else
{
BitHelper.WriteBytes(_lock1, buffer);
BitHelper.WriteBytes(_lock0, buffer);
}
}
}
[ReplayData("Vanilla.Map.Generators.State", "0.0.1")]
internal class rGenerator : ReplayDynamic
{
public LG_PowerGenerator_Core core;
private bool _powered;
public Vector3 position => ((Component)core).transform.position;
public Quaternion rotation => ((Component)core).transform.rotation;
public byte dimensionIndex => (byte)core.SpawnNode.m_dimension.DimensionIndex;
public ushort serialNumber => (ushort)core.m_serialNumber;
public override bool Active => (Object)(object)core != (Object)null;
public override bool IsDirty => _powered != powered;
private bool powered => (int)core.m_stateReplicator.State.status == 0;
public rGenerator(LG_PowerGenerator_Core generator)
: base(((Object)generator).GetInstanceID())
{
core = generator;
}
public override void Write(ByteBuffer buffer)
{
_powered = powered;
BitHelper.WriteBytes(_powered, buffer);
}
public override void Spawn(ByteBuffer buffer)
{
((ReplayDynamic)this).Write(buffer);
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.Generators", "0.0.1")]
internal class rGenerators : ReplayHeader
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(LG_PowerGenerator_Core), "Setup")]
[HarmonyPostfix]
private static void Setup(LG_PowerGenerator_Core __instance)
{
rGenerator rGenerator2 = new rGenerator(__instance);
generators.Add(((ReplayDynamic)rGenerator2).id, rGenerator2);
}
}
internal static Dictionary<int, rGenerator> generators = new Dictionary<int, rGenerator>();
[ReplayOnElevatorStop]
private static void Trigger()
{
int[] array = generators.Keys.ToArray();
foreach (int key in array)
{
if (generators.ContainsKey(key) && (Object)(object)generators[key].core == (Object)null)
{
generators.Remove(key);
}
}
Replay.Trigger((ReplayHeader)(object)new rGenerators());
foreach (rGenerator value in generators.Values)
{
LG_GenericCarryItemInteractionTarget val = ((Il2CppObjectBase)value.core.m_powerCellInteraction).TryCast<LG_GenericCarryItemInteractionTarget>();
if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled)
{
Replay.Spawn((ReplayDynamic)(object)value, true);
}
}
generators.Clear();
}
[ReplayInit]
private static void Init()
{
generators.Clear();
}
public override void Write(ByteBuffer buffer)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
BitHelper.WriteBytes((ushort)generators.Count, buffer);
foreach (rGenerator value in generators.Values)
{
BitHelper.WriteBytes(((ReplayDynamic)value).id, buffer);
BitHelper.WriteBytes(value.dimensionIndex, buffer);
BitHelper.WriteBytes(value.position, buffer);
BitHelper.WriteHalf(value.rotation, buffer);
BitHelper.WriteBytes(value.serialNumber, buffer);
}
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.Items", "0.0.1")]
internal class rItem : ReplayDynamic
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(LG_PickupItem_Sync), "Setup")]
[HarmonyPostfix]
private static void Postfix_Setup(LG_PickupItem_Sync __instance)
{
Replay.Spawn((ReplayDynamic)(object)new rItem(__instance), true);
}
}
public LG_PickupItem_Sync item;
private byte _dimensionIndex;
private Vector3 _position;
private Quaternion _rotation;
private bool _onGround;
private bool _linkedToMachine;
private byte _player = byte.MaxValue;
private ushort _serialNumber = ushort.MaxValue;
public override bool Active => (Object)(object)item != (Object)null;
public override bool IsDirty
{
get
{
//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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
if (dimensionIndex == _dimensionIndex && !(position != _position) && !(rotation != _rotation) && onGround == _onGround && linkedToMachine == _linkedToMachine)
{
return serialNumber != _serialNumber;
}
return true;
}
}
private byte dimensionIndex
{
get
{
//IL_000b: 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_0034: 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_002c: Unknown result type (might be due to invalid IL or missing references)
pPickupItemState state = item.m_stateReplicator.State;
AIG_CourseNode val = default(AIG_CourseNode);
if (((pCourseNode)(ref state.placement.node)).TryGet(ref val))
{
return (byte)val.m_dimension.DimensionIndex;
}
return (byte)Dimension.GetDimensionFromPos(position).DimensionIndex;
}
}
private Vector3 position => item.m_stateReplicator.State.placement.position;
private Quaternion rotation => item.m_stateReplicator.State.placement.rotation;
private bool onGround
{
get
{
//IL_000b: 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_0022: 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)
if ((int)item.m_stateReplicator.State.status != 0)
{
return item.m_stateReplicator.State.placement.droppedOnFloor;
}
return true;
}
}
private bool linkedToMachine => item.m_stateReplicator.State.placement.linkedToMachine;
private byte player
{
get
{
//IL_000b: 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)
pPickupItemState state = item.m_stateReplicator.State;
SNet_Player val = default(SNet_Player);
if (((pPlayer)(ref state.pPlayer)).TryGetPlayer(ref val))
{
return (byte)val.PlayerSlotIndex();
}
return byte.MaxValue;
}
}
private ushort serialNumber
{
get
{
CarryItemPickup_Core val = ((Il2CppObjectBase)item.item).TryCast<CarryItemPickup_Core>();
if ((Object)(object)val != (Object)null)
{
if (((Item)val).ItemDataBlock.addSerialNumberToName)
{
return (ushort)val.m_serialNumber;
}
return ushort.MaxValue;
}
ResourcePackPickup val2 = ((Il2CppObjectBase)item.item).TryCast<ResourcePackPickup>();
if ((Object)(object)val2 != (Object)null)
{
if (((Item)val2).ItemDataBlock.addSerialNumberToName)
{
return (ushort)val2.m_serialNumber;
}
return ushort.MaxValue;
}
GenericSmallPickupItem_Core val3 = ((Il2CppObjectBase)item.item).TryCast<GenericSmallPickupItem_Core>();
if ((Object)(object)val3 != (Object)null)
{
if (((Item)val3).ItemDataBlock.addSerialNumberToName)
{
return (ushort)val3.m_serialNumber1;
}
return ushort.MaxValue;
}
KeyItemPickup_Core val4 = ((Il2CppObjectBase)item.item).TryCast<KeyItemPickup_Core>();
if ((Object)(object)val4 != (Object)null && val4.m_keyItem != null)
{
if (((Item)val4).ItemDataBlock.addSerialNumberToName)
{
return (ushort)val4.m_keyItem.m_keyNum;
}
return ushort.MaxValue;
}
return ushort.MaxValue;
}
}
public rItem(LG_PickupItem_Sync item)
: base((int)item.m_stateReplicator.Replicator.Key)
{
this.item = item;
}
public override void Write(ByteBuffer buffer)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_001f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
_dimensionIndex = dimensionIndex;
_position = position;
_rotation = rotation;
_onGround = onGround;
_linkedToMachine = linkedToMachine;
_player = player;
_serialNumber = serialNumber;
BitHelper.WriteBytes(_dimensionIndex, buffer);
BitHelper.WriteBytes(_position, buffer);
BitHelper.WriteHalf(_rotation, buffer);
BitHelper.WriteBytes(_onGround, buffer);
BitHelper.WriteBytes(_linkedToMachine, buffer);
BitHelper.WriteBytes(_player, buffer);
BitHelper.WriteBytes(_serialNumber, buffer);
}
public override void Spawn(ByteBuffer buffer)
{
((ReplayDynamic)this).Write(buffer);
BitHelper.WriteBytes((BufferWriteable)(object)Identifier.From(item.item), buffer);
}
}
internal class rLadder
{
public readonly byte dimension;
public LG_Ladder ladder;
public Vector3 top => ladder.m_ladderTop;
public float height => ladder.m_height;
public Quaternion rotation => ((Component)ladder).gameObject.transform.rotation;
public rLadder(byte dimension, LG_Ladder ladder)
{
this.dimension = dimension;
this.ladder = ladder;
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.Ladders", "0.0.1")]
internal class rLadders : ReplayHeader
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(LG_BuildLadderAIGNodeJob), "Build")]
[HarmonyPostfix]
private static void Ladder_OnBuild(LG_BuildLadderAIGNodeJob __instance)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
LG_Ladder ladder = __instance.m_ladder;
if (!ladder.m_enemyClimbingOnly)
{
ladders.Add(new rLadder((byte)__instance.m_dimensionIndex, ladder));
}
}
}
internal static List<rLadder> ladders = new List<rLadder>();
[ReplayOnElevatorStop]
private static void Trigger()
{
rLadder[] array = ladders.ToArray();
ladders.Clear();
rLadder[] array2 = array;
foreach (rLadder rLadder2 in array2)
{
if ((Object)(object)rLadder2.ladder != (Object)null)
{
ladders.Add(rLadder2);
}
}
Replay.Trigger((ReplayHeader)(object)new rLadders());
}
[ReplayInit]
private static void Init()
{
ladders.Clear();
}
public override void Write(ByteBuffer buffer)
{
//IL_0032: 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)
BitHelper.WriteBytes((ushort)ladders.Count, buffer);
foreach (rLadder ladder in ladders)
{
BitHelper.WriteBytes(ladder.dimension, buffer);
BitHelper.WriteBytes(ladder.top, buffer);
BitHelper.WriteHalf(ladder.rotation, buffer);
BitHelper.WriteHalf(ladder.height, buffer);
}
ladders.Clear();
}
}
[ReplayData("Vanilla.Map.ResourceContainers.State", "0.0.1")]
internal class rContainer : ReplayDynamic
{
private LG_ResourceContainer_Storage container;
private LG_WeakResourceContainer core;
private LG_ResourceContainer_Sync sync;
public bool registered = true;
public Identifier consumableType = Identifier.unknown;
public eWeakLockType assignedLock;
public bool isLocker;
public byte dimension;
public Vector3 position;
public Quaternion rotation;
private bool _closed = true;
public ushort serialNumber => (ushort)core.m_serialNumber;
public override bool Active => (Object)(object)core != (Object)null;
public override bool IsDirty => _closed != closed;
private bool closed => (int)sync.m_stateReplicator.State.status != 3;
private bool weaklock
{
get
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Invalid comparison between Unknown and I4
if ((Object)(object)core.m_weakLock != (Object)null)
{
return (int)core.m_weakLock.Status == 0;
}
return false;
}
}
private bool hacklock
{
get
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Invalid comparison between Unknown and I4
if ((Object)(object)core.m_weakLock != (Object)null)
{
return (int)core.m_weakLock.Status == 1;
}
return false;
}
}
public rContainer(LG_ResourceContainer_Storage container, bool isLocker, byte dimension)
: base(((Object)container).GetInstanceID())
{
//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_0079: 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)
this.container = container;
this.isLocker = isLocker;
this.dimension = dimension;
core = ((Il2CppObjectBase)container.m_core).Cast<LG_WeakResourceContainer>();
sync = ((Il2CppObjectBase)core.m_sync).Cast<LG_ResourceContainer_Sync>();
position = ((Component)container).transform.position;
rotation = ((Component)container).transform.rotation;
}
public override void Write(ByteBuffer buffer)
{
_closed = closed;
BitHelper.WriteBytes(_closed, buffer);
}
public override void Spawn(ByteBuffer buffer)
{
//IL_0008: 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_0027: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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_0032: Invalid comparison between Unknown and I4
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
((ReplayDynamic)this).Write(buffer);
eWeakLockType val = (eWeakLockType)0;
if ((Object)(object)core.m_weakLock != (Object)null)
{
eWeakLockStatus status = core.m_weakLock.Status;
if ((int)status != 0)
{
if ((int)status == 1)
{
val = (eWeakLockType)2;
}
}
else
{
val = (eWeakLockType)1;
}
}
BitHelper.WriteBytes((byte)val, buffer);
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.ResourceContainers", "0.0.3")]
internal class rContainers : ReplayHeader
{
[HarmonyPatch]
private static class Patches
{
private static bool patched;
private static void SetupContainer(AIG_CourseNode node, rContainer container)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
container.dimension = (byte)node.m_dimension.DimensionIndex;
}
[HarmonyPatch(typeof(GameDataInit), "Initialize")]
[HarmonyPostfix]
private static void Patch_LG_ResourceContainerBuilder()
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
if (!patched)
{
patched = true;
rMetadata.NoArtifact_Compatibility = true;
MethodInfo method = typeof(LG_ResourceContainerBuilder).GetMethod("SetupFunctionGO");
if (method == null)
{
APILogger.Error("[Patch_LG_ResourceContainerBuilder] Failed to patch - Method 'LG_ResourceContainerBuilder.SetupFunctionGO' was not found.");
return;
}
if (GameDataBlockBase<ArtifactDataBlock>.Wrapper.Blocks.Count == 0)
{
APILogger.Warn("Debug resource containers will be disabled - missing 'GameData_ArtifactDatablock_bin.json'");
return;
}
rMetadata.NoArtifact_Compatibility = false;
Plugin.harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(Patches).GetMethod("Postfix_LG_ResourceContainerBuilder_OnBuild", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
private static void Postfix_LG_ResourceContainerBuilder_OnBuild(LG_ResourceContainerBuilder __instance, LG_LayerType layer, GameObject GO)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_006d: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
if ((int)((LG_FunctionMarkerBuilder)__instance).m_function != 10)
{
return;
}
LG_WeakResourceContainer componentInChildren = GO.GetComponentInChildren<LG_WeakResourceContainer>();
if ((Object)(object)componentInChildren == (Object)null)
{
return;
}
LG_ResourceContainer_Storage val = ((Il2CppObjectBase)componentInChildren.m_storage).Cast<LG_ResourceContainer_Storage>();
int instanceID = ((Object)val).GetInstanceID();
if (!containers.ContainsKey(instanceID))
{
containers.Add(instanceID, new rContainer(val, isLocker: false, 0));
}
rContainer rContainer2 = containers[instanceID];
rContainer2.assignedLock = (eWeakLockType)((!(__instance.m_lockRandom < 0.5f)) ? 1 : 2);
ConsumableDistributionDataBlock block = GameDataBlockBase<ConsumableDistributionDataBlock>.GetBlock(((LG_FunctionMarkerBuilder)__instance).m_node.m_zone.m_settings.m_zoneData.ConsumableDistributionInZone);
if (block != null)
{
State state = Random.state;
Random.InitState(__instance.m_randomSeed);
float[] array = new float[block.SpawnData.Count];
for (int i = 0; i < block.SpawnData.Count; i++)
{
array[i] = block.SpawnData[i].Weight;
}
BuilderWeightedRandom val2 = new BuilderWeightedRandom();
val2.Setup(Il2CppStructArray<float>.op_Implicit(array));
rContainer2.consumableType = Identifier.Item(block.SpawnData[val2.GetRandomIndex(Random.value)].ItemID);
Random.state = state;
}
}
[HarmonyPatch(typeof(AIG_CourseNode), "RegisterContainer")]
[HarmonyPostfix]
private static void ResourceContainer_Add(AIG_CourseNode __instance, LG_ResourceContainer_Storage container)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
int instanceID = ((Object)container).GetInstanceID();
if (!containers.ContainsKey(instanceID))
{
containers.Add(instanceID, new rContainer(container, isLocker: false, (byte)__instance.m_dimension.DimensionIndex));
}
SetupContainer(__instance, containers[instanceID]);
}
[HarmonyPatch(typeof(AIG_CourseNode), "UnregisterContainer")]
[HarmonyPostfix]
private static void ResourceContainer_Remove(AIG_CourseNode __instance, LG_ResourceContainer_Storage container)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
int instanceID = ((Object)container).GetInstanceID();
if (!containers.ContainsKey(instanceID))
{
containers.Add(instanceID, new rContainer(container, isLocker: false, (byte)__instance.m_dimension.DimensionIndex));
}
SetupContainer(__instance, containers[instanceID]);
containers[instanceID].registered = false;
}
[HarmonyPatch(typeof(LG_ResourceContainer_Storage), "Setup")]
[HarmonyPostfix]
private static void Resource_Setup(LG_ResourceContainer_Storage __instance, iLG_ResourceContainer_Core core, bool isLocker)
{
int instanceID = ((Object)__instance).GetInstanceID();
if (!containers.ContainsKey(instanceID))
{
containers.Add(instanceID, new rContainer(__instance, isLocker: false, 0));
}
containers[instanceID].isLocker = isLocker;
}
}
internal static Dictionary<int, rContainer> containers = new Dictionary<int, rContainer>();
[ReplayOnElevatorStop]
private static void Trigger()
{
Replay.Trigger((ReplayHeader)(object)new rContainers());
foreach (rContainer value in containers.Values)
{
Replay.Spawn((ReplayDynamic)(object)value, true);
}
containers.Clear();
}
[ReplayInit]
private static void Init()
{
containers.Clear();
}
public override void Write(ByteBuffer buffer)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
BitHelper.WriteBytes((ushort)containers.Count, buffer);
foreach (rContainer value in containers.Values)
{
BitHelper.WriteBytes(((ReplayDynamic)value).id, buffer);
BitHelper.WriteBytes(value.dimension, buffer);
BitHelper.WriteBytes(value.position, buffer);
BitHelper.WriteHalf(value.rotation, buffer);
BitHelper.WriteBytes(value.serialNumber, buffer);
BitHelper.WriteBytes(value.isLocker, buffer);
BitHelper.WriteBytes((BufferWriteable)(object)value.consumableType, buffer);
BitHelper.WriteBytes(value.registered, buffer);
BitHelper.WriteBytes((byte)value.assignedLock, buffer);
}
}
}
internal class rTerminal
{
public readonly byte dimension;
public readonly int id;
public readonly ushort serialNumber;
public LG_ComputerTerminal terminal;
public Vector3 position => ((Component)terminal).transform.position;
public Quaternion rotation => ((Component)terminal).transform.rotation;
public rTerminal(byte dimension, LG_ComputerTerminal terminal)
{
id = ((Object)terminal).GetInstanceID();
this.dimension = dimension;
this.terminal = terminal;
serialNumber = (ushort)terminal.m_serialNumber;
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Map.Terminals", "0.0.2")]
internal class rTerminals : ReplayHeader
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(LG_ComputerTerminal), "Setup")]
[HarmonyPostfix]
private static void Terminal_Setup(LG_ComputerTerminal __instance)
{
//IL_0056: 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_0033: Unknown result type (might be due to invalid IL or missing references)
int instanceID = ((Object)__instance).GetInstanceID();
if (!terminals.ContainsKey(instanceID))
{
if (__instance.SpawnNode == null)
{
terminals.Add(instanceID, new rTerminal((byte)Dimension.GetDimensionFromPos(((Component)__instance).transform.position).DimensionIndex, __instance));
}
else
{
terminals.Add(instanceID, new rTerminal((byte)__instance.SpawnNode.m_dimension.DimensionIndex, __instance));
}
}
}
}
internal static Dictionary<int, rTerminal> terminals = new Dictionary<int, rTerminal>();
[ReplayOnElevatorStop]
private static void Trigger()
{
int[] array = terminals.Keys.ToArray();
foreach (int key in array)
{
if (terminals.ContainsKey(key) && (Object)(object)terminals[key].terminal == (Object)null)
{
terminals.Remove(key);
}
}
Replay.Trigger((ReplayHeader)(object)new rTerminals());
}
[ReplayInit]
private static void Init()
{
terminals.Clear();
}
public override void Write(ByteBuffer buffer)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
BitHelper.WriteBytes((ushort)terminals.Count, buffer);
foreach (rTerminal value in terminals.Values)
{
BitHelper.WriteBytes(value.id, buffer);
BitHelper.WriteBytes(value.dimension, buffer);
BitHelper.WriteBytes(value.position, buffer);
BitHelper.WriteHalf(value.rotation, buffer);
BitHelper.WriteBytes(value.serialNumber, buffer);
}
terminals.Clear();
}
}
}
namespace Vanilla.Sentries
{
internal struct SentryTransform : IReplayTransform
{
private SentryGunInstance sentry;
public bool active => (Object)(object)sentry != (Object)null;
public byte dimensionIndex => (byte)sentry.CourseNode.m_dimension.DimensionIndex;
public Vector3 position => ((Component)sentry).transform.position;
public Quaternion rotation
{
get
{
//IL_0033: 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_0022: Unknown result type (might be due to invalid IL or missing references)
if (sentry.m_firing != null)
{
return Quaternion.LookRotation(sentry.m_firing.MuzzleAlign.forward);
}
return ((Component)sentry).transform.rotation;
}
}
public SentryTransform(SentryGunInstance sentry)
{
this.sentry = sentry;
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Sentry", "0.0.2")]
public class rSentry : DynamicRotation
{
[HarmonyPatch]
private static class Patches
{
[HarmonyPatch(typeof(SentryGunInstance), "OnSpawn")]
[HarmonyPostfix]
private static void Postfix_OnSpawn(SentryGunInstance __instance, pGearSpawnData spawnData)
{
Replay.Spawn((ReplayDynamic)(object)new rSentry(__instance), true);
}
[HarmonyPatch(typeof(SentryGunInstance), "OnDespawn")]
[HarmonyPostfix]
private static void Postfix_OnDespawn(SentryGunInstance __instance)
{
Replay.Despawn((ReplayDynamic)(object)Replay.Get<rSentry>(((Object)__instance).GetInstanceID()), true);
}
}
private SentryGunInstance sentry;
private Vector3 spawnPosition;
private byte spawnDimension;
public rSentry(SentryGunInstance sentry)
: base(((Object)sentry).GetInstanceID(), (IReplayTransform)(object)new SentryTransform(sentry))
{
//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)
this.sentry = sentry;
spawnPosition = base.transform.position;
spawnDimension = base.transform.dimensionIndex;
}
public override void Spawn(ByteBuffer buffer)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
BitHelper.WriteBytes(spawnDimension, buffer);
BitHelper.WriteBytes(spawnPosition, buffer);
((DynamicRotation)this).Spawn(buffer);
if ((Object)(object)((Item)sentry).Owner != (Object)null)
{
BitHelper.WriteBytes(true, buffer);
BitHelper.WriteBytes(((Agent)((Item)sentry).Owner).GlobalID, buffer);
}
else
{
BitHelper.WriteBytes(false, buffer);
}
}
}
}
namespace Vanilla.Player
{
internal static class PlayerManager
{
[ReplayOnPlayerSpawn]
private static void Spawn(PlayerAgent agent)
{
Replay.Spawn((ReplayDynamic)(object)new rPlayer(agent), true);
PlayerBoosterImplantState val = default(PlayerBoosterImplantState);
if (BoosterImplantManager.TryGetPlayerBoosterImplantState(agent.Owner, ref val) && val != null)
{
Replay.Spawn((ReplayDynamic)(object)new rPlayerBoosters(agent, val), true);
}
Replay.Spawn((ReplayDynamic)(object)new rPlayerAnimation(agent), true);
Replay.Spawn((ReplayDynamic)(object)new rPlayerBackpack(agent), true);
Replay.Spawn((ReplayDynamic)(object)new rPlayerStats(agent), true);
}
[ReplayOnPlayerDespawn]
private static void Despawn(int id)
{
Replay.TryDespawn<rPlayerBoosters>(id);
Replay.TryDespawn<rPlayerAnimation>(id);
Replay.TryDespawn<rPlayerBackpack>(id);
Replay.TryDespawn<rPlayerStats>(id);
Replay.TryDespawn<rPlayer>(id);
}
}
[ReplayData("Vanilla.Player", "0.0.2")]
public class rPlayer : DynamicTransform
{
public PlayerAgent agent;
private Identifier lastEquipped = Identifier.unknown;
private bool flashlightEnabled;
private float flashlightRange = 1000f;
private Identifier equipped => Identifier.From(agent.Inventory.WieldedItem);
private bool _flashlightEnabled
{
get
{
if (!((Object)(object)agent.Inventory != (Object)null))
{
return false;
}
return agent.Inventory.FlashlightEnabled;
}
}
private float _flashlightRange
{
get
{
if (!((Object)(object)agent.Inventory != (Object)null) || !agent.Inventory.FlashlightEnabled)
{
return 1000f;
}
return agent.Inventory.m_flashlight.range;
}
}
public override bool Active
{
get
{
if ((Object)(object)agent != (Object)null)
{
return (Object)(object)agent.Owner != (Object)null;
}
return false;
}
}
public override bool IsDirty
{
get
{
if (!((DynamicTransform)this).IsDirty && !(equipped != lastEquipped) && flashlightEnabled == _flashlightEnabled)
{
return flashlightRange != _flashlightRange;
}
return true;
}
}
public rPlayer(PlayerAgent player)
: base((int)((Agent)player).GlobalID, (IReplayTransform)(object)new AgentTransform((Agent)(object)player))
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
agent = player;
}
public override void Write(ByteBuffer buffer)
{
flashlightEnabled = _flashlightEnabled;
flashlightRange = _flashlightRange;
((DynamicTransform)this).Write(buffer);
BitHelper.WriteBytes((BufferWriteable)(object)equipped, buffer);
BitHelper.WriteBytes(flashlightEnabled, buffer);
BitHelper.WriteHalf(flashlightRange, buffer);
lastEquipped = equipped;
}
public override void Spawn(ByteBuffer buffer)
{
((DynamicTransform)this).Spawn(buffer);
BitHelper.WriteBytes(agent.Owner.Lookup, buffer);
BitHelper.WriteBytes((byte)agent.PlayerSlotIndex, buffer);
BitHelper.WriteBytes(agent.Owner.NickName, buffer);
}
}
[ReplayData("Vanilla.Player.Animation.MeleeSwing", "0.0.1")]
public class rMeleeSwing : Id
{
private bool charged;
public rMeleeSwing(PlayerAgent player, bool charged = false)
: base((int)((Agent)player).GlobalID)
{
this.charged = charged;
}
public override void Write(ByteBuffer buffer)
{
((Id)this).Write(buffer);
BitHelper.WriteBytes(charged, buffer);
}
}
[ReplayData("Vanilla.Player.Animation.MeleeShove", "0.0.1")]
public class rMeleeShove : Id
{
public rMeleeShove(PlayerAgent player)
: base((int)((Agent)player).GlobalID)
{
}
}
[ReplayData("Vanilla.Player.Animation.ConsumableThrow", "0.0.1")]
public class rConsumableThrow : Id
{
public rConsumableThrow(PlayerAgent player)
: base((int)((Agent)player).GlobalID)
{
}
}
[ReplayData("Vanilla.Player.Animation.Revive", "0.0.1")]
public class rRevive : Id
{
public rRevive(PlayerAgent player)
: base((int)((Agent)player).GlobalID)
{
}
}
[ReplayData("Vanilla.Player.Animation.Downed", "0.0.1")]
public class rDowned : Id
{
public rDowned(PlayerAgent player)
: base((int)((Agent)player).GlobalID)
{
}
}
[HarmonyPatch]
[ReplayData("Vanilla.Player.Animation", "0.0.1")]
public class rPlayerAnimation : ReplayDynamic
{
[HarmonyPatch]
private static class Patches
{
private static bool swingTrigger;
private static void Trigger(Id e)
{
if (Replay.Has<rPlayerAnimation>(e.id))
{
Replay.Trigger((ReplayEvent)(object)e);
}
}
[HarmonyPatch(typeof(PLOC_Downed), "OnPlayerRevived")]
[HarmonyPrefix]
private static void Prefix_OnPlayerRevived(PLOC_Downed __instance)
{
Trigger((Id)(object)new rRevive(((PLOC_Base)__instance).m_owner));
}
[HarmonyPatch(typeof(PLOC_Downed), "CommonEnter")]
[HarmonyPrefix]
private static void Prefix_CommonEnter(PLOC_Downed __instance)
{
Trigger((Id)(object)new rDowned(((PLOC_Base)__instance).m_owner));
}
[HarmonyPatch(typeof(PlayerSync), "SendThrowStatus")]
[HarmonyPrefix]
private static void Prefix_SendThrowStatus(PlayerSync __instance, StatusEnum status, bool applyLocally)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (!applyLocally)
{
HandleThrowState(__instance.m_agent, status);
}
}
[HarmonyPatch(typeof(PlayerInventorySynced), "SyncThrowState")]
[HarmonyPrefix]
private static void Prefix_SyncThrowState(PlayerInventorySynced __instance, StatusEnum status)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
HandleThrowState(((PlayerInventoryBase)__instance).Owner, status);
}
private static void HandleThrowState(PlayerAgent player, StatusEnum status)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
rPlayerAnimation rPlayerAnimation2 = default(rPlayerAnimation);
if (!Replay.TryGet<rPlayerAnimation>((int)((Agent)player).GlobalID, ref rPlayerAnimation2))
{
return;
}
rPlayerAnimation rPlayerAnimation3 = rPlayerAnimation2;
if ((int)status != 1)
{
if ((int)status == 2)
{
rPlayerAnimation3._chargingThrow = false;
Trigger((Id)(object)new rConsumableThrow(player));
}
}
else
{
rPlayerAnimation3._chargingThrow = true;
}
}
[HarmonyPatch(typeof(MWS_ChargeUp), "Enter")]
[HarmonyPostfix]
private static void Postfix_MWS_ChargeUp(MWS_ChargeUp __instance)
{
rPlayerAnimation rPlayerAnimation2 = default(rPlayerAnimation);
i
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using System.Text.Json.Serialization;
using API;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using DanosStatTracker.BepInEx;
using DanosStatTracker.Data;
using GTFOStats.Data;
using GameData;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ReplayRecorder;
using ReplayRecorder.API.Attributes;
using SNetwork;
using UnityEngine.Analytics;
using Vanilla.Enemy;
using Vanilla.Player;
using Vanilla.StatTracker;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ReplayRecorder.DanosStatTracker")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9035a0255be990ba69c42e16e6e36c6d96205159")]
[assembly: AssemblyProduct("ReplayRecorder.DanosStatTracker")]
[assembly: AssemblyTitle("ReplayRecorder.DanosStatTracker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace API
{
[HarmonyPatch(typeof(GameDataInit))]
internal class GameDataInit_Patches
{
[HarmonyPatch("Initialize")]
[HarmonyWrapSafe]
[HarmonyPostfix]
public static void Initialize_Postfix()
{
Analytics.enabled = false;
}
}
internal static class APILogger
{
private static readonly ManualLogSource logger;
static APILogger()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
logger = new ManualLogSource("Rand-API");
Logger.Sources.Add((ILogSource)(object)logger);
}
private static string Format(string module, object msg)
{
return $"[{module}]: {msg}";
}
public static void Info(string module, object data)
{
logger.LogMessage((object)Format(module, data));
}
public static void Verbose(string module, object data)
{
}
public static void Log(object data)
{
logger.LogDebug((object)Format("ReplayRecorder.DanosStatTracker", data));
}
public static void Debug(object data)
{
if (ConfigManager.Debug)
{
Log(data);
}
}
public static void Warn(object data)
{
logger.LogWarning((object)Format("ReplayRecorder.DanosStatTracker", data));
}
public static void Error(object data)
{
logger.LogError((object)Format("ReplayRecorder.DanosStatTracker", data));
}
}
}
namespace DanosStatTracker.BepInEx
{
public static class Module
{
public const string GUID = "randomuserhi.ReplayRecorder.DanosStatTracker";
public const string Name = "ReplayRecorder.DanosStatTracker";
public const string Version = "0.0.1";
}
public static class ConfigManager
{
public static ConfigFile configFile;
private static ConfigEntry<bool> debug;
private static ConfigEntry<bool> enable;
public static bool Debug
{
get
{
return debug.Value;
}
set
{
debug.Value = value;
}
}
public static bool Enable
{
get
{
return enable.Value;
}
set
{
enable.Value = value;
}
}
static ConfigManager()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "ReplayRecorder.DanosStatTracker.cfg"), true);
debug = configFile.Bind<bool>("Debug", "enable", false, "Enables debug messages when true.");
enable = configFile.Bind<bool>("Settings", "enable", true, "When true, sends data to DanosStatTracker service: https://thunderstore.io/c/gtfo/p/Danos/GTFOStats/.");
}
}
[BepInPlugin("randomuserhi.ReplayRecorder.DanosStatTracker", "ReplayRecorder.DanosStatTracker", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private static bool isMaster;
private static Harmony? harmony;
public override void Load()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
APILogger.Log("Plugin is loaded!");
harmony = new Harmony("randomuserhi.ReplayRecorder.DanosStatTracker");
harmony.PatchAll();
APILogger.Log("Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
if (ConfigManager.Enable && ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("danos.GTFOStats", out var _))
{
APILogger.Debug("Danos-GTFOStats is installed, GTFOReplay will provide additional data.");
Register();
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void Register()
{
DanosStaticStore.RegisterJsonContributor((Func<string>)GenerateReplayJson);
Replay.RegisterAll();
}
[ReplayOnElevatorStop]
private static void OnElevatorStop()
{
DanosStaticStore.currentRunDownDataStore = new DanosRunDownDataStore
{
replayData =
{
isMaster = SNet.IsMaster
}
};
APILogger.Debug("DanosStaticStore Created.");
}
private static string GenerateReplayJson()
{
try
{
if (DanosStaticStore.currentRunDownDataStore == null)
{
APILogger.Error("Unable to generate Danos JSON, datastore was null.");
return string.Empty;
}
JsonSerializerOptions options = new JsonSerializerOptions
{
WriteIndented = true,
Converters = { (JsonConverter)new OneDecimalJsonConverter() }
};
if (!DanosStaticStore.currentRunDownDataStore.replayData.isMaster)
{
DanosStaticStore.currentRunDownDataStore.replayData.masterStats = null;
}
return JsonSerializer.Serialize(DanosStaticStore.currentRunDownDataStore, options);
}
catch (Exception ex)
{
APILogger.Error("Error generating replay data JSON: " + ex.Message);
return string.Empty;
}
}
}
}
namespace DanosStatTracker.Hooks
{
internal class Stats
{
[ReplaySpawnHook(typeof(rPlayer))]
private static void OnPlayerSpawn(long timestamp, rPlayer player)
{
if (DanosStaticStore.currentRunDownDataStore != null)
{
DanosStaticStore.currentRunDownDataStore.replayData.masterStats.GetPlayerStats((long)player.agent.Owner.Lookup);
}
}
[ReplayHook(typeof(rDamage), true)]
private static void DamageHook(long timestamp, rDamage e)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Expected I4, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Invalid comparison between Unknown and I4
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected I4, but got Unknown
rPlayer val = default(rPlayer);
if (DanosStaticStore.currentRunDownDataStore == null || !SNet.IsMaster || !Replay.TryGet<rPlayer>(e.source, ref val))
{
return;
}
ReplayModSummaryData playerStats = DanosStaticStore.currentRunDownDataStore.replayData.masterStats.GetPlayerStats((long)val.agent.Owner.Lookup);
rPlayer val2 = default(rPlayer);
if (Replay.TryGet<rPlayer>((int)e.target, ref val2))
{
if (e.sentry)
{
playerStats.playerSentryDamage += e.damage;
return;
}
Type type = e.type;
if ((int)type != 0)
{
if ((int)type == 1)
{
playerStats.playerExplosiveDamage += e.damage;
}
}
else
{
playerStats.playerBulletDamage += e.damage;
}
}
else
{
rEnemy val3 = default(rEnemy);
if (!Replay.TryGet<rEnemy>((int)e.target, ref val3))
{
return;
}
if (e.sentry)
{
playerStats.sentryDamage += e.damage;
playerStats.sentryStaggerDamage += e.staggerDamage;
return;
}
Type type = e.type;
switch ((int)type)
{
case 0:
playerStats.bulletDamage += e.damage;
break;
case 2:
playerStats.meleeDamage += e.damage;
break;
case 1:
playerStats.explosiveDamage += e.damage;
break;
}
playerStats.staggerDamage += e.staggerDamage;
if (!(((Dam_SyncedDamageBase)val3.agent.Damage).Health <= e.damage))
{
return;
}
type = e.type;
switch ((int)type)
{
case 0:
if (e.sentry)
{
playerStats.sentryKills++;
}
else
{
playerStats.kills++;
}
break;
case 2:
playerStats.kills++;
break;
case 1:
playerStats.mineKills++;
break;
}
}
}
}
}
namespace DanosStatTracker.Data
{
public class DanosStaticStore
{
public static DanosRunDownDataStore? currentRunDownDataStore { get; set; }
}
public class DanosRunDownDataStore
{
public bool fromReplayMod { get; set; } = true;
public ReplayData replayData { get; set; } = new ReplayData();
}
public class ReplayData
{
public bool isMaster { get; set; }
public ReplayModMasterData masterStats { get; set; } = new ReplayModMasterData();
}
public class ReplayModMasterData
{
public Dictionary<long, ReplayModSummaryData> playerStats { get; set; } = new Dictionary<long, ReplayModSummaryData>();
public ReplayModSummaryData GetPlayerStats(long sid)
{
if (!playerStats.ContainsKey(sid))
{
playerStats.Add(sid, new ReplayModSummaryData());
}
return playerStats[sid];
}
}
public class ReplayModSummaryData
{
[JsonConverter(typeof(OneDecimalJsonConverter))]
public float bulletDamage { get; set; }
[JsonConverter(typeof(OneDecimalJsonConverter))]
public float meleeDamage { get; set; }
[JsonConverter(typeof(OneDecimalJsonConverter))]
public float sentryDamage { get; set; }
[JsonConverter(typeof(OneDecimalJsonConverter))]
public float explosiveDamage { get; set; }
[JsonConverter(typeof(OneDecimalJsonConverter))]
public float staggerDamage { get; set; }
[JsonConverter(typeof(OneDecimalJsonConverter))]
public float sentryStaggerDamage { get; set; }
[JsonConverter(typeof(OneDecimalJsonConverter))]
public float playerBulletDamage { get; set; }
[JsonConverter(typeof(OneDecimalJsonConverter))]
public float playerSentryDamage { get; set; }
[JsonConverter(typeof(OneDecimalJsonConverter))]
public float playerExplosiveDamage { get; set; }
public int kills { get; set; }
public int mineKills { get; set; }
public int sentryKills { get; set; }
}
public class OneDecimalJsonConverter : JsonConverter<float>
{
public override float Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return (float)reader.GetDouble();
}
public override void Write(Utf8JsonWriter writer, float value, JsonSerializerOptions options)
{
writer.WriteNumberValue(Math.Round(value, 1));
}
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using API;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using EWC.API;
using EWC.CustomWeapon;
using EWC.CustomWeapon.Enums;
using EWC.CustomWeapon.Properties;
using EWC.CustomWeapon.Properties.Effects;
using EWC.CustomWeapon.Properties.Traits.CustomProjectile.Components;
using EWC.Utils;
using Enemies;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using ReplayRecorder.API;
using ReplayRecorder.API.Attributes;
using ReplayRecorder.Core;
using ReplayRecorder.EWC.BepInEx;
using SNetwork;
using UnityEngine;
using UnityEngine.Analytics;
using Vanilla;
using Vanilla.Events;
using Vanilla.StatTracker;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ReplayRecorder.ExtraWeaponCustomization")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+702170e7f1f13543485a9772e2d5d92bde30f323")]
[assembly: AssemblyProduct("ReplayRecorder.ExtraWeaponCustomization")]
[assembly: AssemblyTitle("ReplayRecorder.ExtraWeaponCustomization")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace API
{
[HarmonyPatch(typeof(GameDataInit))]
internal class GameDataInit_Patches
{
[HarmonyPatch("Initialize")]
[HarmonyWrapSafe]
[HarmonyPostfix]
public static void Initialize_Postfix()
{
Analytics.enabled = false;
}
}
internal static class APILogger
{
private static readonly ManualLogSource logger;
static APILogger()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
logger = new ManualLogSource("Rand-API");
Logger.Sources.Add((ILogSource)(object)logger);
}
private static string Format(string module, object msg)
{
return $"[{module}]: {msg}";
}
public static void Info(string module, object data)
{
logger.LogMessage((object)Format(module, data));
}
public static void Verbose(string module, object data)
{
}
public static void Log(object data)
{
logger.LogDebug((object)Format("ReplayRecorder.EWC", data));
}
public static void Debug(object data)
{
if (ConfigManager.Debug)
{
Log(data);
}
}
public static void Warn(object data)
{
logger.LogWarning((object)Format("ReplayRecorder.EWC", data));
}
public static void Error(object data)
{
logger.LogError((object)Format("ReplayRecorder.EWC", data));
}
}
}
namespace ReplayRecorder.EWC
{
[ReplayData("EWC.Damage", "0.0.2")]
internal class rEWCDamage : ReplayEvent
{
internal static class Hooks
{
public static void Shrapnel(float damage, EnemyAgent enemy, Dam_EnemyDamageLimb limb, PlayerAgent? player, OwnerType ownerType)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)player == (Object)null))
{
Sync.Trigger(new rEWCDamage(Type.Shrapnel, damage, (Agent)(object)player, (Agent)(object)enemy, ((Enum)ownerType).HasFlag((Enum)(object)(OwnerType)8)));
}
}
public static void Explosive(float damage, EnemyAgent enemy, Dam_EnemyDamageLimb limb, PlayerAgent? player, OwnerType ownerType)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)player == (Object)null))
{
Sync.Trigger(new rEWCDamage(Type.Explosive, damage, (Agent)(object)player, (Agent)(object)enemy, ((Enum)ownerType).HasFlag((Enum)(object)(OwnerType)8)));
}
}
public static void DoT(float damage, EnemyAgent enemy, Dam_EnemyDamageLimb limb, PlayerAgent? player, OwnerType ownerType)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)player == (Object)null))
{
Sync.Trigger(new rEWCDamage(Type.DoT, damage, (Agent)(object)player, (Agent)(object)enemy, ((Enum)ownerType).HasFlag((Enum)(object)(OwnerType)8)));
}
}
}
public enum Type
{
Explosive,
DoT,
Shrapnel
}
private static class Sync
{
private const string eventName = "EWC.Damage";
private static ByteBuffer packet = new ByteBuffer();
[ReplayPluginLoad]
private static void Load()
{
RNet.Register("EWC.Damage", (Action<ulong, ArraySegment<byte>>)OnReceive);
}
public static void Trigger(rEWCDamage damage)
{
Replay.Trigger((ReplayEvent)(object)damage);
ByteBuffer val = packet;
val.Clear();
BitHelper.WriteBytes((byte)damage.type, val);
BitHelper.WriteBytes(damage.source, val);
BitHelper.WriteBytes(damage.target, val);
BitHelper.WriteHalf(damage.damage, val);
BitHelper.WriteBytes(damage.isSentry, val);
RNet.Trigger("EWC.Damage", val);
}
private static void OnReceive(ulong sender, ArraySegment<byte> packet)
{
int num = 0;
byte type = BitHelper.ReadByte(packet, ref num);
ushort source = BitHelper.ReadUShort(packet, ref num);
ushort target = BitHelper.ReadUShort(packet, ref num);
float damage = BitHelper.ReadHalf(packet, ref num);
bool isSentry = BitHelper.ReadBool(packet, ref num);
Replay.Trigger((ReplayEvent)(object)new rEWCDamage((Type)type, damage, source, target, isSentry));
}
}
private Type type;
private float damage;
private ushort source;
private ushort target;
private bool isSentry;
public rEWCDamage(Type type, float damage, ushort source, ushort target, bool isSentry)
{
this.type = type;
this.damage = damage;
this.source = source;
this.target = target;
this.isSentry = isSentry;
}
public rEWCDamage(Type type, float damage, Agent source, Agent target, bool isSentry)
{
this.type = type;
this.damage = damage;
this.source = source.GlobalID;
this.target = target.GlobalID;
this.isSentry = isSentry;
}
public override void Write(ByteBuffer buffer)
{
BitHelper.WriteBytes((byte)type, buffer);
BitHelper.WriteBytes(source, buffer);
BitHelper.WriteBytes(target, buffer);
BitHelper.WriteHalf(damage, buffer);
BitHelper.WriteBytes(isSentry, buffer);
}
}
[ReplayData("EWC.Explosion", "0.0.1")]
internal class rEWCExplosion : ReplayEvent
{
internal static class Hooks
{
public static void Trigger(Vector3 position, Explosive explosion)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
Replay.Trigger((ReplayEvent)(object)new rEWCExplosion(position, explosion));
}
}
private Vector3 position;
private Explosive explosion;
public rEWCExplosion(Vector3 position, Explosive explosion)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
this.position = position;
this.explosion = explosion;
}
public override void Write(ByteBuffer buffer)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
BitHelper.WriteBytes(position, buffer);
BitHelper.WriteHalf(explosion.InnerRadius, buffer);
BitHelper.WriteHalf(explosion.Radius, buffer);
}
}
internal class rEWCGunShot
{
internal static class Hooks
{
public static void Trigger(HitData hit, Vector3 start, Vector3 end, WeaponType weaponType)
{
//IL_000c: 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_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
Replay.Trigger((ReplayEvent)new rGunshot(hit.owner, hit.damage, start, end, ((Enum)weaponType).HasFlag((Enum)(object)(WeaponType)16), false, true));
}
}
}
[HarmonyPatch]
internal static class EWCAccuracy
{
private class BulletInfo
{
public int hits;
public int crits;
}
private static Dictionary<ushort, BulletInfo> projectiles = new Dictionary<ushort, BulletInfo>();
private static Identifier currentWeapon = Identifier.unknown;
private static PlayerAgent? currentPlayer = null;
private static BulletInfo currentBullet = new BulletInfo();
[ReplayInit]
private static void Init()
{
projectiles.Clear();
}
public static void OnProjectileDespawn(EWCProjectileComponentBase projectile)
{
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Expected O, but got Unknown
if (projectile.IsManaged)
{
if (!projectiles.ContainsKey(projectile.SyncID))
{
projectiles.Add(projectile.SyncID, new BulletInfo());
}
BulletInfo bulletInfo = projectiles[projectile.SyncID];
if (bulletInfo.hits > 255 || bulletInfo.crits > 255)
{
APILogger.Warn($"Number of enemies hit / crit for this bullet exceeded maximum value of {255}.");
}
Sync.Trigger(new rGunshotInfo(((WeaponPropertyBase)projectile.Settings).CWC.Owner.Player, Identifier.From(((WeaponPropertyBase)projectile.Settings).CWC.Weapon.Component), (byte)bulletInfo.hits, (byte)bulletInfo.crits));
projectiles.Remove(projectile.SyncID);
}
}
public static void OnProjectileHit(EWCProjectileComponentBase projectile, IDamageable? damageable)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Invalid comparison between Unknown and I4
if (!projectile.IsManaged || damageable == null)
{
return;
}
if (!projectiles.ContainsKey(projectile.SyncID))
{
projectiles.Add(projectile.SyncID, new BulletInfo());
}
BulletInfo bulletInfo = projectiles[projectile.SyncID];
Dam_EnemyDamageLimb val = ((Il2CppObjectBase)damageable).TryCast<Dam_EnemyDamageLimb>();
if ((Object)(object)val != (Object)null)
{
bulletInfo.hits++;
if ((int)val.m_type == 1)
{
bulletInfo.crits++;
}
return;
}
if ((Object)(object)((Il2CppObjectBase)damageable).TryCast<Dam_PlayerDamageLimb>() != (Object)null)
{
bulletInfo.hits++;
return;
}
LG_WeakLockDamage val2 = ((Il2CppObjectBase)damageable).TryCast<LG_WeakLockDamage>();
if ((Object)(object)val2 != (Object)null)
{
if (!(val2.Health <= 0f))
{
bulletInfo.hits++;
}
}
else if ((Object)(object)((Il2CppObjectBase)damageable).TryCast<GenericDamageComponent>() != (Object)null)
{
bulletInfo.hits++;
}
}
public static void PreShotFired(HitData hit, Ray ray, WeaponType weaponType)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
if ((!SNet.IsMaster && hit.owner.Owner.IsBot) || (!hit.owner.Owner.IsBot && !((Agent)hit.owner).IsLocallyOwned))
{
return;
}
currentPlayer = hit.owner;
currentWeapon = Identifier.unknown;
(SentryGunInstance, CustomGunComponent) tuple = default((SentryGunInstance, CustomGunComponent));
if (((Enum)weaponType).HasFlag((Enum)(object)(WeaponType)16) && CustomWeaponManager.TryGetSentry(currentPlayer, ref tuple))
{
currentWeapon = Identifier.From((ItemEquippable)(object)tuple.Item1);
return;
}
ItemEquippable wieldedItem = currentPlayer.Inventory.m_wieldedItem;
if (wieldedItem.IsWeapon && (Object)(object)((Il2CppObjectBase)wieldedItem).TryCast<BulletWeapon>() != (Object)null)
{
currentWeapon = Identifier.From(wieldedItem);
}
}
public static void OnShotFired(HitData hit, Vector3 start, Vector3 end, WeaponType weaponType)
{
//IL_006f: 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_0094: Expected O, but got Unknown
if (!((Object)(object)currentPlayer == (Object)null))
{
if (currentBullet.hits > 255 || currentBullet.crits > 255)
{
APILogger.Warn($"Number of enemies hit / crit for this bullet exceeded maximum value of {255}.");
}
Sync.Trigger(new rGunshotInfo(currentPlayer, currentWeapon, (byte)currentBullet.hits, (byte)currentBullet.crits));
currentPlayer = null;
currentBullet.crits = 0;
currentBullet.hits = 0;
}
}
public static void OnExplosiveDamage(float damage, EnemyAgent enemy, Dam_EnemyDamageLimb limb, PlayerAgent? player, OwnerType ownerType)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Invalid comparison between Unknown and I4
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Invalid comparison between Unknown and I4
if (!((Agent)enemy).Alive)
{
return;
}
if ((Object)(object)currentPlayer != (Object)null)
{
currentBullet.hits++;
if ((int)limb.m_type == 1)
{
currentBullet.crits++;
}
}
if ((Object)(object)Patches.currentPlayer != (Object)null)
{
Patches.currentBullet.hits++;
if ((int)limb.m_type == 1)
{
Patches.currentBullet.crits++;
}
}
}
public static void OnShrapnelDamage(float damage, EnemyAgent enemy, Dam_EnemyDamageLimb limb, PlayerAgent? player, OwnerType ownerType)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
OnExplosiveDamage(damage, enemy, limb, player, ownerType);
}
[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "BulletDamage")]
[HarmonyPrefix]
public static void Prefix_EnemyLimbBulletDamage(Dam_EnemyDamageLimb __instance, Agent sourceAgent)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Invalid comparison between Unknown and I4
if (((Agent)__instance.m_base.Owner).Alive && !((Object)(object)currentPlayer == (Object)null))
{
currentBullet.hits++;
if ((int)__instance.m_type == 1)
{
currentBullet.crits++;
}
}
}
[HarmonyPatch(typeof(Dam_PlayerDamageLimb), "BulletDamage")]
[HarmonyPrefix]
public static void Prefix_PlayerLimbBulletDamage(Dam_PlayerDamageLimb __instance, Agent sourceAgent)
{
if (((Agent)__instance.m_base.Owner).Alive && !((Object)(object)currentPlayer == (Object)null))
{
currentBullet.hits++;
}
}
[HarmonyPatch(typeof(GenericDamageComponent), "BulletDamage")]
[HarmonyPrefix]
public static void Prefix_GenericBulletDamage(GenericDamageComponent __instance, Agent sourceAgent)
{
if (!((Object)(object)currentPlayer == (Object)null))
{
currentBullet.hits++;
}
}
[HarmonyPatch(typeof(LG_WeakLockDamage), "BulletDamage")]
[HarmonyPrefix]
public static void Prefix_LockBulletDamage(LG_WeakLockDamage __instance, Agent sourceAgent)
{
if (!(__instance.Health <= 0f) && !((Object)(object)currentPlayer == (Object)null))
{
currentBullet.hits++;
}
}
}
internal struct ProjectileTransform : IReplayTransform
{
private EWCProjectileComponentBase projectile;
private byte dimension;
public byte dimensionIndex => dimension;
public bool active => (Object)(object)projectile != (Object)null;
public Vector3 position => ((Component)projectile).transform.position;
public Quaternion rotation => ((Component)projectile).transform.rotation;
public ProjectileTransform(EWCProjectileComponentBase projectile)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
this.projectile = projectile;
dimension = (byte)Dimension.GetDimensionFromPos(((Component)projectile).transform.position).DimensionIndex;
}
}
[ReplayData("EWC.Projectile", "0.0.1")]
internal class rEWCProjectile : DynamicTransform
{
internal static class Hooks
{
public static void OnSpawn(EWCProjectileComponentBase projectile)
{
try
{
Replay.Spawn((ReplayDynamic)(object)new rEWCProjectile(projectile), true);
}
catch (Exception value)
{
APILogger.Error($"Failed to spawn EWC projectile: {value}");
}
}
public static void OnDespawn(EWCProjectileComponentBase projectile)
{
Replay.TryDespawn<rEWCProjectile>(GetUniqueId(projectile));
}
}
private EWCProjectileComponentBase projectile;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetUniqueId(EWCProjectileComponentBase projectile)
{
return projectile.SyncID + (projectile.PlayerIndex << 16);
}
public rEWCProjectile(EWCProjectileComponentBase projectile)
: base(GetUniqueId(projectile), (IReplayTransform)(object)new ProjectileTransform(projectile))
{
this.projectile = projectile;
}
public override void Spawn(ByteBuffer buffer)
{
((DynamicTransform)this).Spawn(buffer);
BitHelper.WriteBytes((byte)projectile.PlayerIndex, buffer);
BitHelper.WriteHalf(projectile.Settings.ModelScale, buffer);
}
}
}
namespace ReplayRecorder.EWC.BepInEx
{
public static class Module
{
public const string GUID = "randomuserhi.ReplayRecorder.EWC";
public const string Name = "ReplayRecorder.EWC";
public const string Version = "0.0.1";
}
public static class ConfigManager
{
public static ConfigFile configFile;
private static ConfigEntry<bool> debug;
public static bool Debug
{
get
{
return debug.Value;
}
set
{
debug.Value = value;
}
}
static ConfigManager()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "ReplayRecorder.EWC.cfg"), true);
debug = configFile.Bind<bool>("Debug", "enable", false, "Enables debug messages when true.");
}
}
[BepInPlugin("randomuserhi.ReplayRecorder.EWC", "ReplayRecorder.EWC", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private static Harmony? harmony;
public override void Load()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Expected O, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Expected O, but got Unknown
APILogger.Log("Plugin is loaded!");
harmony = new Harmony("randomuserhi.ReplayRecorder.EWC");
harmony.PatchAll();
APILogger.Log("Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
Replay.RegisterAll();
ProjectileAPI.OnProjectileSpawned += new ProjectileCallback(rEWCProjectile.Hooks.OnSpawn);
ProjectileAPI.OnProjectileDestroyed += new ProjectileCallback(rEWCProjectile.Hooks.OnDespawn);
ExplosionAPI.OnExplosionSpawned += new ExplosionSpawnedCallback(rEWCExplosion.Hooks.Trigger);
DamageAPI.PreExplosiveDamage += new DamageCallback(rEWCDamage.Hooks.Explosive);
DamageAPI.PreShrapnelDamage += new DamageCallback(rEWCDamage.Hooks.Shrapnel);
DamageAPI.PreDOTDamage += new DamageCallback(rEWCDamage.Hooks.DoT);
FireShotAPI.OnShotFired += new ShotFiredCallback(rEWCGunShot.Hooks.Trigger);
ProjectileAPI.OnProjectileDestroyed += new ProjectileCallback(EWCAccuracy.OnProjectileDespawn);
ProjectileAPI.OnProjectileHit += new ProjectileHitCallback(EWCAccuracy.OnProjectileHit);
FireShotAPI.OnShotFired += new ShotFiredCallback(EWCAccuracy.OnShotFired);
FireShotAPI.PreShotFired += new PreShotFiredCallback(EWCAccuracy.PreShotFired);
DamageAPI.PreExplosiveDamage += new DamageCallback(EWCAccuracy.OnExplosiveDamage);
DamageAPI.PreShrapnelDamage += new DamageCallback(EWCAccuracy.OnShrapnelDamage);
rGunshot.RegisterCancelSyncedShot((Func<BulletWeapon, bool>)CancelSyncedShot);
}
private static bool CancelSyncedShot(BulletWeapon weapon)
{
return (Object)(object)((Component)weapon).GetComponent<CustomWeaponComponent>() != (Object)null;
}
}
}
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using API;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GameData;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Player;
using RagdollMode;
using ReplayRecorder.API;
using ReplayRecorder.API.Attributes;
using ReplayRecorder.EWC.BepInEx;
using UnityEngine;
using UnityEngine.Analytics;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ReplayRecorder.Ragdoll")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+30449d0de339895e6cc57044e9132a42220b2bf4")]
[assembly: AssemblyProduct("ReplayRecorder.Ragdoll")]
[assembly: AssemblyTitle("ReplayRecorder.Ragdoll")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace ReplayRecorder.EWC
{
[ReplayData("RagdollMode.Ragdoll", "0.0.1")]
internal class rRagdoll : ReplayDynamic
{
internal static class Hooks
{
[ReplayOnPlayerSpawn]
private static void Spawn(PlayerAgent agent)
{
RagdollLogic component = ((Component)agent).GetComponent<RagdollLogic>();
if ((Object)(object)component == (Object)null)
{
APILogger.Error("Could not get RagdollLogic component!");
}
else
{
Replay.Spawn((ReplayDynamic)(object)new rRagdoll(agent, component), true);
}
}
[ReplayOnPlayerDespawn]
private static void Despawn(int id)
{
Replay.TryDespawn<rRagdoll>(id);
}
}
private RagdollLogic ragdoll;
private Transform hip;
private Transform leftUpperLeg;
private Transform leftLowerLeg;
private Transform leftFoot;
private Transform rightUpperLeg;
private Transform rightLowerLeg;
private Transform rightFoot;
private Transform spine0;
private Transform spine1;
private Transform spine2;
private Transform leftShoulder;
private Transform leftUpperArm;
private Transform leftLowerArm;
private Transform leftHand;
private Transform rightShoulder;
private Transform rightUpperArm;
private Transform rightLowerArm;
private Transform rightHand;
private Transform neck;
private Transform head;
private Quaternion hipRot;
private Quaternion leftUpperLegRot;
private Quaternion leftLowerLegRot;
private Quaternion leftFootRot;
private Quaternion rightUpperLegRot;
private Quaternion rightLowerLegRot;
private Quaternion rightFootRot;
private Quaternion spine0Rot;
private Quaternion spine1Rot;
private Quaternion spine2Rot;
private Quaternion leftShoulderRot;
private Quaternion leftUpperArmRot;
private Quaternion leftLowerArmRot;
private Quaternion leftHandRot;
private Quaternion rightShoulderRot;
private Quaternion rightUpperArmRot;
private Quaternion rightLowerArmRot;
private Quaternion rightHandRot;
private Quaternion neckRot;
private Quaternion headRot;
private bool enabled;
public override bool Active => (Object)(object)ragdoll != (Object)null;
public override bool IsDirty
{
get
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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_004d: 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_0068: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00ce: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: 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_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
if (enabled == ragdoll.ragdollEnabled)
{
if (ragdoll.ragdollEnabled)
{
if (!(hip.rotation != hipRot) && !(leftUpperLeg.rotation != leftUpperLegRot) && !(leftLowerLeg.rotation != leftLowerLegRot) && !(leftFoot.rotation != leftFootRot) && !(rightUpperLeg.rotation != rightUpperLegRot) && !(rightLowerLeg.rotation != rightLowerLegRot) && !(rightFoot.rotation != rightFootRot) && !(spine0.rotation != spine0Rot) && !(spine1.rotation != spine1Rot) && !(spine2.rotation != spine2Rot) && !(leftShoulder.rotation != leftShoulderRot) && !(leftUpperArm.rotation != leftUpperArmRot) && !(leftLowerArm.rotation != leftLowerArmRot) && !(leftHand.rotation != leftHandRot) && !(rightShoulder.rotation != rightShoulderRot) && !(rightUpperArm.rotation != rightUpperArmRot) && !(rightLowerArm.rotation != rightLowerArmRot) && !(rightHand.rotation != rightHandRot) && !(neck.rotation != neckRot))
{
return head.rotation != headRot;
}
return true;
}
return false;
}
return true;
}
}
public rRagdoll(PlayerAgent agent, RagdollLogic ragdoll)
: base((int)((Agent)agent).GlobalID)
{
this.ragdoll = ragdoll;
Transform val = ((Component)agent.PlayerSyncModel).transform.Find("PlayerCharacter_rig");
hip = val.Find("Root/Hip");
leftUpperLeg = val.Find("Root/Hip/LeftUpperLeg");
leftLowerLeg = val.Find("Root/Hip/LeftUpperLeg/LeftLowerLeg");
leftFoot = val.Find("Root/Hip/LeftUpperLeg/LeftLowerLeg/LeftFoot");
rightUpperLeg = val.Find("Root/Hip/RightUpperLeg");
rightLowerLeg = val.Find("Root/Hip/RightUpperLeg/RightLowerLeg");
rightFoot = val.Find("Root/Hip/RightUpperLeg/RightLowerLeg/RightFoot");
spine0 = val.Find("Root/Hip/Spine1");
spine1 = val.Find("Root/Hip/Spine1/Spine2");
spine2 = val.Find("Root/Hip/Spine1/Spine2/Spine3");
leftShoulder = val.Find("Root/Hip/Spine1/Spine2/Spine3/LeftShoulder");
leftUpperArm = val.Find("Root/Hip/Spine1/Spine2/Spine3/LeftShoulder/LeftUpperArm");
leftLowerArm = val.Find("Root/Hip/Spine1/Spine2/Spine3/LeftShoulder/LeftUpperArm/LeftLowerArm");
leftHand = val.Find("Root/Hip/Spine1/Spine2/Spine3/LeftShoulder/LeftUpperArm/LeftLowerArm/LeftHand");
rightShoulder = val.Find("Root/Hip/Spine1/Spine2/Spine3/RightShoulder");
rightUpperArm = val.Find("Root/Hip/Spine1/Spine2/Spine3/RightShoulder/RightUpperArm");
rightLowerArm = val.Find("Root/Hip/Spine1/Spine2/Spine3/RightShoulder/RightUpperArm/RightLowerArm");
rightHand = val.Find("Root/Hip/Spine1/Spine2/Spine3/RightShoulder/RightUpperArm/RightLowerArm/RightHand");
neck = val.Find("Root/Hip/Spine1/Spine2/Spine3/Neck");
head = val.Find("Root/Hip/Spine1/Spine2/Spine3/Neck/Head");
}
public override void Write(ByteBuffer buffer)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_0065: 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_008c: 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_00a2: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: 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_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: 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_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
enabled = ragdoll.ragdollEnabled;
BitHelper.WriteBytes(enabled, buffer);
if (enabled)
{
hipRot = ((Component)hip).transform.localRotation;
leftUpperLegRot = ((Component)leftUpperLeg).transform.localRotation;
leftLowerLegRot = ((Component)leftLowerLeg).transform.localRotation;
leftFootRot = ((Component)leftFoot).transform.localRotation;
rightUpperLegRot = ((Component)rightUpperLeg).transform.localRotation;
rightLowerLegRot = ((Component)rightLowerLeg).transform.localRotation;
rightFootRot = ((Component)rightFoot).transform.localRotation;
spine0Rot = ((Component)spine0).transform.localRotation;
spine1Rot = ((Component)spine1).transform.localRotation;
spine2Rot = ((Component)spine2).transform.localRotation;
leftShoulderRot = ((Component)leftShoulder).transform.localRotation;
leftUpperArmRot = ((Component)leftUpperArm).transform.localRotation;
leftLowerArmRot = ((Component)leftLowerArm).transform.localRotation;
leftHandRot = ((Component)leftHand).transform.localRotation;
rightShoulderRot = ((Component)rightShoulder).transform.localRotation;
rightUpperArmRot = ((Component)rightUpperArm).transform.localRotation;
rightLowerArmRot = ((Component)rightLowerArm).transform.localRotation;
rightHandRot = ((Component)rightHand).transform.localRotation;
neckRot = ((Component)neck).transform.localRotation;
headRot = ((Component)head).transform.localRotation;
BitHelper.WriteHalf(hipRot, buffer);
BitHelper.WriteHalf(leftUpperLegRot, buffer);
BitHelper.WriteHalf(leftLowerLegRot, buffer);
BitHelper.WriteHalf(leftFootRot, buffer);
BitHelper.WriteHalf(rightUpperLegRot, buffer);
BitHelper.WriteHalf(rightLowerLegRot, buffer);
BitHelper.WriteHalf(rightFootRot, buffer);
BitHelper.WriteHalf(spine0Rot, buffer);
BitHelper.WriteHalf(spine1Rot, buffer);
BitHelper.WriteHalf(spine2Rot, buffer);
BitHelper.WriteHalf(leftShoulderRot, buffer);
BitHelper.WriteHalf(leftUpperArmRot, buffer);
BitHelper.WriteHalf(leftLowerArmRot, buffer);
BitHelper.WriteHalf(leftHandRot, buffer);
BitHelper.WriteHalf(rightShoulderRot, buffer);
BitHelper.WriteHalf(rightUpperArmRot, buffer);
BitHelper.WriteHalf(rightLowerArmRot, buffer);
BitHelper.WriteHalf(rightHandRot, buffer);
BitHelper.WriteHalf(neckRot, buffer);
BitHelper.WriteHalf(headRot, buffer);
}
}
}
}
namespace ReplayRecorder.EWC.BepInEx
{
public static class Module
{
public const string GUID = "randomuserhi.ReplayRecorder.RagdollMode";
public const string Name = "ReplayRecorder.RagdollMode";
public const string Version = "0.0.1";
}
public static class ConfigManager
{
public static ConfigFile configFile;
private static ConfigEntry<bool> debug;
public static bool Debug
{
get
{
return debug.Value;
}
set
{
debug.Value = value;
}
}
static ConfigManager()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "ReplayRecorder.RagdollMode.cfg"), true);
debug = configFile.Bind<bool>("Debug", "enable", false, "Enables debug messages when true.");
}
}
[BepInPlugin("randomuserhi.ReplayRecorder.RagdollMode", "ReplayRecorder.RagdollMode", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private static Harmony? harmony;
public override void Load()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
APILogger.Log("Plugin is loaded!");
harmony = new Harmony("randomuserhi.ReplayRecorder.RagdollMode");
harmony.PatchAll();
APILogger.Log("Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
Replay.RegisterAll();
}
}
}
namespace API
{
[HarmonyPatch(typeof(GameDataInit))]
internal class GameDataInit_Patches
{
[HarmonyPatch("Initialize")]
[HarmonyWrapSafe]
[HarmonyPostfix]
public static void Initialize_Postfix()
{
Analytics.enabled = false;
}
}
internal static class APILogger
{
private static readonly ManualLogSource logger;
static APILogger()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
logger = new ManualLogSource("Rand-API");
Logger.Sources.Add((ILogSource)(object)logger);
}
private static string Format(string module, object msg)
{
return $"[{module}]: {msg}";
}
public static void Info(string module, object data)
{
logger.LogMessage((object)Format(module, data));
}
public static void Verbose(string module, object data)
{
}
public static void Log(object data)
{
logger.LogDebug((object)Format("ReplayRecorder.RagdollMode", data));
}
public static void Debug(object data)
{
if (ConfigManager.Debug)
{
Log(data);
}
}
public static void Warn(object data)
{
logger.LogWarning((object)Format("ReplayRecorder.RagdollMode", data));
}
public static void Error(object data)
{
logger.LogError((object)Format("ReplayRecorder.RagdollMode", data));
}
}
}