using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 CoffinSleep.Settings;
using CoffinSleep.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 Stunlock.Core;
using Stunlock.Localization;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
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 CoffinSleep
{
[BepInPlugin("CoffinSleep", "CoffinSleep", "2.0.4")]
public class Plugin : BasePlugin
{
public override void Load()
{
if (World.IsServer)
{
Server.Load(((BasePlugin)this).Config, ((BasePlugin)this).Log);
}
if (World.IsClient)
{
Client.Load(((BasePlugin)this).Config, ((BasePlugin)this).Log);
}
}
public override bool Unload()
{
if (World.IsServer)
{
Server.Unload();
}
if (World.IsClient)
{
Client.Unload();
}
return false;
}
}
public static class Server
{
public static Harmony harmony;
internal static void Load(ConfigFile config, ManualLogSource logger)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
CoffinSleep.Settings.Config.Load(config, logger, "Server");
harmony = new Harmony("CoffinSleep");
Log.Trace("Patching harmony");
harmony.PatchAll();
Log.Info("Plugin CoffinSleep v2.0.4 server side is loaded!");
}
internal static bool Unload()
{
harmony.UnpatchSelf();
Log.Info("Plugin CoffinSleep v2.0.4 server side is unloaded!");
return true;
}
}
internal static class Client
{
public static Harmony harmony;
internal static void Load(ConfigFile config, ManualLogSource logger)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
CoffinSleep.Settings.Config.Load(config, logger, "Client");
harmony = new Harmony("CoffinSleep");
Log.Trace("Patching harmony");
harmony.PatchAll();
Log.Info("Plugin CoffinSleep v2.0.4 client side is loaded!");
}
internal static bool Unload()
{
harmony.UnpatchSelf();
Log.Info("Plugin CoffinSleep v2.0.4 client side is unloaded!");
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CoffinSleep";
public const string PLUGIN_NAME = "CoffinSleep";
public const string PLUGIN_VERSION = "2.0.4";
}
}
namespace CoffinSleep.Systems
{
public static class RotationCycle
{
private static int transitionControl = 3;
public static void IncreaseTime(params Action<int>[] actions)
{
//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_0012: 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_002f: 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)
DayNightCycle singleton = DayNightCycle.GetSingleton();
if ((CoffinSleep.Settings.ENV.OnlyDayTimeSleep.Value && !DayNightCycle.IsDay(singleton)) || (CoffinSleep.Settings.ENV.SleepBloodMoon.Value && DayNightCycle.IsBloodMoonDay(singleton) && !DayNightCycle.IsDay(singleton)) || User.IsAllOffline() || (CoffinSleep.Settings.ENV.OnlyAllPlayersSleeping.Value && !PlayerCharacter.IsAllOnlinePlayersSleeping()) || Cache.IsBlocked("speed", 1000L))
{
return;
}
int modifier = CoffinSleep.Settings.ENV.IncreasedTime.Value;
if (CoffinSleep.Settings.ENV.PauseDuringTransitions.Value && !CoffinSleep.Settings.ENV.OnlyDayTimeSleep.Value)
{
handleModifier(ref modifier, singleton);
}
if (modifier != 0)
{
for (int i = 0; i < actions.Length; i++)
{
actions[i](modifier);
}
SetTimeOfDayEvent.Add(modifier);
}
}
private static void handleModifier(ref int modifier, DayNightCycle dnc)
{
//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_001c: 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_002d: 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)
//IL_004e: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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)
float timeSinceDayStart = DayNightCycle.GetTimeSinceDayStart(dnc);
if (inTransition(timeSinceDayStart, dnc))
{
modifier = 0;
return;
}
int num = transitionControl * 2;
float dayDurationInSeconds = DayNightCycle.GetDayDurationInSeconds(dnc);
float dayTimeDurationInSeconds = DayNightCycle.GetDayTimeDurationInSeconds(dnc);
float num2 = (float)modifier * DayNightCycle.GetTimeScale(dnc).TimePerMinute;
if (num2 > dayDurationInSeconds)
{
num2 = dayDurationInSeconds;
}
float num3 = timeSinceDayStart + num2;
if (num3 > dayDurationInSeconds && !DayNightCycle.IsDay(dnc))
{
num2 = dayDurationInSeconds - timeSinceDayStart - (float)num;
}
else if (num3 > dayDurationInSeconds && DayNightCycle.IsDay(dnc))
{
num2 = dayTimeDurationInSeconds - timeSinceDayStart - (float)num;
}
else if (num3 > dayTimeDurationInSeconds && DayNightCycle.IsDay(dnc))
{
num2 = dayTimeDurationInSeconds - timeSinceDayStart - (float)num;
}
modifier = (int)(num2 / DayNightCycle.GetTimeScale(dnc).TimePerMinute);
if (modifier < 0)
{
modifier = 0;
}
}
private static bool inTransition(float gameDayTime, DayNightCycle dnc)
{
//IL_0001: 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)
if (inNightToDayTransition(gameDayTime, dnc))
{
return true;
}
if (inDayToNightTransition(gameDayTime, dnc))
{
return true;
}
return false;
}
private static bool inNightToDayTransition(float gameDayTime, DayNightCycle dnc)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
float dayDurationInSeconds = DayNightCycle.GetDayDurationInSeconds(dnc);
if (gameDayTime >= dayDurationInSeconds - (float)transitionControl && gameDayTime <= (float)transitionControl)
{
return true;
}
return false;
}
private static bool inDayToNightTransition(float gameDayTime, DayNightCycle dnc)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
float dayTimeDurationInSeconds = DayNightCycle.GetDayTimeDurationInSeconds(dnc);
if (gameDayTime >= dayTimeDurationInSeconds - (float)transitionControl && gameDayTime <= dayTimeDurationInSeconds + (float)transitionControl)
{
return true;
}
return false;
}
}
}
namespace CoffinSleep.Settings
{
public class Config
{
public static void Load(ConfigFile configFile, ManualLogSource logger, string worldType)
{
ENV.Server.Setup();
Utils.Settings.Config.Setup("CoffinSleep", configFile, 4);
Utils.Settings.Config.Load();
Utils.Logger.Config.Setup(logger, worldType);
}
}
public class ENV
{
public class Server
{
private static string serverSection = "\ud83d\udd27Server";
public static void Setup()
{
Utils.Settings.Config.AddConfigActions(load);
}
public static void load()
{
IncreasedTime = Utils.Settings.Config.Bind(serverSection, "IncreasedTime", 1, "Change the increased game time in hours per real time second");
OnlyDayTimeSleep = Utils.Settings.Config.Bind(serverSection, "OnlyDayTimeSleep", defaultValue: true, "Enabled, sleep just speeds the time when it's daytime");
OnlyAllPlayersSleeping = Utils.Settings.Config.Bind(serverSection, "OnlyAllPlayersSleeping", defaultValue: true, "Enabled, sleep just speeds the time if all players of the server are sleeping");
PauseDuringTransitions = Utils.Settings.Config.Bind(serverSection, "PauseDuringTransitions", defaultValue: true, "Enabled, will stop time speed during the day and night transitions");
SleepBloodMoon = Utils.Settings.Config.Bind(serverSection, "SleepBloodMoon", defaultValue: false, "Enabled, will stop time speed during blood moon nights");
}
}
public static ConfigElement<int> IncreasedTime;
public static ConfigElement<bool> OnlyDayTimeSleep;
public static ConfigElement<bool> OnlyAllPlayersSleeping;
public static ConfigElement<bool> PauseDuringTransitions;
public static ConfigElement<bool> SleepBloodMoon;
}
}
namespace CoffinSleep.Hooks
{
[HarmonyPatch]
public class SleepInsideSystemPatch
{
[HarmonyPatch(typeof(SleepInsideSystem), "OnCreate")]
public static class OnCreate
{
private static void Prefix(SleepInsideSystem __instance)
{
}
}
[HarmonyPatch(typeof(SleepInsideSystem), "OnUpdate")]
public static class OnUpdate
{
private static void Prefix(SleepInsideSystem __instance)
{
try
{
RotationCycle.IncreaseTime();
}
catch (Exception data)
{
Log.Fatal(data);
}
}
}
}
}