chore: bumped dotnet version to 10
This commit is contained in:
@@ -6,32 +6,29 @@ public class StateEnable : IStateEnable
|
||||
public Event<IHasEntity> OnEntityAssigned { get; } = new();
|
||||
public Event<IAssignable>? OnUnassigned { get; } = new();
|
||||
|
||||
private bool _enabled = true;
|
||||
private IEntity _entity = null!;
|
||||
|
||||
public IEntity Entity => _entity;
|
||||
public IEntity Entity { get; private set; } = null!;
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => _enabled;
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (value == _enabled)
|
||||
if (value == field)
|
||||
return;
|
||||
|
||||
bool previousState = _enabled;
|
||||
_enabled = value;
|
||||
bool previousState = field;
|
||||
field = value;
|
||||
OnEnabledChanged?.Invoke(this, new(previousState));
|
||||
}
|
||||
}
|
||||
} = true;
|
||||
|
||||
protected virtual void OnAssign(IEntity entity) { }
|
||||
public bool Assign(IEntity entity)
|
||||
{
|
||||
if (_entity is not null && _entity.IsInitialized)
|
||||
if (Entity is not null && Entity.IsInitialized)
|
||||
return false;
|
||||
|
||||
_entity = entity;
|
||||
Entity = entity;
|
||||
OnAssign(entity);
|
||||
OnEntityAssigned?.Invoke(this);
|
||||
return true;
|
||||
@@ -39,10 +36,10 @@ public class StateEnable : IStateEnable
|
||||
|
||||
public bool Unassign()
|
||||
{
|
||||
if (_entity is null)
|
||||
if (Entity is null)
|
||||
return false;
|
||||
|
||||
_entity = null!;
|
||||
Entity = null!;
|
||||
OnUnassigned?.Invoke(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user