using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using ChatHistory.Settings;
using ChatHistory.Systems;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Network;
using ProjectM.Scripting;
using ProjectM.UI;
using RTLTMPro;
using Stunlock.Core;
using Stunlock.Localization;
using TMPro;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Utils.Database;
using Utils.Logger;
using Utils.Settings;
using Utils.VRising.Entities;
using Utils.VRising.Systems;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Utils.VRising
{
internal static class Extensions
{
private static EntityManager EntityManager => Utils.VRising.Entities.EntityManager.Get();
public static void Destroy(this Entity entity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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)
EntityManager entityManager = EntityManager;
((EntityManager)(ref entityManager)).DestroyEntity(entity);
}
public static bool Has<T>(this Entity entity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_000f: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = EntityManager;
return ((EntityManager)(ref entityManager)).HasComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0));
}
public unsafe static T Read<T>(this Entity entity) where T : struct
{
//IL_0006: 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_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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)
TypeIndex typeIndex = new ComponentType(Il2CppType.Of<T>(), (AccessMode)0).TypeIndex;
EntityManager entityManager = EntityManager;
return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, typeIndex)));
}
public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
{
//IL_0006: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
TypeIndex typeIndex = new ComponentType(Il2CppType.Of<T>(), (AccessMode)0).TypeIndex;
byte[] array = StructureToByteArray(componentData);
int num = Marshal.SizeOf<T>();
fixed (byte* ptr = array)
{
EntityManager entityManager = EntityManager;
((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, typeIndex, (void*)ptr, num);
}
}
private static byte[] StructureToByteArray<T>(T structure) where T : struct
{
int num = Marshal.SizeOf(structure);
byte[] array = new byte[num];
IntPtr intPtr = Marshal.AllocHGlobal(num);
Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
Marshal.Copy(intPtr, array, 0, num);
Marshal.FreeHGlobal(intPtr);
return array;
}
}
}
namespace Utils.VRising.Systems
{
public class AssetGuid
{
public static AssetGuid GetAssetGuid(string textString)
{
//IL_002f: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
using SHA256 sHA = SHA256.Create();
byte[] array = sHA.ComputeHash(Encoding.UTF8.GetBytes(textString));
return AssetGuid.FromGuid(new Guid(Il2CppStructArray<byte>.op_Implicit(array[..16])));
}
private static AssetGuid FromGuid(Guid uniqueGuid)
{
throw new NotImplementedException();
}
public static LocalizationKey LocalizeString(string text)
{
//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_0022: 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_001b: 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)
AssetGuid assetGuid = GetAssetGuid(text);
if (Localization.Initialized)
{
Localization._LocalizedStrings.TryAdd(assetGuid, text);
return new LocalizationKey(assetGuid);
}
return LocalizationKey.Empty;
}
}
public static class Chat
{
private static readonly ComponentType[] _networkChatMessageServerEventComponents = (ComponentType[])(object)new ComponentType[3]
{
ComponentType.ReadOnly(Il2CppType.Of<NetworkEventType>()),
ComponentType.ReadOnly<SendEventToUser>(),
ComponentType.ReadOnly(Il2CppType.Of<ChatMessageServerEvent>())
};
private static readonly ComponentType[] _networkChatMessageEventComponents = (ComponentType[])(object)new ComponentType[3]
{
ComponentType.ReadOnly(Il2CppType.Of<FromCharacter>()),
ComponentType.ReadOnly(Il2CppType.Of<NetworkEventType>()),
ComponentType.ReadOnly(Il2CppType.Of<ChatMessageEvent>())
};
private static readonly NetworkEventType _networkChatMessageServerEventType = new NetworkEventType
{
IsAdminEvent = false,
EventId = NetworkEvents.EventId_ChatMessageServerEvent,
IsDebugEvent = false
};
private static readonly NetworkEventType _networkChatMessageEventType = new NetworkEventType
{
IsAdminEvent = false,
EventId = NetworkEvents.EventId_ChatMessageEvent,
IsDebugEvent = false
};
public static void SendServerMessage(string message, Entity userEntity, ServerChatMessageType messageType = 6)
{
//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_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_0017: 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_001f: 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_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_003a: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_00a4: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_00f0: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
User val = userEntity.Read<User>();
ChatMessageServerEvent val2 = default(ChatMessageServerEvent);
val2.MessageText = new FixedString512Bytes(message);
val2.MessageType = messageType;
val2.FromUser = userEntity.Read<NetworkId>();
val2.FromCharacter = ((NetworkedEntity)(ref val.LocalCharacter)).GetEntityOnServer().Read<NetworkId>();
val2.TimeUTC = DateTime.UtcNow.Ticks;
ChatMessageServerEvent componentData = val2;
Log.Trace($"Sending server chat message '{message}' to user({val.CharacterName}:{val.Index})");
EntityManager val3 = EntityManager.Get();
Entity entity = ((EntityManager)(ref val3)).CreateEntity(_networkChatMessageServerEventComponents);
entity.Write<SendEventToUser>(new SendEventToUser
{
UserIndex = val.Index
});
entity.Write<NetworkEventType>(_networkChatMessageServerEventType);
entity.Write<ChatMessageServerEvent>(componentData);
}
public static void SendMessage(string message, Entity userEntity, Entity characterEntity, ChatMessageType messageType = 4)
{
//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_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_0017: 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_001f: 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_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_0031: 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_005f: 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_0078: 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_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)
//IL_00b1: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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)
User val = userEntity.Read<User>();
ChatMessageEvent val2 = default(ChatMessageEvent);
val2.MessageText = new FixedString512Bytes(message);
val2.MessageType = messageType;
val2.ReceiverEntity = userEntity.Read<NetworkId>();
ChatMessageEvent componentData = val2;
Log.Trace($"Sending chat message '{message}' to user({val.CharacterName}:{val.Index})");
EntityManager val3 = EntityManager.Get();
Entity entity = ((EntityManager)(ref val3)).CreateEntity(_networkChatMessageEventComponents);
entity.Write<FromCharacter>(new FromCharacter
{
User = userEntity,
Character = characterEntity
});
entity.Write<NetworkEventType>(_networkChatMessageEventType);
entity.Write<ChatMessageEvent>(componentData);
}
}
public static class PrefabCollectionSystem
{
public static PrefabCollectionSystem Get()
{
return World.world.GetExistingSystemManaged<PrefabCollectionSystem>();
}
public static string GetPrefabName(PrefabGUID hashCode)
{
//IL_001e: 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_0024: Unknown result type (might be due to invalid IL or missing references)
PrefabCollectionSystem val = Get();
string result = "Nonexistent";
if (((PrefabGUID)(ref hashCode)).GuidHash == 0)
{
return result;
}
try
{
Entity val2 = ((PrefabLookupMap)(ref ((PrefabCollectionSystem_Base)val).PrefabLookupMap))[hashCode];
return ((object)(Entity)(ref val2)).ToString();
}
catch
{
return "NoPrefabName";
}
}
}
public static class ServerScriptMapper
{
public static ServerScriptMapper Get()
{
return World.world.GetExistingSystemManaged<ServerScriptMapper>();
}
}
}
namespace Utils.VRising.Logger
{
public static class PrettyLog
{
}
}
namespace Utils.VRising.Entities
{
public static class ActiveServantMission
{
public static NativeArray<Entity> GetAll()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0023: 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)
EntityManager entityManager = World.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<ActiveServantMission>() });
return ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
public static DynamicBuffer<ActiveServantMission> GetBuffer(Entity mission)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_000a: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = World.EntityManager;
return ((EntityManager)(ref entityManager)).GetBuffer<ActiveServantMission>(mission, false);
}
public static List<DynamicBuffer<ActiveServantMission>> GetAllBuffers()
{
//IL_0006: 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_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_0018: 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_001f: 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)
List<DynamicBuffer<ActiveServantMission>> list = new List<DynamicBuffer<ActiveServantMission>>();
Enumerator<Entity> enumerator = GetAll().GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
list.Add(GetBuffer(current));
}
return list;
}
public static List<string> GetAllBuffersMissionUIDs()
{
//IL_0015: 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_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)
//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_002f: Unknown result type (might be due to invalid IL or missing references)
List<string> list = new List<string>();
foreach (DynamicBuffer<ActiveServantMission> allBuffer in GetAllBuffers())
{
Enumerator<ActiveServantMission> enumerator2 = allBuffer.GetEnumerator();
while (enumerator2.MoveNext())
{
ActiveServantMission current = enumerator2.Current;
list.Add(GetMissionUID(current));
}
}
return list;
}
public static List<string> GetBufferMissionUIDs(Entity mission)
{
//IL_0006: 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_000c: 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_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_001e: 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)
List<string> list = new List<string>();
Enumerator<ActiveServantMission> enumerator = GetBuffer(mission).GetEnumerator();
while (enumerator.MoveNext())
{
ActiveServantMission current = enumerator.Current;
list.Add(GetMissionUID(current));
}
return list;
}
public static string GetMissionUID(ActiveServantMission mission)
{
//IL_0010: 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_0042: Unknown result type (might be due to invalid IL or missing references)
return Convert.ToBase64String(Encoding.UTF8.GetBytes($"{GetMissiontDataId(mission)}-{GetMissionStartTime(mission)}-{GetMissionName(mission)}"));
}
public static string GetMissionName(ActiveServantMission mission)
{
//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)
return PrefabCollectionSystem.GetPrefabName(mission.MissionID);
}
public static float GetMissionLength(ActiveServantMission mission)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return mission.MissionLengthSeconds;
}
public static long GetMissionLengthTimestamp(ActiveServantMission mission)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
return DateTimeOffset.Now.AddSeconds(GetMissionLength(mission)).ToUnixTimeSeconds();
}
public static void SetMissionLength(ref ActiveServantMission mission, float seconds)
{
mission.MissionLengthSeconds = seconds;
}
public static double GetMissionStartTime(ActiveServantMission mission)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return mission.MissionLengthSeconds;
}
public static int GetMissiontDataId(ActiveServantMission mission)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return mission.MissiontDataId;
}
}
public static class DayNightCycle
{
public static DayNightCycle GetSingleton()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
return ServerScriptMapper.Get()._ServerGameManager.DayNightCycle;
}
public static TimeOfDay GetTimeOfDay(DayNightCycle dnc = default(DayNightCycle))
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if (emptyDNC(dnc))
{
dnc = GetSingleton();
}
return ((DayNightCycle)(ref dnc)).TimeOfDay;
}
public static double GetTime(DayNightCycle dnc = default(DayNightCycle))
{
//IL_0000: 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_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)
if (emptyDNC(dnc))
{
dnc = GetSingleton();
}
return dnc.Time;
}
public static TimeScale GetTimeScale(DayNightCycle dnc = default(DayNightCycle))
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if (emptyDNC(dnc))
{
dnc = GetSingleton();
}
return DayNightCycleExtensions.GetTimeScale(ref dnc);
}
public static float GetTimeSinceDayStart(DayNightCycle dnc = default(DayNightCycle))
{
//IL_0000: 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)
if (emptyDNC(dnc))
{
dnc = GetSingleton();
}
return ((DayNightCycle)(ref dnc)).TimeSinceDayStart;
}
public static float GetDayTimeStartInSeconds(DayNightCycle dnc = default(DayNightCycle))
{
//IL_0000: 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_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)
if (emptyDNC(dnc))
{
dnc = GetSingleton();
}
return dnc.DayTimeStartInSeconds;
}
public static float GetDayTimeDurationInSeconds(DayNightCycle dnc = default(DayNightCycle))
{
//IL_0000: 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_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)
if (emptyDNC(dnc))
{
dnc = GetSingleton();
}
return dnc.DayTimeDurationInSeconds;
}
public static float GetDayDurationInSeconds(DayNightCycle dnc = default(DayNightCycle))
{
//IL_0000: 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_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)
if (emptyDNC(dnc))
{
dnc = GetSingleton();
}
return dnc.DayDurationInSeconds;
}
public static bool IsDay(DayNightCycle dnc = default(DayNightCycle))
{
//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_0007: Invalid comparison between Unknown and I4
return (int)GetTimeOfDay(dnc) == 1;
}
public static bool IsBloodMoonDay(DayNightCycle dnc = default(DayNightCycle))
{
//IL_0000: 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)
if (emptyDNC(dnc))
{
dnc = GetSingleton();
}
return ((DayNightCycle)(ref dnc)).IsBloodMoonDay();
}
private static bool emptyDNC(DayNightCycle dnc)
{
//IL_0005: 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_000e: Unknown result type (might be due to invalid IL or missing references)
return EqualityComparer<DayNightCycle>.Default.Equals(dnc, default(DayNightCycle));
}
}
public static class EntityManager
{
public static EntityManager Get()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return World.EntityManager;
}
}
public static class PlayerCharacter
{
public static NativeArray<Entity> GetAll()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0023: 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)
EntityManager entityManager = World.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<PlayerCharacter>() });
return ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
public static bool IsOnline(Entity playerCharacter)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_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_0014: 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_0018: 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)
EntityManager entityManager = World.EntityManager;
PlayerCharacter componentData = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(playerCharacter);
entityManager = World.EntityManager;
return ((EntityManager)(ref entityManager)).GetComponentData<User>(componentData.UserEntity).IsConnected;
}
public static Entity GetCharacterByUserEntity(Entity userEntity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0023: 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)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = World.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<PlayerCharacter>() });
((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
return Entity.Null;
}
public static Entity GetLocalCharacter()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0023: 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)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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)
EntityManager entityManager = World.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<LocalCharacter>() });
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
if (val2.Length <= 0)
{
return Entity.Null;
}
return val2[0];
}
public static bool IsAllOnlinePlayersSleeping()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_000b: 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_0013: 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)
//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_0026: 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)
NativeArray<Entity> all = Sleeping.GetAll();
Enumerator<Entity> enumerator = GetAll().GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
if (IsOnline(current) && !Sleeping.HasTarget(all, current))
{
return false;
}
}
return true;
}
}
public static class ServantCoffinstation
{
public static NativeArray<Entity> GetAll()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0023: 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)
EntityManager entityManager = World.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<ServantCoffinstation>() });
return ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
public static ServantCoffinstation GetComponentData(Entity servantCoffinStation)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0009: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = World.EntityManager;
return ((EntityManager)(ref entityManager)).GetComponentData<ServantCoffinstation>(servantCoffinStation);
}
public static Dictionary<Entity, ServantCoffinstation> GetAllComponentData()
{
//IL_0006: 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_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_0018: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
Dictionary<Entity, ServantCoffinstation> dictionary = new Dictionary<Entity, ServantCoffinstation>();
Enumerator<Entity> enumerator = GetAll().GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
dictionary.Add(current, GetComponentData(current));
}
return dictionary;
}
public static bool IsConverting(ServantCoffinstation servantCoffinStation)
{
//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_0007: Invalid comparison between Unknown and I4
return (int)servantCoffinStation.State == 3;
}
public static float GetConvertionProgress(ServantCoffinstation servantCoffinStation)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return servantCoffinStation.ConvertionProgress;
}
public static void SetConvertionProgress(ref ServantCoffinstation servantCoffinStation, float seconds)
{
servantCoffinStation.ConvertionProgress = seconds;
}
public static void SetComponentData(Entity coffinStationEntity, ServantCoffinstation coffinStation)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0009: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = World.EntityManager;
((EntityManager)(ref entityManager)).SetComponentData<ServantCoffinstation>(coffinStationEntity, coffinStation);
}
}
public static class ServantMissionSetting
{
public static NativeArray<Entity> GetAll()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0023: 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)
EntityManager entityManager = World.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<ServantMissionSetting>() });
return ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
public static DynamicBuffer<ServantMissionSetting> GetBuffer()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0020: 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_0033: 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)
Enumerator<Entity> enumerator = GetAll().GetEnumerator();
if (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = World.EntityManager;
return ((EntityManager)(ref entityManager)).GetBuffer<ServantMissionSetting>(current, false);
}
return default(DynamicBuffer<ServantMissionSetting>);
}
}
public static class SetTimeOfDayEvent
{
public static void Add(int hour = 0, int day = 0)
{
create(hour, day, (SetTimeType)1);
}
public static void Set(int hour = 0, int day = 0)
{
create(hour, day, (SetTimeType)0);
}
private static void create(int hour, int day, SetTimeType type)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = World.EntityManager;
Entity val = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<SetTimeOfDayEvent>() });
entityManager = World.EntityManager;
((EntityManager)(ref entityManager)).SetComponentData<SetTimeOfDayEvent>(val, new SetTimeOfDayEvent
{
Hour = hour,
Day = day,
Type = type
});
}
}
public static class Sleeping
{
public static NativeArray<Entity> GetAll()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0021: 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)
//IL_002d: 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_0037: 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_0040: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = World.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[3]
{
ComponentType.ReadOnly<Buff>(),
ComponentType.ReadOnly<SpawnSleepingBuff>(),
ComponentType.ReadOnly<InsideBuff>()
});
return ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
public static bool HasTarget(NativeArray<Entity> sleepingEntities, Entity target)
{
//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_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
Enumerator<Entity> enumerator = sleepingEntities.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = World.EntityManager;
if (((EntityManager)(ref entityManager)).GetComponentData<Buff>(current).Target == target)
{
return true;
}
}
return false;
}
}
public static class User
{
public static NativeArray<Entity> GetAll()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0023: 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)
EntityManager entityManager = World.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
return ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
public static Entity GetFirstOnlinePlayer()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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)
Enumerator<Entity> enumerator = GetAll().GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = World.EntityManager;
if (((EntityManager)(ref entityManager)).GetComponentData<User>(current).IsConnected)
{
return current;
}
}
return Entity.Null;
}
public static Entity GetLocalUser()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0015: 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_0023: 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)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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)
EntityManager entityManager = World.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<LocalUser>() });
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
if (val2.Length <= 0)
{
return Entity.Null;
}
return val2[0];
}
public static bool IsAllOffline()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
Enumerator<Entity> enumerator = GetAll().GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = World.EntityManager;
if (((EntityManager)(ref entityManager)).GetComponentData<User>(current).IsConnected)
{
return false;
}
}
return true;
}
}
public static class World
{
internal static World? _world;
public static EntityManager EntityManager => world.EntityManager;
public static World world
{
get
{
if (_world != null)
{
return _world;
}
_world = Server ?? Client;
if (_world != null)
{
return _world;
}
throw new Exception("No Server or Client world found.");
}
}
public static bool IsServer => Application.productName == "VRisingServer";
public static bool IsClient => Application.productName == "VRising";
public static World? Client => GetWorld("Client_0") ?? null;
public static World? Server => GetWorld("Server") ?? null;
public static void UnPatch()
{
_world = null;
}
private static World? GetWorld(string name)
{
Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
while (enumerator.MoveNext())
{
World current = enumerator.Current;
if (current.Name == name)
{
return current;
}
}
return null;
}
}
}
namespace Utils.VRising.Data
{
public static class Prefabs
{
public static readonly PrefabGUID AB_Interact_Throne_Buff_Sit = new PrefabGUID(211319841);
}
}
namespace Utils.Settings
{
public class Config
{
public static string PluginGUID;
public static string PluginFolderPath;
internal static ConfigFile cfg;
private static List<Action> configActions = new List<Action>();
public static ConfigElement<T> Bind<T>(string section, string key, T defaultValue, string description)
{
return new ConfigElement<T>(cfg.Bind<T>(section, key, defaultValue, description), section, key, defaultValue, description);
}
public static void Save()
{
cfg.Save();
}
public static void Setup(string pluginGUID, ConfigFile config, int skipCaller = 4, params Action[] actions)
{
PluginGUID = pluginGUID;
cfg = config;
PluginFolderPath = Paths.ConfigPath + "\\" + PluginGUID;
if (!Directory.Exists(PluginFolderPath))
{
Directory.CreateDirectory(PluginFolderPath);
}
ENV.Debug.Setup(skipCaller);
AddConfigActions(actions);
}
public static void Load()
{
if (configActions == null || configActions.Count == 0)
{
return;
}
foreach (Action configAction in configActions)
{
configAction();
}
}
public static void AddConfigActions(params Action[] actions)
{
configActions.AddRange(actions);
}
}
public class ConfigElement<T>
{
public List<Action<T>> OnValueChanged = new List<Action<T>>();
private ConfigEntry<T> OriginalConfig;
public string Section { get; }
public string Key { get; }
public string Description { get; }
public Type ElementType => typeof(T);
public T Value
{
get
{
return GetValue();
}
set
{
SetValue(value);
}
}
public T DefaultValue { get; }
private T GetValue()
{
return OriginalConfig.Value;
}
public ConfigElement(ConfigEntry<T> original, string section, string key, T defaultValue, string description)
{
OriginalConfig = original;
Section = section;
Key = key;
DefaultValue = defaultValue;
Description = description;
}
private void SetValue(T value)
{
if ((Value == null && value == null) || (Value != null && Value.Equals(value)))
{
return;
}
OriginalConfig.Value = value;
foreach (Action<T> item in OnValueChanged)
{
item?.Invoke(value);
}
}
}
public static class ENV
{
public class Debug
{
private static string debugSection = "\ud83e\udeb2Debug";
private static ConfigElement<bool> DebugLogOnTempFile;
private static ConfigElement<bool> DebugEnableTraceLogs;
public static void Setup(int skipCaller)
{
Config.AddConfigActions(delegate
{
load(skipCaller);
});
}
private static void load(int skipCaller)
{
if (enableDebugConfigs(skipCaller))
{
DebugLogOnTempFile = Config.Bind(debugSection, "LogOnTempFile", defaultValue: false, "Enabled, will log every plugin log on a temp file");
DebugEnableTraceLogs = Config.Bind(debugSection, "EnableTraceLogs", defaultValue: false, "Enabled, will print Trace logs (Debug output in BepInEx)");
}
validateValues();
}
private static void validateValues()
{
if (DebugLogOnTempFile != null)
{
LogOnTempFile = DebugLogOnTempFile.Value;
}
if (DebugEnableTraceLogs != null)
{
EnableTraceLogs = DebugEnableTraceLogs.Value;
}
Config.cfg.Save();
}
private static bool enableDebugConfigs(int skipCaller)
{
return new StackTrace().GetFrame(skipCaller).GetMethod().DeclaringType.Assembly.GetCustomAttribute<AssemblyConfigurationAttribute>()?.Configuration != "Release";
}
}
public static bool LogOnTempFile;
public static bool EnableTraceLogs;
}
}
namespace Utils.Logger
{
public class Config
{
internal static ManualLogSource logger;
private static string tempLogFile;
public static void Setup(ManualLogSource logger, string worldType = "")
{
Config.logger = logger;
string value = "";
if (worldType != "")
{
value = "-" + worldType;
}
tempLogFile = $"{Utils.Settings.Config.PluginFolderPath}\\{Utils.Settings.Config.PluginGUID}{value}.txt";
Log.Start("Using \"" + tempLogFile + "\" to save logs.");
}
public static void TestSetup()
{
}
internal static void logFile(object data, string level, string prefix = "")
{
if (Utils.Settings.ENV.LogOnTempFile)
{
using (StreamWriter streamWriter = File.AppendText(tempLogFile))
{
string value = $"{prefix}{DateTime.Now.ToString("hh:mm:ss")} [{level} {Utils.Settings.Config.PluginGUID}]: {data}";
streamWriter.WriteLine(value);
}
}
}
}
public class Log
{
private static ConcurrentDictionary<string, long> timedLog = new ConcurrentDictionary<string, long>();
private static List<string> firstLog = new List<string>();
public static void Info(object data)
{
Config.logger.LogInfo(data);
Config.logFile(data, "Info: ");
}
public static void Error(object data)
{
Config.logger.LogError(data);
Config.logFile(data, "Error: ");
}
public static void Debug(object data)
{
Config.logger.LogDebug(data);
Config.logFile(data, "Debug: ");
}
public static void Fatal(object data)
{
Config.logger.LogFatal(data);
Config.logFile(data, "Fatal: ");
}
public static void Warning(object data)
{
Config.logger.LogWarning(data);
Config.logFile(data, "Warning:");
}
public static void Message(object data)
{
Config.logger.LogMessage(data);
Config.logFile(data, "Message:");
}
public static void Start(object data)
{
Config.logger.LogMessage(data);
Config.logFile(data, "Start: ", "\n");
}
public static void Trace(object data)
{
if (Utils.Settings.ENV.EnableTraceLogs)
{
Config.logger.LogDebug(data);
Config.logFile(data, "Trace: ");
}
}
public static void Struct<T>(T data)
{
if (Utils.Settings.ENV.EnableTraceLogs)
{
string text = structToString(data);
Config.logger.LogDebug((object)text);
Config.logFile(text, "Struct: ");
}
}
public static void Timed(Action action, int ms, string id = "")
{
if (!blocked(ms, id))
{
action();
}
}
public static void First(Action action, string id = "")
{
if (first(id))
{
action();
}
}
private static string structToString<T>(T data)
{
Type type = data.GetType();
FieldInfo[] fields = type.GetFields();
PropertyInfo[] properties = type.GetProperties();
Dictionary<string, object> values = new Dictionary<string, object>();
Array.ForEach(properties, delegate(PropertyInfo property)
{
values.TryAdd(property.Name, property.GetValue(data));
});
Array.ForEach(fields, delegate(FieldInfo field)
{
values.TryAdd(field.Name, field.GetValue(data));
});
List<string> list = new List<string>();
foreach (KeyValuePair<string, object> item in values)
{
list.Add($"\"{item.Key}\":\"{item.Value}\"");
}
return "\"" + type.ToString() + "\": {" + string.Join(",", list) + "}";
}
private static bool first(string id)
{
if (firstLog.Contains(id))
{
return false;
}
firstLog.Add(id);
return true;
}
private static bool blocked(int ms, string id)
{
long num = DateTimeOffset.Now.ToUnixTimeMilliseconds();
if (!timedLog.TryGetValue(id, out var value))
{
long newTimestamp = DateTimeOffset.Now.AddMilliseconds(ms).ToUnixTimeMilliseconds();
timedLog.AddOrUpdate(id, newTimestamp, (string key, long oldValue) => newTimestamp);
return true;
}
if (num < value)
{
return true;
}
timedLog.TryRemove(id, out var _);
return false;
}
}
}
namespace Utils.Database
{
public static class Cache
{
public static ConcurrentDictionary<string, long> LastUpdate = new ConcurrentDictionary<string, long>();
public static ConcurrentDictionary<string, bool> Cached = new ConcurrentDictionary<string, bool>();
public static bool IsBlocked(string key, long blockedDuration)
{
long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
if (LastUpdate.TryGetValue(key, out var value) && now - value < blockedDuration)
{
return true;
}
LastUpdate.AddOrUpdate(key, now, (string _, long _) => now);
return false;
}
public static bool Key(string key, bool cache = true)
{
if (!cache)
{
return false;
}
return Cached.AddOrUpdate(key, addValue: true, (string _, bool _) => true);
}
public static bool Exists(string key)
{
if (Cached.TryGetValue(key, out var value) && value)
{
return true;
}
return false;
}
public static bool RemoveKey(string key)
{
bool value;
return Cached.TryRemove(key, out value);
}
public static void Clear()
{
Cached.Clear();
LastUpdate.Clear();
}
}
public static class DB
{
private static JsonSerializerOptions JSONOptions = new JsonSerializerOptions
{
WriteIndented = false,
IncludeFields = false
};
private static JsonSerializerOptions Pretty_JSON_options = new JsonSerializerOptions
{
WriteIndented = true,
IncludeFields = true
};
private static List<Action> loadActions = new List<Action>();
private static List<Action> saveActions = new List<Action>();
private static List<Action> cleanActions = new List<Action>();
public static void Setup(List<Action> load, List<Action> save, List<Action> clean)
{
if (load != null)
{
loadActions.AddRange(load);
}
if (save != null)
{
saveActions.AddRange(save);
}
if (clean != null)
{
cleanActions.AddRange(clean);
}
}
public static void Load()
{
if (loadActions == null)
{
return;
}
foreach (Action loadAction in loadActions)
{
loadAction();
}
Log.Info($"All({loadActions.Count}) database actions loaded.");
}
public static void Save()
{
if (saveActions == null)
{
return;
}
foreach (Action saveAction in saveActions)
{
saveAction();
}
Log.Info($"All({saveActions.Count}) database actions saved.");
}
public static void Clean()
{
if (cleanActions == null)
{
return;
}
foreach (Action cleanAction in cleanActions)
{
cleanAction();
}
Log.Info($"All({cleanActions.Count}) database actions cleaned.");
}
public static void AddLoadActions(params Action[] actions)
{
loadActions.AddRange(actions);
}
public static void AddSaveActions(params Action[] actions)
{
saveActions.AddRange(actions);
}
public static void AddCleanActions(params Action[] actions)
{
cleanActions.AddRange(actions);
}
public static void saveFile<T>(string fileName, T data, bool pretty = false, string extension = ".json")
{
JsonSerializerOptions options = JSONOptions;
if (pretty)
{
options = Pretty_JSON_options;
}
File.WriteAllText(Utils.Settings.Config.PluginFolderPath + "\\" + fileName + extension, JsonSerializer.Serialize(data, options));
}
public static void loadFile<T>(string fileName, ref T data, string extension = ".json") where T : new()
{
string path = Utils.Settings.Config.PluginFolderPath + "\\" + fileName + extension;
if (!File.Exists(path))
{
File.Create(path).Dispose();
}
string json = File.ReadAllText(path);
try
{
data = JsonSerializer.Deserialize<T>(json);
Log.Trace(fileName + " DB Populated");
}
catch
{
data = new T();
Log.Trace(fileName + " DB Created");
}
}
}
}
namespace ChatHistory
{
[BepInPlugin("ChatHistory", "ChatHistory", "1.1.0")]
public class Plugin : BasePlugin
{
private static Harmony harmony;
public override void Load()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
if (World.IsClient)
{
ChatHistory.Settings.Config.Load(((BasePlugin)this).Config, ((BasePlugin)this).Log, "Client");
((BasePlugin)this).AddComponent<KeyBindsBehaviour>();
harmony = new Harmony("ChatHistory");
Log.Trace("Patching harmony");
harmony.PatchAll();
Log.Info("Plugin ChatHistory v1.1.0 client side is loaded!");
}
}
public override bool Unload()
{
harmony.UnpatchSelf();
Log.Info("Plugin ChatHistory v1.1.0 client side is unloaded!");
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ChatHistory";
public const string PLUGIN_NAME = "ChatHistory";
public const string PLUGIN_VERSION = "1.1.0";
}
}
namespace ChatHistory.Systems
{
public class History
{
public static TMP_InputField InputField = null;
public static Graphic PlaceholderClone = null;
private static readonly List<string> _history = new List<string>();
private static bool _isFocused = false;
private static int _currentPosition = -1;
private static readonly string HistoryFilePath = Path.Combine(Paths.ConfigPath, "ChatHistory", "chat.history");
private static int _entryCounter = 0;
public static RTLTextMeshPro PlaceholderCloneRTLTextMeshPro => ((Component)PlaceholderClone).GetComponent<RTLTextMeshPro>();
private static int MaxHistorySize => ChatHistory.Settings.ENV.MaximumHistorySize.Value;
private static int TrimThreshold
{
get
{
if (ChatHistory.Settings.ENV.MaximumHistorySize.Value * 2 >= 100)
{
return ChatHistory.Settings.ENV.MaximumHistorySize.Value + 100;
}
return ChatHistory.Settings.ENV.MaximumHistorySize.Value * 2;
}
}
public static bool CanComplete()
{
return !string.IsNullOrEmpty(((TMP_Text)PlaceholderCloneRTLTextMeshPro).text.ToString());
}
public static void SetInputField(TMP_InputField inputField)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_00e0: 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_0113: Unknown result type (might be due to invalid IL or missing references)
if (!Cache.Exists("PlaceholderClone"))
{
PlaceholderClone = Object.Instantiate<Graphic>(inputField.placeholder);
((Component)PlaceholderClone).transform.SetParent(((Component)inputField.placeholder).transform.parent);
((Component)PlaceholderClone).transform.position = ((Component)inputField.placeholder).transform.position;
((Component)PlaceholderClone).transform.localPosition = ((Component)inputField.placeholder).transform.localPosition;
((Behaviour)PlaceholderClone).enabled = true;
((Component)inputField.placeholder).transform.SetParent(((Component)inputField.placeholder).transform.parent.parent);
((Component)inputField.placeholder).transform.localPosition = new Vector3(0f, ((Component)PlaceholderClone).transform.localPosition.y + 21f, ((Component)PlaceholderClone).transform.localPosition.z);
((Graphic)((Component)inputField.placeholder).GetComponent<RTLTextMeshPro>()).color = new Color(1f, 1f, 1f, 1f);
UnityAction<string> val = DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)new Action<string>(Prepend));
((UnityEvent<string>)(object)inputField.onSubmit).AddListener(val);
Cache.Key("PlaceholderClone");
}
SetPlaceHolderEmpty();
InputField = inputField;
}
public static void SetDefaultPlaceholder()
{
if (!((Object)(object)PlaceholderClone == (Object)null))
{
((Behaviour)PlaceholderClone).enabled = true;
}
}
public static void Reset()
{
((TMP_Text)PlaceholderCloneRTLTextMeshPro).text = "";
((Behaviour)InputField.placeholder).enabled = true;
_currentPosition = -1;
}
public static string GetHistory(int index)
{
if (_history.Count == 0 || index == -1)
{
return string.Empty;
}
if (index < 0)
{
index = 0;
}
else if (index >= _history.Count)
{
index = _history.Count - 1;
}
return _history[index];
}
public static string GetCurrentItem()
{
return GetHistory(_currentPosition);
}
public static List<string> SearchHistory(string prefix)
{
if (string.IsNullOrEmpty(prefix))
{
return _history.ToList();
}
return _history.Where((string item) => item.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)).ToList();
}
public static string FindAndNavigateHistory(string prefix, bool searchUp)
{
if (SearchHistory(prefix).Count == 0)
{
return string.Empty;
}
int num = (searchUp ? 1 : (-1));
int i = 0;
int currentPosition = _currentPosition;
for (; i < _history.Count; i++)
{
int num2 = _currentPosition + num;
if (searchUp && num2 >= _history.Count)
{
_currentPosition = currentPosition;
return string.Empty;
}
if (!searchUp && num2 < -1)
{
_currentPosition = -1;
return string.Empty;
}
_currentPosition = num2;
if (_currentPosition == -1)
{
return string.Empty;
}
string currentItem = GetCurrentItem();
if (currentItem.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && !string.Equals(currentItem, prefix, StringComparison.OrdinalIgnoreCase))
{
return currentItem;
}
}
_currentPosition = currentPosition;
return string.Empty;
}
public static string NavigateUp(string currentInput = "")
{
if (_history.Count == 0)
{
return string.Empty;
}
if (!string.IsNullOrEmpty(currentInput))
{
return FindAndNavigateHistory(currentInput, searchUp: true);
}
JumpCurrentPosition();
return GetCurrentItem();
}
public static string NavigateDown(string currentInput = "")
{
if (_history.Count == 0)
{
return string.Empty;
}
if (!string.IsNullOrEmpty(currentInput))
{
return FindAndNavigateHistory(currentInput, searchUp: false);
}
JumpCurrentPosition(-1);
return GetCurrentItem();
}
public static void SetPlaceHolderEmpty()
{
if (!((Object)(object)PlaceholderClone == (Object)null))
{
((TMP_Text)PlaceholderCloneRTLTextMeshPro).text = "";
((Behaviour)PlaceholderClone).enabled = false;
}
}
public static bool SetFocusState(bool state)
{
if (!state)
{
_currentPosition = -1;
SetPlaceHolderEmpty();
}
_isFocused = state;
return _isFocused;
}
public static bool IsFocused()
{
return _isFocused;
}
public static int JumpCurrentPosition(int jumps = 1)
{
int count = _history.Count;
if (count == 0)
{
_currentPosition = -1;
return _currentPosition;
}
_currentPosition += jumps;
if (_currentPosition >= count)
{
_currentPosition = count - 1;
}
else if (_currentPosition < 0)
{
_currentPosition = -1;
}
return _currentPosition;
}
public static void SetCurrentPosition(int position)
{
_currentPosition = position;
}
public static int GetCurrentPosition()
{
return _currentPosition;
}
public static void SaveHistoryEntry(string text)
{
try
{
string directoryName = Path.GetDirectoryName(HistoryFilePath);
if (!Directory.Exists(directoryName))
{
Directory.CreateDirectory(directoryName);
}
string value = Uri.EscapeDataString(text);
using (StreamWriter streamWriter = new StreamWriter(HistoryFilePath, append: true))
{
streamWriter.WriteLine(value);
}
CheckAndTrimIfNeeded();
}
catch (Exception ex)
{
Log.Error("Failed to save history entry: " + ex.Message);
}
}
private static void CheckAndTrimIfNeeded()
{
if (MaxHistorySize <= 0)
{
return;
}
_entryCounter++;
if (_entryCounter <= TrimThreshold)
{
return;
}
_entryCounter = _history.Count;
try
{
if (!File.Exists(HistoryFilePath))
{
return;
}
int num = 0;
using (StreamReader streamReader = new StreamReader(HistoryFilePath))
{
while (streamReader.ReadLine() != null)
{
num++;
if (num > TrimThreshold)
{
break;
}
}
}
if (num > TrimThreshold)
{
Log.Trace($"File exceeded threshold ({num} > {TrimThreshold}), trimming...");
string[] array = File.ReadAllLines(HistoryFilePath);
string[] array2 = array.Skip(array.Length - MaxHistorySize).ToArray();
File.WriteAllLines(HistoryFilePath, array2);
Log.Trace($"Trimmed history file from {array.Length} to {array2.Length} entries");
}
}
catch (Exception ex)
{
Log.Error("Failed to check/trim history file: " + ex.Message);
}
}
public static void LoadHistory()
{
try
{
_history.Clear();
if (!File.Exists(HistoryFilePath))
{
return;
}
string[] array = File.ReadAllLines(HistoryFilePath);
bool flag = array.Length > MaxHistorySize;
foreach (string item2 in array.Reverse())
{
try
{
string item = Uri.UnescapeDataString(item2);
_history.Add(item);
if (MaxHistorySize > 0 && _history.Count >= MaxHistorySize)
{
break;
}
}
catch
{
}
}
if (MaxHistorySize > 0 && flag)
{
string[] array2 = array.Skip(array.Length - MaxHistorySize).ToArray();
File.WriteAllLines(HistoryFilePath, array2);
Log.Trace($"Trimmed history file from {array.Length} to {array2.Length} entries");
}
}
catch (Exception ex)
{
Log.Error("Failed to load history: " + ex.Message);
}
}
public static void Prepend(string text)
{
if (!string.IsNullOrEmpty(text) && (_history.Count <= 0 || !(_history[0] == text)))
{
_history.Insert(0, text);
if (MaxHistorySize > 0 && _history.Count > MaxHistorySize)
{
_history.RemoveAt(_history.Count - 1);
}
if (ChatHistory.Settings.ENV.PersistOnRestart.Value)
{
SaveHistoryEntry(text);
}
}
}
public static void Initialize()
{
if (ChatHistory.Settings.ENV.PersistOnRestart.Value)
{
DateTime now = DateTime.Now;
Log.Trace("Loading history from " + HistoryFilePath);
LoadHistory();
_entryCounter = _history.Count;
double totalMilliseconds = (DateTime.Now - now).TotalMilliseconds;
string value = ((MaxHistorySize > 0) ? MaxHistorySize.ToString() : "∞");
Log.Trace($"Loaded history with {_entryCounter} entries in {totalMilliseconds:F2}ms. Will trim if it exceeds {value} entries.");
}
}
}
public class KeyBindsBehaviour : MonoBehaviour
{
public KeyBindsBehaviour(IntPtr handle)
: base(handle)
{
}
public void Start()
{
History.Initialize();
}
public void Update()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)History.InputField != (Object)null)
{
((Behaviour)History.InputField.placeholder).enabled = true;
}
if (History.IsFocused())
{
if (Input.GetKeyDown(ChatHistory.Settings.ENV.DownHistoryKey.Value))
{
HistoryDown();
}
if (Input.GetKeyDown(ChatHistory.Settings.ENV.UpHistoryKey.Value))
{
HistoryUp();
}
if (Input.GetKeyDown(ChatHistory.Settings.ENV.CompleteHistoryKey.Value))
{
HistoryComplete();
}
}
}
private static void HistoryComplete()
{
if (History.CanComplete())
{
History.InputField.text = ((TMP_Text)History.PlaceholderCloneRTLTextMeshPro).text.ToString();
History.InputField.stringPosition = History.InputField.text.Length;
((Behaviour)History.PlaceholderClone).enabled = false;
((TMP_Text)History.PlaceholderCloneRTLTextMeshPro).text = "";
}
}
private static void HistoryUp()
{
string text = History.InputField.text;
string text2 = History.NavigateUp(text);
if (string.IsNullOrEmpty(text2))
{
History.InputField.stringPosition = text.Length;
return;
}
((Behaviour)History.PlaceholderClone).enabled = true;
((TMP_Text)History.PlaceholderCloneRTLTextMeshPro).text = text2;
History.InputField.stringPosition = text.Length;
}
private static void HistoryDown()
{
string text = History.InputField.text;
string text2 = History.NavigateDown(text);
if (string.IsNullOrEmpty(text2))
{
History.SetPlaceHolderEmpty();
return;
}
((Behaviour)History.PlaceholderClone).enabled = true;
((TMP_Text)History.PlaceholderCloneRTLTextMeshPro).text = text2;
History.InputField.stringPosition = text.Length;
}
}
}
namespace ChatHistory.Settings
{
public class Config
{
public static void Load(ConfigFile configFile, ManualLogSource logger, string worldType)
{
ENV.Testing.Setup();
Utils.Settings.Config.Setup("ChatHistory", configFile, 4);
Utils.Settings.Config.Load();
Utils.Logger.Config.Setup(logger, worldType);
}
}
public static class ENV
{
public static class Testing
{
public static void Setup()
{
Utils.Settings.Config.AddConfigActions(load);
}
private static void load()
{
MaximumHistorySize = Utils.Settings.Config.Bind(settings, "MaximumHistorySize", 50, "The maximum number of messages to keep in the chat history. If the number of messages exceeds this value, the oldest messages will be removed. If set to <= 0, the history will not be limited (use with caution).");
PersistOnRestart = Utils.Settings.Config.Bind(settings, "PersistOnRestart", defaultValue: true, "If true, the chat history will be saved and loaded on restart. If false, the chat history will be lost on restart.");
DownHistoryKey = Utils.Settings.Config.Bind<KeyCode>(settings, "DownHistoryKey", (KeyCode)274, "Down Arrow Key to scroll down the chat history.");
UpHistoryKey = Utils.Settings.Config.Bind<KeyCode>(settings, "UpHistoryKey", (KeyCode)273, "Up Arrow Key to scroll up the chat history.");
CompleteHistoryKey = Utils.Settings.Config.Bind<KeyCode>(settings, "CompleteHistoryKey", (KeyCode)275, "The key to complete the current chat message.");
Utils.Settings.Config.Save();
}
}
private static readonly string settings = "0.⚙\ufe0f Settings";
public static ConfigElement<KeyCode> DownHistoryKey { get; set; }
public static ConfigElement<KeyCode> UpHistoryKey { get; set; }
public static ConfigElement<KeyCode> CompleteHistoryKey { get; set; }
public static ConfigElement<int> MaximumHistorySize { get; set; }
public static ConfigElement<bool> PersistOnRestart { get; set; }
}
}
namespace ChatHistory.Hooks
{
[Harmony]
public class ClientBootstrapSystemPatch
{
[HarmonyPatch(typeof(ClientBootstrapSystem), "OnDestroy")]
public class OnDestroy
{
public static void Postfix()
{
try
{
World.UnPatch();
Cache.Clear();
}
catch (Exception data)
{
Log.Fatal(data);
}
}
}
}
[Harmony]
public class ClientChatSystemPatch
{
[HarmonyPatch(typeof(ClientChatSystem), "_OnInputChanged")]
public class OnInputChanged
{
public static void Prefix()
{
History.Reset();
}
}
[HarmonyPatch(typeof(ClientChatSystem), "_OnInputSelect")]
public class OnInputSelect
{
public static void Prefix(ClientChatSystem __instance)
{
History.SetInputField(__instance._ChatWindow.ChatInputField);
History.SetFocusState(state: true);
}
}
[HarmonyPatch(typeof(ClientChatSystem), "_OnInputDeselect")]
public class OnInputDeselect
{
public static void Prefix()
{
History.SetFocusState(state: false);
}
}
[HarmonyPatch(typeof(ClientChatSystem), "OnInputFocusLoss")]
public class OnInputFocusLoss
{
public static void Prefix()
{
History.SetFocusState(state: false);
}
}
}
}