forked from spacechase0/JsonAssets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApi.cs
70 lines (58 loc) · 1.96 KB
/
Api.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
using System;
namespace JsonAssets
{
public interface IApi
{
void LoadAssets(string path);
int GetObjectId(string name);
int GetCropId(string name);
int GetFruitTreeId(string name);
int GetBigCraftableId(string name);
event EventHandler IdsAssigned;
event EventHandler AddedItemsToShop;
}
public class Api : IApi
{
private readonly Action<string> loadFolder;
public Api(Action<string> loadFolder)
{
this.loadFolder = loadFolder;
}
public void LoadAssets(string path)
{
this.loadFolder(path);
}
public int GetObjectId(string name)
{
return Mod.instance.objectIds.ContainsKey(name) ? Mod.instance.objectIds[name] : -1;
}
public int GetCropId(string name)
{
return Mod.instance.cropIds.ContainsKey(name) ? Mod.instance.cropIds[name] : -1;
}
public int GetFruitTreeId(string name)
{
return Mod.instance.fruitTreeIds.ContainsKey(name) ? Mod.instance.fruitTreeIds[name] : -1;
}
public int GetBigCraftableId(string name)
{
return Mod.instance.bigCraftableIds.ContainsKey(name) ? Mod.instance.bigCraftableIds[name] : -1;
}
public event EventHandler IdsAssigned;
internal void InvokeIdsAssigned()
{
Log.trace("Event: IdsAssigned");
if (IdsAssigned == null)
return;
Util.invokeEvent("JsonAssets.Api.IdsAssigned", IdsAssigned.GetInvocationList(), null);
}
public event EventHandler AddedItemsToShop;
internal void InvokeAddedItemsToShop()
{
Log.trace("Event: AddedItemsToShop");
if (AddedItemsToShop == null)
return;
Util.invokeEvent("JsonAssets.Api.AddedItemsToShop", AddedItemsToShop.GetInvocationList(), null);
}
}
}