diff --git a/Sources/Jazz2/Actors/ActorBase.cpp b/Sources/Jazz2/Actors/ActorBase.cpp index 7f2c01ab..bba1af10 100644 --- a/Sources/Jazz2/Actors/ActorBase.cpp +++ b/Sources/Jazz2/Actors/ActorBase.cpp @@ -443,7 +443,7 @@ namespace Jazz2::Actors } } - bool ActorBase::SetAnimation(AnimState state) + bool ActorBase::SetAnimation(AnimState state, bool skipAnimation) { if (_metadata == nullptr) { LOGE("No metadata loaded"); @@ -475,7 +475,7 @@ namespace Jazz2::Actors } _currentAnimation = anim; - RefreshAnimation(); + RefreshAnimation(skipAnimation); return true; } @@ -1017,12 +1017,12 @@ namespace Jazz2::Actors AABB.B = AABB.T + size.Y; } } else { - OnUpdateHitbox(); + OnUpdateHitbox(); AABB = AABBInner; } } - void ActorBase::RefreshAnimation() + void ActorBase::RefreshAnimation(bool skipAnimation) { GraphicResource* res = (_currentTransition != nullptr ? _currentTransition : _currentAnimation); if (res == nullptr) { @@ -1041,13 +1041,12 @@ namespace Jazz2::Actors _renderer.LoopMode = AnimationLoopMode::FixedSingle; } else { _renderer.FirstFrame = res->FrameOffset; - _renderer.LoopMode = res->LoopMode; } _renderer.FrameCount = res->FrameCount; _renderer.AnimDuration = res->AnimDuration; - _renderer.AnimTime = 0.0f; + _renderer.AnimTime = (skipAnimation && res->AnimDuration >= 0.0f && _renderer.LoopMode != AnimationLoopMode::FixedSingle ? _renderer.AnimDuration : 0.0f); _renderer.Hotspot.X = -((res->Base->FrameDimensions.X / 2) - (IsFacingLeft() ? (res->Base->FrameDimensions.X - res->Base->Hotspot.X) : res->Base->Hotspot.X)); _renderer.Hotspot.Y = -((res->Base->FrameDimensions.Y / 2) - res->Base->Hotspot.Y); diff --git a/Sources/Jazz2/Actors/ActorBase.h b/Sources/Jazz2/Actors/ActorBase.h index 043ccd1c..b9e81799 100644 --- a/Sources/Jazz2/Actors/ActorBase.h +++ b/Sources/Jazz2/Actors/ActorBase.h @@ -293,7 +293,7 @@ namespace Jazz2::Actors virtual float GetIceShrapnelScale() const; std::shared_ptr PlaySfx(const StringView& identifier, float gain = 1.0f, float pitch = 1.0f); - bool SetAnimation(AnimState state); + bool SetAnimation(AnimState state, bool skipAnimation = false); bool SetTransition(AnimState state, bool cancellable, const std::function& callback = nullptr); bool SetTransition(AnimState state, bool cancellable, std::function&& callback); void CancelTransition(); @@ -352,6 +352,6 @@ namespace Jazz2::Actors bool IsCollidingWithAngled(ActorBase* other); bool IsCollidingWithAngled(const AABBf& aabb); - void RefreshAnimation(); + void RefreshAnimation(bool skipAnimation = false); }; } \ No newline at end of file diff --git a/Sources/Jazz2/Actors/Environment/Spring.cpp b/Sources/Jazz2/Actors/Environment/Spring.cpp index 16b05d0f..ec392159 100644 --- a/Sources/Jazz2/Actors/Environment/Spring.cpp +++ b/Sources/Jazz2/Actors/Environment/Spring.cpp @@ -104,7 +104,7 @@ namespace Jazz2::Actors::Environment _strength = 1.50f; break; case 2: // Blue - _strength = 1.65f; + _strength = (_levelHandler->IsReforged() ? 1.65f : 1.72f); break; } } diff --git a/Sources/Jazz2/Actors/Player.cpp b/Sources/Jazz2/Actors/Player.cpp index 7b75fd75..8f9c6ccc 100644 --- a/Sources/Jazz2/Actors/Player.cpp +++ b/Sources/Jazz2/Actors/Player.cpp @@ -403,7 +403,7 @@ namespace Jazz2::Actors if (_fireFramesLeft <= 0.0f) { // Play post-fire animation - if ((_currentAnimation->State & (AnimState::Walk | AnimState::Run | AnimState::Dash | AnimState::Crouch | AnimState::Buttstomp | AnimState::Swim | AnimState::Airboard | AnimState::Lift | AnimState::Spring)) == AnimState::Idle && + if ((_currentAnimation->State & (AnimState::Walk | AnimState::Run | AnimState::Dash | AnimState::Buttstomp | AnimState::Swim | AnimState::Airboard | AnimState::Lift | AnimState::Spring)) == AnimState::Idle && (_currentTransition == nullptr || (_currentTransition->State != AnimState::TransitionRunToIdle && _currentTransition->State != AnimState::TransitionDashToIdle)) && !_isAttachedToPole) { @@ -414,6 +414,8 @@ namespace Jazz2::Actors SetTransition(AnimState::TransitionCopterShootToCopter, false); } else if ((_currentAnimation->State & AnimState::Fall) == AnimState::Fall) { SetTransition(AnimState::TransitionFallShootToFall, false); + } else if ((_currentAnimation->State & AnimState::Crouch) == AnimState::Crouch) { + SetAnimation(AnimState::Crouch, true); } else { SetTransition(AnimState::TransitionShootToIdle, false); } @@ -721,7 +723,9 @@ namespace Jazz2::Actors if (GetState(ActorState::CanJump)) { if (!_isLifting && std::abs(_speed.X) < std::numeric_limits::epsilon()) { _wasDownPressed = true; - SetAnimation(AnimState::Crouch); + if (_fireFramesLeft <= 0.0f) { + SetAnimation(AnimState::Crouch); + } } } else if (!_wasDownPressed && _playerType != PlayerType::Frog) { _wasDownPressed = true; diff --git a/Sources/nCine/Base/HashFunctions.h b/Sources/nCine/Base/HashFunctions.h index b4999b56..c93338ed 100644 --- a/Sources/nCine/Base/HashFunctions.h +++ b/Sources/nCine/Base/HashFunctions.h @@ -265,7 +265,7 @@ namespace nCine } }; - template + template class FNV1aHashFunc> { public: @@ -365,6 +365,16 @@ namespace nCine } }; + template + class CityHash32Func> + { + public: + hash_t operator()(const Pair& pair) const + { + return CityHash32Func()(pair.first()) ^ CityHash32Func()(pair.second()); + } + }; + template class CityHash64Func { @@ -384,4 +394,14 @@ namespace nCine return CityHash64(string.data(), string.size()); } }; + + template + class CityHash64Func> + { + public: + hash64_t operator()(const Pair& pair) const + { + return CityHash64Func()(pair.first()) ^ CityHash64Func()(pair.second()); + } + }; } \ No newline at end of file