A Godot Plugin to create generic components to your project's logic to make better maintenance
Works only on Godot 4.x versions
- Added new UI tab for componentable, easy to create, modify components and see current values
- Automatic creation of componentable and components
- New icons for components
- Many bugs fixed
- Create a UI Editor for all values from components, so you don't need to select component nodes to change values
The main goal of the Componentable is to create components to some classes to share responsibility between nodes.
With this you can split the logic in many scripts with low code, and you can customize some behaviours for many nodes with same scene
Example of selection of components on Componentable
The componentable flow is the componentable will always be required, so when you create a component will always have a variable with the componentable as value, but componentable can call the component but the component could not exist.
- You can search "Componentable" on Godot Assets Library
- You can download this repo, copy and paste the
addons/componentable
into your project's folder
To start just select a node and in the "Componentable" tab click on Create Componentable
Then select a path and a name to your component, will create a Componen
Node don't need to have a script, componentable can be used with build-in types
So for in our component example Glowing
will make the player glow with:
class_name Glowing extends PlayerComponent
#You can access the variable player to get the parent of this component, that is a class named Player
func _ready():
if active: # active is a variable inside PlayerComponent to make some enabling behaviours
create_tween().tween_property(player, "modulate:a", 0, 1)
then you select the Componentable
node you can select the component
This list of components will show all components that is from this node type and node parent types
when selected a component will show up as a node in components node of your Componentable
Here you can see that we have two variables player
that will be automatic assign as the Componentable
Node, and the active
variable, that will disable the behavior in your logic.
You can make more exported variables to create more customization to your component
When you want to get a component from a Componentable
, you can use:
var glowing: Glowing = Component.find(self, "Glowing")
If you want to get a component from a other node, you can use:
var glowing: Glowing = Component.find(player, "Glowing")
Just remember the component can be null
To add a component to a componentable in runtime you can use:
Component.subscribe(node, "ComponentName")
and to remove a component you can use:
Component.unsubscribe(node, "ComponentName")
Component.has(node, "component") # return true if this componentable have this component
Component.get_all(node) # return all components in this componentable
- I Found a BUG! Click here and open an issue
- Can I help with the project? Sure! just send your PR :D
- Can I contact you? Yep, send email to contact@gump.dev