Awperative Beta 1.0 Complete!
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
<dictionary name="project">
|
<dictionary name="project">
|
||||||
<words>
|
<words>
|
||||||
<w>awlf</w>
|
<w>awlf</w>
|
||||||
|
<w>awperative's</w>
|
||||||
</words>
|
</words>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
</component>
|
</component>
|
||||||
@@ -20,6 +20,13 @@ public abstract partial class Component : ComponentDocker
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the component receives time events or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool Enabled;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Order for when Components are called on. Only applies between Components on the same Docker.
|
/// Order for when Components are called on. Only applies between Components on the same Docker.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# Awperative Components
|
# 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
|
- **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
|
"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
|
- **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
|
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**.
|
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
|
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
|
obsolete. Objects are also not built to be flexible like Components, leaving empty, nearly static objects floating in
|
||||||
our Scenes.
|
our Scenes.
|
||||||
@@ -93,7 +95,7 @@ For any further documentation, please refer to the API section of our glorious w
|
|||||||
|
|
||||||
## Examples and Good Practice
|
## 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.
|
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 :
|
Like so :
|
||||||
|
|
||||||
@@ -232,4 +234,4 @@ will cause logged errors, and possibly a runtime error/halt.
|
|||||||
|
|
||||||
---
|
---
|
||||||
# End Of Documentation
|
# End Of Documentation
|
||||||
### Written By Avery Norris
|
### Code and Documentation by Avery Norris
|
||||||
@@ -11,7 +11,7 @@ namespace Awperative;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks> Please don't inherit this. I don't know why you would</remarks>
|
/// <remarks> Please don't inherit this. I don't know why you would</remarks>
|
||||||
/// <author> Avery Norris </author>
|
/// <author> Avery Norris </author>
|
||||||
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
|
/// Amount of all Components in the Docker
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Count => _Components.Count;
|
public int Count => _Components.Count;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private readonly static Comparer<Component> _componentSorter = Comparer<Component>.Create((a, b) => {
|
|
||||||
int result = b.Priority.CompareTo(a.Priority);
|
|
||||||
return (result != 0) ? result : a.GetHashCode().CompareTo(b.GetHashCode());
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -43,6 +35,16 @@ public abstract partial class ComponentDocker
|
|||||||
/// If they are equal it defaults to hash codes to ensure consistent Behavior
|
/// If they are equal it defaults to hash codes to ensure consistent Behavior
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal SortedSet<Component> _Components = new(_componentSorter);
|
internal SortedSet<Component> _Components = new(_componentSorter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How Priority is sorted.
|
||||||
|
/// </summary>
|
||||||
|
private readonly static Comparer<Component> _componentSorter = Comparer<Component>.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.
|
/// Called by Awperative when the game is Closed, sends the event to all children; and they send it to their children.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks> Will not always trigger if the program is force closed </remarks>
|
/// <remarks> Will not always trigger if the program is force closed </remarks>
|
||||||
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(); } } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by Awperative when the game is Opened, sends the event to all children; and they send it to their children.
|
/// Called by Awperative when the game is Opened, sends the event to all children; and they send it to their children.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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(); } } }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by Awperative when the game is Updated sends the event to all children; and they send it to their children.
|
/// Called by Awperative when the game is Updated sends the event to all children; and they send it to their children.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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(); } } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by Awperative when the game is Drawn, sends the event to all children; and they send it to their children.
|
/// Called by Awperative when the game is Drawn, sends the event to all children; and they send it to their children.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks> Only use this method for drawing methods</remarks>
|
/// <remarks> Only use this method for drawing methods</remarks>
|
||||||
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(); } } }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called by Awperative when this is Created, sends the event to all children; and they send it to their children.
|
||||||
|
/// </summary>
|
||||||
|
internal virtual void ChainCreate() { foreach (Component component in (Component[])[.._Components]) { if(component.Enabled) { component.Create(); component.ChainCreate(); } } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks> Not called when the game is closed</remarks>
|
/// <remarks> Not called when the game is closed</remarks>
|
||||||
internal virtual void ChainDestroy() { foreach(Component component in (Component[])[.._Components]) { component.Destroy(); component.ChainDestroy(); } }
|
internal virtual void ChainDestroy() { foreach(Component component in (Component[])[.._Components]) { if(component.Enabled) { component.Destroy(); component.ChainDestroy(); } } }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called by Awperative when this is Created, sends the event to all children; and they send it to their children.
|
|
||||||
/// </summary>
|
|
||||||
internal virtual void ChainCreate() { foreach (Component component in (Component[])[.._Components]) { component.Create(); component.ChainCreate(); } }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user