chore: Added Initial Engine Code
This commit is contained in:
6
Engine.Core/Abstract/Assignable/IAssignable.cs
Normal file
6
Engine.Core/Abstract/Assignable/IAssignable.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the class implementing it has Assignable fields that are necessary for the engine to work properly.
|
||||
/// </summary>
|
||||
public interface IAssignable { }
|
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="IBehaviourController"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableBehaviourController : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="IBehaviourController"/> value has has been assigned a new value.
|
||||
/// </summary>
|
||||
Action<IAssignableBehaviourController>? OnBehaviourControllerAssigned { get; set; }
|
||||
|
||||
/// <inheritdoc cref="IBehaviourController" />
|
||||
IBehaviourController BehaviourController { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Assign a value to the <see cref="IBehaviourController"/> field of this object
|
||||
/// </summary>
|
||||
/// <param name="behaviourController">New <see cref="IBehaviourController"/> to assign.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the value given assigned successfully assigned, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool Assign(IBehaviourController behaviourController);
|
||||
}
|
26
Engine.Core/Abstract/Assignable/IAssignableEntity.cs
Normal file
26
Engine.Core/Abstract/Assignable/IAssignableEntity.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="IEntity"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableEntity : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="IEntity"/> value has has been assigned a new value.
|
||||
/// </summary>
|
||||
Action<IAssignableEntity>? OnEntityAssigned { get; set; }
|
||||
|
||||
/// <inheritdoc cref="IEntity" />
|
||||
IEntity Entity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Assign a value to the <see cref="IEntity"/> field of this object
|
||||
/// </summary>
|
||||
/// <param name="entity">New <see cref="IEntity"/> to assign.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the value given assigned successfully assigned, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool Assign(IEntity entity);
|
||||
}
|
26
Engine.Core/Abstract/Assignable/IAssignableGameObject.cs
Normal file
26
Engine.Core/Abstract/Assignable/IAssignableGameObject.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="IGameObject"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableGameObject : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="IGameObject"/> value has has been assigned a new value.
|
||||
/// </summary>
|
||||
Action<IAssignableGameObject>? OnGameObjectAssigned { get; set; }
|
||||
|
||||
/// <inheritdoc cref="IGameObject" />
|
||||
IGameObject GameObject { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Assign a value to the <see cref="IGameObject"/> field of this object
|
||||
/// </summary>
|
||||
/// <param name="gameObject">New <see cref="IGameObject"/> to assign.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the value given assigned successfully assigned, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool Assign(IGameObject gameObject);
|
||||
}
|
26
Engine.Core/Abstract/Assignable/IAssignableSprite.cs
Normal file
26
Engine.Core/Abstract/Assignable/IAssignableSprite.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="ISprite"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableSprite : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="ISprite"/> value has has been assigned a new value.
|
||||
/// </summary>
|
||||
Action<IAssignableSprite>? OnSpriteAssigned { get; set; }
|
||||
|
||||
/// <inheritdoc cref="ISprite" />
|
||||
ISprite Sprite { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Assign a value to the <see cref="ISprite"/> field of this object
|
||||
/// </summary>
|
||||
/// <param name="sprite">New <see cref="ISprite"/> to assign.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the value given assigned successfully assigned, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool Assign(ISprite sprite);
|
||||
}
|
26
Engine.Core/Abstract/Assignable/IAssignableStateEnable.cs
Normal file
26
Engine.Core/Abstract/Assignable/IAssignableStateEnable.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="IStateEnable"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableStateEnable : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="IStateEnable"/> value has has been assigned a new value.
|
||||
/// </summary>
|
||||
Action<IAssignableStateEnable>? OnStateEnableAssigned { get; set; }
|
||||
|
||||
/// <inheritdoc cref="IStateEnable" />
|
||||
IStateEnable StateEnable { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Assign a value to the <see cref="IStateEnable"/> field of this object
|
||||
/// </summary>
|
||||
/// <param name="stateEnable">New <see cref="IStateEnable"/> to assign.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the value given assigned successfully assigned, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool Assign(IStateEnable stateEnable);
|
||||
}
|
26
Engine.Core/Abstract/Assignable/IAssignableTransform.cs
Normal file
26
Engine.Core/Abstract/Assignable/IAssignableTransform.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the object is an <see cref="IAssignable"/> with an assignable <see cref="ITransform"/> field.
|
||||
/// </summary>
|
||||
public interface IAssignableTransform : IAssignable
|
||||
{
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="ITransform"/> value has has been assigned a new value.
|
||||
/// </summary>
|
||||
Action<IAssignableTransform>? OnTransformAssigned { get; set; }
|
||||
|
||||
/// <inheritdoc cref="ITransform" />
|
||||
ITransform Transform { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Assign a value to the <see cref="ITransform"/> field of this object
|
||||
/// </summary>
|
||||
/// <param name="transform">New <see cref="ITransform"/> to assign.</param>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the value given assigned successfully assigned, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool Assign(ITransform transform);
|
||||
}
|
19
Engine.Core/Abstract/IBehaviour.cs
Normal file
19
Engine.Core/Abstract/IBehaviour.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Responsible for every behaviour an object in the game might have, controlled by <see cref="IBehaviourController"/>.
|
||||
/// </summary>
|
||||
public interface IBehaviour : IEntity, IAssignableBehaviourController, IAssignableStateEnable, IInitialize
|
||||
{
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="Priority"/> has changed.
|
||||
/// </summary>
|
||||
Action<IBehaviour>? OnPriorityChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Call priority of the <see cref="IBehaviour"/>.
|
||||
/// </summary>
|
||||
int Priority { get; set; }
|
||||
}
|
85
Engine.Core/Abstract/IBehaviourController.cs
Normal file
85
Engine.Core/Abstract/IBehaviourController.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
/// <summary>
|
||||
/// Responsible for controlling <see cref="IBehaviour"/>s and notify them accordingly about the engine's updates. Connected to an <see cref="IGameObject"/>.
|
||||
/// </summary>
|
||||
public interface IBehaviourController : IAssignableGameObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="Update(GameTime)"/> is called.
|
||||
/// </summary>
|
||||
Action<IBehaviourController, GameTime>? OnUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="OnPreDraw(GameTime)"/> is called.
|
||||
/// </summary>
|
||||
Action<IBehaviourController, GameTime>? OnPreDraw { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="IBehaviourController"/> has been registered a new <see cref="IBehaviour"/>.
|
||||
/// </summary>
|
||||
Action<IBehaviourController, IBehaviour>? OnBehaviourAdded { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Callback triggered when the <see cref="IBehaviourController"/> has been removed an existing <see cref="IBehaviour"/>.
|
||||
/// </summary>
|
||||
Action<IBehaviourController, IBehaviour>? OnBehaviourRemoved { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Registers the provided <see cref="IBehaviour"/> to be controlled by the <see cref="IBehaviourController"/>.
|
||||
/// </summary>
|
||||
/// <param name="behaviour">Uninitialized <see cref="IBehaviour"/> to be registered.</param>
|
||||
/// <typeparam name="T">An implemented class of <see cref="IBehaviour"/></typeparam>
|
||||
/// <returns>The provided <see cref="IBehaviour"/> class after initialization.</returns>
|
||||
T AddBehaviour<T>(T behaviour) where T : class, IBehaviour;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates the provided <see cref="IBehaviour"/> type and registers it to the <see cref="IBehaviourController"/>.
|
||||
/// </summary>
|
||||
/// <param name="args">Constructor parameters for the given <see cref="IBehaviour"/> class.</param>
|
||||
/// <typeparam name="T">An implemented class of <see cref="IBehaviour"/></typeparam>
|
||||
/// <returns>The instantiated <see cref="IBehaviour"/> class after initialization.</returns>
|
||||
T AddBehaviour<T>(params object?[]? args) where T : class, IBehaviour;
|
||||
|
||||
/// <summary>
|
||||
/// Looks up and tries to get the <see cref="IBehaviour"/> that is controlled by the <see cref="IBehaviourController"/>.
|
||||
/// </summary>
|
||||
/// <param name="behaviour">If return value is <see cref="true"/> outputs the class found in the <see cref="IBehaviourController"/>. If the return value is falls, this parameter is <see cref="null"/></param>
|
||||
/// <typeparam name="T">An implemented class or <see cref="interface"/></typeparam>
|
||||
/// <returns>
|
||||
/// <see cref="true"/>, if the type of <see cref="IBehaviour"/> is present in the <see cref="IBehaviourController"/>, <see cref="false"/> if not.
|
||||
/// </returns>
|
||||
bool TryGetBehaviour<T>([NotNullWhen(returnValue: true)] out T? behaviour);
|
||||
|
||||
/// <typeparam name="T">An implemented class or <see cref="interface"/> of <see cref="IBehaviour"/></typeparam>
|
||||
/// <returns>Returns a list of all the matching <see cref="IBehaviour"/>s found in the <see cref="IBehaviourController"/>.</returns>
|
||||
IList<T> GetBehaviours<T>() where T : IBehaviour;
|
||||
|
||||
/// <summary>
|
||||
/// Removes the <see cref="IBehaviour"/> found in the <see cref="IBehaviourController"/>.
|
||||
/// </summary>
|
||||
/// <param name="removeAll">If all of the instances of the given Type is to be removed or not.</param>
|
||||
/// <typeparam name="T">An implemented class or <see cref="interface"/> of <see cref="IBehaviour"/></typeparam>
|
||||
void RemoveBehaviour<T>(bool removeAll = false) where T : IBehaviour;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// To be called in every frame of the engine. Responsible for notifying <see cref="IBehaviour"/>'s under the <see cref="IBehaviourController"/>'s control that a new frame is happening.
|
||||
/// </summary>
|
||||
/// <param name="gameTime"><see cref="GameTime"/> information from the game.</param>
|
||||
void Update(GameTime gameTime);
|
||||
|
||||
/// <summary>
|
||||
/// To be called before every draw call from the engine. Responsible for notifying <see cref="IBehaviour"/>'s under the <see cref="IBehaviourController"/>'s control that the engine is about to start drawing into the screen.
|
||||
/// </summary>
|
||||
/// <param name="gameTime"><see cref="GameTime"/> information from the game.</param>
|
||||
void UpdatePreDraw(GameTime gameTime);
|
||||
}
|
5
Engine.Core/Abstract/IEntity.cs
Normal file
5
Engine.Core/Abstract/IEntity.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
public interface IEntity : IAssignableStateEnable
|
||||
{
|
||||
}
|
12
Engine.Core/Abstract/IGameObject.cs
Normal file
12
Engine.Core/Abstract/IGameObject.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
public interface IGameObject : IEntity, IAssignableTransform, IAssignableBehaviourController, INameable, IInitialize
|
||||
{
|
||||
Action<IGameObject, GameTime>? OnUpdated { get; set; }
|
||||
|
||||
void Update(GameTime time);
|
||||
}
|
13
Engine.Core/Abstract/IInitialize.cs
Normal file
13
Engine.Core/Abstract/IInitialize.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
public interface IInitialize : IEntity
|
||||
{
|
||||
Action<IInitialize>? OnInitialized { get; set; }
|
||||
Action<IInitialize>? OnFinalized { get; set; }
|
||||
bool Initialized { get; }
|
||||
|
||||
bool Initialize();
|
||||
bool Finalize();
|
||||
}
|
9
Engine.Core/Abstract/INameable.cs
Normal file
9
Engine.Core/Abstract/INameable.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
public interface INameable
|
||||
{
|
||||
Action<IEntity>? OnNameChanged { get; set; }
|
||||
string Name { get; set; }
|
||||
}
|
17
Engine.Core/Abstract/ISprite.cs
Normal file
17
Engine.Core/Abstract/ISprite.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
// TODO Probably gonna have to rethink this
|
||||
public interface ISprite
|
||||
{
|
||||
Action<ISprite>? OnTextureChanged { get; set; }
|
||||
Action<ISprite>? OnColorChanged { get; set; }
|
||||
Action<ISprite>? OnDepthChanged { get; set; }
|
||||
|
||||
Texture2D Texture2D { get; set; }
|
||||
Color Color { get; set; }
|
||||
float Depth { get; set; }
|
||||
}
|
9
Engine.Core/Abstract/IStateEnable.cs
Normal file
9
Engine.Core/Abstract/IStateEnable.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
public interface IStateEnable : IAssignableEntity
|
||||
{
|
||||
Action<IStateEnable>? OnEnabledChanged { get; set; }
|
||||
bool Enabled { get; set; }
|
||||
}
|
17
Engine.Core/Abstract/ITransform.cs
Normal file
17
Engine.Core/Abstract/ITransform.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Syntriax.Engine.Core.Abstract;
|
||||
|
||||
public interface ITransform
|
||||
{
|
||||
Action<ITransform>? OnPositionChanged { get; set; }
|
||||
Action<ITransform>? OnScaleChanged { get; set; }
|
||||
Action<ITransform>? OnRotationChanged { get; set; }
|
||||
|
||||
Vector2 Position { get; set; }
|
||||
Vector2 Scale { get; set; }
|
||||
|
||||
float Rotation { get; set; }
|
||||
}
|
Reference in New Issue
Block a user