visibility rework
This commit is contained in:
parent
6b939d241c
commit
9d0e09220d
37 changed files with 212 additions and 75 deletions
|
|
@ -7,14 +7,15 @@ class_name WeaponSystem
|
|||
|
||||
@export var animation_player: AnimationPlayer
|
||||
@export var camera: PlayerCamera
|
||||
@export var player: Player
|
||||
|
||||
var current_state: WeaponSubStateMachine
|
||||
var last_slot: StringName
|
||||
|
||||
var slots: Dictionary[StringName,WeaponSubStateMachine] = {
|
||||
"primary": null,
|
||||
"secondary": default_pistol,
|
||||
"knife": default_knife,
|
||||
"secondary": null,
|
||||
"knife": null,
|
||||
"bomb": null,
|
||||
"ability_first": null,
|
||||
"ability_second": null,
|
||||
|
|
@ -25,34 +26,31 @@ var slots: Dictionary[StringName,WeaponSubStateMachine] = {
|
|||
signal switched_to(state: WeaponSubStateMachine)
|
||||
|
||||
func _ready() -> void:
|
||||
for child in get_children():
|
||||
if child is WeaponSubStateMachine:
|
||||
child.system = self
|
||||
child.animation_player = animation_player
|
||||
child.player_camera = camera
|
||||
child.request_return.connect(return_to_previous)
|
||||
else:
|
||||
push_warning("Child of weapon system is not ability or weapon")
|
||||
|
||||
current_state = default_pistol
|
||||
slots["knife"] = default_knife
|
||||
slots["secondary"] = default_pistol
|
||||
add(default_knife,"knife")
|
||||
add(default_pistol,"secondary")
|
||||
current_state.enter()
|
||||
|
||||
func can_add(slot: StringName) -> bool:
|
||||
return slots.has(slot)
|
||||
return slots.has(slot) and slots[slot] == null
|
||||
|
||||
@rpc("call_local","reliable")
|
||||
func add(state: WeaponSubStateMachine, slot: StringName) -> void:
|
||||
if can_add(slot) == false:
|
||||
return
|
||||
print('leech')
|
||||
|
||||
add_child(state)
|
||||
if state.get_parent() == null:
|
||||
add_child(state)
|
||||
if state.get_parent() != self:
|
||||
state.reparent(self)
|
||||
|
||||
slots[slot] = state
|
||||
state.system = self
|
||||
state.animation_player = animation_player
|
||||
state.player_camera = camera
|
||||
|
||||
state.player = player
|
||||
state.request_return.connect(return_to_previous)
|
||||
|
||||
func switch(to: StringName):
|
||||
if slots.has(to) == false or slots[to] == null or slots[to] == current_state:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue