### Install Donburi Source: https://pkg.go.dev/github.com/yohamta/donburi Use 'go get' to install the Donburi library. ```bash go get github.com/yohamta/donburi ``` -------------------------------- ### Run Bunnymark Example Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark Execute the Bunnymark example from the source. This command requires Go 1.17 or later for the '@master' tag to function correctly. ```bash go run github.com/yohamta/donburi/examples/bunnymark@master ``` -------------------------------- ### Get Component Data from Entry Source: https://pkg.go.dev/github.com/yohamta/donburi Get retrieves the component data associated with a specific entry. It returns a pointer to the component data. ```go func (c *ComponentType[T]) Get(entry *Entry) *T ``` -------------------------------- ### Get Entry String Representation Source: https://pkg.go.dev/github.com/yohamta/donburi Returns a string representation of the entry. Useful for debugging and logging. ```go func (e *Entry) String() string ``` -------------------------------- ### Get All Components from an Entry Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves all components associated with an entry. This method uses reflection and may be slow; avoid in performance-critical paths. ```go func GetComponents(e *Entry) []any ``` -------------------------------- ### Get Archetype Layout Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Layout returns the associated layout for the archetype. ```go func (archetype *Archetype) Layout() *Layout ``` -------------------------------- ### Get Entry Component Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves a specific component from an entry. Requires the component type to be specified. ```go func (e *Entry) Component(c component.IComponentType) unsafe.Pointer ``` -------------------------------- ### Index SearchFrom Method Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Searches the index for archetypes matching a filter, starting from a specified index. Useful for paginated searches. ```go func (idx *Index) SearchFrom(f filter.LayoutFilter, start int) ArchetypeIterator ``` -------------------------------- ### FontName Get Method Signature Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/fonts Signature for the Get method on FontName, which returns a font.Face. ```go func (f FontName) Get() font.Face ``` -------------------------------- ### Get a Component from an Entry Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves a component of a specific type from an entry. Returns a pointer to the component if found. ```go func Get[T any](e *Entry, c component.IComponentType) *T ``` -------------------------------- ### Get All Component Types Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves a list of all registered component types. This is useful for introspection and serialization purposes. ```go func AllComponentTypes() []IComponentType ``` -------------------------------- ### Query Entities with Components Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieve entities based on the components they possess. Use `First` to get a single entity or `Iter` to iterate over all matching entities. ```go // GameState Component type GameStateData struct { // .. some data } var GameState = donburi.NewComponentType[GameStateData]() // Bullet Component type BulletData struct { // .. some data } var Bullet = donburi.NewComponentType[BulletData]() // Init the world and create entities world := donburi.NewWorld() world.Create(GameState) world.CreateMany(100, Bullet) // Query the first GameState entity if entry, ok := GameState.First(world); ok { gameState := GameState.Get(entry) // .. do stuff with the gameState entity } // Query all Bullet entities for entry := range Bullet.Iter(world) { bullet := Bullet.Get(entry) // .. do stuff with the bullet entity } ``` -------------------------------- ### Get Entity String Representation Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage String returns a string representation of the Entity. ```go func (e Entity) String() string ``` -------------------------------- ### RegisterInitializer Source: https://pkg.go.dev/github.com/yohamta/donburi Registers an initializer function to be called for a world. Initializers are typically used for setup tasks. ```APIDOC ## RegisterInitializer ### Description Registers an initializer for a world. ### Method func RegisterInitializer(initializer initializer) ### Parameters - **initializer** (initializer) - The initializer function to register. ``` -------------------------------- ### Query Entities with a Tag Component Source: https://pkg.go.dev/github.com/yohamta/donburi Tags, being components, can be used directly in queries. This example shows how to create entities with a tag and then iterate only those entities possessing the tag. ```go var EnemyTag = donburi.NewTag("Enemy") world.CreateMany(100, EnemyTag, Position, Velocity) // Search entities with EnemyTag for entry := range EnemyTag.Iter(world) { // Perform some operation on the Entities with the EnemyTag component. } ``` -------------------------------- ### WorldScale Source: https://pkg.go.dev/github.com/yohamta/donburi/features/transform Gets the world scale of an entry. ```APIDOC ## WorldScale ### Description WorldScale returns world scale of the entry. ### Method func WorldScale(entry *donburi.Entry) dmath.Vec2 ### Parameters #### Path Parameters - **entry** (*donburi.Entry) - Required - The entry to get the world scale from. ### Response #### Success Response - **scale** (dmath.Vec2) - The world scale. ``` -------------------------------- ### Get Component Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves a component of a specific type from an entry. Returns a pointer to the component if found. ```APIDOC ## Get Component ### Description Gets the component from the entry. ### Method func Get[T any](e *Entry, c component.IComponentType) *T ### Parameters - **e** (*Entry) - The entry to retrieve the component from. - **c** (component.IComponentType) - The type identifier of the component. ### Returns - ***T** - A pointer to the component data if found, otherwise nil. ``` -------------------------------- ### Get Entity Version Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Version returns the current version number of the Entity. ```go func (e Entity) Version() uint32 ``` -------------------------------- ### Get Next Archetype Index Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Next returns the next ArchetypeIndex in the iteration. ```go func (it *ArchetypeIterator) Next() ArchetypeIndex ``` -------------------------------- ### Add and Remove Components from an Entity Source: https://pkg.go.dev/github.com/yohamta/donburi Dynamically add or remove components from an existing entity using its Entry object. This example shows adding Position and removing Velocity. ```go // Fetch the first entity with PlayerTag component query := donburi.NewQuery(filter.Contains(PlayerTag)) // Query.First() returns only the first entity that // matches the query. if entry, ok := query.First(world); ok { donburi.Add(entry, Position, &PositionData{ X: 100, Y: 100, }) donburi.Remove(entry, Velocity) } ``` -------------------------------- ### Get Component Value from an Entry Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves the value of a component from an entry. This returns the component's value directly. ```go func GetValue[T any](e *Entry, c component.IComponentType) T ``` -------------------------------- ### Get First Entity with Component (MustFirst) Source: https://pkg.go.dev/github.com/yohamta/donburi MustFirst returns the first entity that has the component, panicking if no such entity is found. Use when the existence of the component is guaranteed. ```go func (c *ComponentType[T]) MustFirst(w World) *Entry ``` -------------------------------- ### FontName Type and Get Method Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/fonts Defines the FontName type, which is an alias for string, and provides a Get method to retrieve a font.Face. ```APIDOC ## type FontName ### Description Represents the name of a font. ### Type Definition ``` type FontName string ``` ### Constants ``` const ( Excel FontName = "excel" ) ``` ## func (FontName) Get ### Description Retrieves the font face associated with this FontName. ### Signature ``` func (f FontName) Get() font.Face ``` ### Returns * **font.Face** - The font face. ``` -------------------------------- ### Initialize ECS World and Systems Source: https://pkg.go.dev/github.com/yohamta/donburi Set up the Donburi ECS environment by creating a new World and an ECS instance. This is the foundational step before adding systems. ```go import ( "github.com/yohamta/donburi" ecslib "github.com/yohamta/donburi/ecs" ) world := donburi.NewWorld() ecs := ecslib.NewECS(world) ``` -------------------------------- ### NewStorage Function Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Creates and returns a new, empty Storage instance. This is the entry point for initializing storage management. ```go func NewStorage() *Storage ``` -------------------------------- ### Query Entities with AND and NOT Filters Source: https://pkg.go.dev/github.com/yohamta/donburi Use combined filters like AND and NOT to create more specific queries. This example finds entities with an NpcTag but without a Position component. ```go // This query retrieves entities that have an NpcTag and no Position component. query := donburi.NewQuery(filter.And( filter.Contains(NpcTag), filter.Not(filter.Contains(Position)))) ``` -------------------------------- ### Get First Entity with Component Source: https://pkg.go.dev/github.com/yohamta/donburi First returns the first entity found that has the specified component. It also returns a boolean indicating if an entity was found. ```go func (c *ComponentType[T]) First(w World) (*Entry, bool) ``` -------------------------------- ### Get First Entity with Component (Must) Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves the first entity with a component, panicking if none is found. Use when the component is expected to exist. ```APIDOC ## Get First Entity with Component (Must) ### Description Retrieves the first entity in the world that has the specified component type. Panics if no such entity is found. ### Method Signature ```go func (c *ComponentType[T]) MustFirst(w World) *Entry ``` ### Parameters * **w** (World) - The world to search within. ### Returns * **(*Entry)** - The first entry found that has the component. Panics if no entity is found. ``` -------------------------------- ### Query Entities with AND, OR, and Component Checks Source: https://pkg.go.dev/github.com/yohamta/donburi Demonstrates a complex query using AND and OR filters, and shows how to safely check for optional components using `entry.HasComponent` before accessing them. ```go // We have a query for all entities that have Position and Size, but also any of Sprite, Text or Shape. query := donburi.NewQuery( filter.And( filter.Contains(Position, Size), filter.Or( filter.Contains(Sprite), filter.Contains(Text), filter.Contains(Shape), ), ), ) // In our query we can check if the entity has some of the optional components before attempting to retrieve them for entry := range query.Iter(world) { // We'll always be able to access Position and Size position := Position.Get(entry) size := Size.Get(entry) if entry.HasComponent(Sprite) { sprite := Sprite.Get(entry) // .. do sprite things } if entry.HasComponent(Text) { text := Text.Get(entry) // .. do text things } if entry.HasComponent(Shape) { shape := Shape.Get(entry) // .. do shape things } } ``` -------------------------------- ### Define and Use Multiple Rendering Layers Source: https://pkg.go.dev/github.com/yohamta/donburi Organize rendering and system updates by defining custom layers using `iota`. Systems and renderers can then be added to specific layers for controlled execution order. ```go const ( LayerBackground ecslib.LayerID = iota LayerActors ) // ... ecs. AddSystem(UpdateBackground). AddSystem(UpdateActors). AddRenderer(LayerBackground, DrawBackground). AddRenderer(LayerActors, DrawActors) // ... func (g *Game) Draw(screen *ebiten.Image) { screen.Clear() g.ecs.DrawLayer(LayerBackground, screen) g.ecs.DrawLayer(LayerActors, screen) } ``` -------------------------------- ### Deprecated: Get First Entity (MustFirstEntity) Source: https://pkg.go.dev/github.com/yohamta/donburi MustFirstEntity is a deprecated method for getting the first entity with the component, panicking if none is found. Use MustFirst instead. ```go func (c *ComponentType[T]) MustFirstEntity(w World) *Entry ``` -------------------------------- ### Resume Method Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Resumes the ECS world after it has been paused. This will re-enable updates and rendering. ```go func (ecs *ECS) Resume() ``` -------------------------------- ### Get Component Storage Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Storage returns a pointer to the data storage for a specific component type within an archetype. ```go func (cs *Components) Storage(c component.IComponentType) *Storage ``` -------------------------------- ### WorldRotation Source: https://pkg.go.dev/github.com/yohamta/donburi/features/transform Gets the world rotation of an entry. ```APIDOC ## WorldRotation ### Description WorldRotation returns world rotation of the entry. ### Method func WorldRotation(entry *donburi.Entry) float64 ### Parameters #### Path Parameters - **entry** (*donburi.Entry) - Required - The entry to get the world rotation from. ### Response #### Success Response - **rotation** (float64) - The world rotation. ``` -------------------------------- ### WorldPosition Source: https://pkg.go.dev/github.com/yohamta/donburi/features/transform Gets the world position of an entry. ```APIDOC ## WorldPosition ### Description WorldPosition returns world position of the entry. ### Method func WorldPosition(entry *donburi.Entry) dmath.Vec2 ### Parameters #### Path Parameters - **entry** (*donburi.Entry) - Required - The entry to get the world position from. ### Response #### Success Response - **position** (dmath.Vec2) - The world position. ``` -------------------------------- ### NewECS Function Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Creates a new ECS instance, initializing it with a provided donburi.World. This is the entry point for setting up the ECS. ```go func NewECS(w donburi.World) *ECS ``` -------------------------------- ### Up Source: https://pkg.go.dev/github.com/yohamta/donburi/features/transform Gets the up vector of an entry's local coordinate system. ```APIDOC ## Up ### Description Up returns up vector of the entry. ### Method func Up(entry *donburi.Entry) dmath.Vec2 ### Parameters #### Path Parameters - **entry** (*donburi.Entry) - Required - The entry to get the up vector from. ### Response #### Success Response - **vector** (dmath.Vec2) - The up vector. ``` -------------------------------- ### Set Entity to Ready State Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Ready returns an Entity in a ready state. ```go func (e Entity) Ready() Entity ``` -------------------------------- ### Create Entity Method Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Creates a new entity within a specified layer and with optional initial components. Returns the created entity. ```go func (ecs *ECS) Create(l LayerID, components ...donburi.IComponentType) donburi.Entity ``` -------------------------------- ### Get First Entity with Component Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves the first entity found that has a specific component. Returns a boolean indicating if an entity was found. ```APIDOC ## Get First Entity with Component ### Description Retrieves the first entity in the world that has the specified component type. ### Method Signature ```go func (c *ComponentType[T]) First(w World) (*Entry, bool) ``` ### Parameters * **w** (World) - The world to search within. ### Returns * **(*Entry, bool)** - A tuple containing the first entry found and a boolean indicating whether an entry was found. ``` -------------------------------- ### Define and Use Components Source: https://pkg.go.dev/github.com/yohamta/donburi Define custom component types and manage their data for entities. Components are initialized with default struct values. ```go // Component is any struct that holds some kind of data. type PositionData struct { X, Y float64 } type VelocityData struct { X, Y float64 } // ComponentType represents kind of component which is used to create or query entities. var Position = donburi.NewComponentType[PositionData]() var Velocity = donburi.NewComponentType[VelocityData]() // Create an entity by specifying components that the entity will have. // Component data will be initialized by default value of the struct. entity = world.Create(Position, Velocity) // We can use entity (it's a wrapper of int64) to get an Entry object from World // which allows you to access the components that belong to the entity. entry := world.Entry(entity) // You can set or get the data via the ComponentType Position.SetValue(entry, math.Vec2{X: 10, Y: 20}) Velocity.SetValue(entry, math.Vec2{X: 1, Y: 2}) position := Position.Get(entry) velocity := Velocity.Get(entry) position.X += velocity.X position.Y += velocity.y ``` -------------------------------- ### HierarchySystem Initialization Source: https://pkg.go.dev/github.com/yohamta/donburi/features/transform Initializes the HierarchySystem, which is responsible for managing the hierarchy of entries and ensuring valid parent-child relationships. ```go var HierarchySystem = &hierarchySystem{ query: donburi.NewQuery(filter.Contains(hierarchyParentComponent)), } ``` -------------------------------- ### Get Object from Entry Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/resolv Retrieves the associated resolv.Object from a donburi.Entry. Use this function when you need to access the data or properties of an object linked to an entry. ```go func GetObject(entry *donburi.Entry) *resolv.Object ``` -------------------------------- ### Get Entity ID Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Id returns the unique identifier part of the Entity. ```go func (e Entity) Id() EntityId ``` -------------------------------- ### DrawHelp Function Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/systems Draws help information using the ECS and an ebiten image. ```go func DrawHelp(ecs *ecs.ECS, screen *ebiten.Image) ``` -------------------------------- ### NewIndex Function Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Creates and returns a new, empty search index. This is the entry point for creating an Index instance. ```go func NewIndex() *Index ``` -------------------------------- ### Create Settings Component Type Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/components Creates a new component type for settings data. Use this for game or application settings. ```go var Settings = donburi.NewComponentType[SettingsData]() ``` -------------------------------- ### Right Source: https://pkg.go.dev/github.com/yohamta/donburi/features/transform Gets the right vector of an entry's local coordinate system. ```APIDOC ## Right ### Description Right returns right vector of the entry. ### Method func Right(entry *donburi.Entry) dmath.Vec2 ### Parameters #### Path Parameters - **entry** (*donburi.Entry) - Required - The entry to get the right vector from. ### Response #### Success Response - **vector** (dmath.Vec2) - The right vector. ``` -------------------------------- ### NewGravity Constructor Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/system Constructor function for creating a new Gravity instance. Initializes gravity settings. ```go func NewGravity() *Gravity ``` -------------------------------- ### Get Component Types from Archetype Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage ComponentTypes returns all component types present in the archetype. ```go func (archetype *Archetype) ComponentTypes() []component.IComponentType ``` -------------------------------- ### Layout String Method Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Returns a string representation of the layout. Useful for debugging and logging. ```go func (l *Layout) String() string ``` -------------------------------- ### Get Component Type Name Source: https://pkg.go.dev/github.com/yohamta/donburi Returns the name of the component type. This is useful for debugging and identification. ```APIDOC ## Get Component Type Name ### Description Returns the name of the component type. ### Method Signature ```go func (c *ComponentType[T]) Name() string ``` ### Returns * **string** - The name of the component type. ``` -------------------------------- ### NewRender Constructor Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/system Constructor function for creating a new Render instance. Initializes rendering components. ```go func NewRender() *Render ``` -------------------------------- ### Check if Entity is Ready Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage IsReady checks if the entity is in a ready state. ```go func (e Entity) IsReady() bool ``` -------------------------------- ### CreatePlatform Function Signature Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/factory Signature for creating a static platform entity. Requires an ECS instance and a resolv.Object. ```go func CreatePlatform(ecs *ecs.ECS, object *resolv.Object) *donburi.Entry ``` -------------------------------- ### Get Next Entry from Ordered Iterator Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves the next entry from the OrderedEntryIterator. This method advances the iterator. ```go func (it *OrderedEntryIterator[T]) Next() *Entry ``` -------------------------------- ### Create New Instance of Component Type Source: https://pkg.go.dev/github.com/yohamta/donburi New creates a new, uninitialized instance of the component type. It returns a pointer to the raw memory. ```go func (c *ComponentType[T]) New() unsafe.Pointer ``` -------------------------------- ### Draw Method Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Executes all registered draw systems. This method should be called during the rendering phase of the application loop. ```go func (ecs *ECS) Draw(arg any) ``` -------------------------------- ### Create a New World Source: https://pkg.go.dev/github.com/yohamta/donburi Initialize a new Donburi world to manage entities and components. ```go import "github.com/yohamta/donburi" world := donburi.NewWorld() ``` -------------------------------- ### Get Entry Archetype Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves the archetype associated with an entry. Archetypes define the structure and components of entities. ```go func (e *Entry) Archetype() *storage.Archetype ``` -------------------------------- ### Get Component Type Reflect Type Source: https://pkg.go.dev/github.com/yohamta/donburi Returns the reflect.Type of the ComponentType. This can be used for runtime type inspection. ```APIDOC ## Get Component Type Reflect Type ### Description Returns the reflect.Type of the ComponentType. ### Method Signature ```go func (c *ComponentType[T]) Typ() reflect.Type ``` ### Returns * **reflect.Type** - The reflect.Type of the ComponentType. ``` -------------------------------- ### Get Component Value Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves the value of a component from an entry. This is a convenience method for accessing component data. ```APIDOC ## Get Component Value ### Description Retrieves the value of a component from a given entry. ### Method Signature ```go func (c *ComponentType[T]) GetValue(entry *Entry) T ``` ### Parameters * **entry** (*Entry) - The entry from which to retrieve the component value. ### Returns * **T** - The value of the component. ``` -------------------------------- ### Define and Iterate a Basic Query Source: https://pkg.go.dev/github.com/yohamta/donburi Define a query to find entities with specific components and iterate through them to access and modify component data. ```go // Define a query by declaring what componet you want to find. query := donburi.NewQuery(filter.Contains(Position, Velocity)) // Iterate through the entities found in the world for entry := range query.Iter(world) { // An entry is an accessor to entity and its components. position := Position.Get(entry) velocity := Velocity.Get(entry) position.X += velocity.X position.Y += velocity.Y } ``` -------------------------------- ### Layout Components Method Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Returns a slice of component types registered in the layout. Provides information about the layout's composition. ```go func (l *Layout) Components() []component.IComponentType ``` -------------------------------- ### Get Reflect Type of Component Source: https://pkg.go.dev/github.com/yohamta/donburi Typ returns the reflect.Type of the ComponentType. This can be useful for runtime type inspection. ```go func (c *ComponentType[T]) Typ() reflect.Type ``` -------------------------------- ### Get Entry ID Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves the unique storage identifier for an entry. This ID is used internally for storage and retrieval. ```go func (e *Entry) Id() storage.EntityId ``` -------------------------------- ### Get Entry Entity Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves the entity associated with an entry. An entity is a unique identifier within the ECS world. ```go func (e *Entry) Entity() Entity ``` -------------------------------- ### Config Struct Definition Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/config Defines the structure for configuration, holding Width and Height values. ```go type Config struct { Width int Height int } ``` -------------------------------- ### Get Component Type Name Source: https://pkg.go.dev/github.com/yohamta/donburi Name returns the string name of the component type. This is useful for debugging and identification. ```go func (c *ComponentType[T]) Name() string ``` -------------------------------- ### NewTime Function Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Creates a new Time instance. This should be initialized before the main loop to manage time. ```go func NewTime() *Time ``` -------------------------------- ### CreatePlayer Function Signature Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/factory Signature for creating a player entity. Requires only an ECS instance. ```go func CreatePlayer(ecs *ecs.ECS) *donburi.Entry ``` -------------------------------- ### Get World Scale of an Entry Source: https://pkg.go.dev/github.com/yohamta/donburi/features/transform Returns the world scale of a given entry. This function is part of the transform system. ```go func WorldScale(entry *donburi.Entry) dmath.Vec2 ``` -------------------------------- ### Get Component Type ID Source: https://pkg.go.dev/github.com/yohamta/donburi Returns the unique identifier for a component type. This ID is used internally to manage components. ```APIDOC ## Get Component Type ID ### Description Returns the unique identifier for this component type. ### Method Signature ```go func (c *ComponentType[T]) Id() component.ComponentTypeId ``` ### Returns * **component.ComponentTypeId** - The unique ID of the component type. ``` -------------------------------- ### AddSystem Method Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Adds a system to the ECS. Systems define the logic for updating or processing entities and components. ```go func (ecs *ECS) AddSystem(s System) *ECS ``` -------------------------------- ### Get Iterator for Entities with Component Source: https://pkg.go.dev/github.com/yohamta/donburi Iter returns an iterator for entities that have the specified component. This allows for efficient traversal of components. ```go func (c *ComponentType[T]) Iter(w World) iter.Seq[*Entry] ``` -------------------------------- ### CreateMany Entities Method Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Creates multiple new entities efficiently within a specified layer and with optional initial components. Returns a slice of the created entities. ```go func (ecs *ECS) CreateMany(l LayerID, n int, components ...donburi.IComponentType) []donburi.Entity ``` -------------------------------- ### Get Component Data Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves the component data associated with an entry. This allows access to the specific data stored within a component. ```APIDOC ## Get Component Data ### Description Retrieves the component data from a given entry. ### Method Signature ```go func (c *ComponentType[T]) Get(entry *Entry) *T ``` ### Parameters * **entry** (*Entry) - The entry from which to retrieve the component data. ### Returns * **(*T)** - A pointer to the component data. ``` -------------------------------- ### DrawPlatform Function Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/systems Draws a platform using the ECS and an ebiten image. ```go func DrawPlatform(ecs *ecs.ECS, screen *ebiten.Image) ``` -------------------------------- ### Component Method Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Retrieves a pointer to the component data within a specific archetype and component index. Use this to access existing component data. ```go func (cs *Storage) Component(archetypeIndex ArchetypeIndex, componentIndex ComponentIndex) unsafe.Pointer ``` -------------------------------- ### Get Component Type ID Source: https://pkg.go.dev/github.com/yohamta/donburi Id returns the unique identifier for the component type. This ID is used internally for managing components. ```go func (c *ComponentType[T]) Id() component.ComponentTypeId ``` -------------------------------- ### CreateFloatingPlatform Function Signature Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/factory Signature for creating a floating platform entity. Requires an ECS instance and a resolv.Object. ```go func CreateFloatingPlatform(ecs *ecs.ECS, object *resolv.Object) *donburi.Entry ``` -------------------------------- ### Create and Query Entities on a Specific Layer Source: https://pkg.go.dev/github.com/yohamta/donburi Use `ecslib.Create` and `ecslib.NewQuery` with a layer ID to manage entities and queries within specific layers of the ECS. ```go var layer0 ecs.LayerID = 0 // Create an entity on layer0 ecs.Create(layer0, someComponents...) // Create a query to iterate entities on layer0 queryForLayer0 := ecslib.NewQuery(layer0, filter.Contains(someComponent)) ``` -------------------------------- ### Get Component Value from Entry Source: https://pkg.go.dev/github.com/yohamta/donburi GetValue retrieves the value of a component from an entry. This returns the component's data directly, not a pointer. ```go func (c *ComponentType[T]) GetValue(entry *Entry) T ``` -------------------------------- ### Deprecated: Get First Entity (FirstEntity) Source: https://pkg.go.dev/github.com/yohamta/donburi FirstEntity is a deprecated method for retrieving the first entity with the component. Use First instead. ```go func (c *ComponentType[T]) FirstEntity(w World) (*Entry, bool) ``` -------------------------------- ### Add a Component to an Entry Source: https://pkg.go.dev/github.com/yohamta/donburi Adds a component to a given entry. Ensure the component type and entry are valid before calling. ```go func Add[T any](e *Entry, c component.IComponentType, component *T) ``` -------------------------------- ### Query.First Source: https://pkg.go.dev/github.com/yohamta/donburi Returns the first entity that matches the query. ```APIDOC ## func (*Query) First ### Description First returns the first entity that matches the query. ### Signature ```go func (q *Query) First(w World) (entry *Entry, ok bool) ``` ``` -------------------------------- ### SettingsData Struct Definition Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/components Defines the structure for settings data, including debug mode and help text visibility. ```go type SettingsData struct { Debug bool ShowHelpText bool } ``` -------------------------------- ### Get Transform Data of an Entry Source: https://pkg.go.dev/github.com/yohamta/donburi/features/transform Retrieves the TransformData associated with a specific entry. This is essential for accessing and modifying an entity's transform properties. ```go func GetTransform(entry *donburi.Entry) *TransformData ``` -------------------------------- ### Set Entry Component Source: https://pkg.go.dev/github.com/yohamta/donburi Sets or updates a component on an entry. If the component already exists, it will be replaced. ```go func (e *Entry) SetComponent(c component.IComponentType, component unsafe.Pointer) ``` -------------------------------- ### Update Method Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Runs all registered update systems. This method is typically called once per frame to process game logic. ```go func (ecs *ECS) Update() ``` -------------------------------- ### Render System Query Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark_ecs/system Defines queries for the render system, including an ordered query for entities with Position, Hue, and Sprite components. ```go var Render = &render{ query: donburi.NewQuery( filter.Contains( component.Position, component.Hue, component.Sprite, )), orderedQuery: donburi.NewOrderedQuery[component.PositionData]( filter.Contains( component.Position, component.Hue, component.Sprite, )), } ``` -------------------------------- ### Time Resume Method Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Resumes time tracking after it has been paused. This allows DeltaTime to return accurate values again. ```go func (t *Time) Resume() ``` -------------------------------- ### Define Generic Component Type Source: https://pkg.go.dev/github.com/yohamta/donburi ComponentType represents a type of component and is used to identify components when getting or setting them for an entity. It is a generic type that can hold any data. ```go type ComponentType[T any] struct { // contains filtered or unexported fields } ``` -------------------------------- ### GetOrCreateSettings Function Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/systems Retrieves or creates settings data for the ECS. ```go func GetOrCreateSettings(ecs *ecs.ECS) *components.SettingsData ``` -------------------------------- ### Create New Components Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage NewComponents creates and returns a new, empty structure for storing component data. ```go func NewComponents() *Components ``` -------------------------------- ### Enable Debug Logging Source: https://pkg.go.dev/github.com/yohamta/donburi/features/events Set the global Debug variable to true to enable debug logging for the events package. ```go var Debug = false ``` -------------------------------- ### Set Component on Entry Source: https://pkg.go.dev/github.com/yohamta/donburi Sets a component on an entry. This is used to associate a component with a specific entry. ```go func Set[T any](e *Entry, c component.IComponentType, component *T) ``` -------------------------------- ### CreatePlatform Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/factory Creates a new platform entity within the ECS. It requires an ECS world and an object definition. ```APIDOC ## func CreatePlatform ### Description Creates a new platform entity within the ECS. It requires an ECS world and an object definition. ### Signature ```go func CreatePlatform(ecs *ecs.ECS, object *resolv.Object) *donburi.Entry ``` ### Parameters #### Path Parameters This function does not have path parameters. #### Query Parameters This function does not have query parameters. #### Request Body This function does not have a request body. ### Response #### Success Response - ***donburi.Entry** - A pointer to the created donburi entry representing the platform. ``` -------------------------------- ### Image Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/helper Loads an image from an embedded filesystem. ```APIDOC ## func Image ### Description Loads an image from an embedded filesystem. ### Signature ```go func Image(fs embed.FS, filepath string) *ebiten.Image ``` ``` -------------------------------- ### NewStorage Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Creates a new empty Storage structure for managing component data. ```APIDOC ## NewStorage ### Description Creates a new empty structure that stores the pointer to data of each component. ### Signature ```go func NewStorage() *Storage ``` ``` -------------------------------- ### Register World Initializer Source: https://pkg.go.dev/github.com/yohamta/donburi Registers a function to be called during world initialization. This is useful for setting up default components or systems. ```go func RegisterInitializer(initializer initializer) ``` -------------------------------- ### NewLocationMap Function Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Creates and returns a new, empty LocationMap. This is the constructor for the location storage. ```go func NewLocationMap() *LocationMap ``` -------------------------------- ### Iterate Query with Callback Source: https://pkg.go.dev/github.com/yohamta/donburi Iterates over all entities that match the query's filter. A callback function is executed for each matching entry. ```go func (q *Query) Each(w World, callback func(*Entry)) ``` -------------------------------- ### DrawWall Function Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/systems Draws a wall using the ECS and an ebiten image. ```go func DrawWall(ecs *ecs.ECS, screen *ebiten.Image) ``` -------------------------------- ### And Filter Function Source: https://pkg.go.dev/github.com/yohamta/donburi/filter Creates a LayoutFilter that matches layouts containing all specified filters. Use this when an entity must satisfy multiple filtering conditions simultaneously. ```go func And(filters ...LayoutFilter) LayoutFilter ``` -------------------------------- ### Index Push Method Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Adds an archetype to the search index. This method is used to populate the index with data. ```go func (idx *Index) Push(layout *Layout) ``` -------------------------------- ### CreateWall Function Signature Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/factory Signature for creating a wall entity. Requires an ECS instance and a resolv.Object. ```go func CreateWall(ecs *ecs.ECS, obj *resolv.Object) *donburi.Entry ``` -------------------------------- ### CreatePlayer Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/factory Creates a new player entity within the ECS. It requires an ECS world. ```APIDOC ## func CreatePlayer ### Description Creates a new player entity within the ECS. It requires an ECS world. ### Signature ```go func CreatePlayer(ecs *ecs.ECS) *donburi.Entry ``` ### Parameters #### Path Parameters This function does not have path parameters. #### Query Parameters This function does not have query parameters. #### Request Body This function does not have a request body. ### Response #### Success Response - ***donburi.Entry** - A pointer to the created donburi entry representing the player. ``` -------------------------------- ### Query EachUntil Function Signature and Description Source: https://pkg.go.dev/github.com/yohamta/donburi Signature for the EachUntil function. It iterates over entities matching a query until the callback returns false. ```go func (q *Query) EachUntil(w World, callback func(*Entry) bool) ``` -------------------------------- ### MockComponentType New Method Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Creates a new instance of the component type. Returns an unsafe.Pointer to the newly allocated component. ```go func (m *MockComponentType[T]) New() unsafe.Pointer ``` -------------------------------- ### Components Methods Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Provides methods for managing components within archetypes. ```APIDOC ## Components ### Description Components is a structure that stores data of components. ### Functions #### NewComponents ```func NewComponents() *Components``` Creates a new empty structure that stores data of components. #### Move ```func (cs *Components) Move(src ArchetypeIndex, dst ArchetypeIndex)``` Moves the pointer to data of the component in the archetype. #### PushComponents ```func (cs *Components) PushComponents(components []component.IComponentType, archetypeIndex ArchetypeIndex) ComponentIndex``` Stores the new data of the component in the archetype. #### Remove ```func (cs *Components) Remove(a *Archetype, ci ComponentIndex)``` Removes the component from the storage. #### Storage ```func (cs *Components) Storage(c component.IComponentType) *Storage``` Returns the pointer to data of the component in the archetype. ``` -------------------------------- ### Spawn Update Method Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/system The Update method for the Spawn struct. Manages the process of spawning new entities during gameplay. ```go func (s *Spawn) Update(w donburi.World) ``` -------------------------------- ### DrawFloatingPlatform Function Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/systems Draws a floating platform using the ECS and an ebiten image. ```go func DrawFloatingPlatform(ecs *ecs.ECS, screen *ebiten.Image) ``` -------------------------------- ### Add a Rendering System to ECS Source: https://pkg.go.dev/github.com/yohamta/donburi Register a rendering function for a specific layer using `AddRenderer`. This allows for organized drawing of game elements. ```go ecs.AddRenderer(ecs.LayerDefault, DrawBackground) ``` -------------------------------- ### CreateFloatingPlatform Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/factory Creates a new floating platform entity within the ECS. It requires an ECS world and an object definition. ```APIDOC ## func CreateFloatingPlatform ### Description Creates a new floating platform entity within the ECS. It requires an ECS world and an object definition. ### Signature ```go func CreateFloatingPlatform(ecs *ecs.ECS, object *resolv.Object) *donburi.Entry ``` ### Parameters #### Path Parameters This function does not have path parameters. #### Query Parameters This function does not have query parameters. #### Request Body This function does not have a request body. ### Response #### Success Response - ***donburi.Entry** - A pointer to the created donburi entry representing the floating platform. ``` -------------------------------- ### Create Object Component Type Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/components Creates a new component type for objects. Use this to define custom object components. ```go var Object = donburi.NewComponentType[resolv.Object]() ``` -------------------------------- ### DrawLayer Method Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Executes all draw systems for a specific layer. This allows for layered rendering, controlling the order and visibility of elements. ```go func (ecs *ECS) DrawLayer(l LayerID, arg any) ``` -------------------------------- ### Create Player Component Type Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/components Creates a new component type for player data. This is used to manage player-specific properties. ```go var Player = donburi.NewComponentType[PlayerData]() ``` -------------------------------- ### Arg Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Represents an argument that can be passed to a renderer. ```APIDOC ## Arg ### Description Arg is an argument of the renderer. ### Type ```go interface{} ``` ``` -------------------------------- ### Create New Ordered Query Source: https://pkg.go.dev/github.com/yohamta/donburi Initializes a new OrderedQuery with a specified filter. Use this for queries that require ordered results. ```go func NewOrderedQuery[T IOrderable](filter filter.LayoutFilter) *OrderedQuery[T] ``` -------------------------------- ### GpuInfo Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark_ecs/helper Retrieves information about the GPU. ```APIDOC ## func GpuInfo ### Description Retrieves information about the GPU. ### Signature ```go func GpuInfo() (gpu string) ``` ### Returns * **gpu** (string) - A string containing GPU information. ``` -------------------------------- ### GpuInfo Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/helper Retrieves information about the GPU. ```APIDOC ## func GpuInfo ### Description Retrieves information about the GPU. ### Signature ```go func GpuInfo() (gpu string) ``` ``` -------------------------------- ### NewLayout Function Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Creates a new entity layout with the specified component types. Used to define the structure of entities. ```go func NewLayout(components []component.IComponentType) *Layout ``` -------------------------------- ### GetComponents Source: https://pkg.go.dev/github.com/yohamta/donburi Retrieves all components associated with an entry. This method uses reflection and may have performance implications. ```APIDOC ## GetComponents ### Description Uses reflection to convert the unsafe.Pointers of an entry into its component data instances. Note that this is likely to be slow and should not be used in hot paths or if not necessary. ### Method func GetComponents(e *Entry) []any ### Parameters - **e** (*Entry) - The entry to retrieve components from. ### Returns - **[]any** - A slice of component data instances. ``` -------------------------------- ### Entry Methods Source: https://pkg.go.dev/github.com/yohamta/donburi Provides methods for interacting with an entity entry, such as retrieving its archetype, components, ID, and validity, as well as removing components or the entry itself. ```APIDOC ## Entry Methods ### Description Methods for interacting with an entity entry. ### Archetype ```func (e *Entry) Archetype() *storage.Archetype``` Archetype returns the archetype. ### Component ```func (e *Entry) Component(c component.IComponentType) unsafe.Pointer``` Component returns the component. ### Entity ```func (e *Entry) Entity() Entity``` Entity returns the entity. ### HasComponent ```func (e *Entry) HasComponent(c component.IComponentType) bool``` HasComponent returns true if the entity has the given component type. ### Id ```func (e *Entry) Id() storage.EntityId``` Id returns the entity id. ### Remove ```func (e *Entry) Remove()``` Remove removes the entity from the world. ### RemoveComponent ```func (e *Entry) RemoveComponent(c component.IComponentType)``` RemoveComponent removes the component from the entity. ### SetComponent ```func (e *Entry) SetComponent(c component.IComponentType, component unsafe.Pointer)``` SetComponent sets the component. ### String ```func (e *Entry) String() string``` ### Valid ```func (e *Entry) Valid() bool``` Valid returns true if the entry is valid. ``` -------------------------------- ### Go Method Signature: (*Plot) Last Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/helper Defines the signature for the Last method of the Plot type, which likely returns the last recorded value. ```go func (p *Plot) Last() float64 ``` -------------------------------- ### GetObject Function Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/platformer/resolv Retrieves the resolv.Object associated with a given entry. ```APIDOC ## func GetObject ### Description Retrieves the resolv.Object associated with a given entry. ### Signature ```go func GetObject(entry *donburi.Entry) *resolv.Object ``` ### Parameters * **entry** (*donburi.Entry) - The entry from which to retrieve the object. ### Returns * **(*resolv.Object)** - The resolv.Object associated with the entry, or nil if none is found. ``` -------------------------------- ### Query First Function Signature Source: https://pkg.go.dev/github.com/yohamta/donburi Signature for the First function, which returns the first entity matching the query. ```go func (q *Query) First(w World) (entry *Entry, ok bool) ``` -------------------------------- ### Position Ordering Variable Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark_ecs/system A boolean flag to control position ordering in systems. ```go var UsePositionOrdering bool ``` -------------------------------- ### NewVelocity Constructor Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/system Constructor function for creating a new Velocity instance. Initializes velocity properties. ```go func NewVelocity() *Velocity ``` -------------------------------- ### Spawn Struct Definition Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark_ecs/system Definition of the Spawn struct, likely used for entity spawning logic. ```go type Spawn struct { // contains filtered or unexported fields } ``` -------------------------------- ### PushComponent Method Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Adds a new component's data to the specified archetype. This method is used to store newly created component data. ```go func (cs *Storage) PushComponent(component component.IComponentType, archetypeIndex ArchetypeIndex) ``` -------------------------------- ### Exact Filter Function Source: https://pkg.go.dev/github.com/yohamta/donburi/filter Creates a LayoutFilter that matches layouts containing exactly the same components specified. Use this for precise component matching. ```go func Exact(components []component.IComponentType) LayoutFilter ``` -------------------------------- ### NewQuery Function Source: https://pkg.go.dev/github.com/yohamta/donburi/query Creates a new Query instance. It accepts arbitrary filters for entity selection. It is recommended to use donburi.NewQuery instead. ```go func NewQuery(filter filter.LayoutFilter) *Query ``` -------------------------------- ### Iterate Over Entities with Component Source: https://pkg.go.dev/github.com/yohamta/donburi Each iterates over all entities that possess a specific component. The provided callback function is executed for each entity found. ```go func (c *ComponentType[T]) Each(w World, callback func(*Entry)) ``` -------------------------------- ### Create New Ordered Entry Iterator Source: https://pkg.go.dev/github.com/yohamta/donburi Initializes a new OrderedEntryIterator. It requires the current position, the world, a list of entities, and the component type to order by. ```go func NewOrderedEntryIterator[T IOrderable](current int, w World, entities []Entity, orderedBy *ComponentType[T]) OrderedEntryIterator[T] ``` -------------------------------- ### TimeScale Function Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Returns the current time scale. This indicates how time is currently being scaled within the system. ```go func (t *Time) TimeScale() float64 ``` -------------------------------- ### Publish an Event Source: https://pkg.go.dev/github.com/yohamta/donburi/features/events Use the Publish method on an EventType to send an event to all its subscribers. The event data must match the type T of the EventType. ```go func (e *EventType[T]) Publish(w donburi.World, event T) ``` -------------------------------- ### Add a System Function to ECS Source: https://pkg.go.dev/github.com/yohamta/donburi Register a system by adding a function that accepts an `*ecs.ECS` argument to the ECS instance. Systems define game logic executed per frame or on demand. ```go // Some System's function func SomeFunction(ecs *ecs.ECS) { // ... } ecs.AddSystem(SomeFunction) ``` -------------------------------- ### Render Draw Method Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/system The Draw method for the Render struct. Handles the actual drawing of game elements to the screen. ```go func (r *Render) Draw(w donburi.World, screen *ebiten.Image) ``` -------------------------------- ### NewBounce Constructor Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/system Constructor function for creating a new Bounce instance. Requires image bounds for initialization. ```go func NewBounce(bounds *image.Rectangle) *Bounce ``` -------------------------------- ### Storage.MoveComponent Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Moves a component from a source archetype to a destination archetype. ```APIDOC ## Storage.MoveComponent ### Description Moves the pointer to data of the component in the archetype. ### Signature ```go func (cs *Storage) MoveComponent(srcIndex ArchetypeIndex, index ComponentIndex, dstIndex ArchetypeIndex) ``` ### Parameters * **srcIndex** (ArchetypeIndex) - The index of the source archetype. * **index** (ComponentIndex) - The index of the component to move. * **dstIndex** (ArchetypeIndex) - The index of the destination archetype. ``` -------------------------------- ### NewPlot Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark_ecs/helper Creates a new Plot instance. ```APIDOC ## func NewPlot ### Description Creates and initializes a new Plot. ### Signature ```go func NewPlot(bars int, max float64) *Plot ``` ### Parameters * **bars** (int) - The number of bars or data points the plot should hold. * **max** (float64) - The maximum value for scaling the plot. ``` -------------------------------- ### Define IOrderable Interface Source: https://pkg.go.dev/github.com/yohamta/donburi Defines the IOrderable interface, which requires an Order() method. Used for sorting entries. ```go type IOrderable interface { Order() int } ``` -------------------------------- ### PositionData Order Method Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark_ecs/component Defines the Order method for the PositionData struct. Its purpose is not detailed in the provided context. ```go func (p PositionData) Order() int ``` -------------------------------- ### Iterate Ordered Query with Callback Source: https://pkg.go.dev/github.com/yohamta/donburi Iterates over entities matching the query filter, ordered by the specified component type. The callback function is executed for each matching entry. ```go func (q *OrderedQuery[T]) EachOrdered(w World, orderBy *ComponentType[T], callback func(*Entry)) ``` -------------------------------- ### Create New Archetype Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Use NewArchetype to instantiate a new archetype with a given index and layout. ```go func NewArchetype(index ArchetypeIndex, layout *Layout) *Archetype ``` -------------------------------- ### Pause Method Source: https://pkg.go.dev/github.com/yohamta/donburi/ecs Pauses the ECS world, effectively stopping updates and potentially rendering. Use IsPaused to check the state. ```go func (ecs *ECS) Pause() ``` -------------------------------- ### SettingsData Struct Definition Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark/component Defines the structure for settings data, including various fields like Ticker, Image, bool, int, string, and helper plots. ```go type SettingsData struct { Ticker *time.Ticker Sprite *ebiten.Image Colorful bool Amount int Gpu string Tps *helper.Plot Fps *helper.Plot Objects *helper.Plot } ``` -------------------------------- ### NewSpawn Function Signature Source: https://pkg.go.dev/github.com/yohamta/donburi/examples/bunnymark_ecs/system Signature for the NewSpawn function, used to create a new Spawn instance. ```go func NewSpawn() *Spawn ``` -------------------------------- ### Index Source: https://pkg.go.dev/github.com/yohamta/donburi/internal/storage Index is a structure that indexes archetypes by their component types, enabling efficient searching. It allows adding archetypes and searching for them based on specified filters. ```APIDOC ## Index ### Description A structure that indexes archetypes by their component types for efficient searching. ### Methods #### NewIndex ```go func NewIndex() *Index ``` Creates a new search index. #### Push ```go func (idx *Index) Push(layout *Layout) ``` Adds an archetype to the search index. #### Search ```go func (idx *Index) Search(filter filter.LayoutFilter) ArchetypeIterator ``` Searches for archetypes that match the given filter. #### SearchFrom ```go func (idx *Index) SearchFrom(f filter.LayoutFilter, start int) ArchetypeIterator ``` Searches for archetypes that match the given filter starting from a specific index. ```