Improved code clarity, added documentation.
This commit is contained in:
parent
ecff3d56b7
commit
c94380c809
2 changed files with 18 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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> item) {
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
// To avoid weapons continuing to fire after drop and pickup.
|
||||
auto weapon = std::dynamic_pointer_cast<Weapon>(item);
|
||||
if (weapon)
|
||||
weapon->releaseTrigger();
|
||||
|
||||
mWorld.insert(item);
|
||||
item->drop(getPosition());
|
||||
}
|
||||
|
@ -108,21 +119,15 @@ 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);
|
||||
break;
|
||||
case 3:
|
||||
if (mRightGadget)
|
||||
dropItem(mRightGadget);
|
||||
break;
|
||||
}
|
||||
|
|
Reference in a new issue