class Entity:
    def __init__(self, asset, x, y, action, direction, speed, game):
        self.asset = asset
        
        self.graphics = game.engine.graphics
        self.x = x
        self.y = y
        self.next_cell = (x, y)
        self.target_cell = (x, y)
        self.iso_x, self.iso_y = self.graphics.iso_transform(self.x, self.y)
        self.action = action
        self.direction = direction
        self.speed = speed
        self.frame = 0
        self.game = game
        self.engine = game.engine
        self.selected = True
        self.movement = 0

    def update(self):
        occlusion = self.graphics.get_distance((self.x, self.y), self.game.cursor_pos) / 4

        # Set color based on selection status
        color = (0, 255, 0, 255)
        if self.selected:
            self.graphics.draw_square(self.iso_x, self.iso_y, color=color, margin=4)
            
        # Draw target indicator if target is set
     
            
        occlusion = self.game.map_shadow[self.y][self.x]
        if occlusion >= 0.8:
            return
        
        self.frame = self.graphics.render_sprite(f"{self.asset}_{self.action}_dir{self.direction}", self.iso_x, self.iso_y, self.frame, occlusion)
        