-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPrefabManager.cs
56 lines (53 loc) · 1.8 KB
/
PrefabManager.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Fyrenest
{
/// <summary>
/// Handles the loading of prefabs defined in the Prefabs class
/// </summary>
internal class PrefabManager
{
/// <summary>
/// Returns a list of all prefabs to be loaded for the "Prefabs" class
/// </summary>
public List<(string, string)> GetPreloadNames()
{
List<(string, string)> preloadNames = new List<(string, string)> ();
foreach (FieldInfo prop in typeof(Prefabs).GetFields())
{
if (prop.IsStatic && prop.FieldType == typeof(Prefab))
{
Prefab prefab = (Prefab)prop.GetValue(null);
preloadNames.Add((prefab.OriginRoom, prefab.OriginName));
}
}
return preloadNames;
}
/*
public override List<(string, string)> GetPreloadNames() => new()
{
("GG_Mantis_Lords", "Shot Mantis Lord")
};
*/
/// <summary>
/// Assigns the loaded prefabs to their Prefab objects
/// </summary>
public void InitializePrefabs(Dictionary<string, Dictionary<string, GameObject>> preloadedObjects)
{
Fyrenest.instance.Log("Loaded Prefabs:" + preloadedObjects.Count);
foreach (FieldInfo prop in typeof(Prefabs).GetFields())
{
if (prop.IsStatic && prop.FieldType == typeof(Prefab))
{
Prefab prefab = (Prefab)prop.GetValue(null);
prefab.Object = preloadedObjects[prefab.OriginRoom][prefab.OriginName];
}
}
}
}
}