Fixed annoying error
This commit is contained in:
parent
100afe5e51
commit
aa1c1c8d64
8 changed files with 38 additions and 49 deletions
11
scripts/debug/inventory_preview.gd
Normal file
11
scripts/debug/inventory_preview.gd
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
extends Label
|
||||
|
||||
|
||||
@export var inventory: WeaponSystem
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var weapons = ""
|
||||
for child in inventory.get_children():
|
||||
if child is WeaponSubStateMachine:
|
||||
weapons += child.name + ", "
|
||||
text = weapons
|
||||
1
scripts/debug/inventory_preview.gd.uid
Normal file
1
scripts/debug/inventory_preview.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dmy6ahci16los
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
extends RigidBody3D
|
||||
|
||||
|
||||
@export var radius: float
|
||||
@export var fog: FogVolume
|
||||
|
||||
var bounce_count: int = 0
|
||||
|
||||
|
||||
func _on_body_entered(_body: Node) -> void:
|
||||
if bounce_count > 2:
|
||||
return
|
||||
bounce_count += 1
|
||||
if bounce_count == 2:
|
||||
smoke()
|
||||
|
||||
func smoke():
|
||||
var tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_EXPO)
|
||||
tween.tween_property(fog,"size",Vector3(radius,radius,radius),1.0)
|
||||
tween.tween_interval(10)
|
||||
tween.tween_property(fog.material,"density",0,1.0)
|
||||
tween.tween_callback(queue_free)
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://t5jjqwnkxgvo
|
||||
|
|
@ -7,9 +7,3 @@ const IMPULSE = 10
|
|||
@export var slot: StringName
|
||||
@export var weapon: WeaponSubStateMachine
|
||||
@export var team: Session.TEAMS
|
||||
|
||||
@rpc("any_peer","call_local","reliable")
|
||||
func drop(direction: Vector3,new_position: Vector3):
|
||||
apply_impulse(direction * IMPULSE)
|
||||
global_position = new_position
|
||||
|
||||
|
|
|
|||
|
|
@ -55,14 +55,15 @@ func add(state: WeaponSubStateMachine, slot: StringName) -> void:
|
|||
state.player = player
|
||||
state.request_return.connect(return_to_previous)
|
||||
|
||||
func switch(to: StringName):
|
||||
func switch(to: StringName, exit: bool = true):
|
||||
if slots.has(to) == false or slots[to] == null or slots[to] == current_state or is_multiplayer_authority() == false:
|
||||
return
|
||||
current_state.exit()
|
||||
if current_state.can_be_previous:
|
||||
last_slot = slots.find_key(current_state)
|
||||
else:
|
||||
last_slot = ""
|
||||
if current_state != null and exit:
|
||||
current_state.exit()
|
||||
if current_state.can_be_previous:
|
||||
last_slot = slots.find_key(current_state)
|
||||
else:
|
||||
last_slot = ""
|
||||
current_state = slots[to]
|
||||
current_state.enter()
|
||||
|
||||
|
|
@ -85,8 +86,8 @@ func drop():
|
|||
|
||||
$"../PickupRange".start_temp_ignore()
|
||||
|
||||
Session.despawn(current_state.get_path())
|
||||
return_to_previous()
|
||||
current_state.queue_free()
|
||||
return_to_previous(false)
|
||||
|
||||
# Spawn function
|
||||
# Data should be a dictionary with these keys:
|
||||
|
|
@ -105,15 +106,16 @@ func pick_up_weapon(data: Variant) -> Node:
|
|||
func on_weapon_added(weapon: Node):
|
||||
add(weapon,weapon.slot)
|
||||
|
||||
func return_to_previous():
|
||||
func return_to_previous(exit: bool = true):
|
||||
if last_slot != "":
|
||||
switch(last_slot)
|
||||
switch(last_slot, exit)
|
||||
else:
|
||||
switch("knife")
|
||||
switch("knife", exit)
|
||||
|
||||
@rpc("authority","call_remote","reliable")
|
||||
func update_remotes(to: StringName):
|
||||
current_state.exit()
|
||||
if current_state != null:
|
||||
current_state.exit()
|
||||
current_state = slots[to]
|
||||
current_state.enter()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue