mirror of https://github.com/AxioDL/metaforce.git
CScriptSpecialFunction: Further ThinkSpinnerController implementation
This commit is contained in:
parent
1c5fd85b57
commit
9e0e053906
|
@ -74,7 +74,7 @@ CFlaahgra::CFlaahgra(TUniqueId uid, std::string_view name, const CEntityInfo& in
|
||||||
, x6d4_(g_SimplePool->GetObj({SBIG('PART'), x56c_.xb8_}))
|
, x6d4_(g_SimplePool->GetObj({SBIG('PART'), x56c_.xb8_}))
|
||||||
, x6dc_(x56c_.x78_, x56c_.x7c_)
|
, x6dc_(x56c_.x78_, x56c_.x7c_)
|
||||||
, x704_(x56c_.x98_, x56c_.x9c_)
|
, x704_(x56c_.x98_, x56c_.x9c_)
|
||||||
, x7dc_(GetContactDamage())
|
, x7dc_(x404_contactDamage)
|
||||||
, x820_(xf.origin)
|
, x820_(xf.origin)
|
||||||
, x8a0_(xf.frontVector())
|
, x8a0_(xf.frontVector())
|
||||||
, x8ac_(animRes) {
|
, x8ac_(animRes) {
|
||||||
|
|
|
@ -42,13 +42,13 @@ CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, std::string_view n
|
||||||
, x170_sfx1(CSfxManager::TranslateSFXID(sId1))
|
, x170_sfx1(CSfxManager::TranslateSFXID(sId1))
|
||||||
, x172_sfx2(CSfxManager::TranslateSFXID(sId2))
|
, x172_sfx2(CSfxManager::TranslateSFXID(sId2))
|
||||||
, x174_sfx3(CSfxManager::TranslateSFXID(sId3))
|
, x174_sfx3(CSfxManager::TranslateSFXID(sId3))
|
||||||
, x184_(6, 0.f)
|
, x184_(0.f)
|
||||||
, x1bc_areaSaveId(aId1)
|
, x1bc_areaSaveId(aId1)
|
||||||
, x1c0_layerIdx(aId2)
|
, x1c0_layerIdx(aId2)
|
||||||
, x1c4_item(itemType) {
|
, x1c4_item(itemType) {
|
||||||
x1e4_26_sfx2Played = true;
|
x1e4_26_sfx2Played = true;
|
||||||
if (xe8_function == ESpecialFunction::HUDTarget)
|
if (xe8_function == ESpecialFunction::HUDTarget)
|
||||||
x1c8_touchBounds = {{zeus::CVector3f(-1.f), zeus::CVector3f(1.f)}};
|
x1c8_touchBounds = {-1.f, 1.f};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
void CScriptSpecialFunction::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||||
|
@ -639,7 +639,7 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
|
|
||||||
float spinImpulse =
|
float spinImpulse =
|
||||||
(pl.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed ? 0.025f * mag : 0.f);
|
(pl.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed ? 0.025f * mag : 0.f);
|
||||||
if (spinImpulse > x180_)
|
if (spinImpulse >= x180_)
|
||||||
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
||||||
|
|
||||||
x180_ = spinImpulse;
|
x180_ = spinImpulse;
|
||||||
|
@ -648,7 +648,7 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
if (!noBackward)
|
if (!noBackward)
|
||||||
x138_ -= f29;
|
x138_ -= f29;
|
||||||
} else if (!noBackward) {
|
} else if (!noBackward) {
|
||||||
x138_ = twoByDt - f28;
|
x138_ = f28 - twoByDt;
|
||||||
}
|
}
|
||||||
} else if (mode == ESpinnerControllerMode::One) {
|
} else if (mode == ESpinnerControllerMode::One) {
|
||||||
x138_ = (0.1f * x16c_) * xfc_float1 + f28;
|
x138_ = (0.1f * x16c_) * xfc_float1 + f28;
|
||||||
|
@ -659,7 +659,8 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
if (std::fabs(x16c_) < dt)
|
if (std::fabs(x16c_) < dt)
|
||||||
x16c_ = 0.f;
|
x16c_ = 0.f;
|
||||||
else
|
else
|
||||||
x16c_ += (dt * (x16c_ < 0 ? -1.f : 1.f));
|
x16c_ -= (dt * (x16c_ <= 0.f ? -1.f : 1.f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowWrap) {
|
if (allowWrap) {
|
||||||
|
@ -670,9 +671,9 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
x138_ = zeus::clamp(0.f, x138_, 1.f);
|
x138_ = zeus::clamp(0.f, x138_, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
f28 = f28 - x138_;
|
|
||||||
bool r23 = true;
|
bool r23 = true;
|
||||||
if (zeus::close_enough(1.f, x138_, FLT_EPSILON)) {
|
f28 = x138_ - f28;
|
||||||
|
if (zeus::close_enough(x138_, 1.f, FLT_EPSILON)) {
|
||||||
if (!x1e4_27_sfx3Played) {
|
if (!x1e4_27_sfx3Played) {
|
||||||
if (x174_sfx3 != 0xFFFF)
|
if (x174_sfx3 != 0xFFFF)
|
||||||
CSfxManager::AddEmitter(x174_sfx3, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
CSfxManager::AddEmitter(x174_sfx3, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
||||||
|
@ -685,7 +686,7 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
} else
|
} else
|
||||||
x1e4_27_sfx3Played = false;
|
x1e4_27_sfx3Played = false;
|
||||||
|
|
||||||
if (zeus::close_enough(0.f, x138_, FLT_EPSILON)) {
|
if (zeus::close_enough(x138_, 0.f, FLT_EPSILON)) {
|
||||||
if (!x1e4_26_sfx2Played) {
|
if (!x1e4_26_sfx2Played) {
|
||||||
if (x172_sfx2 != 0xFFFF)
|
if (x172_sfx2 != 0xFFFF)
|
||||||
CSfxManager::AddEmitter(x172_sfx2, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
CSfxManager::AddEmitter(x172_sfx2, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
||||||
|
@ -697,8 +698,29 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
r23 = false;
|
r23 = false;
|
||||||
} else
|
} else
|
||||||
x1e4_26_sfx2Played = false;
|
x1e4_26_sfx2Played = false;
|
||||||
(void)r23;
|
|
||||||
|
// local_1ac = x184_.GetAverage();
|
||||||
|
if (r23) {
|
||||||
|
if (x170_sfx1 != 0xFFFF) {
|
||||||
|
if (r23) { // ?
|
||||||
|
x184_.AddValue(0.f <= f28 ? 100 : 0x7f);
|
||||||
|
} else {
|
||||||
|
x184_.AddValue(0.f);
|
||||||
}
|
}
|
||||||
|
const std::optional<float>& avg = x184_.GetAverage();
|
||||||
|
AddOrUpdateEmitter(0.f <= f28 ? x108_float4 : 1.f, x178_sfxHandle, x170_sfx1, GetTranslation(),
|
||||||
|
avg.value());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DeleteEmitter(x178_sfxHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
CAnimData* animData = plat->GetModelData()->GetAnimationData();
|
||||||
|
float dur = animData->GetAnimationDuration(animData->GetDefaultAnimation()) * x138_;
|
||||||
|
animData->SetPhase(0.f);
|
||||||
|
animData->SetPlaybackRate(1.f);
|
||||||
|
const SAdvancementDeltas& deltas = plat->UpdateAnimation(dur, mgr, true);
|
||||||
|
plat->SetTransform(x13c_ * deltas.xc_rotDelta.toTransform(deltas.x0_posDelta));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -905,6 +927,16 @@ u32 CScriptSpecialFunction::GetSpecialEnding(const CStateManager& mgr) const {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CScriptSpecialFunction::AddOrUpdateEmitter(float pitch, CSfxHandle& handle, u16 id, const zeus::CVector3f& pos,
|
||||||
|
float vol) {
|
||||||
|
if (!handle) {
|
||||||
|
handle = CSfxManager::AddEmitter(id, pos, zeus::skZero3f, vol, true, true, 0x7f, kInvalidAreaId);
|
||||||
|
} else {
|
||||||
|
CSfxManager::UpdateEmitter(handle, pos, zeus::skZero3f, vol);
|
||||||
|
CSfxManager::PitchBend(handle, 8192.f * pitch + 8192.f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CScriptSpecialFunction::SRingController::SRingController(TUniqueId uid, float rotateSpeed, bool reachedTarget)
|
CScriptSpecialFunction::SRingController::SRingController(TUniqueId uid, float rotateSpeed, bool reachedTarget)
|
||||||
: x0_id(uid), x4_rotateSpeed(rotateSpeed), x8_reachedTarget(reachedTarget) {}
|
: x0_id(uid), x4_rotateSpeed(rotateSpeed), x8_reachedTarget(reachedTarget) {}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ private:
|
||||||
CSfxHandle x178_sfxHandle;
|
CSfxHandle x178_sfxHandle;
|
||||||
u32 x17c_;
|
u32 x17c_;
|
||||||
float x180_ = 0.f;
|
float x180_ = 0.f;
|
||||||
std::vector<float> x184_;
|
TReservedAverage<float, 6> x184_;
|
||||||
float x194_ = 0.f;
|
float x194_ = 0.f;
|
||||||
std::vector<SRingController> x198_ringControllers;
|
std::vector<SRingController> x198_ringControllers;
|
||||||
ERingState x1a8_ringState = ERingState::Stopped;
|
ERingState x1a8_ringState = ERingState::Stopped;
|
||||||
|
@ -147,5 +147,6 @@ public:
|
||||||
|
|
||||||
void DeleteEmitter(const CSfxHandle& handle);
|
void DeleteEmitter(const CSfxHandle& handle);
|
||||||
u32 GetSpecialEnding(const CStateManager&) const;
|
u32 GetSpecialEnding(const CStateManager&) const;
|
||||||
|
void AddOrUpdateEmitter(float pitch, CSfxHandle& handle, u16 id, const zeus::CVector3f& pos, float vol);
|
||||||
};
|
};
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
Loading…
Reference in New Issue