namespace Ghost.Entities.Components; public abstract class ScriptComponent : IComponentData { private bool _enable; internal World _world = null!; /// /// Gets or sets a value indicating whether this script component is enabled. /// public bool Enable { get => _enable; set { if (_enable == value) { return; } _enable = value; if (_enable) { OnEnable(); } else { OnDisable(); } } } /// /// Gets the entity that owns this script component. /// public Entity Owner { get; internal set; } /// /// Gets the EntityManager instance associated with the current world. /// protected EntityManager EntityManager => _world.EntityManager; /// /// Gets or sets the priority of the script component. /// Change this during runtime does not affect the execution order. /// public virtual int ExecutionOrder => 0; /// /// Called when the script component is enabled. /// public virtual void OnEnable() { } /// /// Called when the script component is disabled. /// public virtual void OnDisable() { } /// /// Called when the script component is initialized. /// public virtual void Initialize() { } /// /// Called when the script component is started. /// public virtual void Start() { } /// /// Called every frame. /// public virtual void Update() { } /// /// Called every frame after all Update methods have been called. /// public virtual void LateUpdate() { } /// /// Called at a fixed interval. /// This method is called at a fixed time step, independent of the frame rate. /// public virtual void FixedUpdate() { } /// /// Called when the script component is destroyed. /// public virtual void OnDestroy() { } }