mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Implemented configurable shrine
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
#include "../mapObjectConstructors/DwellingInstanceConstructor.h"
|
||||
#include "../mapObjectConstructors/HillFortInstanceConstructor.h"
|
||||
#include "../mapObjectConstructors/ShipyardInstanceConstructor.h"
|
||||
#include "../mapObjectConstructors/ShrineInstanceConstructor.h"
|
||||
#include "../mapObjects/CGCreature.h"
|
||||
#include "../mapObjects/CGPandoraBox.h"
|
||||
#include "../mapObjects/CQuest.h"
|
||||
@@ -54,7 +53,6 @@ CObjectClassesHandler::CObjectClassesHandler()
|
||||
SET_HANDLER_CLASS("bank", CBankInstanceConstructor);
|
||||
SET_HANDLER_CLASS("boat", BoatInstanceConstructor);
|
||||
SET_HANDLER_CLASS("market", MarketInstanceConstructor);
|
||||
SET_HANDLER_CLASS("shrine", ShrineInstanceConstructor);
|
||||
SET_HANDLER_CLASS("hillFort", HillFortInstanceConstructor);
|
||||
SET_HANDLER_CLASS("shipyard", ShipyardInstanceConstructor);
|
||||
SET_HANDLER_CLASS("monster", CreatureInstanceConstructor);
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* ShrineInstanceConstructor.cpp, 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
|
||||
*
|
||||
*/
|
||||
#include "StdInc.h"
|
||||
#include "ShrineInstanceConstructor.h"
|
||||
|
||||
#include "../mapObjects/MiscObjects.h"
|
||||
#include "../JsonRandom.h"
|
||||
#include "../IGameCallback.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
void ShrineInstanceConstructor::initTypeData(const JsonNode & config)
|
||||
{
|
||||
parameters = config;
|
||||
}
|
||||
|
||||
void ShrineInstanceConstructor::randomizeObject(CGShrine * shrine, CRandomGenerator & rng) const
|
||||
{
|
||||
JsonRandom::Variables emptyVariables;
|
||||
|
||||
auto visitTextParameter = parameters["visitText"];
|
||||
|
||||
if (visitTextParameter.isNumber())
|
||||
shrine->visitText.appendLocalString(EMetaText::ADVOB_TXT, static_cast<ui32>(visitTextParameter.Float()));
|
||||
else
|
||||
shrine->visitText.appendRawString(visitTextParameter.String());
|
||||
|
||||
if(shrine->spell == SpellID::NONE) // shrine has no predefined spell
|
||||
shrine->spell =JsonRandom::loadSpell(parameters["spell"], rng, emptyVariables);
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* ShrineInstanceConstructor.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 "CDefaultObjectTypeHandler.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class CGShrine;
|
||||
|
||||
class ShrineInstanceConstructor final : public CDefaultObjectTypeHandler<CGShrine>
|
||||
{
|
||||
JsonNode parameters;
|
||||
|
||||
protected:
|
||||
void initTypeData(const JsonNode & config) override;
|
||||
void randomizeObject(CGShrine * object, CRandomGenerator & rng) const override;
|
||||
|
||||
public:
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & static_cast<AObjectTypeHandler&>(*this);
|
||||
h & parameters;
|
||||
}
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
Reference in New Issue
Block a user