1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

backup of current progress, started design of "Object configurer" that

will be responsible for configuring of ObjectWithReward's from json
config.
This commit is contained in:
Ivan Savenko 2014-04-25 17:59:05 +03:00
parent a6c0886d03
commit 7725232253
4 changed files with 68 additions and 4 deletions

View File

@ -108,3 +108,60 @@ public:
h & objects;
}
};
class IObjectInfo
{
public:
virtual bool givesResources() const = 0;
virtual bool givesExperience() const = 0;
virtual bool givesMana() const = 0;
virtual bool givesMovement() const = 0;
virtual bool givesPrimarySkills() const = 0;
virtual bool givesSecondarySkills() const = 0;
virtual bool givesArtifacts() const = 0;
virtual bool givesCreatures() const = 0;
virtual bool givesSpells() const = 0;
virtual bool givesBonuses() const = 0;
};
class CGObjectInstance;
class IObjectTypeHandler
{
public:
virtual CGObjectInstance * create(ui32 id, ui32 subID) const = 0;
virtual bool handlesID(ui32 id) const = 0;
virtual void configureObject(CGObjectInstance * object) const = 0;
virtual IObjectInfo * getObjectInfo(ui32 id, ui32 subID) const = 0;
};
typedef std::shared_ptr<IObjectTypeHandler> TObjectTypeHandler;
class CObjectTypesHandler
{
/// list of object handlers, each of them handles 1 or more object type
std::vector<TObjectTypeHandler> objectTypes;
public:
/// returns handler for specified object (ID-based). ObjectHandler keeps ownership
IObjectTypeHandler * getHandlerFor(CObjectTemplate tmpl) const;
/// creates object based on specified template
CGObjectInstance * createObject(CObjectTemplate tmpl);
template<typename CObjectClass>
CObjectClass * createObjectTyped(CObjectTemplate tmpl)
{
auto objInst = createObject(tmpl);
auto objClass = dynamic_cast<CObjectClass*>(objInst);
assert(objClass);
return objClass;
}
}

View File

@ -69,7 +69,7 @@ set(lib_SRCS
CModHandler.cpp
CObstacleInstance.cpp
CObjectWithReward.cpp
CObjectWithReward.h
CObjectConstructor.cpp
CSpellHandler.cpp
CThreadHelper.cpp
CTownHandler.cpp
@ -119,5 +119,5 @@ set_target_properties(vcmi PROPERTIES ${PCH_PROPERTIES})
cotire(vcmi)
if (NOT APPLE) # Already inside vcmiclient bundle
install(TARGETS vcmi DESTINATION ${LIB_DIR})
install(TARGETS vcmi DESTINATION ${LIB_DIR})
endif()

View File

@ -447,7 +447,7 @@ static void loadRandomArtifact(CVisitInfo & info, int treasure, int minor, int m
CGPickable::CGPickable()
{
visitMode = VISIT_ONCE;
visitMode = VISIT_UNLIMITED;
selectMode = SELECT_PLAYER;
}
@ -935,6 +935,8 @@ void CGVisitableOPH::initObj()
break;
}
}
//TODO: re-enable. Probably in some different form but still necessary
/*
const std::string & CGVisitableOPH::getHoverText() const
{

View File

@ -13,6 +13,8 @@
*
*/
class CRandomRewardObjectInfo;
/// Limiters of rewards. Rewards will be granted to hero only if he satisfies requirements
/// Note: for this is only a test - it won't remove anything from hero (e.g. artifacts or creatures)
/// NOTE: in future should (partially) replace seer hut/quest guard quests checks
@ -165,7 +167,7 @@ protected:
enum EVisitMode
{
VISIT_UNLIMITED, // any number of times
VISIT_UNLIMITED, // any number of times. Side effect - object hover text won't contain visited/not visited text
VISIT_ONCE, // only once, first to visit get all the rewards
VISIT_HERO, // every hero can visit object once
VISIT_PLAYER // every player can visit object once
@ -231,6 +233,9 @@ public:
h & onSelect & onVisited & onEmpty;
h & soundID & selectMode & selectedReward;
}
// for configuration/object setup
friend class CRandomRewardObjectInfo;
};
class DLL_LINKAGE CGPickable : public CObjectWithReward //campfire, treasure chest, Flotsam, Shipwreck Survivor, Sea Chest