summary refs log tree commit diff stats
path: root/src/input_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_system.cpp')
-rw-r--r--src/input_system.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/input_system.cpp b/src/input_system.cpp index 38423a2..c399e91 100644 --- a/src/input_system.cpp +++ b/src/input_system.cpp
@@ -87,25 +87,17 @@ void InputSystem::tick(double dt) {
87 vec2i checkLoc = sprite.loc + (unitVecInDirection(sprite.dir) * LUCAS_MOVEMENT_SPEED); 87 vec2i checkLoc = sprite.loc + (unitVecInDirection(sprite.dir) * LUCAS_MOVEMENT_SPEED);
88 CollisionResult collision = game_.getSystem<TransformSystem>().checkCollision(spriteId, sprite.loc, checkLoc, sprite.dir); 88 CollisionResult collision = game_.getSystem<TransformSystem>().checkCollision(spriteId, sprite.loc, checkLoc, sprite.dir);
89 89
90 if (collision.horiz.blocked || collision.vert.blocked) { 90 if (collision.blocked) {
91 inFrontOfSomething = true; 91 inFrontOfSomething = true;
92 } 92 }
93 93
94 // If there is a sprite to be interacted with, rotate that sprite so it is facing the player. 94 // If there is a sprite to be interacted with, rotate that sprite so it is facing the player.
95 // Then, run its interaction script if present. 95 // Then, run its interaction script if present.
96 if (collision.horiz.colliderSprite != -1) { 96 for (int colliderSpriteId : collision.colliders) {
97 game_.getSystem<AnimationSystem>().setSpriteDirection(collision.horiz.colliderSprite, oppositeDirection(sprite.dir)); 97 game_.getSystem<AnimationSystem>().setSpriteDirection(colliderSpriteId, oppositeDirection(sprite.dir));
98 98
99 Sprite& collider = game_.getSprite(collision.horiz.colliderSprite); 99 Sprite& collider = game_.getSprite(colliderSpriteId);
100 if (collider.interactionScript != "") { 100 if (!collider.interactionScript.empty()) {
101 game_.getSystem<ScriptSystem>().runScript(game_.getMap().getName(), collider.interactionScript);
102 activated = true;
103 }
104 } else if (collision.vert.colliderSprite != -1) {
105 game_.getSystem<AnimationSystem>().setSpriteDirection(collision.vert.colliderSprite, oppositeDirection(sprite.dir));
106
107 Sprite& collider = game_.getSprite(collision.vert.colliderSprite);
108 if (collider.interactionScript != "") {
109 game_.getSystem<ScriptSystem>().runScript(game_.getMap().getName(), collider.interactionScript); 101 game_.getSystem<ScriptSystem>().runScript(game_.getMap().getName(), collider.interactionScript);
110 activated = true; 102 activated = true;
111 } 103 }