forked from mfoltz/Bloodcraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.cs
100 lines (89 loc) · 3.87 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using Bloodcraft.Patches;
using Bloodcraft.Services;
using Bloodcraft.Systems.Expertise;
using Bloodcraft.Systems.Familiars;
using Bloodcraft.Systems.Leveling;
using Bloodcraft.Systems.Quests;
using Bloodcraft.Utilities;
using ProjectM.Physics;
using ProjectM.Scripting;
using System.Collections;
using Unity.Entities;
using UnityEngine;
namespace Bloodcraft;
internal static class Core
{
static World Server { get; } = GetServerWorld(); // ?? throw new Exception("There is no Server world (yet)...");
public static EntityManager EntityManager => Server.EntityManager;
public static ServerGameManager ServerGameManager => SystemService.ServerScriptMapper.GetServerGameManager();
public static SystemService SystemService { get; } = new(Server);
public static double ServerTime => ServerGameManager.ServerTime;
public static ManualLogSource Log => Plugin.LogInstance;
static MonoBehaviour MonoBehaviour;
public static bool hasInitialized = false;
public static void Initialize()
{
if (hasInitialized) return;
hasInitialized = true;
_ = new PlayerService();
_ = new LocalizationService();
if (ConfigService.ClientCompanion) _ = new EclipseService();
if (ConfigService.ExtraRecipes) RecipeUtilities.ExtraRecipes();
if (ConfigService.StarterKit) ConfigUtilities.StarterKit();
if (ConfigService.PrestigeSystem) BuffUtilities.PrestigeBuffs();
if (ConfigService.SoftSynergies || ConfigService.HardSynergies)
{
ConfigUtilities.ClassBuffMap();
ConfigUtilities.ClassSpellCooldownMap();
ClassUtilities.GenerateAbilityJewelMap();
}
if (ConfigService.LevelingSystem) DeathEventListenerSystemPatch.OnDeathEvent += LevelingSystem.OnUpdate;
if (ConfigService.ExpertiseSystem) DeathEventListenerSystemPatch.OnDeathEvent += WeaponSystem.OnUpdate;
if (ConfigService.QuestSystem)
{
_ = new QuestService();
DeathEventListenerSystemPatch.OnDeathEvent += QuestSystem.OnUpdate;
}
if (ConfigService.FamiliarSystem)
{
ConfigUtilities.FamiliarBans();
DeathEventListenerSystemPatch.OnDeathEvent += FamiliarLevelingSystem.OnUpdate;
DeathEventListenerSystemPatch.OnDeathEvent += FamiliarUnlockSystem.OnUpdate;
}
/*
foreach (var kvp in Server.m_SystemLookup)
{
Il2CppSystem.Type systemType = kvp.Key;
ComponentSystemBase systemBase = kvp.Value;
if (systemBase.EntityQueries.Length == 0) continue;
Core.Log.LogInfo("=============================");
Core.Log.LogInfo(systemType.FullName);
foreach (EntityQuery query in systemBase.EntityQueries)
{
EntityQueryDesc entityQueryDesc = query.GetEntityQueryDesc();
Core.Log.LogInfo($" All: {string.Join(",", entityQueryDesc.All)}");
Core.Log.LogInfo($" Any: {string.Join(",", entityQueryDesc.Any)}");
Core.Log.LogInfo($" Absent: {string.Join(",", entityQueryDesc.Absent)}");
Core.Log.LogInfo($" None: {string.Join(",", entityQueryDesc.None)}");
}
Core.Log.LogInfo("=============================");
}
*/
hasInitialized = true;
}
static World GetServerWorld()
{
return World.s_AllWorlds.ToArray().FirstOrDefault(world => world.Name == "Server");
}
public static void StartCoroutine(IEnumerator routine)
{
if (MonoBehaviour == null)
{
MonoBehaviour = new GameObject("Bloodcraft").AddComponent<IgnorePhysicsDebugSystem>();
UnityEngine.Object.DontDestroyOnLoad(MonoBehaviour.gameObject);
}
MonoBehaviour.StartCoroutine(routine.WrapToIl2Cpp());
}
}