1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

63 lines
1.5 KiB
C++
Raw Normal View History

2018-07-18 22:09:50 +03:00
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_FLAGS_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_FLAGS_H
#include <ostream>
2018-07-18 22:09:50 +03:00
namespace DetourNavigator
{
using Flags = unsigned short;
enum Flag : Flags
{
Flag_none = 0,
Flag_walk = 1 << 0,
2018-07-20 22:11:34 +03:00
Flag_swim = 1 << 1,
Flag_openDoor = 1 << 2,
2018-07-18 22:09:50 +03:00
};
inline std::ostream& operator <<(std::ostream& stream, const Flag value)
{
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";
}
}
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})
{
if (value.mValue & flag)
{
if (!first)
stream << " | ";
first = false;
stream << flag;
}
}
return stream;
}
}
};
2018-07-18 22:09:50 +03:00
}
#endif