1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-30 08:57:00 +02:00
vcmi/client/battle/BattleRenderer.h
Ivan Savenko 428fb832c6 Implemented foreground/background obstacles:
- obstacles now have "foreground" field
- if "foreground" field set, obstacle will appear on top of other
objects, such as units
- if "foreground" is not set, obstacle will appear below units
- updated schema and cleared up obstacles config
2023-06-06 15:53:14 +03:00

55 lines
1.3 KiB
C++

/*
* BattleFieldController.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "../../lib/battle/BattleHex.h"
class Canvas;
class BattleInterface;
enum class EBattleFieldLayer {
// confirmed ordering requirements:
OBSTACLES_BG = 0,
CORPSES = 0,
WALLS = 1,
HEROES = 2,
STACKS = 2, // after corpses, obstacles, walls
OBSTACLES_FG = 3, // after stacks
STACK_AMOUNTS = 3, // after stacks, obstacles, corpses
EFFECTS = 4, // after obstacles, battlements
};
class BattleRenderer
{
public:
using RendererRef = Canvas &;
using RenderFunctor = std::function<void(RendererRef)>;
private:
BattleInterface & owner;
struct RenderableInstance
{
RenderFunctor functor;
EBattleFieldLayer layer;
BattleHex tile;
};
std::vector<RenderableInstance> objects;
void collectObjects();
void sortObjects();
void renderObjects(RendererRef targetCanvas);
public:
BattleRenderer(BattleInterface & owner);
void insert(EBattleFieldLayer layer, BattleHex tile, RenderFunctor functor);
void execute(RendererRef targetCanvas);
};