Files
GhostEngine/Ghost.Entities/Components/ScriptComponent.cs
Misaki bab3be2508 Refactor project structure and improve performance
Changed the `ProjectRepository` class to be static for easier usage.
Changed `ProjectService` constants to public properties for accessibility.
Changed `App.xaml` to consolidate theme resources into `Override.xaml`.
Changed `App.xaml.cs` to implement an `AppStateMachine` for better state management.
Changed `ConsolePage` and `HierarchyPage` to utilize the new ViewModel structure.
Changed `ProjectPage` to use the `ExplorerItem` model for asset display.
Changed `Entity` and `EntityManager` to enhance component management with a new `IComponentData` interface.
Changed the `Logger` class to introduce structured logging functionality.
Changed the system architecture to support dependency management for better organization.
Changed the `QueryEnumerable` class to allow for more flexible entity queries.
Changed the `TypeHandle` class to improve efficiency in retrieving type handles.
Changed the `World` class to support robust world management and multiple worlds.
Updated the `Test` class to demonstrate the new entity and component management system.
2025-06-05 21:45:50 +09:00

96 lines
2.0 KiB
C#

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