diff --git a/src/sprites/Tile.cpp b/src/sprites/Tile.cpp index e2edda0..affcc2a 100644 --- a/src/sprites/Tile.cpp +++ b/src/sprites/Tile.cpp @@ -65,13 +65,17 @@ Tile::getConfig(Type type) { return ""; } } + +/** + * Returns true if collisions with this tile type are enabled. + */ bool Tile::isSolid(Type type) { switch (type) { case Type::FLOOR: return false; case Type::WALL: - // falltrough + return true; default: return true; } diff --git a/src/sprites/abstract/Character.cpp b/src/sprites/abstract/Character.cpp index 65a5dea..f6056e4 100644 --- a/src/sprites/abstract/Character.cpp +++ b/src/sprites/abstract/Character.cpp @@ -91,7 +91,18 @@ Character::getFaction() const { return mFaction; } +/** + * Inserts the item into the world. Does not remove it from the Character. + */ void Character::dropItem(std::shared_ptr item) { + if (!item) + return; + + // To avoid weapons continuing to fire after drop and pickup. + auto weapon = std::dynamic_pointer_cast(item); + if (weapon) + weapon->releaseTrigger(); + mWorld.insert(item); item->drop(getPosition()); } @@ -108,22 +119,16 @@ Character::onDeath() { else switch (rand() % 3) { case 0: - // To avoid weapons continuing to fire after drop and pickup. - mFirstWeapon->releaseTrigger(); dropItem(mFirstWeapon); break; case 1: - // Same here. - mSecondWeapon->releaseTrigger(); dropItem(mSecondWeapon); break; case 2: - if (mLeftGadget) - dropItem(mLeftGadget); + dropItem(mLeftGadget); break; case 3: - if (mRightGadget) - dropItem(mRightGadget); + dropItem(mRightGadget); break; } }