diff --git a/Awperative/Kernel/Communication/Config/TempConfig.cs b/Awperative/Kernel/Communication/Config/TempConfig.cs new file mode 100644 index 0000000..f5db852 --- /dev/null +++ b/Awperative/Kernel/Communication/Config/TempConfig.cs @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000..30c2fe3 --- /dev/null +++ b/Awperative/Kernel/Communication/Config/configget.txt @@ -0,0 +1 @@ +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/AwperativeDebugger.txt b/Awperative/Kernel/Communication/Debug/AwperativeDebugger.txt new file mode 100644 index 0000000..afa8b58 --- /dev/null +++ b/Awperative/Kernel/Communication/Debug/AwperativeDebugger.txt @@ -0,0 +1,5 @@ +Awperative debugger writes errors to file while staying within runtime. + +Searches for a file with any specifiable name in config. that must end in .awlf + +stands for awperative logging format. \ No newline at end of file diff --git a/Awperative/Kernel/Communication/Debug/Core.cs b/Awperative/Kernel/Communication/Debug/Core.cs new file mode 100644 index 0000000..3b6048c --- /dev/null +++ b/Awperative/Kernel/Communication/Debug/Core.cs @@ -0,0 +1,37 @@ +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using Awperative.Kernel.Communication.Config; + + +namespace Awperative; + + +public static partial class Debugger +{ + + + + + + /// + /// 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/Writer.cs b/Awperative/Kernel/Communication/Debug/Writer.cs new file mode 100644 index 0000000..eb3a788 --- /dev/null +++ b/Awperative/Kernel/Communication/Debug/Writer.cs @@ -0,0 +1,68 @@ +using System.Diagnostics; +using System.IO; + + +namespace Awperative; + + +public static partial class Debugger +{ + /// + /// Writes the current message to the log file. + /// + /// Message to debug + public static void DebugState(string __message) => DebugGeneric(__message, "STA"); + + + + + + /// + /// Writes the current message to the log file. + /// + /// Message to debug + public static void DebugValue(string __message) => DebugGeneric(__message, "VAL"); + + + + + + /// + /// Writes the current message to the log file. + /// + /// Message to debug + public static void DebugLog(string __message) => DebugGeneric(__message, "LOG"); + + + + + + /// + /// Writes the current message to the log file. + /// + /// Message to debug + public static void DebugWarning(string __message) => DebugGeneric(__message, "WAR"); + + + + + + /// + /// Writes the current message to the log file. + /// + /// Message to debug + public static void DebugError(string __message) => DebugGeneric(__message, "ERR"); + + + + + + /// + /// Writes the current message to the log file. With any given call sign. + /// + /// Message to debug + /// Message identifier + public static void DebugGeneric(string __message, string __callSign) { + File.AppendAllText(LogFilePath, "\n\n" + __callSign + "- \"" + __message + "\"\n STK-" + new StackTrace()); + } +} \ No newline at end of file diff --git a/Awperative/Kernel/Entities/Bodies/Core.cs b/Awperative/Kernel/Entities/Bodies/Core.cs index ae69e23..56c3f6b 100644 --- a/Awperative/Kernel/Entities/Bodies/Core.cs +++ b/Awperative/Kernel/Entities/Bodies/Core.cs @@ -1,29 +1,83 @@ using System; using System.Collections.Generic; +using System.Linq; namespace Awperative; -public sealed partial class Body +public sealed partial class Body { - public readonly Scene scene; - public readonly Transform transform = new Transform(); - - public readonly List tags = []; - public readonly List components = []; + /// + /// Current scene the body exists in + /// + public Scene Scene { get; internal set; } + + + + + /// + /// All components attached to the body + /// + public List Components => _components.ToList(); + internal HashSet _components { get; private set; } = []; + + + + + + /// + /// All tags attached to the body + /// + public List Tags => _tags.ToList(); + internal HashSet _tags { get; private set; }= []; - public Body(Scene __scene) { - scene = __scene; + + + + + /// + /// Position of the body + /// + public Transform transform { get; internal set; } = new(); + + + + + + //Prevents outside construction + internal Body() {} + + + + + + /// + /// Creates a body in the given scene + /// + /// + internal Body(Scene __scene) { + Scene = __scene; } - public Body(Scene __scene, Transform __transform) { - scene = __scene; + + + + + /// + /// Creates a body with a scene and transform + /// + /// + /// + internal Body(Scene __scene, Transform __transform) { + Scene = __scene; transform = __transform; } - - //todo: make internal + + + + } \ No newline at end of file diff --git a/Awperative/Kernel/Entities/Bodies/Time.cs b/Awperative/Kernel/Entities/Bodies/Time.cs index 8ab5ca3..78f42cb 100644 --- a/Awperative/Kernel/Entities/Bodies/Time.cs +++ b/Awperative/Kernel/Entities/Bodies/Time.cs @@ -1,3 +1,4 @@ +using System.Linq; using Microsoft.Xna.Framework; @@ -6,13 +7,13 @@ namespace Awperative; public sealed partial class Body { - public void Unload() { foreach (Component component in components) component.Unload(); } + public void Unload() { foreach (Component component in components.ToList()) component.Unload(); } - public void Load() { foreach (Component component in components) { component.Load(); } } + public void Load() { foreach (Component component in components.ToList()) { component.Load(); } } - public void Update(GameTime __gameTime) { foreach (Component component in components) { component.Update(__gameTime); } } - public void Draw(GameTime __gameTime) { foreach (Component component in components) { component.Draw(__gameTime); } } + public void Update(GameTime __gameTime) { foreach (Component component in components.ToList()) { component.Update(__gameTime); } } + public void Draw(GameTime __gameTime) { foreach (Component component in components.ToList()) { component.Draw(__gameTime); } } - public void Destroy() { foreach(Component component in components) component.Destroy(); } - public void Create() { foreach (Component component in components) component.Create(); } + public void Destroy() { foreach(Component component in components.ToList()) component.Destroy(); } + public void Create() { foreach (Component component in components.ToList()) component.Create(); } } \ No newline at end of file diff --git a/Awperative/Kernel/Entities/Scenes/Time.cs b/Awperative/Kernel/Entities/Scenes/Time.cs index f0670e0..0b5bd81 100644 --- a/Awperative/Kernel/Entities/Scenes/Time.cs +++ b/Awperative/Kernel/Entities/Scenes/Time.cs @@ -1,3 +1,4 @@ +using System.Linq; using Microsoft.Xna.Framework; @@ -7,22 +8,22 @@ public sealed partial class Scene { public void Unload() { - foreach (Behavior behavior in behaviors) behavior.Unload(); - foreach (Body body in bodies) body.Unload(); + foreach (Behavior behavior in behaviors.ToList()) behavior.Unload(); + foreach (Body body in bodies.ToList()) body.Unload(); } public void Load() { - foreach (Behavior behavior in behaviors) { behavior.Load(); } - foreach (Body body in bodies) { body.Load(); } + foreach (Behavior behavior in behaviors.ToList()) { behavior.Load(); } + foreach (Body body in bodies.ToList()) { body.Load(); } } public void Update(GameTime __gameTime) { - foreach (Behavior behavior in behaviors) { behavior.Update(__gameTime); } - foreach (Body body in bodies) { body.Update(__gameTime); } + foreach (Behavior behavior in behaviors.ToList()) { behavior.Update(__gameTime); } + foreach (Body body in bodies.ToList()) { body.Update(__gameTime); } } public void Draw(GameTime __gameTime) { - foreach (Behavior behavior in behaviors) { behavior.Draw(__gameTime); } - foreach (Body body in bodies) { body.Draw(__gameTime); } + foreach (Behavior behavior in behaviors.ToList()) { behavior.Draw(__gameTime); } + foreach (Body body in bodies.ToList()) { body.Draw(__gameTime); } } } \ No newline at end of file diff --git a/Awperative/Kernel/Overhead/AwperativeClass.cs b/Awperative/Kernel/Overhead/AwperativeClass.cs index 268dbf1..aaa722d 100644 --- a/Awperative/Kernel/Overhead/AwperativeClass.cs +++ b/Awperative/Kernel/Overhead/AwperativeClass.cs @@ -3,6 +3,7 @@ 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 { /// @@ -10,8 +11,15 @@ public interface AwperativeHook /// 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 1dd9481..254221b 100644 --- a/Awperative/Kernel/Overhead/Base.cs +++ b/Awperative/Kernel/Overhead/Base.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using System.Linq; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -8,6 +9,7 @@ namespace Awperative; /// /// Base class of Awperative. Carries events from MonoGame into scenes and hooks. /// +/// Avery Norris public sealed class Base : Game { @@ -19,6 +21,10 @@ public sealed class Base : Game Content.RootDirectory = "Content"; } + + + + /// /// Initialize() is called when the program starts. Goes before LoadContent(). And prepares the kernel for use. /// @@ -29,42 +35,60 @@ public sealed class Base : Game base.Initialize(); } + + + + /// /// 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) - hook.Load(); - foreach(Scene scene in Awperative.LoadedScenes) - scene.Load(); + foreach (AwperativeHook hook in Awperative.EventHooks.ToList()) hook.Load(); + foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.Load(); } + + + + /// /// 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) scene.Update(__gameTime); + foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.Update(__gameTime); base.Update(__gameTime); } + + + + /// /// 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) scene.Draw(__gameTime); + foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.Draw(__gameTime); base.Draw(__gameTime); } + + + + /// /// 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) hook.Unload(); - foreach (Scene scene in Awperative.LoadedScenes) scene.Unload(); + foreach (AwperativeHook hook in Awperative.EventHooks.ToList()) hook.Unload(); + foreach (Scene scene in Awperative.LoadedScenes.ToList()) scene.Unload(); } + + + + } \ No newline at end of file diff --git a/Awperative/Kernel/Overhead/Core.cs b/Awperative/Kernel/Overhead/Core.cs index efdb88e..6b4e659 100644 --- a/Awperative/Kernel/Overhead/Core.cs +++ b/Awperative/Kernel/Overhead/Core.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; @@ -9,29 +10,75 @@ namespace Awperative; /// /// Initiating class of Awperative. Call Start() to start the kernel. /// +/// Avery Norris public static class Awperative { - //Inherits MonoGame and carries events. - public static Base Base; - public static List LoadedScenes = []; - //Handles, graphic Settings, drawing, and loading content respectively. + + + /// + /// Bottom class of Awperative. Contains the MonoGame instance. + /// + public static Base Base { get; internal set; } + + + + + + /// + /// Handles graphics settings through MonoGame. + /// public static GraphicsDeviceManager GraphicsDeviceManager { get; internal set; } - public static SpriteBatch SpriteBatch { get; internal set; } - public static ContentManager ContentManager { get; internal set; } - //Entry points for code - internal static List EventHooks { get; private set; } + + + /// + /// Handles drawing sprites to the screen through MonoGame. + /// + public static SpriteBatch SpriteBatch { get; internal set; } + + + + /// + /// Handles loading content through MonoGame. + /// + public static ContentManager ContentManager { get; internal set; } + + + + + /// + /// List of all scenes currently loaded in the kernel. + /// + public static List LoadedScenes => _loadedScenes.ToList(); + internal static HashSet _loadedScenes { get; private set; }= []; + + + + /// + /// List of all event hooks currently loaded in the kernel. + /// + public static List EventHooks => _eventHooks.ToList(); + internal static HashSet _eventHooks { get; private set; } = []; + + + + + /// /// Start() begins the game; and begins communication with all event hooks. /// /// 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 = __hooks; + _eventHooks = new HashSet(__hooks); Base = new Base(); Base.Run(); } + + + + } \ No newline at end of file diff --git a/Awperative/bin/Debug/net8.0/Awperative.dll b/Awperative/bin/Debug/net8.0/Awperative.dll index 9174b7a..71b7541 100644 Binary files a/Awperative/bin/Debug/net8.0/Awperative.dll and b/Awperative/bin/Debug/net8.0/Awperative.dll differ diff --git a/Awperative/bin/Debug/net8.0/Awperative.pdb b/Awperative/bin/Debug/net8.0/Awperative.pdb index 5f8c3bd..e225dcb 100644 Binary files a/Awperative/bin/Debug/net8.0/Awperative.pdb and b/Awperative/bin/Debug/net8.0/Awperative.pdb differ diff --git a/Awperative/obj/Debug/net8.0/Awperative.AssemblyInfo.cs b/Awperative/obj/Debug/net8.0/Awperative.AssemblyInfo.cs index cd49ef0..7407b74 100644 --- a/Awperative/obj/Debug/net8.0/Awperative.AssemblyInfo.cs +++ b/Awperative/obj/Debug/net8.0/Awperative.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Awperative")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9f744fcd5f47a08f81587169de34e57d3562e7ba")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6370a70e77e58afd49c5270eea3656796c8a8b60")] [assembly: System.Reflection.AssemblyProductAttribute("Awperative")] [assembly: System.Reflection.AssemblyTitleAttribute("Awperative")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Awperative/obj/Debug/net8.0/Awperative.AssemblyInfoInputs.cache b/Awperative/obj/Debug/net8.0/Awperative.AssemblyInfoInputs.cache index 44fafef..f77fe93 100644 --- a/Awperative/obj/Debug/net8.0/Awperative.AssemblyInfoInputs.cache +++ b/Awperative/obj/Debug/net8.0/Awperative.AssemblyInfoInputs.cache @@ -1 +1 @@ -7a962b2fea56a4a2f915d2e475c1e494ec261a6791d7faf4c957d39c460317a6 +65f076e2a35d39f7816008dc38aa7c8c9fe617c292f8f16923e08f8a886186cf diff --git a/Awperative/obj/Debug/net8.0/Awperative.csproj.CoreCompileInputs.cache b/Awperative/obj/Debug/net8.0/Awperative.csproj.CoreCompileInputs.cache index de2c872..9ca9d73 100644 --- a/Awperative/obj/Debug/net8.0/Awperative.csproj.CoreCompileInputs.cache +++ b/Awperative/obj/Debug/net8.0/Awperative.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -be1a95e7069d34b03cfebe4fe9e9ce02a90bff6923670e2ee1bce3618e098560 +f552bda458f25e93b640f2f86a474c139ae16e84a42a47639427c638e2566334 diff --git a/Awperative/obj/Debug/net8.0/Awperative.dll b/Awperative/obj/Debug/net8.0/Awperative.dll index 9174b7a..71b7541 100644 Binary files a/Awperative/obj/Debug/net8.0/Awperative.dll and b/Awperative/obj/Debug/net8.0/Awperative.dll differ diff --git a/Awperative/obj/Debug/net8.0/Awperative.pdb b/Awperative/obj/Debug/net8.0/Awperative.pdb index 5f8c3bd..e225dcb 100644 Binary files a/Awperative/obj/Debug/net8.0/Awperative.pdb and b/Awperative/obj/Debug/net8.0/Awperative.pdb differ diff --git a/Awperative/obj/Debug/net8.0/ref/Awperative.dll b/Awperative/obj/Debug/net8.0/ref/Awperative.dll index 740b8ca..1d43b1c 100644 Binary files a/Awperative/obj/Debug/net8.0/ref/Awperative.dll and b/Awperative/obj/Debug/net8.0/ref/Awperative.dll differ diff --git a/Awperative/obj/Debug/net8.0/refint/Awperative.dll b/Awperative/obj/Debug/net8.0/refint/Awperative.dll index 740b8ca..1d43b1c 100644 Binary files a/Awperative/obj/Debug/net8.0/refint/Awperative.dll and b/Awperative/obj/Debug/net8.0/refint/Awperative.dll differ