1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Add TeleportChannel / TeleportChannelID / ETeleportChannelType

TeleportChannel is structure that contain two vectors of entrances and exits for certain teleport channel. It's also store passability state independently which almost only useful for Player and AI as they can't know if channel passible or not until enough entrances / exits are visible or server passed them information that certain channel is impassible when they visited entrance.

ETeleportChannelType is determined by checking intersection between entrances and exit vectors or checking their size:
 - IMPASSABLE: one of vectors empty or only one entrance id is same as only one exit id.
 - BIDIRECTIONAL: contents of both vectors is exactly the same.
 - UNIDIRECTIONAL: contents of both vectors do not intersect.
 - MIXED: contents of vectors only partially intersect. Not currently used; added for future modding.
This commit is contained in:
ArseniyShestakov 2015-03-08 15:18:53 +03:00
parent f145c82031
commit 04a1df29ad
2 changed files with 35 additions and 0 deletions

View File

@ -252,6 +252,14 @@ class TeamID : public BaseForID<TeamID, ui8>
friend class CNonConstInfoCallback;
};
class TeleportChannelID : public BaseForID<TeleportChannelID, si32>
{
INSTID_LIKE_CLASS_COMMON(TeleportChannelID, si32)
friend class CGameInfoCallback;
friend class CNonConstInfoCallback;
};
// #ifndef INSTANTIATE_BASE_FOR_ID_HERE
// extern template std::ostream & operator << <ArtifactInstanceID>(std::ostream & os, BaseForID<ArtifactInstanceID> id);
// extern template std::ostream & operator << <ObjectInstanceID>(std::ostream & os, BaseForID<ObjectInstanceID> id);
@ -466,6 +474,17 @@ namespace ETileType
};
}
namespace ETeleportChannelType
{
enum ETeleportChannelType
{
IMPASSABLE,
BIDIRECTIONAL,
UNIDIRECTIONAL,
MIXED
};
}
class Obj
{
public:

View File

@ -247,6 +247,22 @@ public:
ui32 defaultResProduction();
};
struct DLL_LINKAGE TeleportChannel
{
enum EPassability {UNKNOWN, IMPASSABLE, PASSABLE};
TeleportChannel() : passability(UNKNOWN) {}
std::vector<ObjectInstanceID> entrances;
std::vector<ObjectInstanceID> exits;
EPassability passability;
template <typename Handler> void serialize(Handler &h, const int version)
{
h & entrances & exits & passability;
}
};
class DLL_LINKAGE CGTeleport : public CGObjectInstance //teleports and subterranean gates
{
public: