mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
SiegeInfo: add foundation for drawbridge mechanics support
EDrawbridgeState enum represent current state of drawbridge. BattleDrawbridgeStateChanged netpack to pass bridge state changes to client.
This commit is contained in:
parent
a7059fe681
commit
1e008b9756
@ -327,6 +327,8 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
|
||||
//setting up siege obstacles
|
||||
if (town && town->hasFort())
|
||||
{
|
||||
curB->si.drawbridgeState = EDrawbridgeState::RAISED;
|
||||
|
||||
for (int b = 0; b < curB->si.wallState.size(); ++b)
|
||||
{
|
||||
curB->si.wallState[b] = EWallState::INTACT;
|
||||
|
@ -33,6 +33,7 @@ class CRandomGenerator;
|
||||
struct DLL_LINKAGE SiegeInfo
|
||||
{
|
||||
std::array<si8, EWallPart::PARTS_COUNT> wallState;
|
||||
EDrawbridgeState drawbridgeState;
|
||||
|
||||
// return EWallState decreased by value of damage points
|
||||
static EWallState::EWallState applyDamage(EWallState::EWallState state, unsigned int value)
|
||||
@ -51,7 +52,7 @@ struct DLL_LINKAGE SiegeInfo
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & wallState;
|
||||
h & wallState & drawbridgeState;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -510,6 +510,15 @@ namespace EWallState
|
||||
};
|
||||
}
|
||||
|
||||
enum class EDrawbridgeState
|
||||
{
|
||||
NONE,
|
||||
RAISED,
|
||||
RAISED_BLOCKED, //dead or alive stack blocking from outside
|
||||
LOWERED,
|
||||
LOWERED_BORKED //gate is destroyed
|
||||
};
|
||||
|
||||
namespace ETileType
|
||||
{
|
||||
enum ETileType
|
||||
|
@ -1689,6 +1689,19 @@ struct BattleObstaclePlaced : public CPackForClient //3020
|
||||
}
|
||||
};
|
||||
|
||||
struct BattleDrawbridgeStateChanged : public CPackForClient//3021
|
||||
{
|
||||
BattleDrawbridgeStateChanged(){type = 3021;};
|
||||
|
||||
DLL_LINKAGE void applyGs(CGameState *gs);
|
||||
|
||||
EDrawbridgeState state;
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & state;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct ShowInInfobox : public CPackForClient //107
|
||||
{
|
||||
|
@ -1208,6 +1208,11 @@ DLL_LINKAGE void BattleObstaclePlaced::applyGs( CGameState *gs )
|
||||
gs->curB->obstacles.push_back(obstacle);
|
||||
}
|
||||
|
||||
DLL_LINKAGE void BattleDrawbridgeStateChanged::applyGs(CGameState *gs)
|
||||
{
|
||||
gs->curB->si.drawbridgeState = state;
|
||||
}
|
||||
|
||||
void BattleResult::applyGs( CGameState *gs )
|
||||
{
|
||||
for (CStack *s : gs->curB->stacks)
|
||||
|
@ -270,6 +270,7 @@ void registerTypesClientPacks2(Serializer &s)
|
||||
s.template registerType<CPackForClient, SetStackEffect>();
|
||||
s.template registerType<CPackForClient, BattleTriggerEffect>();
|
||||
s.template registerType<CPackForClient, BattleObstaclePlaced>();
|
||||
s.template registerType<CPackForClient, BattleDrawbridgeStateChanged>();
|
||||
s.template registerType<CPackForClient, BattleSetStackProperty>();
|
||||
s.template registerType<CPackForClient, StacksInjured>();
|
||||
s.template registerType<CPackForClient, BattleResultsApplied>();
|
||||
|
Loading…
Reference in New Issue
Block a user