chore: Added Initial Engine Code
This commit is contained in:
21
Engine.Core/Factory/BehaviourControllerFactory.cs
Normal file
21
Engine.Core/Factory/BehaviourControllerFactory.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Syntriax.Engine.Core.Abstract;
|
||||
using Syntriax.Engine.Core.Exceptions;
|
||||
|
||||
namespace Syntriax.Engine.Core.Factory;
|
||||
|
||||
public class BehaviourControllerFactory
|
||||
{
|
||||
public IBehaviourController Instantiate(IGameObject gameObject)
|
||||
=> Instantiate<BehaviourController>(gameObject);
|
||||
|
||||
public T Instantiate<T>(IGameObject gameObject, params object?[]? args)
|
||||
where T : class, IBehaviourController
|
||||
{
|
||||
T behaviourController = TypeFactory.Get<T>(args);
|
||||
|
||||
if (!behaviourController.Assign(gameObject))
|
||||
throw AssignException.From(behaviourController, gameObject);
|
||||
|
||||
return behaviourController;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user