Working about pathfinding
This commit is contained in:
1 parent
6a5adb1c79
commit
c6d98bd72a
25 files changed
+1997
-508
No files matched your search
@@ -323,9 +323,9 @@ void InternalGameServer::submit(const GameCommand& command)
|
||||
LocationNetworkState& locationState = *location->second.location;
|
||||
locationState.activeNavigationIndex = value.index;
|
||||
for (const auto& [id, player] : state_.players)
|
||||
if (player) player->forceReplan(locationState, id);
|
||||
if (player) location->second.replanCharacter(id, state_.players);
|
||||
for (const auto& [id, npc] : location->second.npcs)
|
||||
if (npc) npc->forceReplan(locationState, id);
|
||||
if (npc) location->second.replanCharacter(id, state_.players);
|
||||
}
|
||||
} else if constexpr (std::is_same_v<T, SetNavigationAreaAvailableCommand>) {
|
||||
auto location = state_.locations.find(value.locationId);
|
||||
@@ -336,6 +336,10 @@ void InternalGameServer::submit(const GameCommand& command)
|
||||
index < static_cast<int>(locationState.navigationMaps.size())) {
|
||||
locationState.navigationMaps[index].setAreaAvailable(
|
||||
value.areaName, value.available);
|
||||
for (const auto& [id, player] : state_.players)
|
||||
if (player) location->second.replanCharacter(id, state_.players);
|
||||
for (const auto& [id, npc] : location->second.npcs)
|
||||
if (npc) location->second.replanCharacter(id, state_.players);
|
||||
}
|
||||
}
|
||||
} else if constexpr (std::is_same_v<T, AddNavigationObstacleCommand>) {
|
||||
@@ -349,6 +353,10 @@ void InternalGameServer::submit(const GameCommand& command)
|
||||
polygon.name = value.name;
|
||||
polygon.polygon = value.polygon;
|
||||
locationState.navigationMaps[index].addObstaclePolygon(polygon);
|
||||
for (const auto& [id, player] : state_.players)
|
||||
if (player) location->second.replanCharacter(id, state_.players);
|
||||
for (const auto& [id, npc] : location->second.npcs)
|
||||
if (npc) location->second.replanCharacter(id, state_.players);
|
||||
}
|
||||
}
|
||||
} else if constexpr (std::is_same_v<T, AddInventoryItemCommand>) {
|
||||
@@ -424,14 +432,10 @@ void InternalGameServer::submit(const GameCommand& command)
|
||||
if (character) character->attackTargetId.clear();
|
||||
} else if constexpr (std::is_same_v<T, SetCharacterDestinationCommand>) {
|
||||
auto location = state_.locations.find(value.locationId);
|
||||
CharacterState* character =
|
||||
state_.findCharacter(value.locationId, value.characterId);
|
||||
if (character && location != state_.locations.end() &&
|
||||
location->second.location) {
|
||||
character->setTarget(
|
||||
value.target, value.callbackName,
|
||||
*location->second.location, value.characterId);
|
||||
}
|
||||
if (location != state_.locations.end())
|
||||
location->second.setCharacterDestination(
|
||||
value.characterId, value.target, value.callbackName,
|
||||
state_.players);
|
||||
} else if constexpr (std::is_same_v<T, StopCharacterCommand>) {
|
||||
CharacterState* character =
|
||||
state_.findCharacter(value.locationId, value.characterId);
|
||||
@@ -443,13 +447,9 @@ void InternalGameServer::submit(const GameCommand& command)
|
||||
character->stopAndRotateToTarget(value.targetId);
|
||||
} else if constexpr (std::is_same_v<T, ReplanCharacterCommand>) {
|
||||
auto location = state_.locations.find(value.locationId);
|
||||
CharacterState* character =
|
||||
state_.findCharacter(value.locationId, value.characterId);
|
||||
if (character && location != state_.locations.end() &&
|
||||
location->second.location) {
|
||||
character->forceReplan(
|
||||
*location->second.location, value.characterId);
|
||||
}
|
||||
if (location != state_.locations.end())
|
||||
location->second.replanCharacter(
|
||||
value.characterId, state_.players);
|
||||
} else if constexpr (std::is_same_v<T, ResetCharacterAfterDeathCommand>) {
|
||||
CharacterState* character =
|
||||
state_.findCharacter(value.locationId, value.characterId);
|
||||
@@ -518,13 +518,14 @@ void InternalGameServer::update(std::int64_t deltaMs)
|
||||
for (const CharacterSimulationEvent& event :
|
||||
pendingSimulationEvents_.characters) {
|
||||
if (!event.events.navigationRequested) continue;
|
||||
CharacterState* character = state_.findCharacter(
|
||||
state_.currentLocationName, event.characterId);
|
||||
if (character && stored->second.location) {
|
||||
character->setTarget(
|
||||
event.events.navigationTarget, {},
|
||||
*stored->second.location, event.characterId);
|
||||
}
|
||||
if (event.events.forceNavigationReplan)
|
||||
stored->second.replanCharacter(
|
||||
event.characterId, state_.players,
|
||||
event.events.blockingCharacterId);
|
||||
else
|
||||
stored->second.setCharacterDestination(
|
||||
event.characterId, event.events.navigationTarget, {},
|
||||
state_.players);
|
||||
}
|
||||
publishMutation();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user