beta-1.3/restructure-files (#2)
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
17
Entities/Weapons/Projectiles/Scripts/base_projectile.gd
Normal file
17
Entities/Weapons/Projectiles/Scripts/base_projectile.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
extends CharacterBody2D
|
||||
class_name BaseProjectile
|
||||
|
||||
@export var direction: Vector2
|
||||
@export var speed := 100
|
||||
|
||||
# Public Methods
|
||||
func SetProjectileStartAndDirection(start_position: Vector2, projectile_direction: Vector2) -> void:
|
||||
position = start_position
|
||||
direction = projectile_direction
|
||||
rotation = projectile_direction.angle()
|
||||
|
||||
|
||||
# Private Methods
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity = direction * speed * delta
|
||||
move_and_slide()
|
||||
@@ -0,0 +1 @@
|
||||
uid://8q26ldhfyijx
|
||||
29
Entities/Weapons/Projectiles/Scripts/wooden_arrow.gd
Normal file
29
Entities/Weapons/Projectiles/Scripts/wooden_arrow.gd
Normal file
@@ -0,0 +1,29 @@
|
||||
extends BaseProjectile
|
||||
class_name WoodenArrow
|
||||
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
var _despawn_queued := false
|
||||
|
||||
# Private Methods
|
||||
func _ready() -> void:
|
||||
speed = 8000
|
||||
|
||||
|
||||
func _on_collision_detector_area_entered(_area: Area2D) -> void:
|
||||
queue_despawn()
|
||||
|
||||
|
||||
func _on_collision_detector_body_entered(body: Node2D) -> void:
|
||||
if body == self: return
|
||||
queue_despawn()
|
||||
|
||||
|
||||
func queue_despawn() -> void:
|
||||
if _despawn_queued: return
|
||||
_despawn_queued = true
|
||||
|
||||
animation_player.play("shaking")
|
||||
await animation_player.animation_finished
|
||||
|
||||
queue_free()
|
||||
1
Entities/Weapons/Projectiles/Scripts/wooden_arrow.gd.uid
Normal file
1
Entities/Weapons/Projectiles/Scripts/wooden_arrow.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://j5yj4piyfql1
|
||||
Reference in New Issue
Block a user