-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlideshowRecipeReader.cs
More file actions
24 lines (19 loc) · 871 Bytes
/
Copy pathSlideshowRecipeReader.cs
File metadata and controls
24 lines (19 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System.Reflection;
using Vintagestory.API.Client;
namespace QuickCraft;
internal static class SlideshowRecipeReader
{
private const BindingFlags Instance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
public static GridRecipeAndUnnamedIngredients[] GetRecipeGroup(SlideshowGridRecipeTextComponent component)
{
object? value = ReadMember(component, "GridRecipesAndUnnamedIngredients")
?? ReadMember(component, "GridRecipesAndUnIn");
return value as GridRecipeAndUnnamedIngredients[] ?? Array.Empty<GridRecipeAndUnnamedIngredients>();
}
private static object? ReadMember(object instance, string name)
{
Type type = instance.GetType();
return type.GetField(name, Instance)?.GetValue(instance)
?? type.GetProperty(name, Instance)?.GetValue(instance);
}
}