Skip to content

Improve ECS singleton syntax #60

Closed

Description

@AndreaCatania

If you need to read the entity Component, or a Databag, from a standard GDScript function, it's possible to use the ECS singleton in this way:

func _ready():
    var component = ECS.get_active_world().get_entity_component(get_entity_id(), ECS.TransformComponent)

The function get_active_world is used to get the currently active world, however, this function is really verbose. Is it possible to make it shorter?

The function get_entity_component is good, but still verbose. Is it possible to make this shorter?

What about this?
Is still understandable?
Worth it?

func _ready():
    var component = ECS.get_world().get_component(get_entity_id(), ECS.TransformComponent)

Activity

  1. AndreaCatania commented on Jul 21, 2021

    @AndreaCatania
    MemberAuthor

    Moving the proposal to discussions to keep the issue just of technical stuff to fix.

  2. locked and limited conversation to collaborators on Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions