summary refs log tree commit diff stats
path: root/src/systems
diff options
context:
space:
mode:
Diffstat (limited to 'src/systems')
-rw-r--r--src/systems/playing.cpp8
-rw-r--r--src/systems/pondering.cpp26
-rw-r--r--src/systems/pondering.h14
3 files changed, 36 insertions, 12 deletions
diff --git a/src/systems/playing.cpp b/src/systems/playing.cpp index b04f0cb..acec4e7 100644 --- a/src/systems/playing.cpp +++ b/src/systems/playing.cpp
@@ -79,11 +79,7 @@ void PlayingSystem::changeMap(
79 auto& transformable = game_.getEntityManager(). 79 auto& transformable = game_.getEntityManager().
80 getComponent<TransformableComponent>(player); 80 getComponent<TransformableComponent>(player);
81 81
82 auto& animatable = game_.getEntityManager(). 82 auto& pondering = game_.getSystemManager().getSystem<PonderingSystem>();
83 getComponent<AnimatableComponent>(player);
84
85 auto& ponderable = game_.getEntityManager().
86 getComponent<PonderableComponent>(player);
87 83
88 auto& realizing = game_.getSystemManager().getSystem<RealizingSystem>(); 84 auto& realizing = game_.getSystemManager().getSystem<RealizingSystem>();
89 85
@@ -105,6 +101,8 @@ void PlayingSystem::changeMap(
105 playable.mapId = newMapEntity; 101 playable.mapId = newMapEntity;
106 } 102 }
107 103
104 pondering.unferry(player);
105
108 transformable.x = x; 106 transformable.x = x;
109 transformable.y = y; 107 transformable.y = y;
110 108
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,
diff --git a/src/systems/pondering.h b/src/systems/pondering.h index b195814..adc0cda 100644 --- a/src/systems/pondering.h +++ b/src/systems/pondering.h
@@ -16,8 +16,22 @@ public:
16 16
17 void initializeBody(id_type entity, PonderableComponent::Type type); 17 void initializeBody(id_type entity, PonderableComponent::Type type);
18 18
19 /**
20 * Initializes a ponderable map object from its prototype data.
21 *
22 * @requires entity is ponderable
23 * @requires entity is a map object
24 */
19 void initPrototype(id_type prototype); 25 void initPrototype(id_type prototype);
20 26
27 /**
28 * Unferries an entity if it is a passenger of another entity. Use before
29 * moving a ponderable entity outside the PonderingSystem.
30 *
31 * @requires entity is ponderable
32 */
33 void unferry(id_type entity);
34
21private: 35private:
22 36
23 struct CollisionResult 37 struct CollisionResult