-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPropitize.cs
More file actions
74 lines (64 loc) · 2.27 KB
/
Propitize.cs
File metadata and controls
74 lines (64 loc) · 2.27 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
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
using ICities;
using System.Collections.Generic;
using CitiesHarmony.API;
using UnityEngine;
namespace Propitize
{
public class PropitizeMod : LoadingExtensionBase, IUserMod
{
public static bool PrefabsInitialized = false;
public static PropInfo templateProp;
public static Dictionary<TreeInfo, PropInfo> PropitizedTreeMap = new Dictionary<TreeInfo, PropInfo>();
#region IUserMod implementation
public static readonly string version = "0.1";
public string Name
{
get { return "Propitize " + version; }
}
public string Description
{
get { return "Converts Trees to Props. Integrated into Move it"; }
}
public void OnEnabled()
{
HarmonyHelper.DoOnHarmonyReady(() => PropitizePatch.PatchAll());
XMLUtils.LoadSettings();
}
public void OnDisabled()
{
if (HarmonyHelper.IsHarmonyInstalled) PropitizePatch.UnpatchAll();
}
#endregion
#region LoadingExtensionBase overrides
public override void OnLevelLoaded(LoadMode mode)
{
if (!PropitizeMod.PrefabsInitialized)
{
PropitizeMod.PrefabsInitialized = true;
foreach (KeyValuePair<TreeInfo, PropInfo> keyValuePair in PropitizeMod.PropitizedTreeMap)
{
PropInfo propInfo = keyValuePair.Value;
TreeInfo treeInfo = keyValuePair.Key;
PropitizeTool.PropFinalTouch(ref propInfo, ref treeInfo);
}
}
}
public override void OnLevelUnloading()
{
PropitizeMod.PrefabsInitialized = false;
}
#endregion
}
public class AssetExtension : AssetDataExtensionBase
{
public override void OnAssetLoaded(string name, object asset, Dictionary<string, byte[]> userData)
{
if (!(asset is PropInfo)) return;
PropInfo propInfo = asset as PropInfo;
if (((Object)propInfo).name.EndsWith("ElektrixPropConversionTemplate_Data"))
{
PropitizeMod.templateProp = propInfo;
}
}
}
}