Skip to content

Draft: Multiple Filters to `map:get_entities()`.

Cluedrew Kenfar Ink requested to merge Cluedrew/solarus:get-entities into dev

I decided to open a merge request about this because even I forgot I was blocked on it. This is an implementation of #843 (closed). As I was implementing it I made several design changes and I am looking for some feedback on those as well as any review of the implementation.

The design now looks like:

  • A type filter, provided by one of type, types or excluded_types keys, which check the types of entities.
  • The rect test checks if the entity overlaps with a rectangle. Defined by the overlaps and region keys.
  • The prefix test and key checks for a prefix of entity name.
  • The layers test (layer and layers) checks that the entity is on a given layer/layers.
  • The properties key is going to (I haven't implemented it yet) provides checks on the properties of the object.

In addition to the properties checking there is some clean-up to do. I will be working on those two things on my own as now (hopefully at least) I will remember to come back to it. Also I have removed the custom_predicate key, it could be added back but it would probably be added back in as a Lua wrapper because the advantages of this method is that it cuts down on the amount of times we have to go back and forth between Lua and that doesn't apply while calling Lua. I also did not add the model or breed checks because they didn't seem to be too popular.

For the new keys not in the original issue: overlaps replaces rect, layers is like layer but accepts a pair that it uses as an inclusive range and finally properties went though several versions as we work shopped it. I as sticking with the strict property, check and additional value structure for simplicity and forwards compatibility.

Merge request reports