diff --git a/Awperative/Kernel/Communication/Config/TempConfig.cs b/Awperative/Kernel/Communication/Config/TempConfig.cs deleted file mode 100644 index f5db852..0000000 --- a/Awperative/Kernel/Communication/Config/TempConfig.cs +++ /dev/null @@ -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"; -} \ No newline at end of file diff --git a/Awperative/Kernel/Communication/Config/configget.txt b/Awperative/Kernel/Communication/Config/configget.txt deleted file mode 100644 index 30c2fe3..0000000 --- a/Awperative/Kernel/Communication/Config/configget.txt +++ /dev/null @@ -1 +0,0 @@ -todo: make a yaml file for the kernel config and this can find it outside of the kernel diff --git a/Awperative/Kernel/Communication/Debug/Core.cs b/Awperative/Kernel/Communication/Debug/Core.cs deleted file mode 100644 index 4f8f51e..0000000 --- a/Awperative/Kernel/Communication/Debug/Core.cs +++ /dev/null @@ -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 -{ - - - - - - /// - /// True path of the log file Awperative dumps to. - /// - public static string LogFilePath { get; private set; } - - - - - - /// - /// Sets up the Awperative debugger and finds the log file. - /// - 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"); - } -} \ No newline at end of file diff --git a/Awperative/Kernel/Communication/Debug/AwperativeDebugger.txt b/Awperative/Kernel/Debug/AwperativeDebugger.txt similarity index 100% rename from Awperative/Kernel/Communication/Debug/AwperativeDebugger.txt rename to Awperative/Kernel/Debug/AwperativeDebugger.txt diff --git a/Awperative/Kernel/Communication/Debug/Writer.cs b/Awperative/Kernel/Debug/Debug.cs similarity index 88% rename from Awperative/Kernel/Communication/Debug/Writer.cs rename to Awperative/Kernel/Debug/Debug.cs index c539760..996930c 100644 --- a/Awperative/Kernel/Communication/Debug/Writer.cs +++ b/Awperative/Kernel/Debug/Debug.cs @@ -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 { + + + + /// + /// True path of the log file Awperative dumps to. + /// + public static string LogFilePath { get; private set; } + + + + public static string LogFileName { get; private set; } = "Log"; + + + + + + /// + /// Sets up the Awperative debugger and finds the log file. + /// + 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"); + } + + + /// /// Writes the current message to the log file. /// diff --git a/Awperative/Kernel/Debug/Debug.md b/Awperative/Kernel/Debug/Debug.md new file mode 100644 index 0000000..e69de29 diff --git a/Awperative/Kernel/Overhead/Core.cs b/Awperative/Kernel/Overhead/Awperative.cs similarity index 57% rename from Awperative/Kernel/Overhead/Core.cs rename to Awperative/Kernel/Overhead/Awperative.cs index d664bec..41d57b7 100644 --- a/Awperative/Kernel/Overhead/Core.cs +++ b/Awperative/Kernel/Overhead/Awperative.cs @@ -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 /// /// List of all scenes currently loaded in the kernel. /// - public static List LoadedScenes => _loadedScenes.ToList(); - internal static HashSet _loadedScenes { get; private set; }= []; + public static ImmutableArray Scenes => [.._scenes]; + internal static HashSet _scenes { get; private set; } = []; + + + + + + /// + /// Creates a new Scene + /// + 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]); } + + + + /// + /// Finds a Scene from a given name + /// + /// Name to search for + /// + public static Scene Get(string __name) => _scenes.FirstOrDefault(scene => scene.Name == __name, null); /// - /// List of all event hooks currently loaded in the kernel. + /// Returns bool based on whether there a scene with the given name or not. /// - public static List EventHooks => _eventHooks.ToList(); - internal static HashSet _eventHooks { get; private set; } = []; + /// + /// + public static bool Contains(string __name) => _scenes.Any(scene => scene.Name == __name); + + + + /// + /// Closes a Scene + /// + /// + public static void Close(Scene __scene) => Scenes.Remove(Get(__scene.Name)); @@ -73,10 +101,7 @@ public static class Awperative /// /// List of all event hooks you wish to use. /// You cannot add new hooks later; so make sure to register all of them in the Start() method. - public static void Start(List __hooks) { - - _eventHooks = new HashSet(__hooks); - + public static void Start() { Base = new Base(); Base.Run(); } diff --git a/Awperative/Kernel/Overhead/AwperativeClass.cs b/Awperative/Kernel/Overhead/AwperativeClass.cs deleted file mode 100644 index aaa722d..0000000 --- a/Awperative/Kernel/Overhead/AwperativeClass.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Awperative; - -/// -/// Awperative hooks are the source of entry for scripts using Awperative. Create a hook and send into Start() to be recognized by the engine. -/// -/// Avery Norris -public interface AwperativeHook -{ - /// - /// Called when the program starts; It is not recommended you load assets here. - /// - public void Load() {} - - - - - - /// - /// Called when the program closes. - /// - public void Unload() {} - - - -} \ No newline at end of file diff --git a/Awperative/Kernel/Overhead/Base.cs b/Awperative/Kernel/Overhead/Base.cs index c988bca..29b9aac 100644 --- a/Awperative/Kernel/Overhead/Base.cs +++ b/Awperative/Kernel/Overhead/Base.cs @@ -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. /// /// It is recommended to load content during LoadContent() - 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. /// /// Hooks are unable to receive both Update() and Draw() - 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. /// /// Hooks are unable to receive both Update() and Draw() - 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. /// /// This event may not trigger if the program is force closed. - 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(); } diff --git a/Awperative/Kernel/Scene/Core.cs b/Awperative/Kernel/Scene/Core.cs index a89655d..3b9bddf 100644 --- a/Awperative/Kernel/Scene/Core.cs +++ b/Awperative/Kernel/Scene/Core.cs @@ -8,5 +8,24 @@ namespace Awperative; public sealed partial class Scene : ComponentDocker { - //todo: make useful lolol + + /// + /// Whether the scene is enabled or not. + /// + public bool Enabled; + + + + /// + /// Unique Name of the Scene + /// + public string Name; + + + + internal Scene() {} + + + + internal Scene(string __name) { Name = __name; } }