-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documents the Entity-Component framework
- Loading branch information
1 parent
d0297b7
commit 34d64c7
Showing
11 changed files
with
115 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Aurora.Core.EC; | ||
|
||
public abstract class Component : IComponent | ||
{ | ||
/// <summary> | ||
/// The entity this component is attached to. | ||
/// </summary> | ||
public Entity Entity { get; } | ||
|
||
/// <summary> | ||
/// Called every update cycle for this component's logic. | ||
/// </summary> | ||
public virtual void Update() { } | ||
|
||
/// <summary> | ||
/// Called every update cycle for this component's rendering logic. | ||
/// </summary> | ||
public virtual void Render() { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Aurora.Core.EC; | ||
|
||
public interface IEntity | ||
{ | ||
int Id { get; } | ||
|
||
bool Active { get; set; } | ||
|
||
T Get<T>() where T : class, IComponent; | ||
|
||
T Set<T>(T? value) where T : class, IComponent; | ||
|
||
bool Has<T>() where T : class, IComponent; | ||
|
||
bool Remove<T>() where T : class, IComponent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Aurora.Core.EC; | ||
|
||
namespace Aurora.Core.Physics; | ||
|
||
public sealed class Transform(Vector2 position, Vector2? scale = null, float rotation = 0f) : Component | ||
{ | ||
public Vector2 Position = position; | ||
|
||
public Vector2 Scale = scale ?? Vector2.One; | ||
|
||
public float Rotation = rotation; | ||
} |