2022-11-17 13:21:03 +02:00
|
|
|
/*
|
2022-12-11 23:16:23 +02:00
|
|
|
* BattleObstacleController.h, part of VCMI engine
|
2022-11-17 13:21:03 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2022-11-17 18:50:12 +02:00
|
|
|
#include "../../lib/GameConstants.h"
|
2022-11-25 00:26:14 +02:00
|
|
|
#include "../../lib/battle/BattleHex.h"
|
2022-11-17 13:21:03 +02:00
|
|
|
|
2022-11-29 02:00:08 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2022-11-17 18:50:12 +02:00
|
|
|
struct CatapultAttack;
|
2022-11-29 02:00:08 +02:00
|
|
|
class CCreature;
|
2022-11-30 22:05:25 +02:00
|
|
|
class CStack;
|
2022-11-29 02:00:08 +02:00
|
|
|
class CGTownInstance;
|
2023-01-18 17:32:57 +02:00
|
|
|
class Point;
|
2022-11-29 02:00:08 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2022-12-11 22:09:57 +02:00
|
|
|
class Canvas;
|
2022-12-09 13:26:17 +02:00
|
|
|
class BattleInterface;
|
|
|
|
class BattleRenderer;
|
2022-11-25 00:26:14 +02:00
|
|
|
class IImage;
|
2022-11-17 18:50:12 +02:00
|
|
|
|
|
|
|
namespace EWallVisual
|
|
|
|
{
|
|
|
|
enum EWallVisual
|
|
|
|
{
|
2022-11-25 00:26:14 +02:00
|
|
|
BACKGROUND,
|
|
|
|
BACKGROUND_WALL,
|
|
|
|
|
2022-11-17 18:50:12 +02:00
|
|
|
KEEP,
|
|
|
|
BOTTOM_TOWER,
|
|
|
|
BOTTOM_WALL,
|
|
|
|
WALL_BELLOW_GATE,
|
|
|
|
WALL_OVER_GATE,
|
|
|
|
UPPER_WALL,
|
|
|
|
UPPER_TOWER,
|
|
|
|
GATE,
|
2022-11-25 00:26:14 +02:00
|
|
|
|
2022-11-17 18:50:12 +02:00
|
|
|
GATE_ARCH,
|
|
|
|
BOTTOM_STATIC_WALL,
|
|
|
|
UPPER_STATIC_WALL,
|
|
|
|
MOAT,
|
2022-11-27 22:50:18 +02:00
|
|
|
MOAT_BANK,
|
2022-11-17 18:50:12 +02:00
|
|
|
KEEP_BATTLEMENT,
|
|
|
|
BOTTOM_BATTLEMENT,
|
2022-11-25 00:26:14 +02:00
|
|
|
UPPER_BATTLEMENT,
|
|
|
|
|
|
|
|
CREATURE_KEEP,
|
|
|
|
CREATURE_BOTTOM_TOWER,
|
|
|
|
CREATURE_UPPER_TOWER,
|
|
|
|
|
|
|
|
WALL_FIRST = BACKGROUND_WALL,
|
|
|
|
WALL_LAST = UPPER_BATTLEMENT,
|
|
|
|
|
|
|
|
// these entries are mapped to EWallPart enum
|
|
|
|
DESTRUCTIBLE_FIRST = KEEP,
|
|
|
|
DESTRUCTIBLE_LAST = GATE,
|
2022-11-17 18:50:12 +02:00
|
|
|
};
|
|
|
|
}
|
2022-11-17 13:21:03 +02:00
|
|
|
|
2022-12-09 13:26:17 +02:00
|
|
|
class BattleSiegeController
|
2022-11-17 13:21:03 +02:00
|
|
|
{
|
2022-12-13 13:58:16 +02:00
|
|
|
BattleInterface & owner;
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
/// besieged town
|
|
|
|
const CGTownInstance *town;
|
2022-11-17 23:57:51 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
/// sections of castle walls, in their currently visible state
|
|
|
|
std::array<std::shared_ptr<IImage>, EWallVisual::WALL_LAST + 1> wallPieceImages;
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
/// return URI for image for a wall piece
|
2023-01-13 00:35:58 +02:00
|
|
|
std::string getWallPieceImageName(EWallVisual::EWallVisual what, EWallState state) const;
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
/// returns BattleHex to which chosen wall piece is bound
|
|
|
|
BattleHex getWallPiecePosition(EWallVisual::EWallVisual what) const;
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
/// returns true if chosen wall piece should be present in current battle
|
|
|
|
bool getWallPieceExistance(EWallVisual::EWallVisual what) const;
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2023-01-05 14:16:01 +02:00
|
|
|
void showWallPiece(Canvas & canvas, EWallVisual::EWallVisual what);
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-30 22:05:25 +02:00
|
|
|
BattleHex getTurretBattleHex(EWallVisual::EWallVisual wallPiece) const;
|
|
|
|
const CStack * getTurretStack(EWallVisual::EWallVisual wallPiece) const;
|
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
public:
|
2022-12-13 13:58:16 +02:00
|
|
|
BattleSiegeController(BattleInterface & owner, const CGTownInstance *siegeTown);
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
/// call-ins from server
|
2022-11-17 18:50:12 +02:00
|
|
|
void gateStateChanged(const EGateState state);
|
2022-11-25 00:26:14 +02:00
|
|
|
void stackIsCatapulting(const CatapultAttack & ca);
|
2022-11-17 18:50:12 +02:00
|
|
|
|
2022-11-25 00:26:14 +02:00
|
|
|
/// call-ins from other battle controllers
|
2023-01-05 14:16:01 +02:00
|
|
|
void showAbsoluteObstacles(Canvas & canvas);
|
2022-12-09 13:26:17 +02:00
|
|
|
void collectRenderableObjects(BattleRenderer & renderer);
|
2022-11-25 00:26:14 +02:00
|
|
|
|
|
|
|
/// queries from other battle controllers
|
|
|
|
bool isAttackableByCatapult(BattleHex hex) const;
|
|
|
|
std::string getBattleBackgroundName() const;
|
|
|
|
const CCreature *getTurretCreature() const;
|
|
|
|
Point getTurretCreaturePosition( BattleHex position ) const;
|
|
|
|
|
2022-12-02 00:06:57 +02:00
|
|
|
const CGTownInstance *getSiegedTown() const;
|
2022-11-17 13:21:03 +02:00
|
|
|
};
|