-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameInfo.cs
More file actions
47 lines (40 loc) · 1.19 KB
/
GameInfo.cs
File metadata and controls
47 lines (40 loc) · 1.19 KB
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
using System.Collections.Generic;
using CodeName.Modding.Loading;
using CodeName.Modding.Mods;
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace CodeName.Modding
{
public class GameInfo : ScriptableObject
{
[SerializeField] private List<ModInfo> mods = new();
private readonly List<IGameLoadStage> stages = new List<IGameLoadStage>()
{
new LoadMods(),
};
public List<ModInfo> Mods
{
get => mods;
set => mods = value;
}
public async UniTask Load(GameLoadContext context)
{
await GameResources.Unload();
var gameInfo = new LoadedGameInfo(this, context);
GameResources.Initialize(gameInfo);
foreach (var stage in stages)
{
await stage.Process(gameInfo);
}
}
public async UniTask Unload(LoadedGameInfo gameInfo)
{
for (var i = gameInfo.OnUnloadTasks.Count - 1; i >= 0; i--)
{
var task = gameInfo.OnUnloadTasks[i];
await task.Invoke();
}
await Resources.UnloadUnusedAssets();
}
}
}