-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.cs
67 lines (52 loc) · 1.88 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
using System;
using System.Linq;
using VAMP.Services;
using Unity.Entities;
using ProjectM.Physics;
using UnityEngine;
using System.Collections;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using ProjectM.Scripting;
namespace VAMP;
public static class Core
{
public static World Server { get; } = GetServerWorld() ?? throw new Exception("There is no Server world (yet)...");
public static EntityManager EntityManager => Server.EntityManager;
public static ServerScriptMapper ServerScriptMapper { get; private set; }
public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager();
public static PlayerService PlayerService { get; private set; }
public static CastleHeartService CastleHeartService { get; private set; }
public static bool hasInitialized = false;
static MonoBehaviour monoBehaviour;
public static void Initialize()
{
if (hasInitialized) return;
ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
PlayerService = new PlayerService();
CastleHeartService = new CastleHeartService();
hasInitialized = true;
Plugin.OnCoreLoaded?.Invoke();
}
static World GetServerWorld()
{
return World.s_AllWorlds.ToArray().FirstOrDefault(world => world.Name == "Server");
}
public static Coroutine StartCoroutine(IEnumerator routine)
{
if (monoBehaviour == null)
{
var go = new GameObject("FANG");
monoBehaviour = go.AddComponent<IgnorePhysicsDebugSystem>();
UnityEngine.Object.DontDestroyOnLoad(go);
}
return monoBehaviour.StartCoroutine(routine.WrapToIl2Cpp());
}
public static void StopCoroutine(Coroutine coroutine)
{
if (monoBehaviour == null)
{
return;
}
monoBehaviour.StopCoroutine(coroutine);
}
}