Move the renderable part of Entity to a Renderable component
Move symbol, render order, foreground, and background properties on Entity to a new Component called Renderable.
This commit is contained in:
parent
01b549bc6e
commit
def79386d8
5 changed files with 80 additions and 71 deletions
|
|
@ -45,7 +45,8 @@ class Interface:
|
|||
hero = self.engine.hero
|
||||
self.info_window.update_hero(hero)
|
||||
|
||||
sorted_entities = sorted(self.engine.entities, key=lambda e: e.render_order.value)
|
||||
sorted_entities = sorted(filter(lambda e: e.renderable is not None, self.engine.entities),
|
||||
key=lambda e: e.renderable.order.value)
|
||||
self.map_window.entities = sorted_entities
|
||||
|
||||
def draw(self):
|
||||
|
|
|
|||
|
|
@ -190,6 +190,10 @@ class MapWindow(Window):
|
|||
if not self.map.point_is_visible(entity_position):
|
||||
continue
|
||||
|
||||
renderable = ent.renderable
|
||||
if not renderable:
|
||||
continue
|
||||
|
||||
# Entity positions are relative to the (0, 0) point of the Map. In
|
||||
# order to render them in the correct position in the console, we
|
||||
# need to transform them into viewport-relative coordinates.
|
||||
|
|
@ -200,6 +204,6 @@ class MapWindow(Window):
|
|||
console.print(
|
||||
x=position.x,
|
||||
y=position.y,
|
||||
string=ent.symbol,
|
||||
fg=ent.foreground,
|
||||
string=renderable.symbol,
|
||||
fg=renderable.foreground,
|
||||
bg=tuple(map_tile_at_entity_position['bg'][:3]))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue