Skip to content

Entities shouldn't be created when loading but when calling addToScene #11

@Ribosom

Description

@Ribosom

Problems

There are multiple small problems with entity creation in the LDtk Plugin:

  1. When using an EntityIdentifierFactory for an entity-identifier, those entities are created in two different parts. Once when LdtkResource.load is called in EntityLayer.constructor and once on addToScene in runFactories. Entities created when load is called are removed and replace when addToScene is used.
  2. Default entities are only created when load is called. It seems like they are reused instead of creating new ones when calling addToScene.

This is unexpected behavior for the user of the plugin.

Suggestion

  1. Remove the entitiy creation code from the EntityLayer.constructor
  2. Add the creation of default entities (if no EntityIdentifierFactory exists for that identifier) also to addToScene [maybe in runFactories as a fallback when no factory is found]

Open question

Are default entities really something a user would expect? Wouldn't it be better to simply print a warning, that no factory was found and so no entity was created? A warning would help the user to quickly know, that he forgot to add a EntityIdentifierFactory. An invisible default entity might cause issues, like "invisible" entities which affect collision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions