Code-Reference
- class game_core.src.core.Coroutine(func, interval=None, loop_condition=<function Coroutine.<lambda>>, call_delay=None, func_args=None, func_kwargs=None)
Represents a coroutine that periodically executes a function.
- Variables:
is_dead – Indicates whether the coroutine is inactive.
- __init__(func, interval=None, loop_condition=<function Coroutine.<lambda>>, call_delay=None, func_args=None, func_kwargs=None)
Initializes the Coroutine.
- Parameters:
func (callable) – The function to execute periodically. The function can update the ‘interval’, ‘func_args’, and ‘func_kwargs’ by returning them in a dictionary.
interval (float) – The time interval (in milliseconds) between executions.
loop_condition (callable) – A function returning a boolean that determines if the coroutine should continue.
call_delay (float) – Initial delay before the first execution (in milliseconds).
func_args (tuple) – Positional arguments to pass to func.
func_kwargs (dict) – Keyword arguments to pass to func.
- __weakref__
list of weak references to the object (if defined)
- class game_core.src.core.Engine(core: Core)
Represents a game engine responsible for managing coroutines and state machines.
- Variables:
core – Reference to the Core instance managing the game loop.
is_enabled – Indicates whether the engine is active.
priority_layer – Determines the order of engine execution.
state_machines – List of state machines managed by the engine.
- __init__(core: Core)
Initializes the Engine.
- Parameters:
core (Core) – The Core instance managing the game loop.
- enable(**kwargs)
Enables the engine and triggers related events.
- Parameters:
kwargs (dict) – Additional data passed to the on_enable method.
- disable()
Disables the engine and triggers related events.
- start_func_as_coroutine(func, **kwargs)
Starts a function as a coroutine.
- Parameters:
func (callable) – The function to execute as a coroutine.
kwargs (dict) – Arguments for the coroutine, including interval, call_delay, and all other parameters of the Coroutine class.
- start_coroutine(coroutine)
Adds a Coroutine instance to the list of active coroutines.
- Parameters:
coroutine (Coroutine) – The Coroutine instance to start.
- start_coroutines(coroutines)
Adds multiple Coroutine instances to the list of active coroutines.
- Parameters:
coroutines (list) – List of Coroutine instances to start.
- awake(**kwargs)
Called once at the beginning of the engine’s lifecycle for initialization.
- Parameters:
kwargs (dict) – Optional arguments for initialization.
- on_enable(inject=None)
Triggered when the engine is enabled via the enable() method.
- Parameters:
inject (dict) – Optional data to be injected during the enabling process.
- on_disable()
Called when the engine is disabled, via the disable() method.
- start()
Called when the engine starts.
- update()
Called continuously during the game loop.
- fixed_update()
Called at fixed intervals during the game loop.
- on_destroy()
This method is called when the engine is about to be destroyed or when a scene change occurs.
- __weakref__
list of weak references to the object (if defined)