refactor: code styles enforced with .editorconfig

This commit is contained in:
2025-03-17 21:32:37 +03:00
parent d71c135491
commit 9af44d48b3
22 changed files with 243 additions and 48 deletions

View File

@@ -14,7 +14,6 @@ public abstract class BaseEntity : IEntity
public event IAssignableStateEnable.OnStateEnableAssignedEventHandler? OnStateEnableAssigned = null;
public event IAssignable.OnUnassignedEventHandler? OnUnassigned = null;
private IStateEnable _stateEnable = null!;
private bool _initialized = false;

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Syntriax.Engine.Core.Abstract;

View File

@@ -1,5 +1,3 @@
using System.Collections;
namespace Syntriax.Engine.Core.Abstract;
public interface ICoroutineYield

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
namespace Syntriax.Engine.Core.Abstract;

View File

@@ -10,12 +10,10 @@ public abstract class BehaviourBase : BaseEntity, IBehaviour
public event IBehaviour.OnPriorityChangedEventHandler? OnPriorityChanged = null;
private IBehaviourController _behaviourController = null!;
private int _priority = 0;
public IBehaviourController BehaviourController => _behaviourController;
public override bool IsActive => base.IsActive && BehaviourController.GameObject.StateEnable.Enabled;

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Syntriax.Engine.Core.Abstract;
@@ -32,7 +31,6 @@ public class BehaviourController : IBehaviourController
public IGameObject GameObject => _gameObject;
public bool IsInitialized
{
get => _initialized;
@@ -67,7 +65,7 @@ public class BehaviourController : IBehaviourController
public T? GetBehaviour<T>()
{
foreach (var behaviourItem in behaviours)
foreach (IBehaviour behaviourItem in behaviours)
if (behaviourItem is T result)
return result;
@@ -77,7 +75,7 @@ public class BehaviourController : IBehaviourController
public IList<T> GetBehaviours<T>()
{
List<T>? behaviours = null;
foreach (var behaviourItem in this.behaviours)
foreach (IBehaviour behaviourItem in this.behaviours)
{
if (behaviourItem is not T behaviour)
continue;
@@ -92,7 +90,7 @@ public class BehaviourController : IBehaviourController
public void GetBehaviours<T>(IList<T> results)
{
results.Clear();
foreach (var behaviourItem in behaviours)
foreach (IBehaviour behaviourItem in behaviours)
{
if (behaviourItem is not T behaviour)
continue;
@@ -136,7 +134,6 @@ public class BehaviourController : IBehaviourController
return true;
}
public bool Initialize()
{
if (IsInitialized)
@@ -210,7 +207,6 @@ public class BehaviourController : IBehaviourController
behaviours.Add(behaviour);
}
private void OnPriorityChange(IBehaviour sender, int previousPriority)
{
behaviours.Remove(sender);

View File

@@ -1,5 +1,4 @@
using System;
using Syntriax.Engine.Core.Abstract;
namespace Syntriax.Engine.Core.Exceptions;
@@ -11,7 +10,7 @@ public class AssignException : Exception
// public static AssignException FromStateEnable(IStateEnable? stateEnable)
// => new AssignException($"{nameof(IGameObject.AssignStateEnable)} failed on type {stateEnable?.GetType().ToString() ?? "\"null\""}");
public static AssignException From<T, T2>(T to, T2? value)
=> new AssignException($"Assign operation has failed on T: {typeof(T).FullName}, value: {value?.GetType().ToString() ?? "\"null\""}");
=> new($"Assign operation has failed on T: {typeof(T).FullName}, value: {value?.GetType().ToString() ?? "\"null\""}");
// public static AssignException FromBehaviourController(IBehaviourController? behaviourController)
// => new AssignException($"{nameof(IGameObject.AssignBehaviourController)} failed on type {behaviourController?.GetType().ToString() ?? "\"null\""}");
}

View File

@@ -9,7 +9,7 @@ public class NotAssignedException : Exception
public NotAssignedException(string? message) : base(message) { }
public static NotAssignedException From<T1, T2>(T1 to, T2? value) where T1 : IAssignable
=> new NotAssignedException($"{typeof(T2).Name} has not been assigned to {typeof(T1).Name}");
=> new($"{typeof(T2).Name} has not been assigned to {typeof(T1).Name}");
public static void Check<T1, T2>(T1 to, T2? value) where T1 : IAssignable
{

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Syntriax.Engine.Core.Abstract;
@@ -102,7 +101,7 @@ public class GameManager : BaseEntity, IGameManager
base.InitializeInternal();
NotAssignedException.Check(this, StateEnable);
foreach (var gameObject in GameObjects)
foreach (IGameObject gameObject in GameObjects)
gameObject.Initialize();
}

View File

@@ -20,7 +20,6 @@ public class Transform : ITransform
public event ITransform.OnChildrenAddedEventHandler? OnChildrenAdded = null;
public event ITransform.OnChildrenRemovedEventHandler? OnChildrenRemoved = null;
private Vector2D _position = Vector2D.Zero;
private Vector2D _scale = Vector2D.One;
private float _rotation = 0f;
@@ -179,7 +178,7 @@ public class Transform : ITransform
{
// TODO No idea how logical this is to propagate this to the children the way I'm doing right now.
// I was originally gonna just call `child.OnParentChanged?.Invoke(child, child.Parent);` but seems an unnecessary call too?
foreach (var child in Children) // TODO CHECK ERRORS
foreach (ITransform child in Children) // TODO CHECK ERRORS
child.SetParent(this);
}