Añadidos drops, ahora cae cerveza o cafe
This commit is contained in:
1 parent
bbecc76dbe
commit
8bbf70e8cb
11 files changed
+282
-1
No files matched your search
@@ -9,6 +9,7 @@ signal died
|
||||
# actually share instead of guessing an abstraction in advance.
|
||||
|
||||
const PLAYER_HURTBOX_MASK: int = 1 << 3
|
||||
const DROP_MANAGER := preload("res://pickups/drop_manager.gd")
|
||||
|
||||
|
||||
enum AttackState {
|
||||
@@ -88,6 +89,20 @@ enum AttackState {
|
||||
# RESPAWN
|
||||
# ============================================================================
|
||||
|
||||
@export_category("Drops")
|
||||
|
||||
## Table defining what pickups can drop on death (by chance).
|
||||
@export var drop_table: PickupDropTable
|
||||
|
||||
|
||||
@export_category("Respawn")
|
||||
|
||||
@export_category("Drops")
|
||||
|
||||
## Table defining what pickups can drop on death (by chance).
|
||||
@export var drop_table: PickupDropTable
|
||||
|
||||
|
||||
@export_category("Respawn")
|
||||
|
||||
## Enough downtime to make defeating an enemy meaningful before it comes back.
|
||||
@@ -161,7 +176,21 @@ func _ready() -> void:
|
||||
attack_hitbox.collision_mask = PLAYER_HURTBOX_MASK
|
||||
attack_hitbox.monitoring = true
|
||||
|
||||
if drop_table == null:
|
||||
var default_table = load("res://enemies/walker/walker_drop.tres")
|
||||
if default_table != null:
|
||||
drop_table = default_table
|
||||
|
||||
visibility_notifier.screen_entered.connect(_wake_up)
|
||||
if default_table != null:
|
||||
drop_table = default_table
|
||||
|
||||
visibility_notifier.screen_entered.connect(_wake_up)
|
||||
|
||||
if drop_table == null:
|
||||
var default_table := load("res://enemies/walker/walker_drop.tres")
|
||||
if default_table != null:
|
||||
drop_table = default_table as PickupDropTable
|
||||
|
||||
_update_facing()
|
||||
_reset_attack_hitbox_position()
|
||||
@@ -474,6 +503,16 @@ func _die() -> void:
|
||||
is_dead = true
|
||||
died.emit()
|
||||
|
||||
if drop_table != null:
|
||||
var drops = DROP_MANAGER.roll_drop(drop_table)
|
||||
if not drops.is_empty():
|
||||
var parent := get_tree().current_scene
|
||||
if parent == null:
|
||||
parent = get_tree().root.get_child(get_tree().root.get_child_count() - 1)
|
||||
if parent == null:
|
||||
parent = get_tree().root
|
||||
DROP_MANAGER.spawn_drops(drops, parent, global_position)
|
||||
|
||||
velocity = Vector2.ZERO
|
||||
visible = false
|
||||
|
||||
|
||||
Reference in new issue
Block a user