metaforce/Runtime/Input/CRumbleManager.cpp

28 lines
961 B
C++
Raw Normal View History

#include "Runtime/Input/CRumbleManager.hpp"
#include "Runtime/CGameState.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Input/RumbleFxTable.hpp"
#include "Runtime/World/CPlayer.hpp"
2016-02-20 22:34:42 -08:00
2021-04-10 01:42:06 -07:00
namespace metaforce {
2016-02-20 22:34:42 -08:00
2018-12-07 21:30:43 -08:00
s16 CRumbleManager::Rumble(CStateManager& mgr, const zeus::CVector3f& pos, ERumbleFxId fx, float dist,
ERumblePriority priority) {
if (zeus::close_enough(dist, 0.f))
2018-01-26 01:48:42 -08:00
return -1;
2018-12-07 21:30:43 -08:00
zeus::CVector3f delta = mgr.GetPlayer().GetTranslation() - pos;
if (delta.magSquared() < dist * dist)
return Rumble(mgr, fx, 1.f - delta.magnitude() / dist, priority);
return -1;
2017-04-02 18:39:23 -07:00
}
2018-12-07 21:30:43 -08:00
s16 CRumbleManager::Rumble(CStateManager& mgr, ERumbleFxId fx, float gain, ERumblePriority priority) {
if (g_GameState->GameOptions().GetIsRumbleEnabled())
2022-03-19 21:19:43 -07:00
return x0_rumbleGenerator.Rumble(RumbleFxTable[size_t(fx)], gain, priority, EIOPort::Player1);
2018-12-07 21:30:43 -08:00
return -1;
2018-01-26 01:48:42 -08:00
}
2016-02-20 22:34:42 -08:00
2021-04-10 01:42:06 -07:00
} // namespace metaforce