drop on death
This commit is contained in:
parent
3e64a00e43
commit
27f1e0c0aa
5 changed files with 36 additions and 14 deletions
|
|
@ -170,15 +170,15 @@ size = Vector3(41.466846, 22.777176, 35.36573)
|
|||
material = ExtResource("5_bno23")
|
||||
|
||||
[node name="CSGBox3D18" type="CSGBox3D" parent="CSGCombiner3D/CSGBox3D16"]
|
||||
transform = Transform3D(0.2478614, 0, 0.96879554, 0, 1, 0, -0.96879554, 0, 0.2478614, -0.98422813, -9.519702, 10.0603485)
|
||||
transform = Transform3D(0.07983352, 0, 0.9968083, 0, 1, 0, -0.9968083, 0, 0.07983352, 7.1200104, -9.519702, 10.70941)
|
||||
operation = 2
|
||||
size = Vector3(20.900824, 3.737772, 4.796875)
|
||||
size = Vector3(20.900824, 3.737772, 6.9975586)
|
||||
material = ExtResource("5_bno23")
|
||||
|
||||
[node name="CSGBox3D19" type="CSGBox3D" parent="CSGCombiner3D/CSGBox3D16"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.064535, -9.519702, 1.6905918)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 13.488387, -9.519702, 1.6905918)
|
||||
operation = 2
|
||||
size = Vector3(23.704197, 3.737772, 4.796875)
|
||||
size = Vector3(18.856493, 3.737772, 4.796875)
|
||||
material = ExtResource("5_bno23")
|
||||
|
||||
[node name="CSGBox3D4" type="CSGBox3D" parent="CSGCombiner3D"]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://bxdatd1ilfgmc"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bxdatd1ilfgmc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://e6lqknfl4ngt" path="res://scripts/weapon_system/weapon_substate_machine.gd" id="1_krsgt"]
|
||||
[ext_resource type="Script" uid="uid://rx78vdadldm7" path="res://scripts/weapon_system/bomb/bomb_main_state.gd" id="2_870cc"]
|
||||
[ext_resource type="Script" uid="uid://cx7j3kr1laq3s" path="res://scripts/weapon_system/bomb/bomb_idle_state.gd" id="3_1x0so"]
|
||||
[ext_resource type="Script" uid="uid://dmyir46aricwi" path="res://scripts/weapon_system/bomb/bomb_intro_state.gd" id="4_fv3ha"]
|
||||
[ext_resource type="Script" uid="uid://b5eapvgoni1pj" path="res://scripts/weapon_system/bomb/bomb_dropper.gd" id="5_fv3ha"]
|
||||
|
||||
[node name="Bomb" type="Node" node_paths=PackedStringArray("enter_state")]
|
||||
script = ExtResource("1_krsgt")
|
||||
|
|
@ -26,3 +27,6 @@ script = ExtResource("3_1x0so")
|
|||
|
||||
[node name="Intro" type="Node" parent="."]
|
||||
script = ExtResource("4_fv3ha")
|
||||
|
||||
[node name="Dropper" type="Node" parent="."]
|
||||
script = ExtResource("5_fv3ha")
|
||||
|
|
|
|||
9
scripts/weapon_system/bomb/bomb_dropper.gd
Normal file
9
scripts/weapon_system/bomb/bomb_dropper.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
extends Node
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if get_parent().player == null: return
|
||||
get_parent().player.died.connect(on_death)
|
||||
|
||||
func on_death() -> void:
|
||||
get_parent().system.drop_slot("bomb")
|
||||
1
scripts/weapon_system/bomb/bomb_dropper.gd.uid
Normal file
1
scripts/weapon_system/bomb/bomb_dropper.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b5eapvgoni1pj
|
||||
|
|
@ -96,14 +96,17 @@ func update_remotes(to: StringName,exit: bool):
|
|||
|
||||
switched_to.emit(current_state)
|
||||
|
||||
func drop():
|
||||
if slots.find_key(current_state) == "knife":
|
||||
func drop_current():
|
||||
drop(current_state)
|
||||
|
||||
func drop(weapon: WeaponSubStateMachine) -> void:
|
||||
if slots.find_key(weapon) == "knife":
|
||||
return
|
||||
var drop_data: Dictionary = {}
|
||||
drop_data.scene = current_state.droppable
|
||||
drop_data.ammo = current_state.ammo
|
||||
drop_data.remaining_ammo = current_state.remaining_ammo
|
||||
drop_data.slot = current_state.slot
|
||||
drop_data.scene = weapon.droppable
|
||||
drop_data.ammo = weapon.ammo
|
||||
drop_data.remaining_ammo = weapon.remaining_ammo
|
||||
drop_data.slot = weapon.slot
|
||||
drop_data.position = camera.global_position
|
||||
drop_data.impulse = -camera.global_basis.z * 10 + player.velocity
|
||||
|
||||
|
|
@ -111,11 +114,16 @@ func drop():
|
|||
|
||||
$"../PickupRange".start_temp_ignore()
|
||||
|
||||
slots[slots.find_key(current_state)] = null
|
||||
slots[slots.find_key(weapon)] = null
|
||||
slots_updated.emit(slots)
|
||||
current_state.queue_free()
|
||||
weapon.queue_free()
|
||||
return_to_previous(false)
|
||||
|
||||
func drop_slot(slot: StringName):
|
||||
if slots.has(slot) == false or slots[slot] == null:
|
||||
return
|
||||
drop(slots[slot])
|
||||
|
||||
# Spawn function
|
||||
# Data should be a dictionary with these keys:
|
||||
# ammo
|
||||
|
|
@ -198,5 +206,5 @@ func _input(event: InputEvent) -> void:
|
|||
current_state.switch_mode()
|
||||
|
||||
if event.is_action_pressed("plr_drop"):
|
||||
drop()
|
||||
drop_current()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue