artemis-odb icon indicating copy to clipboard operation
artemis-odb copied to clipboard

[FEATURE] Allow Multiple OR Conditions in Aspects

Open spencerflem opened this issue 2 years ago • 0 comments

In general, Aspects are very restrictive in the logic they specify. It's not possible to, for example, ask for systems that have

One of { ComponentA, ComponentB } and also One of { ComponentC ComponentD }

This would be handy for me, since I have several equivalent components. For example, if the component has either a BoxBody or a Pos component I would be able to figure out its position. Similarly with BoxBody and Rotation components.

Currently, if something needs both a Pos-Like component and a Rotation-Like component there is no way to specify this with Aspects and I have to check at runtime. I have WIP plugin that adds InterfaceMappers that allow retrieving an Interface rather than a concrete Component. Not being able to specify what a valid Aspect is makes using it difficult.

There's other boolean logic that seems like it should be possible with aspects that currently aren't, such as:

One of { All of { A, B, C }, All of { D, Exactly One of {E, F, G}} , H }

For my use case, only the multiple ORs are important, but the nested logic seemed worth mentioning.

If this seems like a useful change, I'd be happy to try making a Pull Request for it. I've looked into doing it as a plugin, but Aspects are pretty integrated into Artemis and it seemed gross to need replacement versions for EntityLinkManager, ComponentMappers, and all the other classes that at some point indirectly use Aspects.

Alternatively, possibly Aspect could be modified to be extendable, which would allow ExtendedAspects to be a plugin.

spencerflem avatar Oct 17 '21 15:10 spencerflem