Remove broad command

This commit is contained in:
Vladislav Khorev committed 2026-11-06 21:30:17 +06:00
1 parent 1ab9f300b6
commit 3f68a8ba07
11 files changed
+120 -160

No files matched your search

+17 -42
View File
@@ -132,18 +132,6 @@ namespace FRG
locationId_, character.entityId(), target, std::move(callbackName)});
}
void Location::updateCharacterState(
Character& character,
const std::function<void(CharacterState&)>& mutation)
{
auto snapshot = character.stateSnapshot();
if (!snapshot) return;
CharacterState stateCopy = *snapshot;
mutation(stateCopy);
gameServer_.submit(CommitCharacterStateCommand{
locationId_, character.entityId(), std::move(stateCopy)});
}
void Location::clearCharacterAttackTarget(Character& character)
{
gameServer_.submit(ClearCharacterAttackTargetCommand{
@@ -1847,7 +1835,6 @@ namespace FRG
void Location::update(int64_t delta, const LocationSimulationEvents& events)
{
pathVisualization.update(delta);
synchronizeRemotePlayers();
auto locationState = stateSnapshot();
if (!locationState) return;
@@ -2022,7 +2009,7 @@ namespace FRG
Eigen::Vector3f camRight(cosAzim, 0.f, sinAzim);
Eigen::Vector3f camForward(sinAzim * cosIncl, -sinIncl, -cosAzim * cosIncl);
Eigen::Vector3f camUp(sinAzim * sinIncl, cosIncl, -cosAzim * sinIncl);
const Eigen::Vector3f playerPos = playerState->position;
const Eigen::Vector3f playerPos = player->renderPosition();
Eigen::Vector3f camPos = playerPos + Eigen::Vector3f(-sinAzim * cosIncl, sinIncl, cosAzim * cosIncl) * Environment::zoom + Eigen::Vector3f(0,1,0);
Eigen::Vector3f rayDir = (camForward + camRight * (ndcX * aspect * tanHalfFov) + camUp * (ndcY * tanHalfFov)).normalized();
@@ -2065,10 +2052,7 @@ namespace FRG
? clickedObject->state.interactionPosition
: clickedObject->state.position;
setCharacterTarget(*player, interactionTarget);
auto updatedPlayerState = player->stateSnapshot();
if (updatedPlayerState && !updatedPlayerState->pathWaypoints.empty()) {
pathVisualization.start(*player, interactionTarget);
}
pathVisualization.start(*player, interactionTarget);
clearCharacterAttackTarget(*player);
//logger() << "[CLICK] Player moving to object..." << std::endl;
}
@@ -2101,21 +2085,17 @@ namespace FRG
tryCharacterAttackCombo(*player);
}
const std::string targetId = clickedNpc->entityId();
updateCharacterState(*player, [targetId](CharacterState& workingState) {
workingState.attackTargetId = targetId;
});
gameServer_.submit(SetCharacterTargetCommand{
locationId_, player->entityId(), targetId});
gameServer_.submit(SetLocationTargetsCommand{
locationId_, std::string(), std::string(), std::string()});
if (distance >= Character::kAttackRange) {
setCharacterTarget(*player, clickedNpcState->position);
auto updatedPlayerState = player->stateSnapshot();
if (updatedPlayerState && !updatedPlayerState->pathWaypoints.empty()) {
pathVisualization.start(
*player,
clickedNpcState->position,
PathVisualization::Style::Hostile);
}
pathVisualization.start(
*player,
clickedNpcState->position,
PathVisualization::Style::Hostile);
}
if (distance <= clickedNpcState->interactionRadius) {
@@ -2131,9 +2111,9 @@ namespace FRG
// Already in talk range — fire immediately, stop, and face the player.
//logger() << "[CLICK] *** SUCCESS: Clicked on NPC index: " << npcIndex << " (in range) ***" << std::endl;
setCharacterTarget(*player, playerState->position);
updateCharacterState(*npcs[npcIndex], [this](CharacterState& workingState) {
workingState.faceTargetId = gameServer_.localPlayerId();
});
gameServer_.submit(SetCharacterFaceTargetCommand{
locationId_, npcs[npcIndex]->entityId(),
gameServer_.localPlayerId()});
scriptEngine.callNpcInteractCallback(clickedNpc->entityId());
gameServer_.submit(SetLocationTargetsCommand{
locationId_, std::string(), std::string(), std::string()});
@@ -2142,10 +2122,7 @@ namespace FRG
//logger() << "[CLICK] NPC " << npcIndex << " out of talk range (distance " << distance
// << " > " << NPC_TALK_DISTANCE << "); walking to NPC..." << std::endl;
setCharacterTarget(*player, clickedNpcState->position);
auto updatedPlayerState = player->stateSnapshot();
if (updatedPlayerState && !updatedPlayerState->pathWaypoints.empty()) {
pathVisualization.start(*player, clickedNpcState->position);
}
pathVisualization.start(*player, clickedNpcState->position);
gameServer_.submit(SetLocationTargetsCommand{
locationId_, std::string(), clickedNpc->entityId(),
std::string()});
@@ -2173,13 +2150,10 @@ namespace FRG
locationId_, std::string(), std::string(),
clickedTeleport->id});
setCharacterTarget(*player, clickedTeleport->position);
auto updatedPlayerState = player->stateSnapshot();
if (updatedPlayerState && !updatedPlayerState->pathWaypoints.empty()) {
pathVisualization.start(
*player,
clickedTeleport->position,
PathVisualization::Style::Teleport);
}
pathVisualization.start(
*player,
clickedTeleport->position,
PathVisualization::Style::Teleport);
clearCharacterAttackTarget(*player);
} else {
const Eigen::Vector3f clickedDestination(hit.x(), 0.f, hit.z());
@@ -2235,6 +2209,7 @@ namespace FRG
void Location::updatePresentation(int64_t delta)
{
dialogueSystem.update(static_cast<int>(delta));
pathVisualization.update(delta);
for (auto& tz : teleportZones)
tz.update(static_cast<float>(delta));
}