mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Cleaned up object constructors to reduce duplicated code
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
#include "StdInc.h"
|
||||
#include "ShrineInstanceConstructor.h"
|
||||
|
||||
#include "IObjectInfo.h"
|
||||
#include "../mapObjects/MiscObjects.h"
|
||||
#include "../JsonRandom.h"
|
||||
#include "../IGameCallback.h"
|
||||
@@ -22,25 +21,8 @@ void ShrineInstanceConstructor::initTypeData(const JsonNode & config)
|
||||
parameters = config;
|
||||
}
|
||||
|
||||
CGObjectInstance * ShrineInstanceConstructor::create(std::shared_ptr<const ObjectTemplate> tmpl) const
|
||||
void ShrineInstanceConstructor::randomizeObject(CGShrine * shrine, CRandomGenerator & rng) const
|
||||
{
|
||||
CGShrine * shrine = new CGShrine;
|
||||
|
||||
preInitObject(shrine);
|
||||
|
||||
if(tmpl)
|
||||
shrine->appearance = tmpl;
|
||||
|
||||
return shrine;
|
||||
}
|
||||
|
||||
void ShrineInstanceConstructor::configureObject(CGObjectInstance * object, CRandomGenerator & rng) const
|
||||
{
|
||||
CGShrine * shrine = dynamic_cast<CGShrine*>(object);
|
||||
|
||||
if (!shrine)
|
||||
throw std::runtime_error("Unexpected object instance in ShrineInstanceConstructor!");
|
||||
|
||||
auto visitTextParameter = parameters["visitText"];
|
||||
|
||||
if (visitTextParameter.isNumber())
|
||||
@@ -57,9 +39,4 @@ void ShrineInstanceConstructor::configureObject(CGObjectInstance * object, CRand
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<IObjectInfo> ShrineInstanceConstructor::getObjectInfo(std::shared_ptr<const ObjectTemplate> tmpl) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
Reference in New Issue
Block a user