summary refs log tree commit diff stats
path: root/src/systems/pondering.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-05-04 10:23:02 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-05-09 17:59:13 -0400
commit123192db10cdf5244f27d08256ece738f60a9e2c (patch)
tree9636a010c6f0ce4f0f7ea31822136affdfac3137 /src/systems/pondering.cpp
parent69c04dfb6c49e7b2d34a6699c071f037880fbde5 (diff)
downloadtherapy-123192db10cdf5244f27d08256ece738f60a9e2c.tar.gz
therapy-123192db10cdf5244f27d08256ece738f60a9e2c.tar.bz2
therapy-123192db10cdf5244f27d08256ece738f60a9e2c.zip
Unferried players while changing maps
This fixes the third problem described in 8f1c4f1 -- that if a ferried body's transform is modified outside of the PonderingSystem, it will not be unferried as appropriate. This does still require that any future code that modifies a body's transform also unferries the body first.
Diffstat (limited to 'src/systems/pondering.cpp')
-rw-r--r--src/systems/pondering.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/systems/pondering.cpp b/src/systems/pondering.cpp index ccfd66f..4aa47f2 100644 --- a/src/systems/pondering.cpp +++ b/src/systems/pondering.cpp
@@ -655,7 +655,7 @@ void PonderingSystem::tick(double dt)
655 } 655 }
656 } 656 }
657 657
658 // Handle ferry passengers 658 // Ferry or unferry as necessary
659 if ((ponderable.type == PonderableComponent::Type::freefalling) && 659 if ((ponderable.type == PonderableComponent::Type::freefalling) &&
660 (ponderable.grounded != oldGrounded)) 660 (ponderable.grounded != oldGrounded))
661 { 661 {
@@ -674,15 +674,11 @@ void PonderingSystem::tick(double dt)
674 } else if (ponderable.ferried) 674 } else if (ponderable.ferried)
675 { 675 {
676 // The body is no longer being ferried 676 // The body is no longer being ferried
677 ponderable.ferried = false; 677 unferry(entity);
678
679 auto& ferryPonder = game_.getEntityManager().
680 getComponent<PonderableComponent>(ponderable.ferry);
681
682 ferryPonder.passengers.erase(entity);
683 } 678 }
684 } 679 }
685 680
681 // Update a ferry passenger's relative position
686 if (ponderable.ferried) 682 if (ponderable.ferried)
687 { 683 {
688 auto& ferryTrans = game_.getEntityManager(). 684 auto& ferryTrans = game_.getEntityManager().
@@ -768,6 +764,22 @@ void PonderingSystem::initPrototype(id_type prototype)
768 ponderable.passengers.clear(); 764 ponderable.passengers.clear();
769} 765}
770 766
767void PonderingSystem::unferry(id_type entity)
768{
769 auto& ponderable = game_.getEntityManager().
770 getComponent<PonderableComponent>(entity);
771
772 if (ponderable.ferried)
773 {
774 ponderable.ferried = false;
775
776 auto& ferryPonder = game_.getEntityManager().
777 getComponent<PonderableComponent>(ponderable.ferry);
778
779 ferryPonder.passengers.erase(entity);
780 }
781}
782
771void PonderingSystem::processCollision( 783void PonderingSystem::processCollision(
772 id_type entity, 784 id_type entity,
773 id_type collider, 785 id_type collider,