-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.cs
76 lines (61 loc) · 2.5 KB
/
Core.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System.Collections;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using CrimsonChatFilter.Services;
using ProjectM;
using ProjectM.Physics;
using ProjectM.Scripting;
using Unity.Entities;
using UnityEngine;
internal static class Core
{
public static World Server { get; } = GetWorld("Server") ?? throw new System.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 RelicDestroySystem RelicDestroySystem { get; internal set; }
public static ServerScriptMapper ServerScriptMapper { get; internal set; }
public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager();
public static PlayerService PlayerService { get; internal set; }
public static ServerGameSettingsSystem ServerGameSettingsSystem { get; internal set; }
static MonoBehaviour monoBehaviour;
internal static void InitializeAfterLoaded()
{
if (_hasInitialized) return;
PrefabCollectionSystem = Server.GetExistingSystemManaged<PrefabCollectionSystem>();
RelicDestroySystem = Server.GetExistingSystemManaged<RelicDestroySystem>();
ServerGameSettingsSystem = Server.GetExistingSystemManaged<ServerGameSettingsSystem>();
ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
PlayerService = new PlayerService();
_hasInitialized = true;
}
public static bool _hasInitialized = false;
private static World GetWorld(string name)
{
foreach (var world in World.s_AllWorlds)
{
if (world.Name == name)
{
return world;
}
}
return null;
}
public static Coroutine StartCoroutine(IEnumerator routine)
{
if (monoBehaviour == null)
{
var go = new GameObject("CrimsonShards");
monoBehaviour = go.AddComponent<IgnorePhysicsDebugSystem>();
Object.DontDestroyOnLoad(go);
}
return monoBehaviour.StartCoroutine(routine.WrapToIl2Cpp());
}
public static void StopCoroutine(Coroutine coroutine)
{
if (monoBehaviour == null)
{
return;
}
monoBehaviour.StopCoroutine(coroutine);
}
}