refactor!: IGameObject removed
This commit is contained in:
35
Engine.Core/Factory/HierarchyObjectFactory.cs
Normal file
35
Engine.Core/Factory/HierarchyObjectFactory.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Syntriax.Engine.Core.Abstract;
|
||||
using Syntriax.Engine.Core.Exceptions;
|
||||
|
||||
namespace Syntriax.Engine.Core.Factory;
|
||||
|
||||
public class HierarchyObjectFactory
|
||||
{
|
||||
public T Instantiate<T>(params object?[]? args) where T : class, IHierarchyObject
|
||||
=> Instantiate<T>(behaviourController: null, stateEnable: null, args);
|
||||
|
||||
public T Instantiate<T>(
|
||||
IBehaviourController? behaviourController = null,
|
||||
IStateEnable? stateEnable = null,
|
||||
params object?[]? args
|
||||
)
|
||||
where T : class, IHierarchyObject
|
||||
{
|
||||
T hierarchyObject = TypeFactory.Get<T>(args);
|
||||
|
||||
behaviourController ??= TypeFactory.Get<BehaviourController>();
|
||||
stateEnable ??= TypeFactory.Get<StateEnable>();
|
||||
|
||||
if (!behaviourController.Assign(hierarchyObject))
|
||||
throw AssignException.From(behaviourController, hierarchyObject);
|
||||
if (!stateEnable.Assign(hierarchyObject))
|
||||
throw AssignException.From(stateEnable, hierarchyObject);
|
||||
|
||||
if (!hierarchyObject.Assign(behaviourController))
|
||||
throw AssignException.From(hierarchyObject, behaviourController);
|
||||
if (!hierarchyObject.Assign(stateEnable))
|
||||
throw AssignException.From(hierarchyObject, stateEnable);
|
||||
|
||||
return hierarchyObject;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user