Awperative Beta!

This commit is contained in:
2026-02-15 20:34:29 -05:00
parent de8e9aca44
commit 1f96b653ad
10 changed files with 91 additions and 100 deletions

View File

@@ -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";
}

View File

@@ -1 +0,0 @@
todo: make a yaml file for the kernel config and this can find it outside of the kernel

View File

@@ -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");
}
}

View File

@@ -1,12 +1,44 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
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>
/// Writes the current message to the log file.
/// </summary>

View File

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -53,16 +54,43 @@ public static class Awperative
/// <summary>
/// List of all scenes currently loaded in the kernel.
/// </summary>
public static List<Scene> LoadedScenes => _loadedScenes.ToList();
internal static HashSet<Scene> _loadedScenes { get; private set; }= [];
public static ImmutableArray<Scene> Scenes => [.._scenes];
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>
/// 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>
public static List<AwperativeHook> EventHooks => _eventHooks.ToList();
internal static HashSet<AwperativeHook> _eventHooks { get; private set; } = [];
/// <param name="__name"></param>
/// <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>
/// <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>
public static void Start(List<AwperativeHook> __hooks) {
_eventHooks = new HashSet<AwperativeHook>(__hooks);
public static void Start() {
Base = new Base();
Base.Run();
}

View File

@@ -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() {}
}

View File

@@ -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.
/// </summary>
/// <remarks> It is recommended to load content during LoadContent()</remarks>
protected override void LoadContent() {
foreach (AwperativeHook hook in Awperative.EventHooks.ToList()) hook.Load();
foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.ChainLoad();
}
protected override void LoadContent() { foreach(Scene scene in Awperative.Scenes.ToList()) if(scene.Enabled) 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.
/// </summary>
/// <remarks> Hooks are unable to receive both Update() and Draw()</remarks>
protected override void Update(GameTime __gameTime) {
foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.ChainUpdate();
base.Update(__gameTime);
}
protected override void Update(GameTime __gameTime) { foreach(Scene scene in Awperative.Scenes.ToList()) if(scene.Enabled) 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.
/// </summary>
/// <remarks> Hooks are unable to receive both Update() and Draw()</remarks>
protected override void Draw(GameTime __gameTime) {
foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.ChainDraw();
base.Draw(__gameTime);
}
protected override void Draw(GameTime __gameTime) { foreach(Scene scene in Awperative.Scenes.ToList()) if(scene.Enabled) 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.
/// </summary>
/// <remarks> This event may not trigger if the program is force closed.</remarks>
protected override void EndRun() {
foreach (AwperativeHook hook in Awperative.EventHooks.ToList()) hook.Unload();
foreach (Scene scene in Awperative.LoadedScenes.ToList()) scene.ChainUnload();
}
protected override void EndRun() { foreach (Scene scene in Awperative.Scenes.ToList()) if(scene.Enabled) scene.ChainUnload(); }

View File

@@ -8,5 +8,24 @@ namespace Awperative;
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; }
}