Decompiled source of BetterMissions v2.0.1

vrising-utils.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using Il2CppSystem.Collections.Generic;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Network;
using ProjectM.Scripting;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Utils.VRising.Entities;
using Utils.VRising.Systems;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("caioreix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("6.0.0.0")]
[assembly: AssemblyInformationalVersion("6.0.0-be.691-v.2")]
[assembly: AssemblyProduct("vrising-utils")]
[assembly: AssemblyTitle("vrising-utils")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/caioreix/vrising-utils")]
[assembly: AssemblyVersion("6.0.0.0")]
namespace Utils.VRising.Systems
{
	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_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_001c: 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)
			EntityQuery val = ((EntityManager)(ref World.em)).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_0005: 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)
			return ((EntityManager)(ref World.em)).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)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return ServerScriptMapper.Get()._DayNightCycleAccessor.GetSingleton();
		}

		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 PlayerCharacter
	{
		public static NativeArray<Entity> GetAll()
		{
			//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_001c: 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)
			EntityQuery val = ((EntityManager)(ref World.em)).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_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_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)
			PlayerCharacter componentData = ((EntityManager)(ref World.em)).GetComponentData<PlayerCharacter>(playerCharacter);
			return ((EntityManager)(ref World.em)).GetComponentData<User>(componentData.UserEntity).IsConnected;
		}

		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_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_001c: 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)
			EntityQuery val = ((EntityManager)(ref World.em)).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_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)
			return ((EntityManager)(ref World.em)).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_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)
			((EntityManager)(ref World.em)).SetComponentData<ServantCoffinstation>(coffinStationEntity, coffinStation);
		}
	}
	public static class ServantMissionSetting
	{
		public static NativeArray<Entity> GetAll()
		{
			//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_001c: 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)
			EntityQuery val = ((EntityManager)(ref World.em)).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_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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<Entity> enumerator = GetAll().GetEnumerator();
			if (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				return ((EntityManager)(ref World.em)).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_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_001c: 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_0025: 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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Entity val = ((EntityManager)(ref World.em)).CreateEntity((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<SetTimeOfDayEvent>() });
			((EntityManager)(ref World.em)).SetComponentData<SetTimeOfDayEvent>(val, new SetTimeOfDayEvent
			{
				Hour = hour,
				Day = day,
				Type = type
			});
		}
	}
	public static class Sleeping
	{
		public static NativeArray<Entity> GetAll()
		{
			//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_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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//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_0038: 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)
			EntityQuery val = ((EntityManager)(ref World.em)).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_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_0022: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<Entity> enumerator = sleepingEntities.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				if (((EntityManager)(ref World.em)).GetComponentData<Buff>(current).Target == target)
				{
					return true;
				}
			}
			return false;
		}
	}
	public static class User
	{
		public static NativeArray<Entity> GetAll()
		{
			//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_001c: 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)
			EntityQuery val = ((EntityManager)(ref World.em)).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_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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<Entity> enumerator = GetAll().GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				if (((EntityManager)(ref World.em)).GetComponentData<User>(current).IsConnected)
				{
					return current;
				}
			}
			return Entity.Null;
		}

		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_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)
			Enumerator<Entity> enumerator = GetAll().GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				if (((EntityManager)(ref World.em)).GetComponentData<User>(current).IsConnected)
				{
					return false;
				}
			}
			return true;
		}
	}
	public static class World
	{
		internal static World _world;

		internal static EntityManager em = world.EntityManager;

		public static World world
		{
			get
			{
				if (_world != null)
				{
					return _world;
				}
				Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
				while (enumerator.MoveNext())
				{
					World current = enumerator.Current;
					if (current.Name == "Server" || current.Name == "Client")
					{
						_world = current;
					}
				}
				return _world;
			}
		}

		public static void Set(World world)
		{
			_world = world;
		}
	}
}

bepinex-utils.dll

