mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Add constructor for boat
This commit is contained in:
parent
ed798b06da
commit
d83566bc74
@ -39,6 +39,7 @@ CObjectClassesHandler::CObjectClassesHandler()
|
||||
SET_HANDLER_CLASS("hero", CHeroInstanceConstructor);
|
||||
SET_HANDLER_CLASS("town", CTownInstanceConstructor);
|
||||
SET_HANDLER_CLASS("bank", CBankInstanceConstructor);
|
||||
SET_HANDLER_CLASS("boat", BoatInstanceConstructor);
|
||||
|
||||
SET_HANDLER_CLASS("static", CObstacleConstructor);
|
||||
SET_HANDLER_CLASS("", CObstacleConstructor);
|
||||
@ -54,7 +55,6 @@ CObjectClassesHandler::CObjectClassesHandler()
|
||||
SET_HANDLER("cartographer", CCartographer);
|
||||
SET_HANDLER("artifact", CGArtifact);
|
||||
SET_HANDLER("blackMarket", CGBlackMarket);
|
||||
SET_HANDLER("boat", CGBoat);
|
||||
SET_HANDLER("borderGate", CGBorderGate);
|
||||
SET_HANDLER("borderGuard", CGBorderGuard);
|
||||
SET_HANDLER("monster", CGCreature);
|
||||
|
@ -257,6 +257,26 @@ std::vector<const CCreature *> CDwellingInstanceConstructor::getProducedCreature
|
||||
return creatures;
|
||||
}
|
||||
|
||||
void BoatInstanceConstructor::initTypeData(const JsonNode & input)
|
||||
{
|
||||
layer = EPathfindingLayer::EEPathfindingLayer::SAIL;
|
||||
if(input["layer"].String() == "land")
|
||||
layer = EPathfindingLayer::EEPathfindingLayer::LAND;
|
||||
if(input["layer"].String() == "air")
|
||||
layer = EPathfindingLayer::EEPathfindingLayer::AIR;
|
||||
if(input["layer"].String() == "water")
|
||||
layer = EPathfindingLayer::EEPathfindingLayer::WATER;
|
||||
if(input["layer"].String() == "sail")
|
||||
layer = EPathfindingLayer::EEPathfindingLayer::SAIL;
|
||||
}
|
||||
|
||||
CGObjectInstance * BoatInstanceConstructor::create(std::shared_ptr<const ObjectTemplate> tmpl) const
|
||||
{
|
||||
CGBoat * boat = createTyped(tmpl);
|
||||
boat->layer = layer;
|
||||
return boat;
|
||||
}
|
||||
|
||||
bool CBankInstanceConstructor::hasNameTextID() const
|
||||
{
|
||||
return true;
|
||||
|
@ -140,6 +140,22 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class BoatInstanceConstructor : public CDefaultObjectTypeHandler<CGBoat>
|
||||
{
|
||||
protected:
|
||||
void initTypeData(const JsonNode & config) override;
|
||||
|
||||
EPathfindingLayer::EEPathfindingLayer layer;
|
||||
|
||||
public:
|
||||
CGObjectInstance * create(std::shared_ptr<const ObjectTemplate> tmpl = nullptr) const override;
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<CDefaultObjectTypeHandler<CGBoat>&>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
struct BankConfig
|
||||
{
|
||||
ui32 value = 0; //overall value of given things
|
||||
|
@ -420,18 +420,22 @@ public:
|
||||
ui8 direction;
|
||||
const CGHeroInstance *hero; //hero on board
|
||||
|
||||
EPathfindingLayer::EEPathfindingLayer layer;
|
||||
|
||||
void initObj(CRandomGenerator & rand) override;
|
||||
|
||||
CGBoat()
|
||||
{
|
||||
hero = nullptr;
|
||||
direction = 4;
|
||||
layer = EPathfindingLayer::EEPathfindingLayer::SAIL;
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<CGObjectInstance&>(*this);
|
||||
h & direction;
|
||||
h & hero;
|
||||
h & layer;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -88,6 +88,7 @@ void registerTypesMapObjectTypes(Serializer &s)
|
||||
s.template registerType<AObjectTypeHandler, CTownInstanceConstructor>();
|
||||
s.template registerType<AObjectTypeHandler, CDwellingInstanceConstructor>();
|
||||
s.template registerType<AObjectTypeHandler, CBankInstanceConstructor>();
|
||||
s.template registerType<AObjectTypeHandler, BoatInstanceConstructor>();
|
||||
s.template registerType<AObjectTypeHandler, CObstacleConstructor>();
|
||||
|
||||
#define REGISTER_GENERIC_HANDLER(TYPENAME) s.template registerType<AObjectTypeHandler, CDefaultObjectTypeHandler<TYPENAME> >()
|
||||
|
Loading…
Reference in New Issue
Block a user