refactor: behaviour factory universe object parameter removed
This commit is contained in:
parent
0bf38234c6
commit
3b6a93d37a
@ -36,7 +36,10 @@ public class BehaviourController : BaseEntity, IBehaviourController
|
|||||||
}
|
}
|
||||||
|
|
||||||
public T AddBehaviour<T>(params object?[]? args) where T : class, IBehaviour
|
public T AddBehaviour<T>(params object?[]? args) where T : class, IBehaviour
|
||||||
=> AddBehaviour(Factory.BehaviourFactory.Instantiate<T>(_universeObject, args));
|
{
|
||||||
|
T behaviour = Factory.BehaviourFactory.Instantiate<T>(args);
|
||||||
|
return AddBehaviour(behaviour);
|
||||||
|
}
|
||||||
|
|
||||||
public T? GetBehaviour<T>()
|
public T? GetBehaviour<T>()
|
||||||
{
|
{
|
||||||
|
@ -4,10 +4,10 @@ namespace Syntriax.Engine.Core.Factory;
|
|||||||
|
|
||||||
public class BehaviourFactory
|
public class BehaviourFactory
|
||||||
{
|
{
|
||||||
public static T Instantiate<T>(IUniverseObject universeObject, params object?[]? args) where T : class, IBehaviour
|
public static T Instantiate<T>(params object?[]? args) where T : class, IBehaviour
|
||||||
=> Instantiate<T>(universeObject, stateEnable: null, args);
|
=> Instantiate<T>(stateEnable: null, args);
|
||||||
|
|
||||||
public static T Instantiate<T>(IUniverseObject universeObject, IStateEnable? stateEnable, params object?[]? args)
|
public static T Instantiate<T>(IStateEnable? stateEnable, params object?[]? args)
|
||||||
where T : class, IBehaviour
|
where T : class, IBehaviour
|
||||||
{
|
{
|
||||||
T behaviour = TypeFactory.Get<T>(args);
|
T behaviour = TypeFactory.Get<T>(args);
|
||||||
@ -18,8 +18,6 @@ public class BehaviourFactory
|
|||||||
|
|
||||||
if (!behaviour.Assign(stateEnable))
|
if (!behaviour.Assign(stateEnable))
|
||||||
throw AssignFailedException.From(behaviour, stateEnable);
|
throw AssignFailedException.From(behaviour, stateEnable);
|
||||||
if (!behaviour.Assign(universeObject.BehaviourController))
|
|
||||||
throw AssignFailedException.From(behaviour, universeObject.BehaviourController);
|
|
||||||
|
|
||||||
return behaviour;
|
return behaviour;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user