#include "CMapUniverse.hpp" #include "GameGlobalObjects.hpp" #include "CSimplePool.hpp" #include "CGameState.hpp" namespace urde { CMapUniverse::CMapUniverse(CInputStream& in, u32 version) : x0_hexagonId(in.readUint32Big()) { x4_hexagonToken = g_SimplePool->GetObj({'MAPA', x0_hexagonId}); u32 count = in.readUint32Big(); x10_worldDatas.reserve(count); for (u32 i = 0 ; iGetNumSurfaces(); std::vector sortInfos; sortInfos.reserve(totalSurfaceCount); for (int w=0 ; wStateForWorld(data.GetWorldAssetId()).MapWorldInfo(); if (!mwInfo.IsAnythingSet()) continue; zeus::CColor surfColor, outlineColor; if (w == parms.GetFocusWorldIndex()) { surfColor = data.GetSurfaceColorSelected(); surfColor.a *= parms.GetAlpha(); outlineColor = data.GetOutlineColorSelected(); outlineColor.a *= parms.GetAlpha(); } else { surfColor = data.GetSurfaceColorUnselected(); surfColor.a *= parms.GetAlpha(); outlineColor = data.GetSurfaceColorUnselected(); outlineColor.a *= parms.GetAlpha(); } for (int h=0 ; hGetNumSurfaces() ; ++s) { const CMapArea::CMapAreaSurface& surf = x4_hexagonToken->GetSurface(s); zeus::CVector3f centerPos = hexXf * surf.GetCenterPosition(); sortInfos.emplace_back(centerPos.y, w, h, s, surfColor, outlineColor); } } } std::sort(sortInfos.begin(), sortInfos.end(), [](const CMapObjectSortInfo& a, const CMapObjectSortInfo& b) { return a.GetZDistance() < b.GetZDistance(); }); int lastWldIdx = -1; int lastHexIdx = -1; int instIdx = 0; for (const CMapObjectSortInfo& info : sortInfos) { const CMapWorldData& mwData = x10_worldDatas[info.GetWorldIndex()]; zeus::CColor surfColor = info.GetSurfaceColor(); zeus::CColor outlineColor = info.GetOutlineColor(); if (parms.GetWorldAssetId() == mwData.GetWorldAssetId() && parms.GetClosestArea() == info.GetAreaIndex()) { surfColor = zeus::CColor::lerp(g_tweakAutoMapper->GetSurfaceSelectVisitedColor(), g_tweakAutoMapper->GetAreaFlashPulseColor(), parms.GetFlashPulse()); surfColor.a = info.GetSurfaceColor().a; outlineColor = zeus::CColor::lerp(g_tweakAutoMapper->GetOutlineSelectVisitedColor(), g_tweakAutoMapper->GetAreaFlashPulseColor(), parms.GetFlashPulse()); outlineColor.a = info.GetOutlineColor().a; } zeus::CTransform hexXf = mwData.GetMapAreaData(info.GetAreaIndex()); hexXf.orthonormalize(); const CMapArea::CMapAreaSurface& surf = x4_hexagonToken->GetSurface(info.GetObjectIndex()); zeus::CColor color(std::max(0.f, (-parms.GetCameraTransform().basis[1]).dot(hexXf.rotate(surf.GetNormal()))) * g_tweakAutoMapper->GetMapSurfaceNormColorLinear() + g_tweakAutoMapper->GetMapSurfaceNormColorConstant()); surfColor *= color; if (info.GetAreaIndex() != lastHexIdx || info.GetWorldIndex() != lastWldIdx) CGraphics::SetModelMatrix(parms.GetPaneProjectionTransform() * mwData.GetMapAreaData(info.GetAreaIndex())); surf.Draw(x4_hexagonToken->GetVertices(), surfColor, outlineColor, 2.f, instIdx++); } } CFactoryFnReturn FMapUniverseFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&, CObjectReference*) { in.readUint32Big(); u32 version = in.readUint32Big(); return TToken::GetIObjObjectFor(std::make_unique(in, version)); } }