Decided to just implement auto it reload since it feels better on the player end. Also added much needed logging for tileset loading
This commit is contained in:
parent
ff8bcf3480
commit
02403b142a
2 changed files with 17 additions and 7 deletions
|
|
@ -94,7 +94,8 @@ bool Weapon::shoot()
|
|||
sol::error err = result;
|
||||
std::cerr << "lua error: " << err.what() << std::endl;
|
||||
}
|
||||
weaponMag -= 1;
|
||||
// auto reload
|
||||
if ((weaponMag -= 1) <= 0) reload();
|
||||
}
|
||||
}
|
||||
else if (weaponMag <= 0) reload();
|
||||
|
|
|
|||
|
|
@ -440,12 +440,21 @@ bool XMLLoader::loadTile(tinyxml2::XMLElement* tileElement, TileSetData::TileDat
|
|||
Notice we just return true if there is no property, we can just safely default to walkable = true
|
||||
*/
|
||||
tinyxml2::XMLElement* properties = tileElement->FirstChildElement("properties");
|
||||
if (properties == NULL)
|
||||
return true;
|
||||
tinyxml2::XMLElement* propWalk = properties->FirstChildElement("property");
|
||||
if (propWalk == NULL || !propWalk->Attribute("name", "walkable"))
|
||||
return true;
|
||||
propWalk->QueryBoolAttribute("value", &tileData.walkable);
|
||||
if (properties == NULL) {
|
||||
LOG(WARN, "No properties found on tile id: {} assuming defaults", tileData.id);
|
||||
} else {
|
||||
tinyxml2::XMLElement* propWalk = properties->FirstChildElement("property");
|
||||
if (propWalk == NULL) {
|
||||
LOG(WARN, "No walkable propery found on tile id: {} assuming walkable", tileData.id);
|
||||
} else {
|
||||
for (auto& prop = propWalk; prop != NULL; prop = prop->NextSiblingElement()) {
|
||||
if (prop->Attribute("name", "walkable")) {
|
||||
prop->QueryBoolAttribute("value", &tileData.walkable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tileData.type = tileType;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue