From 08a134d2fcf9974f497f1059d85fc0271d227e5d Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Sat, 8 Apr 2023 17:17:48 +0200 Subject: [PATCH] Cleanup Code --- Scripts/EntitySystem/Bunny.gd | 4 ++-- Scripts/WeaponSystem/Projectile.gd | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Scripts/EntitySystem/Bunny.gd b/Scripts/EntitySystem/Bunny.gd index f95b4b3..f5a3040 100644 --- a/Scripts/EntitySystem/Bunny.gd +++ b/Scripts/EntitySystem/Bunny.gd @@ -8,12 +8,12 @@ var team : int var on_death_callbacks : Array func damage(damage : int): - health -= health + health -= damage if(health <= 0): on_death() pass func heal(health : int): - health += health + self.health += health pass func on_death(): diff --git a/Scripts/WeaponSystem/Projectile.gd b/Scripts/WeaponSystem/Projectile.gd index f36d4b2..96a7755 100644 --- a/Scripts/WeaponSystem/Projectile.gd +++ b/Scripts/WeaponSystem/Projectile.gd @@ -6,20 +6,17 @@ extends Area2D @export_flags_2d_physics var map_collision_layer : int @export_flags_2d_physics var bunny_collision_layer : int -const bunny_script = preload("res://Scripts/EntitySystem/Bunny.gd") - func _process(delta): self.translate(Vector2(cos(self.rotation), sin(self.rotation)) * speed * delta) pass - func _on_collision(body): var collision_layer = null; - match body.get_class(): - "TileMap": - collision_layer = body.tile_set.get_physics_layer_collision_layer(0) - _: - if(body.has_method("get_collision_layer")): collision_layer = body.get_collision_layer() + + if body.get_class() == "TileMap": + collision_layer = body.tile_set.get_physics_layer_collision_layer(0) + if(body.has_method("get_collision_layer")): + collision_layer = body.get_collision_layer() if collision_layer & map_collision_layer: queue_free() @@ -27,3 +24,4 @@ func _on_collision(body): var bunny = body as Bunny bunny.damage(damage) queue_free() + pass