public override void InitMod(Mod Mod) { if (Bootables.ContainsKey(Mod.ModID)) { Sys.Ref.ConsoleSys.Error("Tried to init twice " + Mod.ModID); return; } ModSys ModSys = Sys.Ref.Shared.GetObject <ModSys>(); AssemblySys AssemblySys = Sys.Ref.Shared.GetNode <AssemblySys>(); string BootTarget = ModSys.GetManifest(Mod).Boot; if (BootTarget == null) { Sys.Ref.ConsoleSys.Error("Tried to init " + Mod.ModID + " without Boot target"); return; } Type BootType = AssemblySys.GetType(BootTarget); if (BootType == null) { Sys.Ref.ConsoleSys.Error("Tried to init " + Mod.ModID + " with invalid Boot target"); return; } IBoot NewBoot = (IBoot)Activator.CreateInstance(BootType); Bootables[Mod.ModID] = NewBoot; Bootables[Mod.ModID].AddShared(); }
public override void InitCore(Mod Mod) { if (ModIDFiles.ContainsKey(Mod.ModID)) { return; } ModSys ModSys = Sys.Ref.Shared.GetObject <ModSys>(); string PCKPath = Mod.Path + '/' + Mod.ModID + ".pck"; string PCKManifest = Mod.Path + '/' + Mod.ModID + ".json"; #if DEBUG if (!FilesystemUtil.GD.PackPCK(Mod.ModID, Mod.Path, new List <string>() { })) { Sys.Ref.ConsoleSys.Error("Failed to repack " + Mod.ModID); return; } #endif if (!FilesystemUtil.Sys.FileExists(PCKPath)) { Sys.Ref.ConsoleSys.Error(Mod.ModID + " is not providing a package to load from"); return; } if (!FilesystemUtil.Sys.FileExists(PCKManifest)) { Sys.Ref.ConsoleSys.Error(Mod.ModID + " is not providing a package manifest to load from"); return; } string Manifest = FilesystemUtil.Sys.FileRead(PCKManifest); if (Manifest == null) { Sys.Ref.ConsoleSys.Error(Mod.ModID + " is providing a package manifest but it is empty"); return; } try { List <string> Files = JsonConvert.DeserializeObject <List <string> >(Manifest); ModIDFiles[Mod.ModID] = Files; CorePath = Mod.Path; } catch (Exception) { return; } if (!ProjectSettings.LoadResourcePack(PCKPath)) { Sys.Ref.ConsoleSys.Error("Failed to load package of " + Mod.ModID); return; } }
public override void InitMod(Mod Mod) { if (ModIDFiles.ContainsKey(Mod.ModID)) { return; } ModSys ModSys = Sys.Ref.Shared.GetObject <ModSys>(); if (!FilesystemUtil.GD.DirContainsFiles(Mod.Path, Mod.ModID + ".pck")) { return; } #if DEBUG List <string> TargetFolders = new List <string>(); TargetFolders.Add(Mod.ModID); if (ModSys.GetManifest(Mod).Overrides != null) { TargetFolders.AddRange(ModSys.GetManifest(Mod).Overrides); } TargetFolders = TargetFolders.Distinct().ToList(); FilesystemUtil.GD.PackPCK(Mod.ModID, Mod.Path, TargetFolders); #endif string Manifest = FilesystemUtil.Sys.FileRead(Mod.Path + '/' + Mod.ModID + ".json"); if (Manifest == null) { return; } try { List <string> Files = JsonConvert.DeserializeObject <List <string> >(Manifest); ModIDFiles[Mod.ModID] = Files; } catch (Exception) { return; } if (!ProjectSettings.LoadResourcePack(Mod.Path + '/' + Mod.ModID + ".pck")) { return; } }