Decompiled 5 months ago
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.Versioning;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Utils.Logger;
using Utils.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("caioreix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("6.0.0.0")]
[assembly: AssemblyInformationalVersion("6.0.0-be.691-v.3")]
[assembly: AssemblyProduct("bepinex-utils")]
[assembly: AssemblyTitle("bepinex-utils")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/caioreix/bepinex-utils")]
[assembly: AssemblyVersion("6.0.0.0")]
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 ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description)
		{
			return cfg.Bind<T>(section, key, defaultValue, description);
		}

		public static void Save()
		{
			cfg.Save();
		}

		public static void Setup(string pluginGUID, ConfigFile config, params Action[] actions)
		{
			PluginGUID = pluginGUID;
			cfg = config;
			PluginFolderPath = Paths.ConfigPath + "\\" + PluginGUID;
			if (!Directory.Exists(PluginFolderPath))
			{
				Directory.CreateDirectory(PluginFolderPath);
			}
			ENV.Debug.Setup();
			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 static class ENV
	{
		public class Debug
		{
			private static string debugSection = "\ud83e\udeb2Debug";

			private static ConfigEntry<bool> DebugLogOnTempFile;

			private static ConfigEntry<bool> DebugEnableTraceLogs;

			public static void Setup()
			{
				Config.AddConfigActions(delegate
				{
					load();
				});
			}

			private static void load()
			{
				if (enableDebugConfigs())
				{
					DebugLogOnTempFile = Config.cfg.Bind<bool>(debugSection, "LogOnTempFile", false, "Enabled, will log every plugin log on a temp file");
					DebugEnableTraceLogs = Config.cfg.Bind<bool>(debugSection, "EnableTraceLogs", 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()
			{
				return typeof(Debug).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;
			tempLogFile = $"{Utils.Settings.Config.PluginFolderPath}\\{Utils.Settings.Config.PluginGUID}-{worldType}.txt";
			Log.Start("Using \"" + tempLogFile + "\" to save logs.");
		}

		public static void TestSetup()
		{
		}

		internal static void logFile(object data, string level, string prefix = "")
		{
			if (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 (ENV.EnableTraceLogs)
			{
				Config.logger.LogDebug(data);
				Config.logFile(data, "Trace:  ");
			}
		}

		public static void Struct<T>(T data)
		{
			if (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 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");
			}
		}
	}
}

BetterMissions.dll

Decompiled 5 months ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json.Serialization;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BetterMissions.Database;
using BetterMissions.Settings;
using BetterMissions.Systems;
using Bloodstone.API;
using HarmonyLib;
using ProjectM;
using ProjectM.Shared.Systems;
using Unity.Entities;
using Utils.Database;
using Utils.Logger;
using Utils.Settings;
using Utils.VRising.Entities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("caioreix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("An VRising mod to do a better control of the servant missions.")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1+1.Branch.main.Sha.110586c46921608affdefdcc65e789f831381800")]
[assembly: AssemblyProduct("BetterMissions")]
[assembly: AssemblyTitle("BetterMissions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.1.0")]
[module: UnverifiableCode]
namespace BetterMissions
{
	[BepInPlugin("BetterMissions", "BetterMissions", "2.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		public override void Load()
		{
			if (VWorld.IsServer)
			{
				Server.Load(((BasePlugin)this).Config, ((BasePlugin)this).Log);
			}
			if (VWorld.IsClient)
			{
				Client.Load(((BasePlugin)this).Config, ((BasePlugin)this).Log);
			}
		}

		public override bool Unload()
		{
			if (VWorld.IsServer)
			{
				Server.Unload();
			}
			if (VWorld.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
			Config.Load(config, logger, "Server");
			harmony = new Harmony("BetterMissions");
			Log.Trace((object)"Patching harmony");
			harmony.PatchAll();
			Log.Info((object)"Plugin BetterMissions v2.0.1 server side is loaded!");
		}

		internal static bool Unload()
		{
			harmony.UnpatchSelf();
			Log.Info((object)"Plugin BetterMissions v2.0.1 server side is unloaded!");
			return true;
		}
	}
	internal static class Client
	{
		internal static void Load(ConfigFile config, ManualLogSource logger)
		{
			Config.Load(config, logger, "Client");
			Log.Info((object)"Plugin BetterMissions v2.0.1 client side is loaded!");
		}

		internal static void Unload()
		{
			Log.Info((object)"Plugin BetterMissions v2.0.1 client side is unloaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BetterMissions";

		public const string PLUGIN_NAME = "BetterMissions";

		public const string PLUGIN_VERSION = "2.0.1";
	}
}
namespace BetterMissions.Systems
{
	public static class Mission
	{
		public static void Setup()
		{
			DB.AddCleanActions(Array.Empty<Action>());
		}

		public static bool ApplyModifiers()
		{
			//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_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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			DynamicBuffer<ServantMissionSetting> buffer = ServantMissionSetting.GetBuffer();
			if (!buffer.IsCreated)
			{
				return false;
			}
			for (int i = 0; i < buffer.Length; i++)
			{
				ServantMissionSetting val = buffer[i];
				string missionSettingsKey = getMissionSettingsKey(val.MissionLength);
				if (BetterMissions.Database.Mission.Settings.TryGetValue(missionSettingsKey, out var value))
				{
					val.MissionLength = value.MissionLength;
					val.SuccessRateBonus = value.SuccessRateBonus;
					val.InjuryChance = value.InjuryChance;
					val.LootFactor = value.LootFactor;
				}
				else
				{
					val.MissionLength /= ENV.MissionLengthModifier.Value;
					val.SuccessRateBonus /= ENV.MissionSuccessRateBonusModifier.Value;
					val.InjuryChance /= ENV.MissionInjuryChanceModifier.Value;
					val.LootFactor /= ENV.MissionLootFactorModifier.Value;
				}
				buffer[i] = val;
			}
			Log.Trace((object)"Mission modifiers applied");
			return true;
		}

		private static string getMissionSettingsKey(float missionLength)
		{
			if (missionLength <= 14400f)
			{
				if (missionLength == 7200f)
				{
					return "Reckless_1";
				}
				if (missionLength == 14400f)
				{
					return "Reckless_2";
				}
			}
			else
			{
				if (missionLength == 28800f)
				{
					return "Normal_1";
				}
				if (missionLength == 57600f)
				{
					return "Prepared_1";
				}
				if (missionLength == 82800f)
				{
					return "Prepared_2";
				}
			}
			return "";
		}
	}
}
namespace BetterMissions.Settings
{
	public class Config
	{
		public static void Load(ConfigFile configFile, ManualLogSource logger, string worldType)
		{
			ENV.Mission.Setup();
			Config.Setup("BetterMissions", configFile, Array.Empty<Action>());
			Config.Load();
			Config.Setup(logger, worldType);
		}
	}
	public static class ENV
	{
		public static class Mission
		{
			public static void Setup()
			{
				Config.AddConfigActions(new Action[1] { load });
			}

			private static void load()
			{
				MissionLengthModifier = Config.Bind<float>(missionGeneral, "MissionLengthModifier", 2f, "Define the mission length modifier. (MissionLength / modifier)");
				MissionSuccessRateBonusModifier = Config.Bind<float>(missionGeneral, "MissionSuccessRateBonusModifier", 1f, "Define the mission success rate bonus modifier. (MissionSuccessRateBonus / modifier)");
				MissionInjuryChanceModifier = Config.Bind<float>(missionGeneral, "MissionInjuryChanceModifier", 1f, "Define the mission injury chance bonus modifier. (MissionInjuryChance / modifier)");
				MissionLootFactorModifier = Config.Bind<float>(missionGeneral, "MissionLootFactorModifier", 1f, "Define the mission loot factor bonus modifier. (MissionLootFactor / modifier)");
				EnableReckless1Settings = Config.Bind<bool>(missionReckless1, "EnableReckless1Settings", false, "Enabled, will use the specific mission level settings");
				Reckless1MissionLength = Config.Bind<float>(missionReckless1, "Reckless1MissionLength", 7200f, "Define the Reckless1 mission length in seconds.");
				Reckless1MissionSuccessRateBonus = Config.Bind<float>(missionReckless1, "Reckless1MissionSuccessRateBonus", -0.2f, "Define the Reckless1 mission success rate bonus.");
				Reckless1MissionInjuryChance = Config.Bind<float>(missionReckless1, "Reckless1MissionInjuryChance", 0.3f, "Define the Reckless1 mission injury chance bonus.");
				Reckless1MissionLootFactor = Config.Bind<float>(missionReckless1, "Reckless1MissionLootFactor", 0.5f, "Define the Reckless1 mission loot factor bonus.");
				EnableReckless2Settings = Config.Bind<bool>(missionReckless2, "EnableReckless2Settings", false, "Enabled, will use the specific mission level settings");
				Reckless2MissionLength = Config.Bind<float>(missionReckless2, "Reckless2MissionLength", 1440f, "Define the Reckless2 mission length in seconds.");
				Reckless2MissionSuccessRateBonus = Config.Bind<float>(missionReckless2, "Reckless2MissionSuccessRateBonus", -0.1f, "Define the Reckless2 mission success rate bonus.");
				Reckless2MissionInjuryChance = Config.Bind<float>(missionReckless2, "Reckless2MissionInjuryChance", 0.3f, "Define the Reckless2 mission injury chance bonus.");
				Reckless2MissionLootFactor = Config.Bind<float>(missionReckless2, "Reckless2MissionLootFactor", 0.75f, "Define the Reckless2 mission loot factor bonus.");
				EnableNormal1Settings = Config.Bind<bool>(missionNormal1, "EnableNormal1Settings", false, "Enabled, will use the specific mission level settings");
				Normal1MissionLength = Config.Bind<float>(missionNormal1, "Normal1MissionLength", 28800f, "Define the Normal1 mission length in seconds.");
				Normal1MissionSuccessRateBonus = Config.Bind<float>(missionNormal1, "Normal1MissionSuccessRateBonus", 0f, "Define the Normal1 mission success rate bonus.");
				Normal1MissionInjuryChance = Config.Bind<float>(missionNormal1, "Normal1MissionInjuryChance", 0.25f, "Define the Normal1 mission injury chance bonus.");
				Normal1MissionLootFactor = Config.Bind<float>(missionNormal1, "Normal1MissionLootFactor", 1f, "Define the Normal1 mission loot factor bonus.");
				EnablePrepared1Settings = Config.Bind<bool>(missionPrepared1, "EnablePrepared1Settings", false, "Enabled, will use the specific mission level settings");
				Prepared1MissionLength = Config.Bind<float>(missionPrepared1, "Prepared1MissionLength", 57600f, "Define the Prepared1 mission length in seconds.");
				Prepared1MissionSuccessRateBonus = Config.Bind<float>(missionPrepared1, "Prepared1MissionSuccessRateBonus", 0.1f, "Define the Prepared1 mission success rate bonus.");
				Prepared1MissionInjuryChance = Config.Bind<float>(missionPrepared1, "Prepared1MissionInjuryChance", 0.2f, "Define the Prepared1 mission injury chance bonus.");
				Prepared1MissionLootFactor = Config.Bind<float>(missionPrepared1, "Prepared1MissionLootFactor", 1.25f, "Define the Prepared1 mission loot factor bonus.");
				EnablePrepared2Settings = Config.Bind<bool>(missionPrepared2, "EnablePrepared2Settings", false, "Enabled, will use the specific mission level settings");
				Prepared2MissionLength = Config.Bind<float>(missionPrepared2, "Prepared2MissionLength", 82800f, "Define the Prepared2 mission length in seconds.");
				Prepared2MissionSuccessRateBonus = Config.Bind<float>(missionPrepared2, "Prepared2MissionSuccessRateBonus", 0.2f, "Define the Prepared2 mission success rate bonus.");
				Prepared2MissionInjuryChance = Config.Bind<float>(missionPrepared2, "Prepared2MissionInjuryChance", 0.2f, "Define the Prepared2 mission injury chance bonus.");
				Prepared2MissionLootFactor = Config.Bind<float>(missionPrepared2, "Prepared2MissionLootFactor", 1.5f, "Define the Prepared2 mission loot factor bonus.");
				validateValues();
			}

			private static void validateValues()
			{
				if (EnableReckless1Settings.Value)
				{
					BetterMissions.Database.Mission.Settings.TryAdd("Reckless_1", new BetterMissions.Database.Mission.Setting
					{
						InjuryChance = Reckless1MissionInjuryChance.Value,
						LootFactor = Reckless1MissionLootFactor.Value,
						MissionLength = Reckless1MissionLength.Value,
						SuccessRateBonus = Reckless1MissionSuccessRateBonus.Value
					});
				}
				if (EnableReckless2Settings.Value)
				{
					BetterMissions.Database.Mission.Settings.TryAdd("Reckless_2", new BetterMissions.Database.Mission.Setting
					{
						InjuryChance = Reckless2MissionInjuryChance.Value,
						LootFactor = Reckless2MissionLootFactor.Value,
						MissionLength = Reckless2MissionLength.Value,
						SuccessRateBonus = Reckless2MissionSuccessRateBonus.Value
					});
				}
				if (EnableNormal1Settings.Value)
				{
					BetterMissions.Database.Mission.Settings.TryAdd("Normal_1", new BetterMissions.Database.Mission.Setting
					{
						InjuryChance = Normal1MissionInjuryChance.Value,
						LootFactor = Normal1MissionLootFactor.Value,
						MissionLength = Normal1MissionLength.Value,
						SuccessRateBonus = Normal1MissionSuccessRateBonus.Value
					});
				}
				if (EnablePrepared1Settings.Value)
				{
					BetterMissions.Database.Mission.Settings.TryAdd("Prepared_1", new BetterMissions.Database.Mission.Setting
					{
						InjuryChance = Prepared1MissionInjuryChance.Value,
						LootFactor = Prepared1MissionLootFactor.Value,
						MissionLength = Prepared1MissionLength.Value,
						SuccessRateBonus = Prepared1MissionSuccessRateBonus.Value
					});
				}
				if (EnablePrepared2Settings.Value)
				{
					BetterMissions.Database.Mission.Settings.TryAdd("Prepared_2", new BetterMissions.Database.Mission.Setting
					{
						InjuryChance = Prepared2MissionInjuryChance.Value,
						LootFactor = Prepared2MissionLootFactor.Value,
						MissionLength = Prepared2MissionLength.Value,
						SuccessRateBonus = Prepared2MissionSuccessRateBonus.Value
					});
				}
				Config.Save();
			}
		}

		private static string missionGeneral = "0.\ud83d\udea9 Mission";

		public static ConfigEntry<float> MissionLengthModifier;

		public static ConfigEntry<float> MissionSuccessRateBonusModifier;

		public static ConfigEntry<float> MissionInjuryChanceModifier;

		public static ConfigEntry<float> MissionLootFactorModifier;

		private static string missionReckless1 = "1.\ud83d\udea9 Mission-Reckless-1";

		private static ConfigEntry<bool> EnableReckless1Settings;

		private static ConfigEntry<float> Reckless1MissionLength;

		private static ConfigEntry<float> Reckless1MissionSuccessRateBonus;

		private static ConfigEntry<float> Reckless1MissionInjuryChance;

		private static ConfigEntry<float> Reckless1MissionLootFactor;

		private static string missionReckless2 = "2.\ud83d\udea9 Mission-Reckless-2";

		private static ConfigEntry<bool> EnableReckless2Settings;

		private static ConfigEntry<float> Reckless2MissionLength;

		private static ConfigEntry<float> Reckless2MissionSuccessRateBonus;

		private static ConfigEntry<float> Reckless2MissionInjuryChance;

		private static ConfigEntry<float> Reckless2MissionLootFactor;

		private static string missionNormal1 = "3.\ud83d\udea9 Mission-Normal";

		private static ConfigEntry<bool> EnableNormal1Settings;

		private static ConfigEntry<float> Normal1MissionLength;

		private static ConfigEntry<float> Normal1MissionSuccessRateBonus;

		private static ConfigEntry<float> Normal1MissionInjuryChance;

		private static ConfigEntry<float> Normal1MissionLootFactor;

		private static string missionPrepared1 = "4.\ud83d\udea9 Mission-Prepared-1";

		private static ConfigEntry<bool> EnablePrepared1Settings;

		private static ConfigEntry<float> Prepared1MissionLength;

		private static ConfigEntry<float> Prepared1MissionSuccessRateBonus;

		private static ConfigEntry<float> Prepared1MissionInjuryChance;

		private static ConfigEntry<float> Prepared1MissionLootFactor;

		private static string missionPrepared2 = "5.\ud83d\udea9 Mission-Prepared-2";

		private static ConfigEntry<bool> EnablePrepared2Settings;

		private static ConfigEntry<float> Prepared2MissionLength;

		private static ConfigEntry<float> Prepared2MissionSuccessRateBonus;

		private static ConfigEntry<float> Prepared2MissionInjuryChance;

		private static ConfigEntry<float> Prepared2MissionLootFactor;
	}
}
namespace BetterMissions.Hooks
{
	[HarmonyPatch]
	public class GameBootstrapPatch
	{
		[HarmonyPatch(typeof(GameBootstrap), "OnApplicationQuit")]
		public class OnApplicationQuit
		{
			public static void Prefix()
			{
			}
		}
	}
	[HarmonyPatch]
	public class ServantMissionUpdateSystemPatch
	{
		[HarmonyPatch(typeof(ServantMissionUpdateSystem), "OnCreate")]
		public static class OnCreate
		{
			public static void Prefix(ServantMissionUpdateSystem __instance)
			{
				try
				{
					if (VWorld.IsClient)
					{
						World.Set(VWorld.Client);
					}
					if (VWorld.IsServer)
					{
						World.Set(VWorld.Server);
					}
				}
				catch (Exception ex)
				{
					Log.Fatal((object)ex);
				}
			}
		}

		[HarmonyPatch(typeof(ServantMissionUpdateSystem), "OnUpdate")]
		public static class OnUpdate
		{
			public static void Prefix(ServantMissionUpdateSystem __instance)
			{
				try
				{
					if (!Cache.Exists("ApplyModifiers"))
					{
						Cache.Key("ApplyModifiers", BetterMissions.Systems.Mission.ApplyModifiers());
					}
				}
				catch (Exception ex)
				{
					Log.Fatal((object)ex);
				}
			}
		}

		[HarmonyPatch(typeof(ServantMissionUpdateSystem), "OnDestroy")]
		public static class OnDestroy
		{
			public static void Prefix(ServantMissionUpdateSystem __instance)
			{
			}
		}
	}
	[HarmonyPatch]
	public class TriggerPersistenceSaveSystemPatch
	{
		[HarmonyPatch(typeof(TriggerPersistenceSaveSystem), "TriggerSave")]
		public class TriggerSave
		{
			public static void Prefix()
			{
			}
		}
	}
}
namespace BetterMissions.Database
{
	public static class LocalDB
	{
		public static void Load()
		{
			DB.Load();
		}

		public static void Save()
		{
			DB.Clean();
			DB.Save();
		}

		public static void Clean()
		{
			DB.Clean();
		}
	}
	public static class Mission
	{
		public struct Progress
		{
			[JsonIgnore]
			public bool Synced;

			public long EndTimestamp { get; set; }
		}

		public struct Setting
		{
			public float SuccessRateBonus { get; set; }

			public float MissionLength { get; set; }

			public float InjuryChance { get; set; }

			public float LootFactor { get; set; }
		}

		private static string category = "Mission";

		public static ConcurrentDictionary<string, Progress> Progresses;

		public static Dictionary<string, Setting> Settings = new Dictionary<string, Setting>();

		public static void Setup()
		{
			DB.AddLoadActions(new Action[1]
			{
				delegate
				{
					DB.loadFile<ConcurrentDictionary<string, Progress>>(category + "Progresses", ref Progresses, ".json");
				}
			});
			DB.AddSaveActions(new Action[1]
			{
				delegate
				{
					DB.saveFile<ConcurrentDictionary<string, Progress>>(category + "Progresses", Progresses, true, ".json");
				}
			});
		}
	}
}