From a632ac98923b78a0cc38c995d262bee92e0d2ea7 Mon Sep 17 00:00:00 2001 From: unfa Date: Sun, 2 May 2021 23:27:25 +0200 Subject: [PATCH] Started implementing proper weapon control API --- Game/Assets/Weapons/Handgun/Handgun.gd | 26 ++++++++++++++++++++++++++ Game/Classes/Player/Player.gd | 3 ++- Game/Classes/Weapon/Weapon.gd | 11 +++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Game/Assets/Weapons/Handgun/Handgun.gd diff --git a/Game/Assets/Weapons/Handgun/Handgun.gd b/Game/Assets/Weapons/Handgun/Handgun.gd new file mode 100644 index 0000000..046eeee --- /dev/null +++ b/Game/Assets/Weapons/Handgun/Handgun.gd @@ -0,0 +1,26 @@ +extends "res://Classes/Weapon/Weapon.gd" + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" +#var trigger_held_primary = false +#var trigger_held_secondary = false +#var is_reloading = false + +func set_trigger_held_primary(active:bool): + trigger_held_primary = active + print("trigger_active", active) + +#func get_trigger_held_primary(): +# return trigger_held_primary +# print("trigger_get") + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/Game/Classes/Player/Player.gd b/Game/Classes/Player/Player.gd index f9a6517..af24ef7 100644 --- a/Game/Classes/Player/Player.gd +++ b/Game/Classes/Player/Player.gd @@ -380,7 +380,8 @@ func shoot(trigger_held): # The underscore indicates an unused variable. # Because it is declared in this scope, it will disappear as soon as the # function returns. As is, it exists solely to catch the return value of shoot(). - var _remaining_ammo = active_weapon.shoot($Camera, true, trigger_held) + #var _remaining_ammo = active_weapon.shoot($Camera, true, trigger_held) + active_weapon.trigger_held_primary = trigger_held func reload(): active_weapon.reload() diff --git a/Game/Classes/Weapon/Weapon.gd b/Game/Classes/Weapon/Weapon.gd index 30fdee2..c3b4b05 100644 --- a/Game/Classes/Weapon/Weapon.gd +++ b/Game/Classes/Weapon/Weapon.gd @@ -25,6 +25,17 @@ var cached_fire = false var casing = preload("res://Assets/Weapons/Handgun/Casing.tscn") var tracer = preload("res://Assets/Effects/BulletTracer.tscn") +var trigger_held_primary = false setget set_trigger_held_primary, get_trigger_held_primary +var trigger_held_secondary = false +var is_reloading = false +#var is_active = false #TODO - for reimplementing weapins switching + +func set_trigger_held_primary(active:bool): + trigger_held_primary = active + +func get_trigger_held_primary(): + return trigger_held_primary + func _ready(): $Sounds.global_transform.origin = camera.global_transform.origin