update
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
class_name NotificationManager
|
||||
extends RefCounted
|
||||
|
||||
# Centralized usage of display_message RPC
|
||||
# Ensures consistent message types and easy refactoring
|
||||
|
||||
enum MessageType {
|
||||
NORMAL = 0,
|
||||
POWERUP = 1,
|
||||
GOAL = 2,
|
||||
CYCLE = 3,
|
||||
WARNING = 4
|
||||
}
|
||||
|
||||
const MESSAGES = {
|
||||
# Turn / Game Flow
|
||||
"TURN_START": "It's your turn!",
|
||||
"GOAL_COMPLETED": "Goal completed!",
|
||||
|
||||
# Attack / Damage
|
||||
"CRUSHED": "C R U S H E D !",
|
||||
"CRITICALLY_HIT": "CRITICALLY HIT!",
|
||||
"DROPPED_ITEM": "Dropped item!",
|
||||
"CANT_TARGET_SELF": "Can't target self!",
|
||||
|
||||
# Special Effects (Format strings)
|
||||
"BURNED_BY": "Burned by %s!",
|
||||
"TILES_SPAWNED": "Tiles Spawned!",
|
||||
"FROZEN_BY": "Frozen by %s!",
|
||||
"FLOOR_BLOCKED": "Floor Blocked!",
|
||||
"INVISIBLE": "Invisible!",
|
||||
"INVISIBILITY_ENDED": "Invisibility Ended!", # Changed slightly to be consistent if needed, or keep original
|
||||
"SHIELD_BLOCKED": "Shield blocked an attack!",
|
||||
"UNFROZEN": "Unfrozen!",
|
||||
|
||||
# Powerups
|
||||
"ATTACK_MODE_READY": "ATTACK MODE READY!",
|
||||
"USED_SPECIAL_POWER": "Used a special power!"
|
||||
}
|
||||
|
||||
static func send_message(target: Node, message: String, type: int = MessageType.NORMAL):
|
||||
if is_instance_valid(target) and target.has_method("rpc"):
|
||||
# Check if the text is empty, do nothing
|
||||
if message.is_empty():
|
||||
return
|
||||
|
||||
# Call the RPC on the target (usually a Player node)
|
||||
# "any_peer" allows any client to send this message to the target
|
||||
target.rpc("display_message", message, type)
|
||||
|
||||
# Helper for broadcasting to all players (if needed in future)
|
||||
static func broadcast_to_all(tree: SceneTree, message: String, type: int = MessageType.NORMAL):
|
||||
var players = tree.get_nodes_in_group("Players")
|
||||
for player in players:
|
||||
send_message(player, message, type)
|
||||
Reference in New Issue
Block a user