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

Small refactor of the interaction system. #1261

Open
stilnat opened this issue Sep 19, 2023 · 0 comments
Open

Small refactor of the interaction system. #1261

stilnat opened this issue Sep 19, 2023 · 0 comments
Labels
Difficulty: medium 🥼 For those that already have some understanding of the code base. Feature A new system or other feature. Interactions Tasks specific to the interaction system or specific interactions.

Comments

@stilnat
Copy link
Contributor

stilnat commented Sep 19, 2023

Summary

The Interaction class implementing IInteraction is more trouble than help. First of all, it introduces another layer of inheritance, it doesn't implement anything, or it does it without real use. All it does is "hiding" some methods from things that inherits from it, but those methods will often be used and then throw a NotImplementedException(). The compiler doesn't complain because Interaction still provides an implementation, but if it's just to throw an exception it probably should just not exist.

The issue is that IInteraction contains more than it should. Some methods are useless for instant interactions, such as update and cancel. "ClientInteraction" are not occuring that often too and could have their own interface.

So divide IInteraction in three interface :

  • IInteraction with methods GetName, GetIcon, CanInteract, Start
  • IDelayedInteraction with methods Update, Cancel
  • IClientInteractionCreator with method CreateClients

Remove class Interaction, and have every interaction implementing the interface directly.

Some script like interaction controller relies on IInteraction being full, it'll be necessary to change those scripts as well, and to add some logic to check which interfaces are implemented.

DelayedInteraction is nice though, it implements what's generic and leaves abstract what it can't handle, forcing inheriting classes to implement them. We can leave it and use it.

@stilnat stilnat added Feature A new system or other feature. Interactions Tasks specific to the interaction system or specific interactions. Difficulty: medium 🥼 For those that already have some understanding of the code base. labels Sep 19, 2023
@cosmiccoincidence cosmiccoincidence pinned this issue Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: medium 🥼 For those that already have some understanding of the code base. Feature A new system or other feature. Interactions Tasks specific to the interaction system or specific interactions.
Projects
None yet
Development

No branches or pull requests

1 participant