using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AutoBrazier.Hooks;
using AutoBrazier.Services;
using AutoBrazier.Structs;
using AutoBrazier.Utility;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Scripting;
using Stunlock.Core;
using Stunlock.Network;
using Unity.Collections;
using Unity.Entities;
using Unity.Transforms;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("AutoBrazier")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Automatically turns braziers on/off with day/night cycle")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+Branch.master.Sha.1784eac4891bb3bab56d8aa85b41f1354344dc5d.1784eac4891bb3bab56d8aa85b41f1354344dc5d")]
[assembly: AssemblyProduct("AutoBrazier")]
[assembly: AssemblyTitle("AutoBrazier")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace AutoBrazier
{
internal static class Core
{
private static MonoBehaviour MonoBehaviour;
private static bool _hasInitialized = false;
public static World Server { get; } = GetWorld("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?");
public static EntityManager EntityManager { get; } = Server.EntityManager;
public static GameDataSystem GameDataSystem { get; } = Server.GetExistingSystemManaged<GameDataSystem>();
public static PrefabCollectionSystem PrefabCollectionSystem { get; internal set; }
public static ServerScriptMapper ServerScriptMapper { get; internal set; }
public static double ServerTime => ServerGameManager.ServerTime;
public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager();
public static PlayerService PlayerService { get; internal set; }
public static ServerGameSettingsSystem ServerGameSettingsSystem { get; internal set; }
public static ManualLogSource Log { get; } = Plugin._logger;
public static bool HasInitialized => _hasInitialized;
public static void LogException(Exception e, [CallerMemberName] string caller = null)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
ManualLogSource log = Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(51, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failure in ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(caller);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nMessage: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner:");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.Message);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\nStack: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.StackTrace);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nInner Stack: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.StackTrace);
}
log.LogError(val);
}
internal static void InitializeAfterLoaded()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
if (!_hasInitialized)
{
PrefabCollectionSystem = Server.GetExistingSystemManaged<PrefabCollectionSystem>();
ServerGameSettingsSystem = Server.GetExistingSystemManaged<ServerGameSettingsSystem>();
ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
PlayerService = new PlayerService();
BonfirePatch.Load();
_hasInitialized = true;
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("InitializeAfterLoaded");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" completed");
}
log.LogInfo(val);
}
}
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;
}
public static void StartCoroutine(IEnumerator routine)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)MonoBehaviour == (Object)null)
{
MonoBehaviour = (MonoBehaviour)(object)new GameObject("AutoBrazier").AddComponent<IgnorePhysicsDebugSystem>();
Object.DontDestroyOnLoad((Object)(object)((Component)MonoBehaviour).gameObject);
}
MonoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
}
}
[BepInPlugin("AutoBrazier", "AutoBrazier", "1.0.3")]
public class Plugin : BasePlugin
{
public enum LogSystem
{
Core
}
public static Harmony _harmony;
public static ConfigEntry<bool> AutoToggleEnabled;
public static ManualLogSource _logger;
private void InitConfig()
{
AutoToggleEnabled = ((BasePlugin)this).Config.Bind<bool>("Server", "autoToggleEnabled", true, "Turn braziers on when day starts, and off during the night starts, for online players/clans only.");
}
public override void Load()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
_logger = ((BasePlugin)this).Log;
InitConfig();
_harmony = new Harmony("AutoBrazier");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
Log("Plugin AutoBrazier version 1.0.3 is loaded!", LogSystem.Core, (LogLevel)16);
}
public override bool Unload()
{
((BasePlugin)this).Config.Clear();
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
public static void Log(string message, LogSystem system = LogSystem.Core, LogLevel logLevel = 16, bool forceLog = false)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
_logger.Log(logLevel, (object)ToLogMessage(system, message));
}
private static string ToLogMessage(LogSystem logSystem, string message)
{
return $"{DateTime.Now:u}: [{Enum.GetName(logSystem)}] {message}";
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "AutoBrazier";
public const string PLUGIN_NAME = "AutoBrazier";
public const string PLUGIN_VERSION = "1.0.3";
}
}
namespace AutoBrazier.Utility
{
public static class ECSExtensions
{
public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
{
//IL_0030: 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_0039: 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_003b: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
byte[] array = StructureToByteArray(componentData);
int num = Marshal.SizeOf<T>();
fixed (byte* ptr = array)
{
EntityManager entityManager = Core.EntityManager;
((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
}
}
public 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;
}
public unsafe static T Read<T>(this Entity entity) where T : struct
{
//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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = Core.EntityManager;
return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex)));
}
public static bool Has<T>(this Entity entity)
{
//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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = Core.EntityManager;
return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
}
public static string LookupName(this PrefabGUID prefabGuid)
{
//IL_0011: 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_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)
PrefabCollectionSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
object obj;
if (!existingSystemManaged.PrefabGuidToNameDictionary.ContainsKey(prefabGuid))
{
obj = "GUID Not Found";
}
else
{
string text = existingSystemManaged.PrefabGuidToNameDictionary[prefabGuid];
PrefabGUID val = prefabGuid;
obj = text + " " + ((object)(PrefabGUID)(ref val)).ToString();
}
return obj.ToString();
}
public static void Add<T>(this Entity entity)
{
//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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = Core.EntityManager;
((EntityManager)(ref entityManager)).AddComponent(entity, val);
}
public static void Remove<T>(this Entity entity)
{
//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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = Core.EntityManager;
((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
}
public static NativeArray<Entity> GetEntitiesByComponentType<T1>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
{
//IL_0001: 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_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0013: 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_001f: 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_0022: 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_0035: Expected O, but got Unknown
//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)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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_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)
EntityQueryOptions val = (EntityQueryOptions)0;
if (includeAll)
{
val = (EntityQueryOptions)(val | 0xC3);
}
if (includeDisabled)
{
val = (EntityQueryOptions)(val | 2);
}
if (includeSpawn)
{
val = (EntityQueryOptions)(val | 0x40);
}
if (includePrefab)
{
val = (EntityQueryOptions)(val | 1);
}
if (includeDestroyed)
{
val = (EntityQueryOptions)(val | 0x80);
}
EntityQueryDesc val2 = new EntityQueryDesc();
val2.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1]
{
new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0)
});
val2.Options = val;
EntityQueryDesc val3 = val2;
EntityManager entityManager = Core.EntityManager;
EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val3 });
return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2>(bool includeAll = false, bool includeDisabled = false, bool includeSpawn = false, bool includePrefab = false, bool includeDestroyed = false)
{
//IL_0001: 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_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0013: 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_001f: 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_0022: 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_0035: Expected O, but got Unknown
//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)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_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)
EntityQueryOptions val = (EntityQueryOptions)0;
if (includeAll)
{
val = (EntityQueryOptions)(val | 0xC3);
}
if (includeDisabled)
{
val = (EntityQueryOptions)(val | 2);
}
if (includeSpawn)
{
val = (EntityQueryOptions)(val | 0x40);
}
if (includePrefab)
{
val = (EntityQueryOptions)(val | 1);
}
if (includeDestroyed)
{
val = (EntityQueryOptions)(val | 0x80);
}
EntityQueryDesc val2 = new EntityQueryDesc();
val2.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
{
new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0),
new ComponentType(Il2CppType.Of<T2>(), (AccessMode)0)
});
val2.Options = val;
EntityQueryDesc val3 = val2;
EntityManager entityManager = Core.EntityManager;
EntityQuery val4 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val3 });
return ((EntityQuery)(ref val4)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
}
internal class EntityQueries
{
private static readonly ComponentType[] BrazierComponents = (ComponentType[])(object)new ComponentType[2]
{
ComponentType.ReadOnly(Il2CppType.Of<Bonfire>()),
ComponentType.ReadOnly(Il2CppType.Of<BurnContainer>())
};
public static NativeArray<Entity> GetUserEntities()
{
//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 = Core.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 NativeArray<Entity> GetBonfireEntities()
{
//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_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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = Core.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery(BrazierComponents);
return ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
}
}
namespace AutoBrazier.Structs
{
public struct PlayerData
{
public FixedString64Bytes CharacterName { get; set; }
public ulong SteamID { get; set; }
public bool IsOnline { get; set; }
public Entity UserEntity { get; set; }
public Entity CharEntity { get; set; }
public PlayerData(FixedString64Bytes characterName, ulong steamID, bool isOnline, Entity userEntity, Entity charEntity)
{
//IL_0001: 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_001e: Unknown result type (might be due to invalid IL or missing references)
CharacterName = characterName;
SteamID = steamID;
IsOnline = isOnline;
UserEntity = userEntity;
CharEntity = charEntity;
}
}
public class Player
{
public string Name { get; set; }
public ulong SteamID { get; set; }
public bool IsOnline { get; set; }
public bool IsAdmin { get; set; }
public Entity User { get; set; }
public Entity Character { get; set; }
public Player(Entity userEntity = default(Entity))
{
//IL_0007: 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_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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
User = userEntity;
User val = User.Read<User>();
Character = val.LocalCharacter._Entity;
Name = ((object)(FixedString64Bytes)(ref val.CharacterName)).ToString();
IsOnline = val.IsConnected;
IsAdmin = val.IsAdmin;
SteamID = val.PlatformId;
}
}
}
namespace AutoBrazier.Services
{
internal class AutoToggle
{
private static TimeOfDay currentTimeOfDay;
public static void OnTimeOfDayChanged(TimeOfDay timeOfDay)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Invalid comparison between Unknown and I4
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
currentTimeOfDay = timeOfDay;
if ((int)timeOfDay != 1)
{
if ((int)timeOfDay != 2)
{
if ((int)timeOfDay != int.MaxValue)
{
throw new ArgumentOutOfRangeException("timeOfDay", timeOfDay, null);
}
}
else
{
TurnOffAllBonfires();
}
}
else
{
TurnOnBonfiresForOnlinePlayersOnly();
}
}
private static void TurnOffAllBonfires()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
ManualToggle.SetBurning(EntityQueries.GetBonfireEntities(), isBurning: false);
}
private static void TurnOnBonfiresForOnlinePlayersOnly()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//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_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_0021: 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_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_0036: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
if ((int)currentTimeOfDay == 2)
{
return;
}
NativeArray<Entity> userEntities = EntityQueries.GetUserEntities();
List<Team> list = new List<Team>();
Enumerator<Entity> enumerator = userEntities.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = Core.Server.EntityManager;
if (((EntityManager)(ref entityManager)).GetComponentData<User>(current).IsConnected)
{
entityManager = Core.Server.EntityManager;
Team componentData = ((EntityManager)(ref entityManager)).GetComponentData<Team>(current);
list.Add(componentData);
}
}
List<Entity> bonfires = GetBonfires(list, isOnlineCheck: true);
foreach (Entity bonfire in GetBonfires(list, isOnlineCheck: false))
{
ManualToggle.SetBurning(bonfire, isBurning: false);
}
foreach (Entity item in bonfires)
{
ManualToggle.SetBurning(item, isBurning: true);
}
}
public static void PlayerConnected(ServerBootstrapSystem bootstrapSystem, NetConnectionId player)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//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_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_0030: 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_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_0041: 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)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
if ((int)currentTimeOfDay != 1)
{
return;
}
int num = bootstrapSystem._NetEndPointToApprovedUserIndex[player];
Entity userEntity = ((Il2CppArrayBase<ServerClient>)(object)bootstrapSystem._ApprovedUsersLookup)[num].UserEntity;
Enumerator<Entity> enumerator = EntityQueries.GetBonfireEntities().GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
ServerGameManager serverGameManager = Core.ServerGameManager;
if (((ServerGameManager)(ref serverGameManager)).IsAllies(current, userEntity))
{
ManualToggle.SetBurning(current, isBurning: true);
}
}
}
public static void PlayerDisconnected(ServerBootstrapSystem bootstrapSystem, NetConnectionId player, ConnectionStatusChangeReason reason, string extraData)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//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_003c: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
if ((int)currentTimeOfDay == 2)
{
return;
}
int num = bootstrapSystem._NetEndPointToApprovedUserIndex[player];
Entity userEntity = ((Il2CppArrayBase<ServerClient>)(object)bootstrapSystem._ApprovedUsersLookup)[num].UserEntity;
ServerGameManager serverGameManager;
foreach (Entity item in PlayerService.GetUsersOnline().ToList())
{
serverGameManager = Core.ServerGameManager;
if (((ServerGameManager)(ref serverGameManager)).IsAllies(item, userEntity))
{
return;
}
}
Enumerator<Entity> enumerator2 = EntityQueries.GetBonfireEntities().GetEnumerator();
while (enumerator2.MoveNext())
{
Entity current2 = enumerator2.Current;
serverGameManager = Core.ServerGameManager;
if (((ServerGameManager)(ref serverGameManager)).IsAllies(current2, userEntity))
{
ManualToggle.SetBurning(current2, isBurning: false);
}
}
}
private static List<Entity> GetBonfires(List<Team> onlineTeams, bool isOnlineCheck)
{
//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_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_0023: 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_0033: 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_0039: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
NativeArray<Entity> bonfireEntities = EntityQueries.GetBonfireEntities();
List<Entity> list = new List<Entity>();
List<Entity> list2 = new List<Entity>();
Enumerator<Entity> enumerator = bonfireEntities.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = Core.EntityManager;
Team bonfireTeam = ((EntityManager)(ref entityManager)).GetComponentData<Team>(current);
if (onlineTeams.Any(delegate(Team onlineTeam)
{
//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_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)
ServerGameManager serverGameManager = Core.ServerGameManager;
return ((ServerGameManager)(ref serverGameManager)).IsAllies(bonfireTeam, onlineTeam);
}))
{
list.Add(current);
}
else
{
list2.Add(current);
}
}
if (isOnlineCheck)
{
return list;
}
return list2;
}
}
internal class DayNightCycleTracker
{
public delegate void Event(TimeOfDay timeOfDay);
private TimeOfDay _previousTimeOfDay;
public event Event OnTimeOfDayChanged;
public void Update(DayNightCycle dayNightCycle)
{
//IL_0002: 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_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_002a: Unknown result type (might be due to invalid IL or missing references)
if (((DayNightCycle)(ref dayNightCycle)).TimeOfDay != _previousTimeOfDay)
{
_previousTimeOfDay = ((DayNightCycle)(ref dayNightCycle)).TimeOfDay;
this.OnTimeOfDayChanged?.Invoke(((DayNightCycle)(ref dayNightCycle)).TimeOfDay);
}
}
}
internal class ManualToggle
{
private static readonly PrefabGUID BoneGuid = new PrefabGUID(1821405450);
private static void Toggle(Entity brazier, out bool isBurning)
{
//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)
//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_0016: 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_002e: 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_0039: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = Core.Server.EntityManager;
BurnContainer componentData = ((EntityManager)(ref entityManager)).GetComponentData<BurnContainer>(brazier);
componentData.Enabled = !componentData.Enabled;
entityManager = Core.Server.EntityManager;
((EntityManager)(ref entityManager)).SetComponentData<BurnContainer>(brazier, componentData);
isBurning = componentData.Enabled;
}
public static void SetBurning(Entity brazier, bool isBurning)
{
//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)
//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_0021: 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_0029: 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)
EntityManager entityManager = Core.Server.EntityManager;
BurnContainer componentData = ((EntityManager)(ref entityManager)).GetComponentData<BurnContainer>(brazier);
componentData.Enabled = isBurning;
entityManager = Core.Server.EntityManager;
((EntityManager)(ref entityManager)).SetComponentData<BurnContainer>(brazier, componentData);
}
public static void SetBurning(NativeArray<Entity> braziers, bool isBurning)
{
//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_001c: 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_0033: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
Enumerator<Entity> enumerator = braziers.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = Core.Server.EntityManager;
BurnContainer componentData = ((EntityManager)(ref entityManager)).GetComponentData<BurnContainer>(current);
componentData.Enabled = isBurning;
entityManager = Core.Server.EntityManager;
((EntityManager)(ref entityManager)).SetComponentData<BurnContainer>(current, componentData);
}
}
private static Vector3 ToVector3(LocalToWorld localToWorld)
{
//IL_0002: 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_001a: 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)
return new Vector3(((LocalToWorld)(ref localToWorld)).Position.x, ((LocalToWorld)(ref localToWorld)).Position.y, ((LocalToWorld)(ref localToWorld)).Position.z);
}
public static void AddBonesIfEmpty(FromCharacter fromCharacter, Entity brazier)
{
//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_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_00c6: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
Entity val = default(Entity);
InventoryUtilities.TryGetInventoryEntity(Core.Server.EntityManager, fromCharacter.Character, ref val, 0);
Entity val2 = default(Entity);
InventoryUtilities.TryGetInventoryEntity(Core.Server.EntityManager, brazier, ref val2, 0);
GameDataSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<GameDataSystem>();
int itemAmount = InventoryUtilities.GetItemAmount(Core.Server.EntityManager, val, BoneGuid, default(Nullable_Unboxed<int>));
int itemAmount2 = InventoryUtilities.GetItemAmount(Core.Server.EntityManager, val2, BoneGuid, default(Nullable_Unboxed<int>));
if (itemAmount > 0 && itemAmount2 == 0)
{
int num = default(int);
InventoryUtilities.TryGetItemSlot(Core.Server.EntityManager, val, BoneGuid, ref num);
InventoryUtilitiesServer.SplitItemStacks(Core.Server.EntityManager, existingSystemManaged.ItemHashLookupMap, val, num);
InventoryUtilitiesServer.TryMoveItem(Core.Server.EntityManager, existingSystemManaged.ItemHashLookupMap, val, num, val2, -1, true, default(Nullable_Unboxed<int>));
}
}
}
internal class PlayerService
{
private readonly Dictionary<FixedString64Bytes, PlayerData> namePlayerCache = new Dictionary<FixedString64Bytes, PlayerData>();
private readonly Dictionary<ulong, PlayerData> steamPlayerCache = new Dictionary<ulong, PlayerData>();
private readonly Dictionary<NetworkId, PlayerData> idPlayerCache = new Dictionary<NetworkId, PlayerData>();
internal bool TryFindSteam(ulong steamId, out PlayerData playerData)
{
return steamPlayerCache.TryGetValue(steamId, out playerData);
}
internal bool TryFindName(FixedString64Bytes name, out PlayerData playerData)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return namePlayerCache.TryGetValue(name, out playerData);
}
internal PlayerService()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
namePlayerCache.Clear();
steamPlayerCache.Clear();
Enumerator<Entity> enumerator = ECSExtensions.GetEntitiesByComponentType<User>(includeAll: false, includeDisabled: true).GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = Core.EntityManager;
User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(current);
PlayerData value = new PlayerData(componentData.CharacterName, componentData.PlatformId, componentData.IsConnected, current, componentData.LocalCharacter._Entity);
namePlayerCache.TryAdd(FixedString64Bytes.op_Implicit(((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString().ToLower()), value);
steamPlayerCache.TryAdd(componentData.PlatformId, value);
}
_ = from p in namePlayerCache.Values
where p.IsOnline
select $"\t{p.CharacterName}";
}
internal void UpdatePlayerCache(Entity userEntity, string oldName, string newName, bool forceOffline = false)
{
//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_001b: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = Core.EntityManager;
User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity);
namePlayerCache.Remove(FixedString64Bytes.op_Implicit(oldName.ToLower()));
if (forceOffline)
{
componentData.IsConnected = false;
}
PlayerData value = new PlayerData(FixedString64Bytes.op_Implicit(newName), componentData.PlatformId, componentData.IsConnected, userEntity, componentData.LocalCharacter._Entity);
namePlayerCache[FixedString64Bytes.op_Implicit(newName.ToLower())] = value;
steamPlayerCache[componentData.PlatformId] = value;
idPlayerCache[userEntity.Read<NetworkId>()] = value;
}
public bool TryFindUserFromNetworkId(NetworkId networkId, out Entity userEntity)
{
//IL_0006: 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_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)
if (idPlayerCache.TryGetValue(networkId, out var value))
{
userEntity = value.UserEntity;
return true;
}
userEntity = Entity.Null;
return false;
}
public static IEnumerable<Entity> GetUsersOnline()
{
EntityManager entityManager = Core.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
Enumerator<Entity> enumerator = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
entityManager = Core.EntityManager;
if (((EntityManager)(ref entityManager)).Exists(current) && current.Read<User>().IsConnected)
{
yield return current;
}
}
}
public IEnumerable<Entity> GetCachedUsersOnline()
{
PlayerData[] array = namePlayerCache.Values.ToArray();
foreach (PlayerData playerData in array)
{
Entity userEntity = playerData.UserEntity;
EntityManager entityManager = Core.EntityManager;
if (((EntityManager)(ref entityManager)).Exists(userEntity) && userEntity.Read<User>().IsConnected)
{
yield return userEntity;
}
}
}
}
}
namespace AutoBrazier.Hooks
{
internal class BonfirePatch
{
private static DayNightCycleTracker _dayNightCycleTracker;
private const string InitialErrorMessage = "System.InvalidOperationException: GetSingleton<ProjectM.DayNightCycle>() requires that exactly one ProjectM.DayNightCycle exist that match this query, but there are 0.";
private static byte _currentDay;
private static bool _isDnInitialized;
public static void Load()
{
_dayNightCycleTracker = new DayNightCycleTracker();
_dayNightCycleTracker.OnTimeOfDayChanged += AutoToggle.OnTimeOfDayChanged;
if (Plugin.AutoToggleEnabled.Value)
{
Core.StartCoroutine(Check());
}
}
private static IEnumerator Check()
{
while (true)
{
yield return (object)new WaitForSeconds(10f);
if (!Core.HasInitialized)
{
yield return null;
}
if (_dayNightCycleTracker == null)
{
yield return null;
}
if (Core.ServerGameManager.HasDayNightCycle)
{
try
{
DayNightCycle dayNightCycle = Core.ServerGameManager.DayNightCycle;
if (!_isDnInitialized)
{
_currentDay = dayNightCycle.GameDateTimeNow.Day;
_isDnInitialized = true;
_dayNightCycleTracker.Update(dayNightCycle);
}
else
{
_currentDay = dayNightCycle.GameDateTimeNow.Day;
_dayNightCycleTracker.Update(dayNightCycle);
}
}
catch (Exception ex)
{
if (ex.Message.StartsWith("System.InvalidOperationException: GetSingleton<ProjectM.DayNightCycle>() requires that exactly one ProjectM.DayNightCycle exist that match this query, but there are 0."))
{
Plugin.Log("DNC singleton not yet ready. This error should only appear on the initial creation/startup of the server.", Plugin.LogSystem.Core, (LogLevel)16);
}
else
{
Plugin.Log("DayNightCycle: " + ex.Message, Plugin.LogSystem.Core, (LogLevel)16);
}
}
}
else
{
Plugin.Log("Core.ServerGameManager.HasDayNightCycle = False", Plugin.LogSystem.Core, (LogLevel)4);
}
}
}
}
[HarmonyPatch(typeof(SpawnTeamSystem_OnPersistenceLoad), "OnUpdate")]
internal class OnLoadPatches
{
[HarmonyPostfix]
public static void OneShot_AfterLoad_InitializationPatch()
{
Core.InitializeAfterLoaded();
Plugin._harmony.Unpatch((MethodBase)typeof(SpawnTeamSystem_OnPersistenceLoad).GetMethod("OnUpdate"), typeof(OnLoadPatches).GetMethod("OneShot_AfterLoad_InitializationPatch"));
}
}
[HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserConnected")]
public static class OnUserConnectedPatch
{
public static void Postfix(ServerBootstrapSystem __instance, NetConnectionId netConnectionId)
{
//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_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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
if (Core.PlayerService == null)
{
Core.InitializeAfterLoaded();
}
try
{
EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
int num = __instance._NetEndPointToApprovedUserIndex[netConnectionId];
Entity userEntity = ((Il2CppArrayBase<ServerClient>)(object)__instance._ApprovedUsersLookup)[num].UserEntity;
User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity);
if (!((FixedString64Bytes)(ref componentData.CharacterName)).IsEmpty)
{
string text = ((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString();
Core.PlayerService.UpdatePlayerCache(userEntity, text, text);
}
AutoToggle.PlayerConnected(__instance, netConnectionId);
}
catch (Exception ex)
{
Plugin.Log(ex.Message, Plugin.LogSystem.Core, (LogLevel)16);
}
}
}
[HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserDisconnected")]
public static class OnUserDisconnectedPatch
{
private static void Prefix(ServerBootstrapSystem __instance, NetConnectionId netConnectionId, ConnectionStatusChangeReason connectionStatusReason, string extraData)
{
//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_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (Core.PlayerService == null)
{
Core.InitializeAfterLoaded();
}
try
{
int num = __instance._NetEndPointToApprovedUserIndex[netConnectionId];
ServerClient val = ((Il2CppArrayBase<ServerClient>)(object)__instance._ApprovedUsersLookup)[num];
EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(val.UserEntity);
if (!((FixedString64Bytes)(ref componentData.CharacterName)).IsEmpty)
{
string text = ((object)(FixedString64Bytes)(ref componentData.CharacterName)).ToString();
Core.PlayerService.UpdatePlayerCache(val.UserEntity, text, text, forceOffline: true);
}
AutoToggle.PlayerDisconnected(__instance, netConnectionId, connectionStatusReason, extraData);
}
catch
{
}
}
}
}