53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
#include "Gen.h"
|
|
|
|
namespace Generated
|
|
{
|
|
bool IsValid(const ModelHandle& h)
|
|
{
|
|
return h.ModelIdx != UINT16_MAX && IsValid(h.Asset);
|
|
}
|
|
bool IsValid(const AssetHandle& h)
|
|
{
|
|
return h.Idx != UINT32_MAX;
|
|
}
|
|
bool IsValid(const TextureHandle& h)
|
|
{
|
|
return h.TextureIdx != UINT16_MAX && IsValid(h.Asset);
|
|
}
|
|
bool operator==(const AssetHandle& lhs, const AssetHandle& rhs)
|
|
{
|
|
return lhs.Idx == rhs.Idx;
|
|
}
|
|
bool operator==(const ModelHandle& lhs, const ModelHandle& rhs)
|
|
{
|
|
if (!IsValid(lhs) || !IsValid(rhs)) return IsValid(lhs) == IsValid(rhs);
|
|
return lhs.ModelIdx == rhs.ModelIdx && lhs.Asset == rhs.Asset;
|
|
}
|
|
PuzPos operator+=(PuzPos lhs, const PuzPos& rhs)
|
|
{
|
|
lhs.X += rhs.X;
|
|
lhs.Y += rhs.Y;
|
|
return lhs;
|
|
}
|
|
PuzPos operator+(PuzPos lhs, const PuzPos& rhs)
|
|
{
|
|
PuzPos res = lhs;
|
|
res.X += rhs.X;
|
|
res.Y += rhs.Y;
|
|
return res;
|
|
}
|
|
PuzPos operator-=(PuzPos lhs, const PuzPos& rhs)
|
|
{
|
|
lhs.X -= rhs.X;
|
|
lhs.Y -= rhs.Y;
|
|
return lhs;
|
|
}
|
|
PuzPos operator-(PuzPos lhs, const PuzPos& rhs)
|
|
{
|
|
PuzPos res = lhs;
|
|
res.X += rhs.X;
|
|
res.Y += rhs.Y;
|
|
return res;
|
|
}
|
|
} // namespace Generated
|