using System; namespace gaemstone.ECS; [AttributeUsage(AttributeTargets.Method)] public class SystemAttribute : Attribute { public string? Expression { get; set; } public Phase Phase { get; set; } public SystemAttribute() : this(Phase.OnUpdate) { } public SystemAttribute(Phase phase) => Phase = phase; } [AttributeUsage(AttributeTargets.Parameter)] public class SourceAttribute : Attribute { public Type Type { get; } public SourceAttribute(Type type) => Type = type; } [AttributeUsage(AttributeTargets.Parameter)] public class HasAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter)] public class NotAttribute : Attribute { } public enum Phase { PreFrame, /// /// This phase contains all the systems that load data into your ECS. /// This would be a good place to load keyboard and mouse inputs. /// OnLoad, /// /// Often the imported data needs to be processed. Maybe you want to associate /// your keypresses with high level actions rather than comparing explicitly /// in your game code if the user pressed the 'K' key. /// PostLoad, /// /// Now that the input is loaded and processed, it's time to get ready to /// start processing our game logic. Anything that needs to happen after /// input processing but before processing the game logic can happen here. /// This can be a good place to prepare the frame, maybe clean up some /// things from the previous frame, etcetera. /// PreUpdate, /// /// This is usually where the magic happens! This is where you put all of /// your gameplay systems. By default systems are added to this phase. /// OnUpdate, /// /// This phase was introduced to deal with validating the state of the game /// after processing the gameplay systems. Sometimes you entities too close /// to each other, or the speed of an entity is increased too much. /// This phase is for righting that wrong. A typical feature to implement /// in this phase would be collision detection. /// OnValidate, /// /// When your game logic has been updated, and your validation pass has ran, /// you may want to apply some corrections. For example, if your collision /// detection system detected collisions in the OnValidate phase, /// you may want to move the entities so that they no longer overlap. /// PostUpdate, /// /// Now that all of the frame data is computed, validated and corrected for, /// it is time to prepare the frame for rendering. Any systems that need to /// run before rendering, but after processing the game logic should go here. /// A good example would be a system that calculates transform matrices from /// a scene graph. /// PreStore, /// /// This is where it all comes together. Your frame is ready to be /// rendered, and that is exactly what you would do in this phase. /// OnStore, PostFrame, }