using System;
using Artemis.Core.Plugins.Abstract.DataModels;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
namespace Artemis.Core.Plugins.Abstract
{
///
/// Allows you to expand the application-wide datamodel
///
public abstract class BaseDataModelExpansion : BaseDataModelExpansion where T : DataModel
{
///
/// The data model driving this module
///
public T DataModel
{
get => (T) InternalDataModel;
internal set => InternalDataModel = value;
}
internal override void InternalEnablePlugin()
{
DataModel = Activator.CreateInstance();
DataModel.PluginInfo = PluginInfo;
DataModel.DataModelDescription = GetDataModelDescription();
base.InternalEnablePlugin();
}
internal override void InternalDisablePlugin()
{
DataModel = null;
base.InternalDisablePlugin();
}
}
///
/// For internal use only, to implement your own layer property type, extend
/// instead.
///
public abstract class BaseDataModelExpansion : Plugin
{
internal DataModel InternalDataModel { get; set; }
public abstract void Update(double deltaTime);
///
/// Override to provide your own data model description. By default this returns a description matching your plugin
/// name and description
///
///
public virtual DataModelPropertyAttribute GetDataModelDescription()
{
return new DataModelPropertyAttribute {Name = PluginInfo.Name, Description = PluginInfo.Description};
}
}
}