local Grid = require "lib.grid.grid" --- @class CharacterGrid: Grid local CharacterGrid = setmetatable({}, { __index = Grid }) CharacterGrid.__index = CharacterGrid function CharacterGrid.new(width, height) return setmetatable(Grid.new(width, height, nil), CharacterGrid) end --- Adds a character id to the grid --- @param character Character function CharacterGrid:add(character) local cx, cy = math.floor(character.logic.mapLogic.position.x), math.floor(character.logic.mapLogic.position.y) local sx, sy = character.logic.mapLogic.size.x, character.logic.mapLogic.size.y self:fillRect(cx, cy, sx, sy, character.id) end --- Removes a character id from the grid --- @param character Character function CharacterGrid:remove(character) local cx, cy = math.floor(character.logic.mapLogic.position.x), math.floor(character.logic.mapLogic.position.y) local sx, sy = character.logic.mapLogic.size.x, character.logic.mapLogic.size.y self:fillRect(cx, cy, sx, sy, nil) end return { new = CharacterGrid.new }