From 32487dcd5fded2b987d64db8f1563f42e06ec466 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 18 May 2025 19:48:40 -0700 Subject: [PATCH] fix: reverse bounce paths (#1798) --- dGame/dComponents/MovementAIComponent.cpp | 4 +++- dGame/dComponents/MovementAIComponent.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dGame/dComponents/MovementAIComponent.cpp b/dGame/dComponents/MovementAIComponent.cpp index efe711b3..9463e7d6 100644 --- a/dGame/dComponents/MovementAIComponent.cpp +++ b/dGame/dComponents/MovementAIComponent.cpp @@ -54,6 +54,7 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) : m_SourcePosition = m_Parent->GetPosition(); m_Paused = false; m_SavedVelocity = NiPoint3Constant::ZERO; + m_IsBounced = false; if (!m_Parent->GetComponent()) SetPath(m_Parent->GetVarAsString(u"attached_path")); } @@ -158,8 +159,9 @@ void MovementAIComponent::Update(const float deltaTime) { if (m_Path->pathBehavior == PathBehavior::Loop) { SetPath(m_Path->pathWaypoints); } else if (m_Path->pathBehavior == PathBehavior::Bounce) { + m_IsBounced = !m_IsBounced; std::vector waypoints = m_Path->pathWaypoints; - std::reverse(waypoints.begin(), waypoints.end()); + if (m_IsBounced) std::reverse(waypoints.begin(), waypoints.end()); SetPath(waypoints); } else if (m_Path->pathBehavior == PathBehavior::Once) { Stop(); diff --git a/dGame/dComponents/MovementAIComponent.h b/dGame/dComponents/MovementAIComponent.h index 15b5aaed..dbb0661c 100644 --- a/dGame/dComponents/MovementAIComponent.h +++ b/dGame/dComponents/MovementAIComponent.h @@ -321,6 +321,8 @@ private: bool m_Paused; NiPoint3 m_SavedVelocity; + + bool m_IsBounced{}; }; #endif // MOVEMENTAICOMPONENT_H