Skip to content

Commit

Permalink
Merge pull request #1057 from OutpostUniverse/DecayedRoadsSlowTrucks
Browse files Browse the repository at this point in the history
Decayed roads slow trucks
  • Loading branch information
ldicker83 authored Sep 27, 2021
2 parents 3683c36 + ef48a09 commit 9345b14
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions OPHD/Constants/Numbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ namespace constants
inline constexpr int RobotCommRange{15};
inline constexpr int LanderCommRange{5};

inline constexpr int RoadIntegrityChange{80};

inline constexpr float RouteBaseCost{0.5f};
inline constexpr float RouteRoadCost{0.25f};
}
15 changes: 14 additions & 1 deletion OPHD/Map/TileMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,20 @@ void TileMap::AdjacentCost(void* state, std::vector<micropather::StateCost>* adj
}
else if (adjacentTile.thingIsStructure() && adjacentTile.structure()->structureId() == StructureID::SID_ROAD)
{
cost = 0.5f;
Structure& road = *adjacentTile.structure();

if (road.state() != StructureState::Operational)
{
cost *= static_cast<float>(TerrainType::Difficult) + 1.0f;
}
else if (road.integrity() < constants::RoadIntegrityChange)
{
cost = 0.75f;
}
else
{
cost = 0.5f;
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion OPHD/States/MapViewStateTurn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void MapViewState::updateRoads()

std::string tag = "";

if (road->integrity() < 80) { tag = "-decayed"; }
if (road->integrity() < constants::RoadIntegrityChange) { tag = "-decayed"; }
else if (road->integrity() == 0) { tag = "-destroyed"; }

road->sprite().play(IntersectionPatternTable.at(surroundingTiles) + tag);
Expand Down

0 comments on commit 9345b14

Please sign in to comment.