diff --git a/.idea/.idea.Awperative/.idea/dictionaries/project.xml b/.idea/.idea.Awperative/.idea/dictionaries/project.xml index 7361106..c7c65ce 100644 --- a/.idea/.idea.Awperative/.idea/dictionaries/project.xml +++ b/.idea/.idea.Awperative/.idea/dictionaries/project.xml @@ -2,6 +2,7 @@ awlf + awperative's \ No newline at end of file diff --git a/Awperative/Kernel/Component/Component.cs b/Awperative/Kernel/Component/Component.cs index e97e0fb..608d15f 100644 --- a/Awperative/Kernel/Component/Component.cs +++ b/Awperative/Kernel/Component/Component.cs @@ -20,6 +20,13 @@ public abstract partial class Component : ComponentDocker + /// + /// If the component receives time events or not. + /// + public bool Enabled; + + + /// /// Order for when Components are called on. Only applies between Components on the same Docker. /// diff --git a/Awperative/Kernel/Component/Behavior.md b/Awperative/Kernel/Component/Component.md similarity index 95% rename from Awperative/Kernel/Component/Behavior.md rename to Awperative/Kernel/Component/Component.md index f54295a..e7783bf 100644 --- a/Awperative/Kernel/Component/Behavior.md +++ b/Awperative/Kernel/Component/Component.md @@ -1,5 +1,7 @@ # Awperative Components +### Code and Documentation by Avery Norris + --- @@ -15,7 +17,7 @@ an Entity Component system involves 2/3 types of data. - **Components** are what we actually care about, shockingly, they are the "Component" in Entity Component System, and you can think about them as the actual -scripts or program in your Game, but a little more object oriented. +scripts or program in your Game, but a little more object-oriented. - **GameObjects** are the parents components are glued to, in most Game Libraries and Engines @@ -45,7 +47,7 @@ As of this current version, Awperative's **ECS** has taken on a different form t One of the main **Awperative Principles** is **Generalization**; and during development it became clear GameObjects are unnecessary, which caused them to be replaced by: the **Component**. -**Components** are a combination of the **GameObjects** and **Components** we discussed earlier. Awperative +While they are still called **Components**, Awperative's Components are actually a combination of the **GameObjects** and **Components** we discussed earlier. Awperative does not implement many fancy features out of the box; because of that the traditionally useful GameObjects became obsolete. Objects are also not built to be flexible like Components, leaving empty, nearly static objects floating in our Scenes. @@ -93,7 +95,7 @@ For any further documentation, please refer to the API section of our glorious w ## Examples and Good Practice -First let's see how we can recreate typical GameObject Component. I would most recommend using **Nested Components** to acheive this. +First let's see how we can recreate typical GameObject Component. I would most recommend using **Nested Components** to achieve this. If we pretend we have implemented a few modules for basic transform profiles and sprite management, then we can easily make a basic movable sprite object. Like so : @@ -232,4 +234,4 @@ will cause logged errors, and possibly a runtime error/halt. --- # End Of Documentation -### Written By Avery Norris +### Code and Documentation by Avery Norris diff --git a/Awperative/Kernel/ComponentDocker/ComponentDocker.cs b/Awperative/Kernel/ComponentDocker/ComponentDocker.cs index aacacac..2a4e794 100644 --- a/Awperative/Kernel/ComponentDocker/ComponentDocker.cs +++ b/Awperative/Kernel/ComponentDocker/ComponentDocker.cs @@ -11,7 +11,7 @@ namespace Awperative; /// /// Please don't inherit this. I don't know why you would /// Avery Norris -public abstract partial class ComponentDocker +public abstract class ComponentDocker { @@ -27,15 +27,7 @@ public abstract partial class ComponentDocker /// Amount of all Components in the Docker /// public int Count => _Components.Count; - - - - private readonly static Comparer _componentSorter = Comparer.Create((a, b) => { - int result = b.Priority.CompareTo(a.Priority); - return (result != 0) ? result : a.GetHashCode().CompareTo(b.GetHashCode()); - }); - - + /// @@ -43,6 +35,16 @@ public abstract partial class ComponentDocker /// If they are equal it defaults to hash codes to ensure consistent Behavior /// internal SortedSet _Components = new(_componentSorter); + + + + /// + /// How Priority is sorted. + /// + private readonly static Comparer _componentSorter = Comparer.Create((a, b) => { + int result = b.Priority.CompareTo(a.Priority); + return (result != 0) ? result : a.GetHashCode().CompareTo(b.GetHashCode()); + }); @@ -78,38 +80,38 @@ public abstract partial class ComponentDocker /// Called by Awperative when the game is Closed, sends the event to all children; and they send it to their children. /// /// Will not always trigger if the program is force closed - internal virtual void ChainUnload() { foreach (Component component in (Component[])[.._Components]) { component.Unload(); component.ChainUnload(); } } + internal virtual void ChainUnload() { foreach (Component component in (Component[])[.._Components]) { if(component.Enabled) { component.Unload(); component.ChainUnload(); } } } /// /// Called by Awperative when the game is Opened, sends the event to all children; and they send it to their children. /// - internal virtual void ChainLoad() { foreach (Component component in (Component[])[.._Components]) { component.Load(); component.ChainLoad(); } } + internal virtual void ChainLoad() { foreach (Component component in (Component[])[.._Components]) { if(component.Enabled) { component.Load(); component.ChainLoad(); } } } /// /// Called by Awperative when the game is Updated sends the event to all children; and they send it to their children. /// - internal virtual void ChainUpdate() { foreach (Component component in (Component[])[.._Components]) { component.Update(); component.ChainUpdate(); } } + internal virtual void ChainUpdate() { foreach (Component component in (Component[])[.._Components]) { if(component.Enabled) { component.Update(); component.ChainUpdate(); } } } /// /// Called by Awperative when the game is Drawn, sends the event to all children; and they send it to their children. /// /// Only use this method for drawing methods - internal virtual void ChainDraw() { foreach (Component component in (Component[])[.._Components]) { component.Draw(); component.ChainDraw(); } } + internal virtual void ChainDraw() { foreach (Component component in (Component[])[.._Components]) { if(component.Enabled) { component.Draw(); component.ChainDraw(); } } } + /// + /// Called by Awperative when this is Created, sends the event to all children; and they send it to their children. + /// + internal virtual void ChainCreate() { foreach (Component component in (Component[])[.._Components]) { if(component.Enabled) { component.Create(); component.ChainCreate(); } } } + /// /// Called by Awperative when this Component is destroyed, sends the event to all children; since they will be Destroyed too. And they send it to their children. /// /// Not called when the game is closed - internal virtual void ChainDestroy() { foreach(Component component in (Component[])[.._Components]) { component.Destroy(); component.ChainDestroy(); } } - - /// - /// Called by Awperative when this is Created, sends the event to all children; and they send it to their children. - /// - internal virtual void ChainCreate() { foreach (Component component in (Component[])[.._Components]) { component.Create(); component.ChainCreate(); } } + internal virtual void ChainDestroy() { foreach(Component component in (Component[])[.._Components]) { if(component.Enabled) { component.Destroy(); component.ChainDestroy(); } } }