Global refactor
This commit is contained in:
parent
3868af29e3
commit
0589ca4e23
180 changed files with 249 additions and 401 deletions
|
|
@ -1,80 +0,0 @@
|
|||
extends SubStateMachine
|
||||
|
||||
class_name WeaponSubStateMachine
|
||||
|
||||
@export var animation_prefix: StringName
|
||||
@export var index: StringName
|
||||
@export var visibility_target: StringName
|
||||
|
||||
@export var max_ammo: int
|
||||
@export var ammo: int = -1:
|
||||
set(value):
|
||||
if value < 0:
|
||||
ammo = 0
|
||||
else:
|
||||
ammo = value
|
||||
ammo_updated.emit()
|
||||
if ammo <= 0 and remaining_ammo <= 0:
|
||||
ammo_depleted.emit()
|
||||
get:
|
||||
return ammo
|
||||
@export var ammo_mags: int = 3
|
||||
@export var remaining_ammo: int = -1:
|
||||
set(value):
|
||||
if value < 0:
|
||||
remaining_ammo = 0
|
||||
else:
|
||||
remaining_ammo = value
|
||||
|
||||
@export var speed_modifier: float = 1.0
|
||||
@export var can_be_previous: bool = true
|
||||
@export var destroy_when_empty: bool = false
|
||||
|
||||
@export var slot: StringName
|
||||
|
||||
signal request_return
|
||||
signal ammo_updated
|
||||
signal ammo_depleted
|
||||
|
||||
var system: WeaponSystem
|
||||
var animation_player: AnimationPlayer
|
||||
var player_camera: PlayerCamera
|
||||
var player: Player
|
||||
|
||||
func _ready() -> void:
|
||||
if remaining_ammo == -1:
|
||||
remaining_ammo = max_ammo * ammo_mags
|
||||
if ammo == -1:
|
||||
ammo = max_ammo
|
||||
for child in get_children():
|
||||
if child is WeaponState:
|
||||
states[child.name] = child
|
||||
child.machine = self
|
||||
child.transition.connect(on_transition_required)
|
||||
child.return_to_previous.connect(request_return.emit)
|
||||
|
||||
func enter() -> void:
|
||||
super()
|
||||
player.weapon_models[visibility_target].show()
|
||||
|
||||
func exit() -> void:
|
||||
super()
|
||||
player.weapon_models[visibility_target].hide()
|
||||
|
||||
@rpc("authority","call_local","reliable")
|
||||
func use_begin() -> void:
|
||||
if current_state != null:
|
||||
current_state.use_begin()
|
||||
|
||||
@rpc("authority","call_local","reliable")
|
||||
func use_end() -> void:
|
||||
if current_state != null:
|
||||
current_state.use_end()
|
||||
func alternate_state() -> void:
|
||||
if current_state != null:
|
||||
current_state.alternate_state()
|
||||
# Need to clarify naming; Switch mode like firemode. For different states use
|
||||
# alternate_state
|
||||
func switch_mode() -> void:
|
||||
if current_state != null:
|
||||
current_state.switch_mode()
|
||||
Loading…
Add table
Add a link
Reference in a new issue