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

+28 -9
View File
@@ -136,17 +136,38 @@ struct SetQuestActiveObjectiveCommand {
};
struct SetGlobalIntCommand { std::string key; int value; };
struct SetGlobalFloatCommand { std::string key; float value; };
struct SetCharacterTransformCommand {
struct SetCharacterPositionCommand {
std::string locationId;
std::string characterId;
Eigen::Vector3f position;
bool updateHomePosition = false;
};
struct SetCharacterFacingAngleCommand {
std::string locationId;
std::string characterId;
float angle;
bool setCurrentAngle = false;
};
struct SetCharacterHomePositionCommand {
std::string locationId;
std::string characterId;
Eigen::Vector3f position;
float facingAngle;
};
struct SetCharacterTargetCommand {
std::string locationId;
std::string characterId;
std::string targetId;
};
struct SetCharacterFaceTargetCommand {
std::string locationId;
std::string characterId;
std::string targetId;
};
struct SetCharacterEnabledCommand {
std::string locationId;
std::string characterId;
bool enabled;
};
struct ClearCharacterAttackTargetCommand {
std::string locationId;
std::string characterId;
@@ -196,11 +217,6 @@ struct DamageCharacterCommand {
float amount;
std::string attackerId;
};
struct CommitCharacterStateCommand {
std::string locationId;
std::string characterId;
CharacterState state;
};
struct SetInteractiveObjectActiveCommand {
std::string locationId;
std::string objectId;
@@ -241,8 +257,12 @@ using GameCommand = std::variant<
SetQuestActiveObjectiveCommand,
SetGlobalIntCommand,
SetGlobalFloatCommand,
SetCharacterTransformCommand,
SetCharacterPositionCommand,
SetCharacterFacingAngleCommand,
SetCharacterHomePositionCommand,
SetCharacterTargetCommand,
SetCharacterFaceTargetCommand,
SetCharacterEnabledCommand,
ClearCharacterAttackTargetCommand,
SetCharacterDestinationCommand,
StopCharacterCommand,
@@ -253,7 +273,6 @@ using GameCommand = std::variant<
SetCharacterHealthCommand,
SetCharacterAnimationMetadataCommand,
DamageCharacterCommand,
CommitCharacterStateCommand,
SetInteractiveObjectActiveCommand,
SetTriggerZoneEnabledCommand,
ReloadQuestDefinitionsCommand>;
+32 -7
View File
@@ -378,18 +378,47 @@ void InternalGameServer::submit(const GameCommand& command)
state_.globalInts[value.key] = value.value;
} else if constexpr (std::is_same_v<T, SetGlobalFloatCommand>) {
state_.globalFloats[value.key] = value.value;
} else if constexpr (std::is_same_v<T, SetCharacterTransformCommand>) {
} else if constexpr (std::is_same_v<T, SetCharacterPositionCommand>) {
CharacterState* character =
state_.findCharacter(value.locationId, value.characterId);
if (character) {
character->position = value.position;
character->facingAngle = value.facingAngle;
character->targetFacingAngle = value.facingAngle;
if (value.updateHomePosition)
character->homePosition = value.position;
}
} else if constexpr (std::is_same_v<T, SetCharacterFacingAngleCommand>) {
CharacterState* character =
state_.findCharacter(value.locationId, value.characterId);
if (character) {
character->targetFacingAngle = value.angle;
if (value.setCurrentAngle)
character->facingAngle = value.angle;
}
} else if constexpr (std::is_same_v<T, SetCharacterHomePositionCommand>) {
CharacterState* character =
state_.findCharacter(value.locationId, value.characterId);
if (character)
character->homePosition = value.position;
} else if constexpr (std::is_same_v<T, SetCharacterTargetCommand>) {
CharacterState* character =
state_.findCharacter(value.locationId, value.characterId);
if (character) character->attackTargetId = value.targetId;
} else if constexpr (std::is_same_v<T, SetCharacterFaceTargetCommand>) {
CharacterState* character =
state_.findCharacter(value.locationId, value.characterId);
if (character) character->faceTargetId = value.targetId;
} else if constexpr (std::is_same_v<T, SetCharacterEnabledCommand>) {
CharacterState* character =
state_.findCharacter(value.locationId, value.characterId);
if (character) {
character->enabled = value.enabled;
character->attack = 0;
character->attack_cooldown = 0;
character->currentState = AnimationState::STAND;
if (character->canAttack)
character->attackTargetId = "player";
character->battle_state = 0;
}
} else if constexpr (std::is_same_v<T, ClearCharacterAttackTargetCommand>) {
CharacterState* character =
state_.findCharacter(value.locationId, value.characterId);
@@ -445,10 +474,6 @@ void InternalGameServer::submit(const GameCommand& command)
CharacterState* character =
state_.findCharacter(value.locationId, value.characterId);
if (character) character->hp = (std::max)(0.f, character->hp - (std::max)(0.f, value.amount));
} else if constexpr (std::is_same_v<T, CommitCharacterStateCommand>) {
CharacterState* character =
state_.findCharacter(value.locationId, value.characterId);
if (character) *character = value.state;
} else if constexpr (std::is_same_v<T, SetInteractiveObjectActiveCommand>) {
auto location = state_.locations.find(value.locationId);
if (location == state_.locations.end()) return;