1using System.Reflection;
11 public new const string fName =
"SurvivalCraftModEntity";
37 for (
int i = 0; i < readers.Count; i++) {
46 Size = memoryStream.Length;
49 MemoryStream memoryStream =
new();
50 const string ContentPath =
"app:/Content.zip";
56 Assembly.GetExecutingAssembly().GetManifestResourceStream(
"Game.Content.zip")?.CopyTo(memoryStream);
58 if (memoryStream ==
null) {
59 throw new Exception(
"Unable to load Content.zip file.");
61 Size = memoryStream.Length;
62 memoryStream.Position = 0L;
67 modInfo.LoadOrder =
int.MinValue;
80#pragma warning disable IL2026
81 Type[] types = assembly.GetTypes();
82#pragma warning restore IL2026
83 foreach (Type type
in types) {
85 && !type.IsAbstract) {
86#pragma warning disable IL2072
87 if (Activator.CreateInstance(type) is not
ModLoader modLoader) {
88#pragma warning restore IL2072
91 modLoader.Entity =
this;
92 modLoader.__ModInitialize();
96 else if (type.IsSubclassOf(typeof(
Block))
97 && !type.IsAbstract) {
98#pragma warning disable IL2072
99 FieldInfo fieldInfo = type.GetRuntimeFields().FirstOrDefault(p => p.Name ==
"Index" && p.IsPublic && p.IsStatic);
100#pragma warning restore IL2072
101 if (fieldInfo ==
null
102 || fieldInfo.FieldType != typeof(
int)) {
104 new InvalidOperationException($
"Block type \"{type.FullName}\" does not have static field Index of type int.")
117 public override void LoadXdb(ref XElement xElement) {
123 public override void LoadCr(ref XElement xElement) {
Game.IContentReader.StringReader StringReader
static partial void SetContentPtr(IntPtr ptr)
static Stream OpenFile(string path, OpenFileMode openFileMode)
static bool FileExists(string path)
static void LoadBlocksData(string blocksDataString)
static void AddCategory(string category)
static UnmanagedMemoryStream GetStream()
static IntPtr Initialize()
static bool GetIsDownloaded()
static object Get(Type type, string name)
static Dictionary< string, IContentReader.IContentReader > ReaderList
static void Dispose(string name)
可能需要带上文件后缀,即获取名字+获取的后缀
static void Info(string mesg)
virtual void InitResources()
初始化Content资源
override void LoadBlocksData()
初始化BlocksData资源
override void HandleAssembly(Assembly assembly)
override void LoadCr(ref XElement xElement)
初始化CraftingRecipe
override Assembly[] GetAssemblies()
加载mod程序集
override void LoadClo(ClothingBlock block, ref XElement xElement)
初始化Clothing数据
override void SaveSettings(XElement xElement)
保存设置
override void LoadXdb(ref XElement xElement)
初始化Database数据
override void LoadSettings(XElement xElement)
加载设置
override void OnBlocksInitalized()
BlocksManager初始化完毕
static ZipArchive Open(Stream stream, bool keepStreamOpen=false)
static List< ModLoader > ModLoaders
static void AddException(Exception e, bool AllowContinue_=false)