chore: Finalize Don't Set Fields to Null Anymore
This commit is contained in:
parent
44bee2df08
commit
8a8c09f043
|
@ -54,7 +54,7 @@ public abstract class Behaviour : IBehaviour
|
||||||
|
|
||||||
public bool Assign(IStateEnable stateEnable)
|
public bool Assign(IStateEnable stateEnable)
|
||||||
{
|
{
|
||||||
if (_initialized)
|
if (Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_stateEnable = stateEnable;
|
_stateEnable = stateEnable;
|
||||||
|
@ -65,7 +65,7 @@ public abstract class Behaviour : IBehaviour
|
||||||
|
|
||||||
public bool Assign(IBehaviourController behaviourController)
|
public bool Assign(IBehaviourController behaviourController)
|
||||||
{
|
{
|
||||||
if (_behaviourController is not null)
|
if (Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_behaviourController = behaviourController;
|
_behaviourController = behaviourController;
|
||||||
|
@ -90,9 +90,6 @@ public abstract class Behaviour : IBehaviour
|
||||||
if (!Initialized)
|
if (!Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_behaviourController = null!;
|
|
||||||
_stateEnable = null!;
|
|
||||||
|
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class BehaviourController : IBehaviourController
|
||||||
|
|
||||||
public bool Assign(IGameObject gameObject)
|
public bool Assign(IGameObject gameObject)
|
||||||
{
|
{
|
||||||
if (_gameObject is not null)
|
if (GameObject.Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_gameObject = gameObject;
|
_gameObject = gameObject;
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class DrawableSpriteBehaviour : Behaviour, IDrawBehaviour, IAssignableSpr
|
||||||
|
|
||||||
public bool Assign(ISprite sprite)
|
public bool Assign(ISprite sprite)
|
||||||
{
|
{
|
||||||
if (_sprite is not null)
|
if (Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_sprite = sprite;
|
_sprite = sprite;
|
||||||
|
|
|
@ -2,6 +2,7 @@ using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
using Syntriax.Engine.Core.Abstract;
|
using Syntriax.Engine.Core.Abstract;
|
||||||
|
using Syntriax.Engine.Core.Exceptions;
|
||||||
using Syntriax.Engine.Core.Factory;
|
using Syntriax.Engine.Core.Factory;
|
||||||
|
|
||||||
namespace Syntriax.Engine.Core;
|
namespace Syntriax.Engine.Core;
|
||||||
|
@ -63,6 +64,8 @@ public class GameManager : IInitialize
|
||||||
if (Initialized)
|
if (Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
NotAssignedException.Check(this, StateEnable);
|
||||||
|
|
||||||
foreach (var gameObject in GameObjects)
|
foreach (var gameObject in GameObjects)
|
||||||
gameObject.Initialize();
|
gameObject.Initialize();
|
||||||
|
|
||||||
|
@ -84,7 +87,7 @@ public class GameManager : IInitialize
|
||||||
|
|
||||||
public bool Assign(IStateEnable stateEnable)
|
public bool Assign(IStateEnable stateEnable)
|
||||||
{
|
{
|
||||||
if (_stateEnable is not null)
|
if (Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_stateEnable = stateEnable;
|
_stateEnable = stateEnable;
|
||||||
|
|
|
@ -92,17 +92,13 @@ public class GameObject : IGameObject
|
||||||
behaviour => behaviour.Finalize()
|
behaviour => behaviour.Finalize()
|
||||||
);
|
);
|
||||||
|
|
||||||
_transform = null!;
|
|
||||||
_behaviourController = null!;
|
|
||||||
_stateEnable = null!;
|
|
||||||
|
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Assign(IStateEnable stateEnable)
|
public bool Assign(IStateEnable stateEnable)
|
||||||
{
|
{
|
||||||
if (_stateEnable is not null)
|
if (Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_stateEnable = stateEnable;
|
_stateEnable = stateEnable;
|
||||||
|
@ -112,7 +108,7 @@ public class GameObject : IGameObject
|
||||||
|
|
||||||
public bool Assign(ITransform transform)
|
public bool Assign(ITransform transform)
|
||||||
{
|
{
|
||||||
if (_transform is not null)
|
if (Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_transform = transform;
|
_transform = transform;
|
||||||
|
@ -122,7 +118,7 @@ public class GameObject : IGameObject
|
||||||
|
|
||||||
public bool Assign(IBehaviourController behaviourController)
|
public bool Assign(IBehaviourController behaviourController)
|
||||||
{
|
{
|
||||||
if (_behaviourController is not null)
|
if (Initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_behaviourController = behaviourController;
|
_behaviourController = behaviourController;
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class StateEnable : IStateEnable
|
||||||
|
|
||||||
public bool Assign(IEntity entity)
|
public bool Assign(IEntity entity)
|
||||||
{
|
{
|
||||||
if (_entity is not null)
|
if (_entity is not null) // TODO: IInitialize Maybe?
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_entity = entity;
|
_entity = entity;
|
||||||
|
|
Loading…
Reference in New Issue