chore: bumped dotnet version to 10
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Engine.Systems</RootNamespace>
|
||||
|
||||
@@ -29,22 +29,21 @@ public class NetworkManager : Behaviour, IEnterUniverse, IExitUniverse, INetwork
|
||||
private readonly BehaviourCollector<INetworkEntity> _networkEntityCollector = new();
|
||||
public IBehaviourCollector<INetworkEntity> NetworkEntityCollector => _networkEntityCollector;
|
||||
|
||||
private INetworkCommunicator _networkCommunicator = null!;
|
||||
public INetworkCommunicator NetworkCommunicator
|
||||
{
|
||||
get => _networkCommunicator;
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (_networkCommunicator == value)
|
||||
if (field == value)
|
||||
return;
|
||||
|
||||
INetworkCommunicator? previousCommunicator = _networkCommunicator;
|
||||
_networkCommunicator = value;
|
||||
INetworkCommunicator? previousCommunicator = field;
|
||||
field = value;
|
||||
|
||||
if (previousCommunicator is not null) UnsubscribeCommunicatorMethods(previousCommunicator);
|
||||
if (_networkCommunicator is not null) SubscribeCommunicatorMethods(_networkCommunicator);
|
||||
if (field is not null) SubscribeCommunicatorMethods(field);
|
||||
}
|
||||
}
|
||||
} = null!;
|
||||
|
||||
#region Communicator Subscriptions
|
||||
private void SubscribeCommunicatorMethods(INetworkCommunicator networkCommunicator)
|
||||
|
||||
@@ -2,15 +2,14 @@ namespace Engine.Systems.Network;
|
||||
|
||||
public static class TypeHasher<T>
|
||||
{
|
||||
private static long _fnv1a = 0;
|
||||
public static long FNV1a
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_fnv1a == 0)
|
||||
_fnv1a = Hasher.FNV1a(typeof(T).FullName ?? typeof(T).Name);
|
||||
if (field == 0)
|
||||
field = Hasher.FNV1a(typeof(T).FullName ?? typeof(T).Name);
|
||||
|
||||
return _fnv1a;
|
||||
return field;
|
||||
}
|
||||
}
|
||||
} = 0;
|
||||
}
|
||||
|
||||
@@ -14,23 +14,22 @@ public class State : BaseEntity, IState
|
||||
|
||||
private readonly List<StateTransition> transitions = [];
|
||||
private readonly Dictionary<string, StateTransition> possibleTransitions = [];
|
||||
private string _name = "Default State Name";
|
||||
|
||||
public IReadOnlyList<StateTransition> Transitions => transitions;
|
||||
public IReadOnlyDictionary<string, StateTransition> PossibleTransitions => possibleTransitions;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (_name.CompareTo(value) == 0)
|
||||
if (field.CompareTo(value) == 0)
|
||||
return;
|
||||
|
||||
string previousName = _name;
|
||||
_name = value;
|
||||
string previousName = field;
|
||||
field = value;
|
||||
OnNameChanged?.Invoke(this, new(previousName));
|
||||
}
|
||||
}
|
||||
} = "Default State Name";
|
||||
|
||||
public void RemoveTransition(string name)
|
||||
{
|
||||
|
||||
@@ -10,20 +10,19 @@ public abstract class StateBehaviourBase : Behaviour, IState
|
||||
public Event<IState, IState.StateTransitionReadyArguments> OnStateTransitionReady { get; } = new();
|
||||
public Event<INameable, INameable.NameChangedArguments> OnNameChanged { get; } = new();
|
||||
|
||||
private string _name = string.Empty;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (_name.CompareTo(value) == 0)
|
||||
if (field.CompareTo(value) == 0)
|
||||
return;
|
||||
|
||||
string previousName = _name;
|
||||
_name = value;
|
||||
string previousName = field;
|
||||
field = value;
|
||||
OnNameChanged?.Invoke(this, new(previousName));
|
||||
}
|
||||
}
|
||||
} = string.Empty;
|
||||
|
||||
protected virtual void OnUpdateState() { }
|
||||
public void Update()
|
||||
|
||||
@@ -9,33 +9,26 @@ public class StateMachine : Behaviour, IUpdate
|
||||
|
||||
private readonly Event<IState, IState.StateTransitionReadyArguments>.EventHandler delegateOnStateTransitionReady = null!;
|
||||
|
||||
private IState _state = new State();
|
||||
|
||||
public StateMachine()
|
||||
{
|
||||
delegateOnStateTransitionReady = OnStateTransitionReady;
|
||||
}
|
||||
|
||||
[Serialize]
|
||||
public IState State
|
||||
{
|
||||
get => _state;
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (_state == value)
|
||||
if (field == value)
|
||||
return;
|
||||
|
||||
IState previousState = _state;
|
||||
IState previousState = field;
|
||||
previousState.OnStateTransitionReady.RemoveListener(delegateOnStateTransitionReady);
|
||||
|
||||
_state = value;
|
||||
field = value;
|
||||
previousState.TransitionFrom(value);
|
||||
value.TransitionTo(_state);
|
||||
value.TransitionTo(field);
|
||||
OnStateChanged?.Invoke(this, new(value, previousState));
|
||||
|
||||
value.OnStateTransitionReady.AddListener(delegateOnStateTransitionReady);
|
||||
}
|
||||
}
|
||||
} = new State();
|
||||
|
||||
private void OnStateTransitionReady(IState sender, IState.StateTransitionReadyArguments args)
|
||||
{
|
||||
@@ -55,5 +48,10 @@ public class StateMachine : Behaviour, IUpdate
|
||||
State.Update();
|
||||
}
|
||||
|
||||
public StateMachine()
|
||||
{
|
||||
delegateOnStateTransitionReady = OnStateTransitionReady;
|
||||
}
|
||||
|
||||
public readonly record struct StateChangedArguments(IState CurrentState, IState PreviousState);
|
||||
}
|
||||
|
||||
@@ -14,18 +14,17 @@ public class Timer : Behaviour, IUpdate, IEnterUniverse, IExitUniverse, ITimer
|
||||
public double StartTime { get; protected set; } = 0f;
|
||||
public float Percentage => (float)(1f - (Remaining / StartTime));
|
||||
|
||||
private double _remaining = 0f;
|
||||
public double Remaining
|
||||
{
|
||||
get => _remaining;
|
||||
get;
|
||||
protected set
|
||||
{
|
||||
if (value < .0f)
|
||||
value = .0f;
|
||||
|
||||
_remaining = value;
|
||||
field = value;
|
||||
}
|
||||
}
|
||||
} = 0f;
|
||||
|
||||
private bool shouldBeTicking = false;
|
||||
private bool hasStartedTickingBefore = false;
|
||||
|
||||
@@ -13,17 +13,18 @@ internal class Tween : ITween
|
||||
public Event<ITween> OnUpdated { get; } = new();
|
||||
public Event<ITween, ITween.TweenDeltaArguments> OnDeltaUpdated { get; } = new();
|
||||
|
||||
private TweenState _state = TweenState.Idle;
|
||||
private float _counter = 0f;
|
||||
|
||||
public TweenState State
|
||||
{
|
||||
get => _state;
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (value == _state)
|
||||
if (value == field)
|
||||
return;
|
||||
|
||||
TweenState previousState = _state;
|
||||
_state = value;
|
||||
TweenState previousState = field;
|
||||
field = value;
|
||||
switch (value)
|
||||
{
|
||||
case TweenState.Completed: OnCompleted?.Invoke(this); OnEnded?.Invoke(this); break;
|
||||
@@ -37,11 +38,10 @@ internal class Tween : ITween
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} = TweenState.Idle;
|
||||
|
||||
public float Duration { get; internal set; } = 1f;
|
||||
public float Progress { get; internal set; } = 0f;
|
||||
private float _counter = 0f;
|
||||
|
||||
public IEasing Easing { get; set; } = EaseLinear.Instance;
|
||||
public float Value => Easing.Evaluate(Progress);
|
||||
|
||||
Reference in New Issue
Block a user