rbxts-flamework / core

Flamework is an extensible game framework. It requires typescript and offers many useful features.
MIT License
112 stars 8 forks source link

Ability to get all Components that extend from a base component (Polymorphism) #38

Closed Felyrun closed 2 years ago

Felyrun commented 2 years ago

(Kind of related to https://github.com/rbxts-flamework/core/issues/33, but also different)

Currently, there is no possibility to retrieve all components that extend from a base component, which would be a great feature for writing decoupled code.

For example, I have different types of Interaction Classes for things like Seats or Heal Stations, that all derive from a BaseInteraction Class for common functionality. Then, I have a GUI to display an interaction prompt on all of these. Currently, I have to call getAllComponents() for each of these Interaction Classes manually (Which also means I have to reference them), instead of using one getAllComponents() call that supports Polymorphism.

I know that could be hard to implement as these types don't really exist on runtime, but I could imagine something like this working through the metadata that Flamework defines for each Component.

Fireboltofdeath commented 2 years ago

https://github.com/rbxts-flamework/components/pull/4 https://github.com/rbxts-flamework/transformer/pull/15