载入中...
搜索中...
未找到
VehicleDefinitionRuntime.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
15#include "common/Snapshot.h"
20
21#include <string>
22#include <string_view>
23
24namespace eve::vehicle {
25
26class Vehicle;
27
37
40 float x = 0.f;
41 float y = 0.f;
42 float heading = 0.f;
43 float speed = 0.f;
44 float health = 0.f;
45 std::string faction;
46 bool destroyed = false;
47};
48
58public:
63 [[nodiscard]] static eve::Result<VehicleDefinitionRuntime> create(
66
68 [[nodiscard]] static eve::Result<VehicleDefinitionRuntime> create(
71
73 [[nodiscard]] static eve::Result<VehicleDefinitionRuntime> create(
74 Vehicle& module, std::string_view definitionId, eve::PersistentId instanceId,
76
80 VehicleDefinitionRuntime& operator=(VehicleDefinitionRuntime&&) noexcept = default;
85
87 [[nodiscard]] const eve::definition::InstanceIdentity& identity() const noexcept;
89 [[nodiscard]] const VehicleRuntimeState& state() const noexcept;
91 [[nodiscard]] VehicleRuntimeState& state() noexcept;
93 [[nodiscard]] eve::definition::DefinitionHandle definitionHandle() const noexcept;
95 [[nodiscard]] eve::Result<VehicleDefinition> definition() const;
97 [[nodiscard]] eve::definition::ReloadPolicy reloadPolicy() const noexcept { return policy_; }
99 void setActive(bool active) noexcept;
101 [[nodiscard]] bool isActive() const noexcept;
102
108 [[nodiscard]] eve::Result<void> applyTo(VehicleEntity* entity) const;
109
111 [[nodiscard]] eve::Result<eve::definition::ReloadOutcome> reload(eve::definition::ReloadPolicy policy);
112
115 const eve::SnapshotHashProvider& hashProvider) const;
117 [[nodiscard]] eve::Result<std::string> snapshotJson(eve::Revision revision, eve::SimulationTick tick,
118 const eve::SnapshotHashProvider& hashProvider) const;
123 [[nodiscard]] eve::Result<void> restore(const eve::SnapshotEnvelope& snapshot,
124 const eve::SnapshotHashProvider& hashProvider);
125
126private:
127 VehicleDefinitionRuntime(eve::definitions::DefinitionRegistry& registry,
128 eve::definition::RuntimeInstance<VehicleRuntimeState> runtime,
129 eve::definition::ReloadPolicy policy)
130 : registry_(&registry), runtime_(std::move(runtime)), policy_(policy) {}
131
132 eve::definitions::DefinitionRegistry* registry_ = nullptr; // borrowed
135};
136
137} // namespace eve::vehicle
bool & active
std::uint64_t revision
Common identity and hot-reload contract for typed runtime instances.
EnvironmentTest definition
int instanceId
#define EVENGINE_API_DOMAINS
Definition Export.h:110
std::map< unsigned, Colour > definitions
const eve::script::BindingContractRegistry & registry
const EntityFact * entity
Shared SnapshotEnvelope codec for typed definition runtime instances.
std::string_view source
Versioned, integrity-checked persistence envelopes.
SimulationTick tick
uint64_t identity
Stable definition reference backed by LogicalId.
Definition ResourceRef.h:85
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Owns one strongly typed runtime state and its definition identity.
Deterministic registry of topic-neutral, versioned JSON definitions.
Definition Definitions.h:58
Id128 public API.
Definition Identity.h:111
Binds a VehicleDefinition to a VehicleEntity without a new root type.
VehicleDefinitionRuntime(VehicleDefinitionRuntime &&) noexcept=default
Vehicle definition runtime.
载具实体:数据全部在组件里,行为在 VehicleSystem。
载具模块(eve.Vehicle)。
Definition Vehicle.h:33
ReloadPolicy
Policy used when a live definition is replaced.
@ RebuildInstance
Let the consumer atomically construct a new state from the new definition.
驾驶者接口与玩家控制状态。
eve::Result< VehicleDefinition > parseVehicleDefinition(const eve::definitions::Definition &source)
Parse one canonical registry definition into a short-lived typed projection.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
std::function< Result< ContentId >(std::string_view canonicalInput)> SnapshotHashProvider
Injected content-digest implementation used by snapshots.
Definition Snapshot.h:36
Stable outer format shared by persistence and cross-process snapshots.
Definition Snapshot.h:46
One immutable view of a registered versioned JSON definition.
Definition Definitions.h:31
载具模板(registerVehiclesFromJson 注册,进程级注册表)。
Mutable state owned by one typed vehicle runtime instance.