Awperative V1.3A
This commit is contained in:
@@ -34,7 +34,7 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(ComponentDocker __docker, Component __component) {
|
public static bool VerifyOrThrow(ComponentDocker __docker, Component __component) {
|
||||||
if (__docker.Contains(__component)) return true;
|
if (__docker.Contains(__component)) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("Docker does not own the Component!",
|
Debug.LogError("Docker does not own the Component!",
|
||||||
["ComponentType", "ComponentName", "ComponentHash", "DockerType", "DockerName", "DockerHash"], [
|
["ComponentType", "ComponentName", "ComponentHash", "DockerType", "DockerName", "DockerHash"], [
|
||||||
__component.GetType().Name,
|
__component.GetType().Name,
|
||||||
__component.Name,
|
__component.Name,
|
||||||
@@ -44,7 +44,7 @@ public static class DebugAttributes
|
|||||||
__docker.GetHashCode().ToString("N0")
|
__docker.GetHashCode().ToString("N0")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(ComponentDocker __docker, Component __component) {
|
public static bool VerifyOrThrow(ComponentDocker __docker, Component __component) {
|
||||||
if (!__docker.Contains(__component)) return true;
|
if (!__docker.Contains(__component)) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("Docker owns the Component!",
|
Debug.LogError("Docker owns the Component!",
|
||||||
["ComponentType", "ComponentName", "ComponentHash", "DockerType", "DockerName", "DockerHash"], [
|
["ComponentType", "ComponentName", "ComponentHash", "DockerType", "DockerName", "DockerHash"], [
|
||||||
__component.GetType().Name,
|
__component.GetType().Name,
|
||||||
__component.Name,
|
__component.Name,
|
||||||
@@ -71,7 +71,7 @@ public static class DebugAttributes
|
|||||||
__docker.GetHashCode().ToString("N0")
|
__docker.GetHashCode().ToString("N0")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(Component __component) {
|
public static bool VerifyOrThrow(Component __component) {
|
||||||
if (__component.ComponentDocker == null) return true;
|
if (__component.ComponentDocker == null) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("Component is already owned!",
|
Debug.LogError("Component is already owned!",
|
||||||
["ComponentType", "ComponentName", "ComponentHash", "DockerType", "DockerName", "DockerHash"], [
|
["ComponentType", "ComponentName", "ComponentHash", "DockerType", "DockerName", "DockerHash"], [
|
||||||
__component.GetType().Name,
|
__component.GetType().Name,
|
||||||
__component.Name,
|
__component.Name,
|
||||||
@@ -98,7 +98,7 @@ public static class DebugAttributes
|
|||||||
__component.ComponentDocker.GetHashCode().ToString("N0")
|
__component.ComponentDocker.GetHashCode().ToString("N0")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,13 +115,13 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(ComponentDocker __docker, ComponentDocker __other) {
|
public static bool VerifyOrThrow(ComponentDocker __docker, ComponentDocker __other) {
|
||||||
if (!__docker.Equals(__other)) return true;
|
if (!__docker.Equals(__other)) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("The dockers are the same!", ["DockerType", "DockerName", "DockerHash"], [
|
Debug.LogError("The dockers are the same!", ["DockerType", "DockerName", "DockerHash"], [
|
||||||
__docker.GetType().Name,
|
__docker.GetType().Name,
|
||||||
__docker switch { Scene scene => scene.Name, Component component => component.Name, _ => "unknown" },
|
__docker switch { Scene scene => scene.Name, Component component => component.Name, _ => "unknown" },
|
||||||
__docker.GetHashCode().ToString("N0")
|
__docker.GetHashCode().ToString("N0")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,9 +138,9 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(Component __component) {
|
public static bool VerifyOrThrow(Component __component) {
|
||||||
if (__component != null) return true;
|
if (__component != null) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("Component is null!");
|
Debug.LogError("Component is null!");
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,9 +157,9 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(ComponentDocker __componentDocker) {
|
public static bool VerifyOrThrow(ComponentDocker __componentDocker) {
|
||||||
if (__componentDocker != null) return true;
|
if (__componentDocker != null) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("Docker is null!");
|
Debug.LogError("Docker is null!");
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +176,9 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(Scene __scene) {
|
public static bool VerifyOrThrow(Scene __scene) {
|
||||||
if (__scene != null) return true;
|
if (__scene != null) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("Scene is null!");
|
Debug.LogError("Scene is null!");
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,11 +191,11 @@ public static class DebugAttributes
|
|||||||
/// <inheritdoc cref="DockerOwns.VerifyOrThrow"/>
|
/// <inheritdoc cref="DockerOwns.VerifyOrThrow"/>
|
||||||
[MarkerAttributes.Expense(MarkerAttributes.Expense.ExpenseLevel.VeryLow), MarkerAttributes.Complexity(MarkerAttributes.Complexity.TimeComplexity.O1)]
|
[MarkerAttributes.Expense(MarkerAttributes.Expense.ExpenseLevel.VeryLow), MarkerAttributes.Complexity(MarkerAttributes.Complexity.TimeComplexity.O1)]
|
||||||
public static bool VerifyOrThrow(Scene __scene) {
|
public static bool VerifyOrThrow(Scene __scene) {
|
||||||
if (Awperative._scenes.Contains(__scene)) return true;
|
if (!Awperative._scenes.Contains(__scene)) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("Scene already exists!");
|
Debug.LogError("Scene already exists!");
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,12 +213,12 @@ public static class DebugAttributes
|
|||||||
|
|
||||||
/// <inheritdoc cref="DockerOwns.VerifyOrThrow"/>
|
/// <inheritdoc cref="DockerOwns.VerifyOrThrow"/>
|
||||||
public static bool VerifyOrThrow(IEnumerable<object> __enumerator) {
|
public static bool VerifyOrThrow(IEnumerable<object> __enumerator) {
|
||||||
if (__enumerator == null) { Awperative.Debug.LogError("A given enumerator is null!"); return Awperative.Debug.IgnoreErrors; }
|
if (__enumerator == null) { Debug.LogError("A given enumerator is null!"); return Debug.IgnoreErrors; }
|
||||||
|
|
||||||
foreach (object obj in __enumerator) {
|
foreach (object obj in __enumerator) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
Awperative.Debug.LogError("A given enumerator has null members!", ["Type"], [__enumerator.GetType().Name]);
|
Debug.LogError("A given enumerator has null members!", ["Type"], [__enumerator.GetType().Name]);
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,9 +238,9 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(IEnumerable<object> __enumerator, object __object) {
|
public static bool VerifyOrThrow(IEnumerable<object> __enumerator, object __object) {
|
||||||
if (__enumerator.Contains(__object)) return true;
|
if (__enumerator.Contains(__object)) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("A given enumerator does not contains an object!", ["EnumeratorType", "ObjectType", "Value"], [__enumerator.GetType().Name, __object.GetType().Name, __object.ToString()]);
|
Debug.LogError("A given enumerator does not contains an object!", ["EnumeratorType", "ObjectType", "Value"], [__enumerator.GetType().Name, __object.GetType().Name, __object.ToString()]);
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,9 +256,9 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(IEnumerable<object> __enumerator, object __object) {
|
public static bool VerifyOrThrow(IEnumerable<object> __enumerator, object __object) {
|
||||||
if (!__enumerator.Contains(__object)) return true;
|
if (!__enumerator.Contains(__object)) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("A given enumerator already contains the object object!", ["EnumeratorType", "ObjectType", "Value"], [__enumerator.GetType().Name, __object.GetType().Name, __object.ToString()]);
|
Debug.LogError("A given enumerator already contains the object object!", ["EnumeratorType", "ObjectType", "Value"], [__enumerator.GetType().Name, __object.GetType().Name, __object.ToString()]);
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,9 +274,9 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(Object __object) {
|
public static bool VerifyOrThrow(Object __object) {
|
||||||
if (__object != null) return true;
|
if (__object != null) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("A given object is null!");
|
Debug.LogError("A given object is null!");
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,9 +292,9 @@ public static class DebugAttributes
|
|||||||
public static bool VerifyOrThrow(int __index, int __min, int __max) {
|
public static bool VerifyOrThrow(int __index, int __min, int __max) {
|
||||||
if (__index >= __min && __index <= __max) return true;
|
if (__index >= __min && __index <= __max) return true;
|
||||||
|
|
||||||
Awperative.Debug.LogError("Value does not fit range!", ["Index"], [__index.ToString("N0")]);
|
Debug.LogError("Value does not fit range!", ["Index"], [__index.ToString("N0")]);
|
||||||
|
|
||||||
return Awperative.Debug.IgnoreErrors;
|
return Debug.IgnoreErrors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
namespace AwperativeKernel;
|
|
||||||
|
|
||||||
|
|
||||||
internal static class DependencyAttributes
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary> Shows the source for a given module interface </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Property)]
|
|
||||||
public class RequiredModule : Attribute
|
|
||||||
{
|
|
||||||
/// <summary> Where to assign in the Awperative class.</summary>
|
|
||||||
public string Source { get; set; }
|
|
||||||
|
|
||||||
public RequiredModule() {}
|
|
||||||
|
|
||||||
public RequiredModule(string Source) {
|
|
||||||
this.Source = Source;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
132
AwperativeKernel/Kernel/Debug/Debug.cs
Normal file
132
AwperativeKernel/Kernel/Debug/Debug.cs
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace AwperativeKernel;
|
||||||
|
|
||||||
|
|
||||||
|
public static class Debug
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True path of the log file Awperative dumps to.
|
||||||
|
/// </summary>
|
||||||
|
public static string LogFilePath { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Target name of the log file
|
||||||
|
/// </summary>
|
||||||
|
public static string LogFileName { get; private set; } = "Log";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If this is running or not
|
||||||
|
/// </summary>
|
||||||
|
private static bool Running = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Whether to throw error exceptions
|
||||||
|
public static bool ThrowExceptions { get; set; } = false;
|
||||||
|
//Whether to ignore/pass through errors or not
|
||||||
|
public static bool IgnoreErrors { get; set; } = false;
|
||||||
|
//Whether to debug errors at all
|
||||||
|
public static bool DebugErrors { get; set; } = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static SafetyLevel safetyLevel {
|
||||||
|
get => _safetyLevel;
|
||||||
|
set {
|
||||||
|
ThrowExceptions = value is SafetyLevel.Extreme;
|
||||||
|
IgnoreErrors = value is SafetyLevel.Low or SafetyLevel.None;
|
||||||
|
DebugErrors = value is not SafetyLevel.None;
|
||||||
|
_safetyLevel = value;
|
||||||
|
}
|
||||||
|
} private static SafetyLevel _safetyLevel;
|
||||||
|
|
||||||
|
public enum SafetyLevel {
|
||||||
|
Extreme, //Throw exceptions and stop the whole program
|
||||||
|
Normal, //Just debug it to the console, and halt current process
|
||||||
|
Low, //Push through tasks but debug error
|
||||||
|
None, //Ignore most/all errors and do not debug it,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets up the Awperative debugger and finds the log file.
|
||||||
|
/// </summary>
|
||||||
|
public static void Start() {
|
||||||
|
if(Running) return;
|
||||||
|
|
||||||
|
Running = true;
|
||||||
|
|
||||||
|
string directoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||||
|
if(directoryPath == null) throw new Exception("Failed to get directory path!");
|
||||||
|
|
||||||
|
LogFilePath = Path.Join(directoryPath, LogFileName + ".awlf");
|
||||||
|
|
||||||
|
if(!Directory.GetFiles(directoryPath).Contains(LogFileName + ".awlf")) { File.Create(LogFilePath).Close(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Stop() {
|
||||||
|
Running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogAction(string __message) {
|
||||||
|
LogGeneric(__message, "ACT", [], [], false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogAction(string __message, IEnumerable<string> __values, IEnumerable<string> __args) {
|
||||||
|
LogGeneric(__message, "ACT", __values, __args, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void LogWarning(string __message) {
|
||||||
|
LogGeneric(__message, "WRN", [], [], false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogWarning(string __message, IEnumerable<string> __values, IEnumerable<string> __args) {
|
||||||
|
LogGeneric(__message, "WRN", __values, __args, false);;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void LogError(string __message) {
|
||||||
|
LogGeneric(__message, "ERR", [], [], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogError(string __message, IEnumerable<string> __values, IEnumerable<string> __args) {
|
||||||
|
LogGeneric(__message, "ERR", __values, __args, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the current message to the log file. With any given call sign.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="__message"> Message to debug</param>
|
||||||
|
/// <param name="__callSign"> Message identifier</param>
|
||||||
|
/// <param name="__parameters"> Names of values to debug</param>
|
||||||
|
/// <param name="__values"> Values to debug</param>
|
||||||
|
/// <param name="__exception"> Should this throw an exception instead</param>
|
||||||
|
public static void LogGeneric(string __message, string __callSign, IEnumerable<string> __parameters, IEnumerable<string> __values, bool __exception) {
|
||||||
|
string output = "\n\n" + __callSign + "- \"" + __message + "\"\n STK-" + new StackTrace();
|
||||||
|
|
||||||
|
for (int i = 0; i < __parameters.Count() || i < __values.Count(); i++)
|
||||||
|
output += "\n " + __parameters.ElementAt(i) + "- " + __values.ElementAt(i);
|
||||||
|
|
||||||
|
if (__exception && ThrowExceptions) throw new Exception(output);
|
||||||
|
|
||||||
|
File.AppendAllText(LogFilePath, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,10 +11,10 @@ using Awperative.Kernel.Overhead.Reflection;
|
|||||||
namespace AwperativeKernel;
|
namespace AwperativeKernel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initiating class of Awperative. Call Start() to start the kernel.
|
/// Main class of Awperative, allows you to Create() scenes and Start() the game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <author> Avery Norris </author>
|
/// <author> Avery Norris </author>
|
||||||
public static partial class Awperative
|
public static class Awperative
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -39,12 +39,6 @@ public static partial class Awperative
|
|||||||
public static bool IsStarted { get; private set; } = false;
|
public static bool IsStarted { get; private set; } = false;
|
||||||
/// <summary> Displays if the update loop is active</summary>
|
/// <summary> Displays if the update loop is active</summary>
|
||||||
public static bool IsRunning { get; private set; } = false;
|
public static bool IsRunning { get; private set; } = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary> Awperative's debugger of choice, found from the module manager.</summary>
|
|
||||||
[MarkerAttributes.UnsafeInternal, DependencyAttributes.RequiredModule]
|
|
||||||
public static IDebugger Debug { get; internal set; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -54,13 +48,14 @@ public static partial class Awperative
|
|||||||
if (!DebugAttributes.NotNull.VerifyOrThrow(__name)) return null;
|
if (!DebugAttributes.NotNull.VerifyOrThrow(__name)) return null;
|
||||||
if (!DebugAttributes.SceneDoesNotExist.VerifyOrThrow(GetScene(__name))) return null;
|
if (!DebugAttributes.SceneDoesNotExist.VerifyOrThrow(GetScene(__name))) return null;
|
||||||
|
|
||||||
Scene newScene = new Scene(__name);
|
Scene newScene = new (__name);
|
||||||
_scenes.Add(newScene);
|
_scenes.Add(newScene);
|
||||||
return newScene;
|
return newScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>Adds a new scene that you construct. </summary>
|
||||||
|
/// <param name="__scene"></param>
|
||||||
[MarkerAttributes.Expense(MarkerAttributes.Expense.ExpenseLevel.Low), MarkerAttributes.Complexity(MarkerAttributes.Complexity.TimeComplexity.O1)]
|
[MarkerAttributes.Expense(MarkerAttributes.Expense.ExpenseLevel.Low), MarkerAttributes.Complexity(MarkerAttributes.Complexity.TimeComplexity.O1)]
|
||||||
public static void AddScene([DebugAttributes.SceneNotNull, DebugAttributes.SceneDoesNotExist] Scene __scene) {
|
public static void AddScene([DebugAttributes.SceneNotNull, DebugAttributes.SceneDoesNotExist] Scene __scene) {
|
||||||
if (!DebugAttributes.SceneNotNull.VerifyOrThrow(__scene)) return;
|
if (!DebugAttributes.SceneNotNull.VerifyOrThrow(__scene)) return;
|
||||||
@@ -103,7 +98,8 @@ public static partial class Awperative
|
|||||||
IsStarted = true;
|
IsStarted = true;
|
||||||
|
|
||||||
ReflectionManager.ResolveModules(AppDomain.CurrentDomain.GetAssemblies());
|
ReflectionManager.ResolveModules(AppDomain.CurrentDomain.GetAssemblies());
|
||||||
|
|
||||||
|
Debug.Start();
|
||||||
Debug.LogAction("Successfully Compiled Classes!");
|
Debug.LogAction("Successfully Compiled Classes!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,9 +110,7 @@ public static partial class Awperative
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> Starts Awperative up! This method runs until the game is closed. </summary>
|
||||||
/// Starts Awperative up! This method runs forever.
|
|
||||||
/// </summary>
|
|
||||||
public static void Run() {
|
public static void Run() {
|
||||||
if(!IsStarted && IsRunning) return;
|
if(!IsStarted && IsRunning) return;
|
||||||
IsRunning = true;
|
IsRunning = true;
|
||||||
@@ -124,35 +118,24 @@ public static partial class Awperative
|
|||||||
Base.Run();
|
Base.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load, 0
|
/// <summary> Closes Awperative! </summary>
|
||||||
//Unload, 1
|
public static void Close() {
|
||||||
//Update, 2
|
Base.Close();
|
||||||
//Draw 3
|
}
|
||||||
//Create, 4
|
|
||||||
//Remove, 5
|
|
||||||
|
|
||||||
// 0000 0000
|
|
||||||
//
|
|
||||||
|
|
||||||
|
/// <summary> Performs a mock update. </summary>
|
||||||
|
[MarkerAttributes.UnsafeInternal]
|
||||||
public static void TestUpdate() {
|
public static void TestUpdate() {
|
||||||
foreach (Scene scene in Scenes) {
|
foreach (Scene scene in Scenes) {
|
||||||
scene.ChainEvent(2);
|
scene.ChainEvent(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Performs a mock draw call. </summary>
|
||||||
|
[MarkerAttributes.UnsafeInternal]
|
||||||
public static void TestDraw() {
|
public static void TestDraw() {
|
||||||
foreach (Scene scene in Scenes) {
|
foreach (Scene scene in Scenes) {
|
||||||
scene.ChainEvent(3);
|
scene.ChainEvent(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of all type of components and the associated time events
|
|
||||||
/// Each event is a 0 or 1 based on true or false, stored at their index in the byte
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
|
|
||||||
//What to do if there is an error, keep in mind low and none still can have errors, because you are turning off validation checking
|
|
||||||
}
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using AwperativeKernel;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Awperative.Kernel.Overhead.Reflection;
|
|
||||||
|
|
||||||
|
|
||||||
internal static class DependencyManager
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary> Resolves any needed Awperative dependencies! Given the Type, it searches recursively for all interfaces. If any of the interfaces
|
|
||||||
/// Has the RequiredModule() attribute, or one of the interfaces in required modules. It will assign it to the assosiated field in the Awperative class.</summary>
|
|
||||||
[MarkerAttributes.UnsafeInternal]
|
|
||||||
internal static void ResolveDependency(Type __type) {
|
|
||||||
|
|
||||||
Console.WriteLine(__type.FullName);
|
|
||||||
|
|
||||||
foreach (Type typeInterface in __type.GetInterfaces()) {
|
|
||||||
//Console.WriteLine(" " + typeInterface.FullName);
|
|
||||||
object[] dependencyInfo = typeInterface.GetCustomAttributes(typeof(DependencyAttribute), true);
|
|
||||||
|
|
||||||
if (dependencyInfo.Length == 0) continue;
|
|
||||||
|
|
||||||
foreach (object attribute in dependencyInfo) {
|
|
||||||
if (attribute is not DependencyAttributes.RequiredModule moduleAttribute) continue;
|
|
||||||
|
|
||||||
PropertyInfo data = typeof(AwperativeKernel.Awperative).GetProperty(moduleAttribute.Source, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
|
|
||||||
if (data != null) data.SetValue(null, Activator.CreateInstance(__type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Checks all dependency marked variables in Awperative, and ensures that all are present!</summary>
|
|
||||||
[MarkerAttributes.UnsafeInternal]
|
|
||||||
internal static void ResolveFulfillment() {
|
|
||||||
|
|
||||||
foreach (PropertyInfo propertyInfo in typeof(AwperativeKernel.Awperative).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) {
|
|
||||||
object[] attributes = propertyInfo.GetCustomAttributes(typeof(DependencyAttribute), true);
|
|
||||||
|
|
||||||
if (attributes.Length == 0) continue;
|
|
||||||
|
|
||||||
IModule module = propertyInfo.GetValue(null) as IModule;
|
|
||||||
|
|
||||||
if (module == null) throw new Exception("Failed to find dependency! " + propertyInfo.Name);
|
|
||||||
|
|
||||||
ReflectionManager._modules.Add(module);
|
|
||||||
module.Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,6 +10,10 @@ using AwperativeKernel;
|
|||||||
namespace Awperative.Kernel.Overhead.Reflection;
|
namespace Awperative.Kernel.Overhead.Reflection;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers events for component type objects.
|
||||||
|
/// </summary>
|
||||||
|
/// <author> Avery Norris </author>
|
||||||
internal static class EventManager
|
internal static class EventManager
|
||||||
{
|
{
|
||||||
/// <summary> Holds an associated action for each component and a time event. Is built with CompileType() during Start().</summary>
|
/// <summary> Holds an associated action for each component and a time event. Is built with CompileType() during Start().</summary>
|
||||||
|
|||||||
@@ -7,26 +7,22 @@ using AwperativeKernel;
|
|||||||
namespace Awperative.Kernel.Overhead.Reflection;
|
namespace Awperative.Kernel.Overhead.Reflection;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Manages all Awperative reflection based activities, right now limited to registering events.
|
||||||
|
/// </summary>
|
||||||
|
/// <author> Avery Norris </author>
|
||||||
internal static class ReflectionManager
|
internal static class ReflectionManager
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary> List of all modules in Awperative</summary>
|
|
||||||
[MarkerAttributes.UnsafeInternal]
|
|
||||||
internal static List<IModule> _modules = [];
|
|
||||||
|
|
||||||
/// <summary> Resolves all the modules from the calling assembly and module manager</summary>
|
/// <summary> Resolves all the modules from the calling assembly and module manager</summary>
|
||||||
[MarkerAttributes.UnsafeInternal]
|
[MarkerAttributes.UnsafeInternal]
|
||||||
internal static void ResolveModules(Assembly[] __assemblies) {
|
internal static void ResolveModules(Assembly[] __assemblies) {
|
||||||
foreach (Assembly assembly in __assemblies) ResolveAssembly(assembly);
|
foreach (Assembly assembly in __assemblies) ResolveAssembly(assembly);
|
||||||
|
|
||||||
DependencyManager.ResolveFulfillment();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Resolves all the types in an assembly.</summary>
|
/// <summary> Resolves all the types in an assembly.</summary>
|
||||||
[MarkerAttributes.UnsafeInternal]
|
[MarkerAttributes.UnsafeInternal]
|
||||||
internal static void ResolveAssembly(Assembly __assembly) {
|
internal static void ResolveAssembly(Assembly __assembly) {
|
||||||
foreach (Type type in __assembly.GetTypes()) {
|
foreach (Type type in __assembly.GetTypes()) {
|
||||||
DependencyManager.ResolveDependency(type);
|
|
||||||
EventManager.CompileType(type);
|
EventManager.CompileType(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace AwperativeKernel;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[DependencyAttributes.RequiredModule(Source: "Debug")]
|
|
||||||
public interface IDebugger : IModule
|
|
||||||
{
|
|
||||||
|
|
||||||
public void LogAction(string __message);
|
|
||||||
public void LogAction(string __message, IEnumerable<string> __values, IEnumerable<string> __args);
|
|
||||||
|
|
||||||
public void LogWarning(string __message);
|
|
||||||
public void LogWarning(string __message, IEnumerable<string> __values, IEnumerable<string> __args);
|
|
||||||
|
|
||||||
public void LogError(string __message);
|
|
||||||
public void LogError(string __message, IEnumerable<string> __values, IEnumerable<string> __args);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public bool ThrowExceptions { get; set; }
|
|
||||||
public bool IgnoreErrors { get; set; }
|
|
||||||
public bool DebugErrors { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
namespace AwperativeKernel;
|
|
||||||
|
|
||||||
|
|
||||||
public interface IModule
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public void Start();
|
|
||||||
public void Stop();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,25 +1,24 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
|
|
||||||
namespace AwperativeKernel;
|
namespace AwperativeKernel;
|
||||||
|
|
||||||
public sealed partial class Scene : ComponentDocker
|
/// <summary>
|
||||||
|
/// One of the main Awperative entities. Acts like a master folder for components to be stored in.
|
||||||
|
/// </summary>
|
||||||
|
/// <author> Avery Norris </author>
|
||||||
|
public class Scene : ComponentDocker
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> Whether the scene should receive updates or not</summary>
|
||||||
/// Whether the scene is enabled or not.
|
|
||||||
/// </summary>
|
|
||||||
public bool Enabled = true;
|
public bool Enabled = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary> Unique identifier of the Scene</summary>
|
||||||
/// Unique Name of the Scene
|
|
||||||
/// </summary>
|
|
||||||
public string Name;
|
public string Name;
|
||||||
|
|
||||||
|
|
||||||
|
//Blocks external construction
|
||||||
internal Scene() {}
|
internal Scene() {}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,4 +43,12 @@ Beta Reflection And Speed Increasment
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Finished Reflection, and Awperative is MUCH faster.
|
Finished Reflection, and Awperative is MUCH faster.
|
||||||
|
|
||||||
|
# Awperative V1.3A
|
||||||
|
|
||||||
|
### March 02 2026
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Awperative is nearly in a ready to deploy state! Aside from documentation and on the side support.
|
||||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("AwperativeKernel")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("AwperativeKernel")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+227e70219acaaa9bbd4981af01eb79aaf1d96e0e")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+21747aa062b0a2602d7565f0b233fde393cc54c2")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("AwperativeKernel")]
|
[assembly: System.Reflection.AssemblyProductAttribute("AwperativeKernel")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("AwperativeKernel")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("AwperativeKernel")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
5f132d4abe29f474cced3dd72be32c95430c59618df6c594ae25e534fec8180c
|
724a17504a0397b13f88a93dc5710a4c7a348910bcabad50e67ffb6927f0fa03
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
33413ce2ba51fbf0a7062dcd01f5b1a867dc2f45dcea968b5bdf25fdfd4515ac
|
9bb3f60279095695d105894a656dbaad7a0575a2cc3d0cea10961bba7a20f857
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user