Going to bed but i wanna show off my cool debugging system
This commit is contained in:
@@ -3,6 +3,7 @@ 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>
|
||||
@@ -10,8 +11,15 @@ public interface AwperativeHook
|
||||
/// </summary>
|
||||
public void Load() {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called when the program closes.
|
||||
/// </summary>
|
||||
public void Unload() {}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
/// <summary>
|
||||
/// Base class of Awperative. Carries events from MonoGame into scenes and hooks.
|
||||
/// </summary>
|
||||
/// <author> Avery Norris </author>
|
||||
public sealed class Base : Game
|
||||
{
|
||||
|
||||
@@ -19,6 +21,10 @@ public sealed class Base : Game
|
||||
Content.RootDirectory = "Content";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initialize() is called when the program starts. Goes before LoadContent(). And prepares the kernel for use.
|
||||
/// </summary>
|
||||
@@ -29,42 +35,60 @@ public sealed class Base : Game
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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) scene.Update(__gameTime);
|
||||
foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.Update(__gameTime);
|
||||
base.Update(__gameTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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) scene.Draw(__gameTime);
|
||||
foreach(Scene scene in Awperative.LoadedScenes.ToList()) scene.Draw(__gameTime);
|
||||
base.Draw(__gameTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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) 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
/// <summary>
|
||||
/// Initiating class of Awperative. Call Start() to start the kernel.
|
||||
/// </summary>
|
||||
/// <author> Avery Norris </author>
|
||||
public static class Awperative
|
||||
{
|
||||
//Inherits MonoGame and carries events.
|
||||
public static Base Base;
|
||||
public static List<Scene> LoadedScenes = [];
|
||||
|
||||
//Handles, graphic Settings, drawing, and loading content respectively.
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Bottom class of Awperative. Contains the MonoGame instance.
|
||||
/// </summary>
|
||||
public static Base Base { get; internal set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles graphics settings through MonoGame.
|
||||
/// </summary>
|
||||
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<AwperativeHook> EventHooks { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles drawing sprites to the screen through MonoGame.
|
||||
/// </summary>
|
||||
public static SpriteBatch SpriteBatch { get; internal set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles loading content through MonoGame.
|
||||
/// </summary>
|
||||
public static ContentManager ContentManager { get; internal set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <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; }= [];
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// List of all event hooks currently loaded in the kernel.
|
||||
/// </summary>
|
||||
public static List<AwperativeHook> EventHooks => _eventHooks.ToList();
|
||||
internal static HashSet<AwperativeHook> _eventHooks { get; private set; } = [];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Start() begins the game; and begins communication with all event hooks.
|
||||
/// </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 = __hooks;
|
||||
_eventHooks = new HashSet<AwperativeHook>(__hooks);
|
||||
|
||||
Base = new Base();
|
||||
Base.Run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user