Awperative Beta!
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
namespace Awperative.Kernel.Communication.Config;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TEMPORARY LIST OF VARIABLES, CONFIG DOESNT EXIST YET SO IM MAKING A VARIABLE LIST TO SEE WHAT I NEED TO REPLACE
|
|
||||||
public static class Config
|
|
||||||
{
|
|
||||||
|
|
||||||
public static string logFileName = "log";
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
todo: make a yaml file for the kernel config and this can find it outside of the kernel
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using Awperative.Kernel.Communication.Config;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Awperative;
|
|
||||||
|
|
||||||
|
|
||||||
public static partial class Debug
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// True path of the log file Awperative dumps to.
|
|
||||||
/// </summary>
|
|
||||||
public static string LogFilePath { get; private set; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets up the Awperative debugger and finds the log file.
|
|
||||||
/// </summary>
|
|
||||||
internal static void Initiate() {
|
|
||||||
string directoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
||||||
if(directoryPath == null) throw new Exception("Failed to get directory path!");
|
|
||||||
|
|
||||||
if(!Directory.GetFiles(directoryPath).Contains(Config.logFileName + ".awlf")) throw new Exception("Failed to find log file!");
|
|
||||||
LogFilePath = Path.Join(directoryPath, Config.logFileName + ".awlf");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,44 @@
|
|||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
|
||||||
namespace Awperative;
|
namespace Awperative;
|
||||||
|
|
||||||
|
|
||||||
public static partial class Debug
|
public static class Debug
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True path of the log file Awperative dumps to.
|
||||||
|
/// </summary>
|
||||||
|
public static string LogFilePath { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static string LogFileName { get; private set; } = "Log";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets up the Awperative debugger and finds the log file.
|
||||||
|
/// </summary>
|
||||||
|
internal static void Initiate() {
|
||||||
|
string directoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||||
|
if(directoryPath == null) throw new Exception("Failed to get directory path!");
|
||||||
|
|
||||||
|
if(!Directory.GetFiles(directoryPath).Contains(LogFileName + ".awlf")) throw new Exception("Failed to find log file!");
|
||||||
|
LogFilePath = Path.Join(directoryPath, LogFileName + ".awlf");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes the current message to the log file.
|
/// Writes the current message to the log file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
0
Awperative/Kernel/Debug/Debug.md
Normal file
0
Awperative/Kernel/Debug/Debug.md
Normal file
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Immutable;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -53,16 +54,43 @@ public static class Awperative
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of all scenes currently loaded in the kernel.
|
/// List of all scenes currently loaded in the kernel.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<Scene> LoadedScenes => _loadedScenes.ToList();
|
public static ImmutableArray<Scene> Scenes => [.._scenes];
|
||||||
internal static HashSet<Scene> _loadedScenes { get; private set; }= [];
|
internal static HashSet<Scene> _scenes { get; private set; } = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new Scene
|
||||||
|
/// </summary>
|
||||||
|
public static void Create(string __name) { if (Contains(__name)) _scenes.Add(new Scene(__name)); else Debug.LogError("Awperative already has a Scene with that name!", ["Scene", "Name"], [Get(__name).GetHashCode().ToString(), __name]); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finds a Scene from a given name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="__name"> Name to search for</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Scene Get(string __name) => _scenes.FirstOrDefault(scene => scene.Name == __name, null);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of all event hooks currently loaded in the kernel.
|
/// Returns bool based on whether there a scene with the given name or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<AwperativeHook> EventHooks => _eventHooks.ToList();
|
/// <param name="__name"></param>
|
||||||
internal static HashSet<AwperativeHook> _eventHooks { get; private set; } = [];
|
/// <returns></returns>
|
||||||
|
public static bool Contains(string __name) => _scenes.Any(scene => scene.Name == __name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes a Scene
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="__scene"></param>
|
||||||
|
public static void Close(Scene __scene) => Scenes.Remove(Get(__scene.Name));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -73,10 +101,7 @@ public static class Awperative
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="__hooks"> List of all event hooks you wish to use. </param>
|
/// <param name="__hooks"> List of all event hooks you wish to use. </param>
|
||||||
/// <remarks> You cannot add new hooks later; so make sure to register all of them in the Start() method.</remarks>
|
/// <remarks> You cannot add new hooks later; so make sure to register all of them in the Start() method.</remarks>
|
||||||
public static void Start(List<AwperativeHook> __hooks) {
|
public static void Start() {
|
||||||
|
|
||||||
_eventHooks = new HashSet<AwperativeHook>(__hooks);
|
|
||||||
|
|
||||||
Base = new Base();
|
Base = new Base();
|
||||||
Base.Run();
|
Base.Run();
|
||||||
}
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
namespace Awperative;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Awperative hooks are the source of entry for scripts using Awperative. Create a hook and send into Start() to be recognized by the engine.
|
|
||||||
/// </summary>
|
|
||||||
/// <author> Avery Norris </author>
|
|
||||||
public interface AwperativeHook
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Called when the program starts; It is not recommended you load assets here.
|
|
||||||
/// </summary>
|
|
||||||
public void Load() {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called when the program closes.
|
|
||||||
/// </summary>
|
|
||||||
public void Unload() {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -44,10 +44,7 @@ public sealed class Base : Game
|
|||||||
/// LoadContent() is called when the program starts; right after Initialize(). Override Load() in scripting tools or use hooks to call from this event.
|
/// LoadContent() is called when the program starts; right after Initialize(). Override Load() in scripting tools or use hooks to call from this event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks> It is recommended to load content during LoadContent()</remarks>
|
/// <remarks> It is recommended to load content during LoadContent()</remarks>
|
||||||
protected override void LoadContent() {
|
protected override void LoadContent() { foreach(Scene scene in Awperative.Scenes.ToList()) if(scene.Enabled) scene.ChainLoad(); }
|
||||||
foreach (AwperativeHook hook in Awperative.EventHooks.ToList()) hook.Load();
|
|
||||||
foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.ChainLoad();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -57,10 +54,7 @@ public sealed class Base : Game
|
|||||||
/// Update() is called every frame; before Draw(). Override Update() in scripting tools to call from this event.
|
/// Update() is called every frame; before Draw(). Override Update() in scripting tools to call from this event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks> Hooks are unable to receive both Update() and Draw()</remarks>
|
/// <remarks> Hooks are unable to receive both Update() and Draw()</remarks>
|
||||||
protected override void Update(GameTime __gameTime) {
|
protected override void Update(GameTime __gameTime) { foreach(Scene scene in Awperative.Scenes.ToList()) if(scene.Enabled) scene.ChainUpdate(); base.Update(__gameTime); }
|
||||||
foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.ChainUpdate();
|
|
||||||
base.Update(__gameTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -70,10 +64,7 @@ public sealed class Base : Game
|
|||||||
/// Draw() is called every frame; after Update(). Override Draw() in scripting tools to call from this event.
|
/// Draw() is called every frame; after Update(). Override Draw() in scripting tools to call from this event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks> Hooks are unable to receive both Update() and Draw()</remarks>
|
/// <remarks> Hooks are unable to receive both Update() and Draw()</remarks>
|
||||||
protected override void Draw(GameTime __gameTime) {
|
protected override void Draw(GameTime __gameTime) { foreach(Scene scene in Awperative.Scenes.ToList()) if(scene.Enabled) scene.ChainDraw(); base.Draw(__gameTime); }
|
||||||
foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.ChainDraw();
|
|
||||||
base.Draw(__gameTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -83,10 +74,7 @@ public sealed class Base : Game
|
|||||||
/// EndRun() is called if the program closes. Override Terminate() in scripting tools or use hooks to call from this event.
|
/// EndRun() is called if the program closes. Override Terminate() in scripting tools or use hooks to call from this event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks> This event may not trigger if the program is force closed.</remarks>
|
/// <remarks> This event may not trigger if the program is force closed.</remarks>
|
||||||
protected override void EndRun() {
|
protected override void EndRun() { foreach (Scene scene in Awperative.Scenes.ToList()) if(scene.Enabled) scene.ChainUnload(); }
|
||||||
foreach (AwperativeHook hook in Awperative.EventHooks.ToList()) hook.Unload();
|
|
||||||
foreach (Scene scene in Awperative.LoadedScenes.ToList()) scene.ChainUnload();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,5 +8,24 @@ namespace Awperative;
|
|||||||
|
|
||||||
public sealed partial class Scene : ComponentDocker
|
public sealed partial class Scene : ComponentDocker
|
||||||
{
|
{
|
||||||
//todo: make useful lolol
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the scene is enabled or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool Enabled;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unique Name of the Scene
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
internal Scene() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
internal Scene(string __name) { Name = __name; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user