22 lines
679 B
C#
22 lines
679 B
C#
using Syntriax.Engine.Core.Abstract;
|
|
using Syntriax.Engine.Core.Exceptions;
|
|
|
|
namespace Syntriax.Engine.Core.Factory;
|
|
|
|
public class BehaviourControllerFactory
|
|
{
|
|
public IBehaviourController Instantiate(IHierarchyObject hierarchyObject)
|
|
=> Instantiate<BehaviourController>(hierarchyObject);
|
|
|
|
public T Instantiate<T>(IHierarchyObject hierarchyObject, params object?[]? args)
|
|
where T : class, IBehaviourController
|
|
{
|
|
T behaviourController = TypeFactory.Get<T>(args);
|
|
|
|
if (!behaviourController.Assign(hierarchyObject))
|
|
throw AssignException.From(behaviourController, hierarchyObject);
|
|
|
|
return behaviourController;
|
|
}
|
|
}
|