- GDScript 100%
|
|
||
|---|---|---|
| gloom-2d | ||
| gloom-3d | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
gloom-godot-templates
Godot project templates for a basic 2D and 3D game
Dependency Injection
These templates use signals and Callables for dependency injection. Signals are used in cases where code needs to respond to behavior, and Callables are used when code needs to initiate behavior.
When signals need to be broadcast globally, there is a signal_bus.gd object autoloaded that may be accessed by any node.
Saving
Saving is done automatically with some adjustments done as needed. Saving copies every child node under World and when loaded recreates the nodes, copying their name, position, and rotation while also perserving the tree hierarchy. Variables that contain references will just use the default values unless a custom save method is provided.
To provide a custom save method, add the node to the "persist" group then define a save method that looks like the following:
func save() -> Dictionary :
var save_dict = {
"attack" : attack,
"defense" : defense,
"current_health" : current_health,
"max_health" : max_health,
"damage" : damage,
"regen" : regen,
"experience" : experience,
"tnl" : tnl,
"level" : level,
"attack_growth" : attack_growth,
"defense_growth" : defense_growth,
"health_growth" : health_growth,
"is_alive" : is_alive,
"last_attack" : last_attack
}
return save_dict
Keep in mind that things like position, and rotation will already be captured, this will just add more fields that get saved alongside the node. This can be used to get around errors with variable references that are tricky to save.
To provide a custom load method add the node to the "persist" group then define a load method that has the following signature:
func load(data: Dictionary) -> void:
# Do stuff with data
pass
This will receive the same data that was returned from the save method, and if no save method was defined, it just receives data for the default fields.