2023-06-02 20:47:37 +02:00
|
|
|
/*
|
|
|
|
* IObjectInterface.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
|
|
|
|
|
2024-05-07 21:17:05 +02:00
|
|
|
#include "../GameCallbackHolder.h"
|
|
|
|
#include "../constants/EntityIdentifiers.h"
|
2023-10-23 12:59:15 +02:00
|
|
|
#include "../networkPacks/EInfoWindowMode.h"
|
2023-11-06 18:27:16 +02:00
|
|
|
#include "../networkPacks/ObjProperty.h"
|
2024-05-07 21:17:05 +02:00
|
|
|
#include "../serializer/Serializeable.h"
|
2023-06-02 20:47:37 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
struct BattleResult;
|
2023-06-06 18:19:30 +02:00
|
|
|
struct UpgradeInfo;
|
2023-10-23 12:59:15 +02:00
|
|
|
class BoatId;
|
2023-06-02 20:47:37 +02:00
|
|
|
class CGObjectInstance;
|
|
|
|
class CRandomGenerator;
|
2023-10-23 12:59:15 +02:00
|
|
|
class CStackInstance;
|
|
|
|
class CGHeroInstance;
|
2023-06-02 20:47:37 +02:00
|
|
|
class IGameCallback;
|
|
|
|
class ResourceSet;
|
|
|
|
class int3;
|
2023-06-17 22:52:42 +02:00
|
|
|
class MetaString;
|
2023-10-23 12:59:15 +02:00
|
|
|
class PlayerColor;
|
2023-06-02 20:47:37 +02:00
|
|
|
|
2024-05-07 21:17:05 +02:00
|
|
|
class DLL_LINKAGE IObjectInterface : public GameCallbackHolder, public virtual Serializeable
|
2023-06-02 20:47:37 +02:00
|
|
|
{
|
|
|
|
public:
|
2024-01-01 16:37:48 +02:00
|
|
|
using GameCallbackHolder::GameCallbackHolder;
|
2023-06-02 20:47:37 +02:00
|
|
|
|
|
|
|
virtual ~IObjectInterface() = default;
|
|
|
|
|
2023-10-24 16:11:25 +02:00
|
|
|
virtual MapObjectID getObjGroupIndex() const = 0;
|
|
|
|
virtual MapObjectSubID getObjTypeIndex() const = 0;
|
2023-06-02 20:47:37 +02:00
|
|
|
|
|
|
|
virtual PlayerColor getOwner() const = 0;
|
|
|
|
virtual int3 visitablePos() const = 0;
|
|
|
|
virtual int3 getPosition() const = 0;
|
|
|
|
|
|
|
|
virtual void onHeroVisit(const CGHeroInstance * h) const;
|
|
|
|
virtual void onHeroLeave(const CGHeroInstance * h) const;
|
|
|
|
virtual void newTurn(CRandomGenerator & rand) const;
|
|
|
|
virtual void initObj(CRandomGenerator & rand); //synchr
|
2023-10-25 12:50:11 +02:00
|
|
|
virtual void pickRandomObject(CRandomGenerator & rand);
|
2023-11-06 18:27:16 +02:00
|
|
|
virtual void setProperty(ObjProperty what, ObjPropertyID identifier);//synchr
|
2023-06-02 20:47:37 +02:00
|
|
|
|
|
|
|
//Called when queries created DURING HERO VISIT are resolved
|
|
|
|
//First parameter is always hero that visited object and triggered the query
|
|
|
|
virtual void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const;
|
|
|
|
virtual void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const;
|
|
|
|
virtual void garrisonDialogClosed(const CGHeroInstance *hero) const;
|
|
|
|
virtual void heroLevelUpDone(const CGHeroInstance *hero) const;
|
|
|
|
|
|
|
|
//unified helper to show info dialog for object owner
|
|
|
|
virtual void showInfoDialog(const ui32 txtID, const ui16 soundID = 0, EInfoWindowMode mode = EInfoWindowMode::AUTO) const;
|
|
|
|
|
|
|
|
//unified interface, AI helpers
|
|
|
|
virtual bool wasVisited (PlayerColor player) const;
|
|
|
|
virtual bool wasVisited (const CGHeroInstance * h) const;
|
|
|
|
|
|
|
|
static void preInit(); //called before objs receive their initObj
|
|
|
|
static void postInit();//called after objs receive their initObj
|
|
|
|
|
2024-01-20 20:34:51 +02:00
|
|
|
template <typename Handler> void serialize(Handler &h)
|
2023-06-02 20:47:37 +02:00
|
|
|
{
|
|
|
|
logGlobal->error("IObjectInterface serialized, unexpected, should not happen!");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-06-06 18:19:30 +02:00
|
|
|
class DLL_LINKAGE ICreatureUpgrader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void fillUpgradeInfo(UpgradeInfo & info, const CStackInstance &stack) const = 0;
|
|
|
|
|
|
|
|
virtual ~ICreatureUpgrader() = default;
|
|
|
|
};
|
|
|
|
|
2023-06-02 20:47:37 +02:00
|
|
|
class DLL_LINKAGE IBoatGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IBoatGenerator() = default;
|
|
|
|
|
2023-06-07 00:55:21 +02:00
|
|
|
virtual const IObjectInterface * getObject() const = 0;
|
|
|
|
|
|
|
|
virtual BoatId getBoatType() const = 0; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral
|
|
|
|
virtual void getOutOffsets(std::vector<int3> & offsets) const = 0; //offsets to obj pos when we boat can be placed
|
2023-06-02 20:47:37 +02:00
|
|
|
int3 bestLocation() const; //returns location when the boat should be placed
|
|
|
|
|
2023-06-07 00:55:21 +02:00
|
|
|
enum EGeneratorState {GOOD, BOAT_ALREADY_BUILT, TILE_BLOCKED, NO_WATER, UNKNOWN};
|
|
|
|
virtual EGeneratorState shipyardStatus() const;
|
2023-06-02 20:47:37 +02:00
|
|
|
void getProblemText(MetaString &out, const CGHeroInstance *visitor = nullptr) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE IShipyard : public IBoatGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void getBoatCost(ResourceSet & cost) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|