using IPA.Loader;
using System;
namespace IPA
{
///
/// Marks a class as being a BSIPA plugin.
///
///
///
///
///
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class PluginAttribute : Attribute
{
///
/// The passed into the constructor of this attribute.
///
// whenever this changes, PluginLoader.LoadMetadata must also change
public RuntimeOptions RuntimeOptions { get; }
///
/// Initializes a with the given
/// to indicate the runtime capabilities of the plugin.
///
/// the options to use for this plugin
public PluginAttribute(RuntimeOptions runtimeOptions)
{
RuntimeOptions = runtimeOptions;
}
}
///
/// Options that a plugin must specify to describe how it expects to be run.
///
///
///
///
///
///
///
// TODO: figure out a better name for this
public enum RuntimeOptions
{
///
///
/// Indicates that this plugin expects to be initialized and enabled with the game, and disabled with the game.
///
///
/// With this option set, whether or not the plugin is disabled during a given run is constant for that entire run.
///
///
SingleStartInit,
///
///
/// Indicates that this plugin supports runtime enabling and disabling.
///
///
/// When this is set, the plugin may be disabled at reasonable points during runtime. As with ,
/// it will be initialized and enabled with the game if it is enabled on startup, and disabled with the game if it is enabled
/// on shutdown.
///
///
/// When a plugin with this set is enabled mid-game, the first time it is enabled, its initialization methods will be called,
/// then its enable methods. All subsequent enables will NOT re-initialize, however the enable methods will be called.
///
///
/// When a plugin with this set is disabled mid-game, the plugin instance will NOT be destroyed, and will instead be
/// re-used for subsequent enables. The plugin is expected to handle this gracefully, and behave in a way that makes sense.
///
///
DynamicInit
}
///
/// Marks a method or a constructor as an inialization method.
///
///
///
/// If more than one constructor is marked with this attribute, the one with the most parameters, whether or not they can be injected, will be used.
///
///
/// Parameter injection is done with .
///
///
///
///
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
public sealed class InitAttribute : Attribute { }
}