Skip to content

Commit

Permalink
chore: pr changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Krystian Jandy committed Aug 31, 2023
1 parent 0919d82 commit 228b88a
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions entity/object/agent/Agent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit 228b88a

Please sign in to comment.