20 lines
536 B
C#
20 lines
536 B
C#
using Syntriax.Engine.Core.Abstract;
|
|
using Syntriax.Engine.Core.Exceptions;
|
|
|
|
namespace Syntriax.Engine.Core.Factory;
|
|
|
|
public class StateEnableFactory
|
|
{
|
|
public IStateEnable Instantiate(IEntity entity) => Instantiate<StateEnable>(entity);
|
|
|
|
public T Instantiate<T>(IEntity entity, params object?[]? args) where T : class, IStateEnable
|
|
{
|
|
T stateEnable = TypeFactory.Get<T>(args);
|
|
|
|
if (!stateEnable.Assign(entity))
|
|
throw AssignException.From(stateEnable, entity);
|
|
|
|
return stateEnable;
|
|
}
|
|
}
|