45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "evo/simulation/world.hpp"
|
|
|
|
#include <optional>
|
|
#include <variant>
|
|
|
|
namespace evo {
|
|
inline constexpr std::uint32_t scheduler_version = 1;
|
|
inline constexpr std::size_t max_commands_per_tick = 1'024;
|
|
|
|
struct CreateEntity {
|
|
Position2 position{};
|
|
};
|
|
struct RemoveEntity {
|
|
EntityId id;
|
|
};
|
|
struct Command {
|
|
std::uint64_t sequence;
|
|
std::variant<CreateEntity, RemoveEntity> operation;
|
|
};
|
|
struct CommandReceipt {
|
|
std::uint64_t sequence;
|
|
EntityId entity;
|
|
auto operator<=>(const CommandReceipt&) const = default;
|
|
};
|
|
enum class ScheduleErrorCode : std::uint8_t {
|
|
wrong_tick,
|
|
batch_limit,
|
|
invalid_sequence,
|
|
duplicate_sequence,
|
|
simulation_failure
|
|
};
|
|
struct ScheduleError {
|
|
ScheduleErrorCode code;
|
|
std::uint64_t sequence{};
|
|
std::optional<Error> cause{};
|
|
};
|
|
|
|
// Single-owner call. No input is retained. Rejection leaves world unchanged.
|
|
// target is the next completed tick; receipts follow ascending sequence.
|
|
[[nodiscard]] std::expected<std::vector<CommandReceipt>, ScheduleError>
|
|
advance(SimulationWorld& world, Tick target, std::span<const Command> commands = {});
|
|
} // namespace evo
|