diff --git a/entity/object/agent/Agent.gd b/entity/object/agent/Agent.gd index 5e9cb23c..9161d898 100644 --- a/entity/object/agent/Agent.gd +++ b/entity/object/agent/Agent.gd @@ -2,16 +2,17 @@ extends LynxObject class_name LynxAgent var _tick = String() -@onready var _border = get_node("Border") -@onready var _sprite = get_node("AnimatedSprite2D") func _ready(): var color = self._generate_color_from_id(int(self._owner)) - self._sprite.modulate = color + var border = get_node("Border") + var sprite = get_node("AnimatedSprite2D") + + sprite.modulate = color if self._owner == Globals.USER_ID: - self._border.set_default_color(Color.WHITE) + border.set_default_color(Color.WHITE) else: - self._border.visible = false + border.visible = false func init(_position, _id, _owner, _tick): @@ -42,14 +43,8 @@ func serialize(): func _generate_color_from_id(agent_id: int) -> Color: # Hash agent_id for more diverse color generation. var hashed_id = hash(agent_id) - var r = ((agent_id >> 5) & 0xFF) / 255.0 - var g = ((agent_id >> 13) & 0xFF) / 255.0 - var b = ((agent_id >> 21) & 0xFF) / 255.0 - - # Highlight the color - if agent_id == self._id: - r = min(r + 0.2, 1.0) - g = min(g + 0.2, 1.0) - b = min(b + 0.2, 1.0) + var r = ((hashed_id >> 5) & 0xFF) / 255.0 + var g = ((hashed_id >> 13) & 0xFF) / 255.0 + var b = ((hashed_id >> 21) & 0xFF) / 255.0 return Color(r, g, b)