added some amazing changes
This commit is contained in:
@@ -838,7 +838,11 @@ func _open_chest(by_player: Node = null):
|
||||
if by_player and is_instance_valid(by_player) and by_player.is_in_group("player") and chest_item:
|
||||
# Add item to player inventory
|
||||
if by_player.character_stats:
|
||||
var was_encumbered = by_player.character_stats.is_over_encumbered()
|
||||
by_player.character_stats.add_item(chest_item)
|
||||
if not was_encumbered and by_player.character_stats.is_over_encumbered():
|
||||
if by_player.has_method("show_floating_status"):
|
||||
by_player.show_floating_status("Encumbered!", Color(1.0, 0.5, 0.2))
|
||||
|
||||
# Show pickup notification
|
||||
var items_texture = load(chest_item.spritePath) if chest_item.spritePath != "" else null
|
||||
@@ -853,12 +857,11 @@ func _open_chest(by_player: Node = null):
|
||||
else:
|
||||
item_color = Color.WHITE
|
||||
|
||||
# Show notification with item sprite
|
||||
# Show notification with item sprite (pass chest_item for ItemSprite colorization)
|
||||
if items_texture:
|
||||
_show_item_pickup_notification(by_player, display_text, item_color, items_texture, chest_item.spriteFrames.x, chest_item.spriteFrames.y, chest_item.spriteFrame)
|
||||
_show_item_pickup_notification(by_player, display_text, item_color, items_texture, chest_item.spriteFrames.x, chest_item.spriteFrames.y, chest_item.spriteFrame, chest_item)
|
||||
else:
|
||||
# Fallback: just show text
|
||||
_show_item_pickup_notification(by_player, display_text, item_color, null, 0, 0, 0)
|
||||
_show_item_pickup_notification(by_player, display_text, item_color, null, 0, 0, 0, chest_item)
|
||||
|
||||
# Play chest open sound
|
||||
if has_node("SfxChestOpen"):
|
||||
@@ -955,9 +958,9 @@ func _sync_chest_open(loot_type_str: String = "coin", player_peer_id: int = 0, i
|
||||
item_color = Color.CYAN # Cyan for equipment (matches loot pickup color)
|
||||
|
||||
if items_texture:
|
||||
_show_item_pickup_notification(player, display_text, item_color, items_texture, chest_item.spriteFrames.x, chest_item.spriteFrames.y, chest_item.spriteFrame)
|
||||
_show_item_pickup_notification(player, display_text, item_color, items_texture, chest_item.spriteFrames.x, chest_item.spriteFrames.y, chest_item.spriteFrame, chest_item)
|
||||
else:
|
||||
_show_item_pickup_notification(player, display_text, item_color, null, 0, 0, 0)
|
||||
_show_item_pickup_notification(player, display_text, item_color, null, 0, 0, 0, chest_item)
|
||||
else:
|
||||
# Fallback to old loot type system (for backwards compatibility)
|
||||
match loot_type_str:
|
||||
@@ -980,7 +983,7 @@ func _sync_chest_open(loot_type_str: String = "coin", player_peer_id: int = 0, i
|
||||
var items_texture = load("res://assets/gfx/pickups/items_n_shit.png")
|
||||
_show_item_pickup_notification(player, "+1 KEY", Color.YELLOW, items_texture, 20, 14, (13 * 20) + 10)
|
||||
|
||||
func _show_item_pickup_notification(player: Node, text: String, text_color: Color, item_texture: Texture2D = null, sprite_hframes: int = 1, sprite_vframes: int = 1, sprite_frame: int = 0):
|
||||
func _show_item_pickup_notification(player: Node, text: String, text_color: Color, item_texture: Texture2D = null, sprite_hframes: int = 1, sprite_vframes: int = 1, sprite_frame: int = 0, item = null):
|
||||
# Show item graphic and text above player's head for 0.5s, then fade out over 0.5s
|
||||
var floating_text_scene = preload("res://scenes/floating_text.tscn")
|
||||
if floating_text_scene and player and is_instance_valid(player):
|
||||
@@ -990,7 +993,7 @@ func _show_item_pickup_notification(player: Node, text: String, text_color: Colo
|
||||
parent.add_child(floating_text)
|
||||
# Position at player.position.y - 20 (just above head)
|
||||
floating_text.global_position = Vector2(player.global_position.x, player.global_position.y - 20)
|
||||
floating_text.setup(text, text_color, 0.5, 0.5, item_texture, sprite_hframes, sprite_vframes, sprite_frame) # Show for 0.5s, fade over 0.5s
|
||||
floating_text.setup(text, text_color, 0.5, 0.5, item_texture, sprite_hframes, sprite_vframes, sprite_frame, item)
|
||||
|
||||
func play_destroy_sound():
|
||||
if object_type == "Pot":
|
||||
|
||||
Reference in New Issue
Block a user