forked from CadeEvs/FrostyToolsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResResource.cs
56 lines (46 loc) · 1.71 KB
/
ResResource.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 FrostySdk.IO;
using FrostySdk.Managers;
using FrostySdk.Managers.Entries;
namespace Frosty.Core.Mod
{
public class ResResource : BaseModResource
{
public override ModResourceType Type => ModResourceType.Res;
public uint ResType => resType;
protected uint resType;
protected ulong resRid;
protected byte[] resMeta;
public ResResource()
{
}
internal ResResource(ResAssetEntry entry)
: base(entry)
{
}
public override void Read(NativeReader reader)
{
base.Read(reader);
resType = reader.ReadUInt();
resRid = reader.ReadULong();
resMeta = reader.ReadBytes(reader.ReadInt());
// @todo: prevent loading of data that requires a handler but has not been exported with said handler
// the same goes for the other types
//foreach (var attr in Assembly.GetExecutingAssembly().GetCustomAttributes<ResCustomHandlerAttribute>())
//{
// if ((uint)attr.ResType == resType && handlerHash == 0)
// {
// // block all res files that require a custom handler when one is not specified
// throw new FrostyModLoadException("Failed to load a resource that requires a custom handler, due to a null handler found");
// }
//}
}
public override void FillAssetEntry(object entry)
{
base.FillAssetEntry(entry);
ResAssetEntry resEntry = entry as ResAssetEntry;
resEntry.ResType = resType;
resEntry.ResRid = resRid;
resEntry.ResMeta = resMeta;
}
}
}