Skip to content

developer-benny-zhu/gommand

Repository files navigation

Contributors Forks Stargazers Issues MIT License


Logo

Gommand

Gommand is a command-based framework for Godot 4.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Roadmap
  3. Contributing
  4. License
  5. Acknowledgments

About The Project

Gommand is a command framework for Godot 4 that helps you write declarative code. It is inspired by the command framework as part of WPILib.

What you get:

  • Declarative style: describe your code in a way that is more "what" than "how"
  • Composable flows: chain sequences, run things in parallel, add conditions and repeats
  • Input wiring: bind player actions to commands with ActionTrigger

Gommand At a Glance

Without Gommand

extends Node3D

var is_dashing := false
var dash_time := 0.0
var attack_pending := false

func _ready() -> void:
    print("Press ui_accept to dash, then attack.")

func _physics_process(delta: float) -> void:
    if Input.is_action_just_pressed("ui_accept") and not is_dashing:
        is_dashing = true
        dash_time = 0.2
        start_dash()

    if is_dashing:
        dash_time -= delta
        if dash_time <= 0.0:
            is_dashing = false
            stop_dash()
            attack_pending = true

    if attack_pending:
        attack_pending = false
        attack_target()


func start_dash() -> void:
    print("Dash start")


func stop_dash() -> void:
    print("Dash end")


func attack_target() -> void:
    print("Attack")

With Gommand

extends Node3D

var trigger: ActionTrigger


func _ready() -> void:
    print("Press ui_accept to run dash + attack sequence.")

    var dash_and_attack := SequentialCommandGroup.new([
        PrintCommand.new("Dash start"),
        WaitCommand.new(0.2),
        PrintCommand.new("Dash end"),
        PrintCommand.new("Attack"),
    ])

    trigger = (
        ActionTrigger
        .builder("ui_accept")
        .add_on_action_pressed(dash_and_attack)
        .build()
    )

(back to top)

Built With

  • Godot
  • GDScript

(back to top)

Roadmap

  • Core framework
  • Documentation

See the open issues for a full list of proposed features and known issues.

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Top contributors:

contrib.rocks image

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Acknowledgments

(back to top)