2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-05-13 19:11:20 +00:00
metaforce/Runtime/Input/CRumbleManager.cpp
Lioncash 9983366a53 RumbleFxTable: Use std::array for the lookup table
Strongly enforces the type of the array and also allows size querying,
etc, directly from the type.
2019-09-10 19:13:34 -04:00

27 lines
887 B
C++

#include "CRumbleManager.hpp"
#include "CStateManager.hpp"
#include "World/CPlayer.hpp"
#include "GameGlobalObjects.hpp"
#include "CGameState.hpp"
#include "RumbleFxTable.hpp"
namespace urde {
s16 CRumbleManager::Rumble(CStateManager& mgr, const zeus::CVector3f& pos, ERumbleFxId fx, float dist,
ERumblePriority priority) {
if (zeus::close_enough(dist, 0.f))
return -1;
zeus::CVector3f delta = mgr.GetPlayer().GetTranslation() - pos;
if (delta.magSquared() < dist * dist)
return Rumble(mgr, fx, 1.f - delta.magnitude() / dist, priority);
return -1;
}
s16 CRumbleManager::Rumble(CStateManager& mgr, ERumbleFxId fx, float gain, ERumblePriority priority) {
if (g_GameState->GameOptions().GetIsRumbleEnabled())
return x0_rumbleGenerator.Rumble(RumbleFxTable[size_t(fx)], gain, priority, EIOPort::Zero);
return -1;
}
} // namespace urde