matter icon indicating copy to clipboard operation
matter copied to clipboard

world:clear() breaks queryChanged use (0.9.0-beta.0)

Open TheyCallMeRyan opened this issue 1 year ago • 1 comments

Description

Again getting no results from queryChanged, but this time it appears to be the inverse of my 0.8.4 issue.

Having an already-initialized queryChanged hookState will fail to catch any new entities.

Steps to reproduce

No Minimum Reproduction right now, but working on making one.

Expected behavior

TheyCallMeRyan avatar Dec 01 '24 15:12 TheyCallMeRyan

This may have existed in 0.8.4 as well, but the root of the issue is I used world:clear() and expected to be able to continue using the world in systems.

With the current behavior, the line self._changedStorage = {} deletes all active changedStorage and then queryChanged never recreates the component in _changedStorage so changes will never be added to the storage.

Potential solutions would be:

  1. Clearing hookStates as well
  • I think this is ideal for this case, although I'm not sure how it would affect other hookStates or if they should be cleared at all
  1. table.clear() every individual changedStorage[component][storage] so that active updates are deleted, but new updates can still be replicated
  • Also great, but requires a bit more code in clear() and is a bit less efficient but one-time cost
  1. queryChanged checks that the storage still exists in _changedStorage
  • Would need to convert _changedStorage[component] from a list to a dictionary, not preferred because it affects frame-by-frame

TheyCallMeRyan avatar Dec 01 '24 16:12 TheyCallMeRyan