Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ActiveCollisionPublisher/Consumer extend generic class #432

Open
thestonefox opened this issue Oct 11, 2019 · 1 comment
Open

Make ActiveCollisionPublisher/Consumer extend generic class #432

thestonefox opened this issue Oct 11, 2019 · 1 comment
Labels
enhancement Making something better

Comments

@thestonefox
Copy link
Member

The ActiveCollisionPublisher and ActiveCollisionConsumer provide a good, reusable generic pattern of one side of a contract (the publisher) being able to pass a payload on to any consumer and can be limited by any given rule.

At the moment the components only work with active collisions, but most of the code can be moved into an abstract class to offer other mechanisms.

E.g.

A more general GameObject Publisher/Consumer could be used by the Pointer to create interactable elements

E.g.

OnPointerSelected
-> Add Selected GameObject to Publisher List
-> Call Publish

if the selected GameObject has a Consumer then it can digest the method and do something.

Also, if it used an ObservableList to store the contents and the ObsList was updated to take a validity rule so only objects that are considered valid can be added to the obs list, then this would mean both the publisher and consumer could impose restrictions.

At the moment only the consumer can choose to ignore all publishers sending it a message.

@thestonefox thestonefox added the enhancement Making something better label Oct 11, 2019
@thestonefox
Copy link
Member Author

Adding the rule to the observable list wouldn't actually help here, because the publisher Add method would need to look up if the given object had any consumers on it to determine if to ignore or not. So it's the publisher that would have the rule, and if the rule exists then it simply wouldn't add it.

Because of this, it wouldn't be right to use an ObsList because you'd be able to bypass the rule check by going directly to the ObsList.

This actually makes it easier to implement the above suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Making something better
Projects
None yet
Development

No branches or pull requests

1 participant