refactor: made factories static

This commit is contained in:
2025-04-01 12:18:33 +03:00
parent 9f3e39e337
commit 067bc51487
9 changed files with 16 additions and 27 deletions

View File

@@ -4,7 +4,6 @@ using System.Collections.Generic;
using Syntriax.Engine.Core.Abstract;
using Syntriax.Engine.Core.Exceptions;
using Syntriax.Engine.Core.Factory;
namespace Syntriax.Engine.Core;
@@ -19,16 +18,6 @@ public class GameManager : BaseEntity, IGameManager
private readonly List<IHierarchyObject> _hierarchyObjects = new(Constants.GAME_OBJECTS_SIZE_INITIAL);
private HierarchyObjectFactory _hierarchyObjectFactory = null!;
private HierarchyObjectFactory HierarchyObjectFactory
{
get
{
_hierarchyObjectFactory ??= new HierarchyObjectFactory();
return _hierarchyObjectFactory;
}
}
public IReadOnlyList<IHierarchyObject> HierarchyObjects => _hierarchyObjects;
public override IStateEnable StateEnable
@@ -37,7 +26,7 @@ public class GameManager : BaseEntity, IGameManager
{
if (base.StateEnable is null)
{
Assign(new StateEnableFactory().Instantiate(this));
Assign(Factory.StateEnableFactory.Instantiate(this));
if (base.StateEnable is null)
throw NotAssignedException.From(this, base.StateEnable);
}
@@ -72,7 +61,7 @@ public class GameManager : BaseEntity, IGameManager
public T InstantiateHierarchyObject<T>(params object?[]? args) where T : class, IHierarchyObject
{
T hierarchyObject = HierarchyObjectFactory.Instantiate<T>(args);
T hierarchyObject = Factory.HierarchyObjectFactory.Instantiate<T>(args);
Register(hierarchyObject);
return hierarchyObject;
}