From b4814d1ac145e3827600b829b2f5daaaa0cb6752 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 24 Sep 2024 14:21:40 +0100 Subject: [PATCH 1/4] ci: Run pre-commit on main & PRs https://phabricator.endlessm.com/T35658 --- .github/workflows/checks.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/checks.yaml diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml new file mode 100644 index 0000000..a2e8673 --- /dev/null +++ b/.github/workflows/checks.yaml @@ -0,0 +1,24 @@ +name: Checks + +on: + pull_request: + push: + branches: + - main + +jobs: + pre-commit: + name: Linting and Formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: set PY + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + - uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + - uses: pre-commit/action@v3.0.1 From 5491e92a44f4fee076bae9a0427bbcdf96f3a8fa Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 24 Sep 2024 14:22:13 +0100 Subject: [PATCH 2/4] ci: Use Dependabot to keep GitHub Actions up-to-date https://phabricator.endlessm.com/T35658 --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b3eec7a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +# Set update schedule for GitHub Actions + +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every week + interval: "weekly" From 8552cc3edee4ef7829108c7beb796c081d573af6 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 24 Sep 2024 14:23:19 +0100 Subject: [PATCH 3/4] Fix formatting with pre-commit https://phabricator.endlessm.com/T35658 --- addons/DampedOscillator/DampedOscillator.gd | 5 +++- .../scripts/AnimationInstance.gd | 24 +++++++++++-------- .../scripts/DampedOscillator.gd | 19 ++++++++------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/addons/DampedOscillator/DampedOscillator.gd b/addons/DampedOscillator/DampedOscillator.gd index 3b3a4e7..510054c 100644 --- a/addons/DampedOscillator/DampedOscillator.gd +++ b/addons/DampedOscillator/DampedOscillator.gd @@ -3,7 +3,10 @@ extends EditorPlugin func _enter_tree(): - add_autoload_singleton("DampedOscillator", "res://addons/DampedOscillator/scripts/damped_oscillator.tscn") + add_autoload_singleton( + "DampedOscillator", "res://addons/DampedOscillator/scripts/damped_oscillator.tscn" + ) + func _exit_tree(): remove_autoload_singleton("DampedOscillator") diff --git a/addons/DampedOscillator/scripts/AnimationInstance.gd b/addons/DampedOscillator/scripts/AnimationInstance.gd index 0f065b6..5a4c371 100644 --- a/addons/DampedOscillator/scripts/AnimationInstance.gd +++ b/addons/DampedOscillator/scripts/AnimationInstance.gd @@ -1,6 +1,5 @@ extends Node - # node values var node var propertie @@ -19,38 +18,43 @@ var active = true signal started signal ended + func _physics_process(delta): # Do the math var force = -spring_force * displacement - damp * velocity velocity += force * delta displacement += velocity * delta - + # Check if node is gone var wr = weakref(node) - + if !wr.get_ref(): set_physics_process(false) queue_free() return - + # Apply the math - + match typeof(node.get(propertie)): TYPE_FLOAT: - node.set(propertie, original_value + displacement*scale_factor) + node.set(propertie, original_value + displacement * scale_factor) TYPE_INT: - node.set(propertie, original_value + int(displacement*scale_factor)) + node.set(propertie, original_value + int(displacement * scale_factor)) TYPE_VECTOR2: - node.set(propertie, original_value + Vector2(displacement,-displacement)*scale_factor ) - + node.set( + propertie, original_value + Vector2(displacement, -displacement) * scale_factor + ) + if abs(velocity - 0) < 0.001: - end() # Bye bye + end() # Bye bye + func start(): set_physics_process(true) active = true emit_signal("started") + func end(): emit_signal("ended") node.set(propertie, original_value) diff --git a/addons/DampedOscillator/scripts/DampedOscillator.gd b/addons/DampedOscillator/scripts/DampedOscillator.gd index 7bfe355..85b3b57 100644 --- a/addons/DampedOscillator/scripts/DampedOscillator.gd +++ b/addons/DampedOscillator/scripts/DampedOscillator.gd @@ -4,22 +4,24 @@ extends Node var animation_instance = preload("res://addons/DampedOscillator/scripts/animation_instance.tscn") var queue_sysem_enabled = false -func animate(node, propertie: String, string: float, damp: float, velocity: float, scale_factor: float): + +func animate( + node, propertie: String, string: float, damp: float, velocity: float, scale_factor: float +): # Spawn new animation instance var i = animation_instance.instantiate() - + # Update node values i.node = node i.propertie = propertie i.original_value = node.get(propertie) - + # Update oscillator values i.spring_force = string i.damp = damp i.velocity = velocity i.scale_factor = scale_factor - - + # Queue system for animation in get_children(): if animation.node == node and animation.propertie == propertie: @@ -29,13 +31,12 @@ func animate(node, propertie: String, string: float, damp: float, velocity: floa add_child(i) return i.active = false - - animation.ended.connect(Callable(i,"start")) + + animation.ended.connect(Callable(i, "start")) i.original_value = animation.original_value i.set_physics_process(false) add_child(i) return - + # Yayy finally add_child(i) - From dfbe3b8b3216074f7fd211e99ef972c7777441a5 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Tue, 24 Sep 2024 14:24:03 +0100 Subject: [PATCH 4/4] AnimationInstance: Declare signals before top-level variables addons/DampedOscillator/scripts/AnimationInstance.gd:18: Error: Definition out of order in None (class-definitions-order) addons/DampedOscillator/scripts/AnimationInstance.gd:19: Error: Definition out of order in None (class-definitions-order) --- addons/DampedOscillator/scripts/AnimationInstance.gd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/DampedOscillator/scripts/AnimationInstance.gd b/addons/DampedOscillator/scripts/AnimationInstance.gd index 5a4c371..67ad49b 100644 --- a/addons/DampedOscillator/scripts/AnimationInstance.gd +++ b/addons/DampedOscillator/scripts/AnimationInstance.gd @@ -1,5 +1,8 @@ extends Node +signal started +signal ended + # node values var node var propertie @@ -15,9 +18,6 @@ var scale_factor = 1.0 var active = true -signal started -signal ended - func _physics_process(delta): # Do the math