public override void Setup(IXmlConfigurator configurator) { Mdp = new MdpClient(); configurator.RegisterAction("Config", (_, node) => Mdp.Configure(node)); configurator.RegisterAction("AddFiles", (_, node) => Mdp.AddFiles(node)); configurator.RegisterAction("MdpVerify", (_, node) => Mdp.Run(ModLoader.CurrentLoader.Configuration.ParentDirectory)); }
protected void IncludeXml(IXmlConfigurator configurator, XmlNode node) { string path = node.Attributes["src"]?.Value; if (path is null) { return; } ExecuteFromPath(path); }
public override void Setup(IXmlConfigurator configurator) { configurator.RegisterAction("Asset", LoadAsset); configurator.RegisterAction("Texture", LoadTexture); configurator.RegisterAction("Assembly", LoadAssembly); configurator.RegisterAction("Model", LoadModel); configurator.RegisterAction("Audio", LoadAudio); configurator.RegisterAction("Text", LoadText); configurator.RegisterAction("BinaryData", LoadData); configurator.RegisterAction("Bundle", LoadBundle); configurator.RegisterAction("RequireAsset", RequireAsset); configurator.RegisterAction("CreateAssetDatabase", CreateAssetDatabase); }
private void RequireAsset(IXmlConfigurator _, XmlNode node) { string path = node.Attributes["path"]?.Value; if (path is null) { throw new System.ArgumentException($"Invalid asset path [Empty]"); } string[] parts = path.Split(':'); if (parts.Length != 2) { throw new System.ArgumentException($"Invalid asset path \"{path}\". Must be in the format \"ModName:AssetName\""); } }
private void LoadBundle(IXmlConfigurator _, XmlNode node) { // TODO: reimplement this, create better exceptions string path = node.Attributes["src"]?.Value; string name = node.Attributes["name"]?.Value; if (path is null) { Debug.Fail($"tried to load a data file, but no path was given"); return; } if (name is null) { Debug.Fail($"tried to load a data file, but no name was given"); return; } UnityEngine.AssetBundle data = UnityEngine.AssetBundle.LoadFromFile(Path.Combine(ModLoader.CurrentLoader.CurrentMod.Directory, path)); GetModAssets(ModLoader.CurrentLoader.CurrentMod.Name).AddResource(name, data); }
private void LoadAssembly(IXmlConfigurator _, XmlNode node) { // TODO: reimplement this, create better exceptions string path = node.Attributes["src"]?.Value; string name = node.Attributes["name"]?.Value; if (path is null) { Debug.Fail($"tried to load an assembly, but no path was given"); return; } if (name is null) { Debug.Fail($"tried to load an assembly, but no name was given"); return; } Assembly assembly = Assembly.LoadFrom(Path.Combine(ModLoader.CurrentLoader.CurrentMod.Directory, path)); GetModAssets(ModLoader.CurrentLoader.CurrentMod.Name).AddResource(name, assembly); }
private void LoadAudio(IXmlConfigurator _, XmlNode node) { }
private void LoadModel(IXmlConfigurator _, XmlNode node) { }
private void LoadTexture(IXmlConfigurator _, XmlNode node) { }
private void LoadAsset(IXmlConfigurator _, XmlNode node) { }
private void CreateAssetDatabase(IXmlConfigurator _, XmlNode __) { assets.Add(ModLoader.CurrentLoader.CurrentMod.Name, new ResourceDatabase()); }
public override void Setup(IXmlConfigurator configurator) { Configurator = configurator; configurator.RegisterAction("AddModule", (_, node) => AddModuleFromXml(node)); }
public abstract void Setup(IXmlConfigurator configurator);