-
Notifications
You must be signed in to change notification settings - Fork 1
/
ItemManager.cs
179 lines (148 loc) · 7.15 KB
/
ItemManager.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using JudesEquipment.Configuration;
namespace JudesEquipment
{
public static class ItemManager
{
public static Transform cloneContainer;
public static Transform GetCloneHolder()
{
if (cloneContainer == null)
{
cloneContainer = GameObject.CreatePrimitive(PrimitiveType.Cube).transform;
UnityEngine.Object.DontDestroyOnLoad(cloneContainer);
cloneContainer.gameObject.SetActive(false);
return cloneContainer;
}
return cloneContainer;
}
public static List<PrefabConfig> prefabs = new List<PrefabConfig>();
public static List<StatusEffect> customSEs = new List<StatusEffect>();
public static List<BlacksmithsToolsConfig> bsmithCfgs = new List<BlacksmithsToolsConfig>();
public static Dictionary<string, Dictionary<string, string>> colorConfig = new Dictionary<string, Dictionary<string, string>>
{
{ "ArmorBarbarianBronzeHelmetJD", new Dictionary<string, string> { { "Color 1", "#FF892A" }, { "Color 2", "#FFFFFF" } } },
{ "ArmorBarbarianBronzeChestJD", new Dictionary<string, string> { { "Color 1", "#FF892A" }, { "Color 2", "#FFFFFF" } } },
{ "ArmorBarbarianBronzeLegsJD", new Dictionary<string, string> { { "Color 1", "#FF892A" }, { "Color 2", "#FFFFFF" } } },
{ "ArmorWarriorHelmet", new Dictionary<string, string> { { "Color 1", "#FF892A" } } },
{ "ArmorWarriorChest", new Dictionary<string, string> { { "Color 1", "#FF892A" } } },
{ "ArmorPlateIronHelmetJD", new Dictionary<string, string> { { "Color 1", "#FFFFFF" } } },
{ "ArmorPlateIronChestJD", new Dictionary<string, string> { { "Color 1", "#FFFFFF" } } },
{ "ArmorPlateIronLegsJD", new Dictionary<string, string> { { "Color 1", "#FFFFFF" } } },
{ "ArmorDragonslayerHelmet", new Dictionary<string, string> { { "Color 1", "#373737" } } },
{ "ArmorDragonslayerChest", new Dictionary<string, string> { { "Color 1", "#373737" } } },
{ "ArmorDragonslayerLegs", new Dictionary<string, string> { { "Color 1", "#373737" } } },
{ "ArmorWandererChest", new Dictionary<string, string> { { "Color 1", "#FFFFFF" } } },
{ "ArmorWandererLegs", new Dictionary<string, string> { { "Color 1", "#FFFFFF" } } },
{ "ArmorBlackmetalgarbHelmet", new Dictionary<string, string> { { "Color 1", "#264C35" } } },
{ "ArmorBlackmetalgarbChest", new Dictionary<string, string> { { "Color 1", "#264C35" } } },
{ "ArmorBlackmetalgarbLegs", new Dictionary<string, string> { { "Color 1", "#264C35" } } },
{ "ArmorSerpentHelmet", new Dictionary<string, string> { { "Color 1", "#264C35" }, { "Color 2", "#FFFFFF" } } },
{ "ArmorSerpentChest", new Dictionary<string, string> { { "Color 1", "#264C35" }, { "Color 2", "#FFFFFF" } } },
{ "ArmorSerpentLegs", new Dictionary<string, string> { { "Color 1", "#264C35" }, { "Color 2", "#FFFFFF" } } },
{ "ArmorMistlandsHelmet", new Dictionary<string, string> { { "Color 1", "#545454" }, { "Emission color", "#BF3000" } } },
{ "ArmorMistlandsChest", new Dictionary<string, string> { { "Color 1", "#545454" }, { "Emission color", "#BF3000" } } },
{ "ArmorMistlandsLegs", new Dictionary<string, string> { { "Color 1", "#545454" }, { "Emission color", "#BF3000" } } }
};
public static void AddItemsToDBs(ObjectDB odb)
{
LoadPrefabsFromBundle();
foreach(PrefabConfig prefab in prefabs)
{
if (prefab.GetPrefab() == null) continue;
if (!odb.m_itemByHash.ContainsKey(prefab.GetPrefab().name.GetStableHashCode()))
{
odb.m_itemByHash.Add(prefab.GetPrefab().name.GetStableHashCode(), prefab.GetPrefab());
}
if (!odb.m_items.Contains(prefab.GetPrefab()))
{
odb.m_items.Add(prefab.GetPrefab());
}
if (ZNetScene.instance != null)
{
if (!ZNetScene.instance.m_prefabs.Contains(prefab.GetPrefab()))
{
ZNetScene.instance.m_prefabs.Add(prefab.GetPrefab());
}
if (!ZNetScene.instance.m_namedPrefabs.ContainsKey(prefab.GetPrefab().name.GetStableHashCode()))
{
ZNetScene.instance.m_namedPrefabs.Add(prefab.GetPrefab().name.GetStableHashCode(), prefab.GetPrefab());
}
}
}
customSEs.ForEach(se => { if (!odb.m_StatusEffects.Contains(se)) odb.m_StatusEffects.Add(se); });
}
public static void InsertBsmithToolsCfgs()
{
if (Main.bsmithAvailable)
{
Type type = Type.GetType("BlacksmithTools.BodypartSystem,BlacksmithTools");
var list = type.GetField("bodypartSettingsAsBones");
Dictionary<string, List<int>> boneDict = (Dictionary<string, List<int>>)list.GetValue(list);
foreach (BlacksmithsToolsConfig cfg in bsmithCfgs)
{
if(boneDict.ContainsKey(cfg.itemName))
{
boneDict[cfg.itemName] = new List<int>(cfg.bonesToHide);
}
else
{
boneDict.Add(cfg.itemName, new List<int>(cfg.bonesToHide));
}
}
}
}
static void LoadPrefabsFromBundle()
{
AssetBundle bundle = Util.LoadBundle(Main.bundleName);
ItemManager.prefabs.Clear();
allPrefabs.ForEach(_prefab => ItemManager.prefabs.Add(new PrefabConfig()
{
prefab = bundle.LoadAsset<GameObject>(_prefab)
}));
bundle.Unload(false);
}
public static readonly List<string> allPrefabs = new List<string>()
{
"ArmorNobleHelmet",
"ArmorNobleChest",
"ArmorNobleLegs",
"ArmorNobleCape",
"ArmorBarbarianBronzeHelmetJD",
"ArmorBarbarianBronzeChestJD",
"ArmorBarbarianBronzeLegsJD",
"ArmorBarbarianCapeJD",
"ArmorWarriorHelmet",
"ArmorWarriorChest",
"ArmorWarriorLegs",
"ArmorPlateIronHelmetJD",
"ArmorPlateIronChestJD",
"ArmorPlateIronLegsJD",
"ArmorPlateCape",
"ArmorDragonslayerHelmet",
"ArmorDragonslayerChest",
"ArmorDragonslayerLegs",
"ArmorWandererHelmet",
"ArmorWandererChest",
"ArmorWandererLegs",
"ArmorWandererCape",
"ArmorBlackmetalgarbHelmet",
"ArmorBlackmetalgarbChest",
"ArmorBlackmetalgarbLegs",
"ArmorSerpentHelmet",
"ArmorSerpentChest",
"ArmorSerpentLegs",
"ArmorSerpentCape",
"ArmorMistlandsHelmet",
"ArmorMistlandsChest",
"ArmorMistlandsLegs",
"BackpackSimple",
"BackpackHeavy"
};
}
}