1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 12:19:55 +00:00
openmw-tes3mp/components/detournavigator/flags.hpp

69 lines
1.6 KiB
C++
Raw Normal View History

2018-07-18 19:09:50 +00:00
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_FLAGS_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_FLAGS_H
#include <ostream>
2018-07-18 19:09:50 +00:00
namespace DetourNavigator
{
using Flags = unsigned short;
enum Flag : Flags
{
Flag_none = 0,
Flag_walk = 1 << 0,
2018-07-20 19:11:34 +00:00
Flag_swim = 1 << 1,
Flag_openDoor = 1 << 2,
Flag_usePathgrid = 1 << 3,
2018-07-18 19:09:50 +00:00
};
inline std::ostream& operator <<(std::ostream& stream, const Flag value)
{
2018-10-31 06:18:29 +00:00
switch (value)
{
case Flag_none:
return stream << "none";
case Flag_walk:
return stream << "walk";
case Flag_swim:
return stream << "swim";
case Flag_openDoor:
return stream << "openDoor";
case Flag_usePathgrid:
return stream << "usePathgrid";
}
2018-10-31 06:18:29 +00:00
return stream;
}
struct WriteFlags
{
Flags mValue;
friend inline std::ostream& operator <<(std::ostream& stream, const WriteFlags& value)
{
if (value.mValue == Flag_none)
{
return stream << Flag_none;
}
else
{
bool first = true;
for (const auto flag : {Flag_walk, Flag_swim, Flag_openDoor, Flag_usePathgrid})
{
if (value.mValue & flag)
{
if (!first)
stream << " | ";
first = false;
stream << flag;
}
}
return stream;
}
}
};
2018-07-18 19:09:50 +00:00
}
#endif