Refactored weapon component to handle weapon swaping.
This commit is contained in:
parent
d041531716
commit
e2cf516c90
6 changed files with 46 additions and 11 deletions
|
|
@ -1,10 +1,8 @@
|
|||
extends Area2D
|
||||
|
||||
|
||||
@onready var bullet: PackedScene = load("res://scenes/player_weapons/weapon_stock.tscn")
|
||||
@onready var shot_data: = load("res://resources/player_weapon_resources/weapon_shot_stock.tres")
|
||||
|
||||
|
||||
# Data to be set externally when this bullet is instantiated
|
||||
var bullet_scene: PackedScene = null
|
||||
var shot_data: WeaponShot = null
|
||||
|
||||
# Time offset when this bullet was fired (relative to other bullets in the same shot)
|
||||
var time_offset: float = 0.5
|
||||
|
|
@ -38,3 +36,8 @@ func _on_visible_on_screen_notifier_2d_screen_exited():
|
|||
# Set fire_time for the next shot (staggered firing)
|
||||
var current_time = Time.get_ticks_msec() / 1000.0
|
||||
fire_time = current_time + shot_data.stagger_offset
|
||||
|
||||
# Function to set the bullet data (called from parent scene)
|
||||
func set_weapon_data(bullet_scene_param: PackedScene, shot_data_param: WeaponShot):
|
||||
bullet_scene = bullet_scene_param
|
||||
shot_data = shot_data_param
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue