Added battles in networking

This commit is contained in:
Vladislav Khorev committed 2026-11-07 14:27:22 +06:00
1 parent be8ee31f03
commit 40527f10ac
8 files changed
+302 -36

No files matched your search

+23 -1
View File
@@ -28,6 +28,12 @@ struct DestinationInputMessage {
Eigen::Vector3f target = Eigen::Vector3f::Zero();
};
struct CharacterActionInputMessage {
std::uint64_t clientSequence = 0;
std::string action;
std::string targetId;
};
struct ScheduledDestinationCommand {
std::uint64_t commandSequence = 0;
std::string playerId;
@@ -41,9 +47,17 @@ struct ScheduledCharacterEnabledCommand {
bool enabled = false;
};
struct ScheduledCharacterActionCommand {
std::uint64_t commandSequence = 0;
std::string playerId;
std::string action;
std::string targetId;
};
using ScheduledCommand = std::variant<
ScheduledDestinationCommand,
ScheduledCharacterEnabledCommand>;
ScheduledCharacterEnabledCommand,
ScheduledCharacterActionCommand>;
struct TickMessage {
std::uint64_t tickId = 0;
@@ -63,6 +77,9 @@ public:
std::uint64_t scheduleCharacterEnabled(
const std::string& locationId, const std::string& characterId,
bool enabled);
std::uint64_t scheduleCharacterAction(
const std::string& playerId, std::string action,
std::string targetId = {});
TickMessage advance();
private:
@@ -78,6 +95,11 @@ bool parseInitialStateMessage(
std::string makeDestinationInputMessage(const DestinationInputMessage& message);
bool parseDestinationInputMessage(
const std::string& text, DestinationInputMessage& message, std::string& error);
std::string makeCharacterActionInputMessage(
const CharacterActionInputMessage& message);
bool parseCharacterActionInputMessage(
const std::string& text, CharacterActionInputMessage& message,
std::string& error);
std::string makeTickMessage(const TickMessage& message);
bool parseTickMessage(
const std::string& text, TickMessage& message, std::string& error);