Chione::
World class
| Superclass | Object |
The main ECS container
Attributes
- components_by_entity R
The Hash of Hashes of Components which have been added to an Entity, keyed by the Entity’s ID and the Component class.
- deferred_events R
The queue of events that have not yet been sent to subscribers.
- entities R
The Hash of all Entities in the
World, keyed by ID- entities_by_component R
The Hash of Sets of Entities which have a particular component, keyed by Component class.
- main_thread R
The Thread object running the World’s IO reactor loop
- managers R
The Hash of all Managers currently in the
World, keyed by class.- subscriptions R
The Hash of event subscription callbacks registered with the world, keyed by event pattern.
- systems R
The Hash of all Systems currently in the
World, keyed by class.- tick_count RW
The number of times the event loop has executed.
- world_threads R
The ThreadGroup that contains all Threads managed by the
World.
Public Class Methods
Create a new Chione::World
Public Instance Methods
Call the specified callback with the provided event_name and payload, returning true if the callback executed without error.
Call the callbacks of any subscriptions matching the specified event_name with the given payload.
Whether or not to queue published events instead of sending them to subscribers immediately.
Kill the threads other than the main thread in the world’s thread list.
Publish an event with the specified event_name and payload.
Send any deferred events to subscribers.
Start the world; returns the Thread in which the world is running.
Start any Managers registered with the world.
Start any Systems registered with the world.
Returns true if the World has been started (but is not necessarily running yet).
Return a Hash of information about the world suitable for display in tools.
Stop the world.
Stop any Managers running in the world.
Stop any Systems running in the world.
Halt the main timing loop. By default, this just kills the world’s main thread.
Subscribe to events with the specified event_name. Returns the callback object for later unsubscribe calls.
Step the world delta_seconds into the future.
Unsubscribe from events that publish to the specified callback.
Protected Instance Methods
Return a Hash of the loaded Chione::Systems that system_class has requested be injected into it.
The loop the main thread executes after the world is started. The default implementation just broadcasts the timing event, so you will likely want to override this if the main thread should do something else.
Update any entity caches in the system when an entity has its components hash changed.
Component API
↑ topPublic Instance Methods
Add the specified component to the specified entity.
Return a Hash of the Component instances associated with entity, keyed by their class.
Return the Component instance of the specified component_class that’s associated with the given entity, if it has one.
Return true if the specified entity has the given component. If component is a Component subclass, any instance of it will test true. If component is a Component instance, it will only test true if the entity is associated with that particular instance.
Remove the specified component from the given entity. If component is a Component subclass, any instance of it will be removed. If it’s a Component instance, it will be removed iff it is the same instance associated with the given entity.
Entity API
↑ topPublic Instance Methods
Return a new Chione::Entity with no components for the receiving world. Override this if you wish to use a class other than Chione::Entity for your world.
Return a new Chione::Entity for the receiving World, using the optional archetype to populate it with components if it’s specified.
Destroy the specified entity and remove it from any registered systems/managers.
Returns true if the world contains the specified entity or an entity with entity as the ID.
Manager API
↑ topPublic Instance Methods
Add an instance of the specified manager_type to the world and return it. It will replace any existing manager of the same type.
Remove the instance of the specified manager_type from the world and return it if it’s been added. Returns nil if no instance of the specified manager_type was added.
System API
↑ topPublic Instance Methods
Add an instance of the specified system_type to the world and return it. It will replace any existing system of the same type.
Return an Array of all entities that match the specified aspect.
Remove the instance of the specified system_type from the world and return it if it’s been added. Returns nil if no instance of the specified system_type was added.