载入中...
搜索中...
未找到
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
36
39 float x = 0.f;
40 float y = 0.f;
41 float heading = 0.f;
42 float speed = 0.f;
43 float health = 0.f;
44 std::string faction;
45 bool destroyed = false;
46};
47
57public:
62 [[nodiscard]] static eve::Result<VehicleDefinitionRuntime> create(
65
67 [[nodiscard]] static eve::Result<VehicleDefinitionRuntime> create(
68 eve::definitions::DefinitionRegistry& registry, std::string_view definitionId, eve::PersistentId instanceId,
70
72 [[nodiscard]] static eve::Result<VehicleDefinitionRuntime> create(
73 Vehicle& module, std::string_view definitionId, eve::PersistentId instanceId,
75
79 VehicleDefinitionRuntime& operator=(VehicleDefinitionRuntime&&) noexcept = default;
84
86 [[nodiscard]] const eve::definition::InstanceIdentity& identity() const noexcept;
88 [[nodiscard]] const VehicleRuntimeState& state() const noexcept;
90 [[nodiscard]] VehicleRuntimeState& state() noexcept;
92 [[nodiscard]] eve::definition::DefinitionHandle definitionHandle() const noexcept;
94 [[nodiscard]] eve::Result<VehicleDefinition> definition() const;
96 [[nodiscard]] eve::definition::ReloadPolicy reloadPolicy() const noexcept { return policy_; }
98 void setActive(bool active) noexcept;
100 [[nodiscard]] bool isActive() const noexcept;
101
107 [[nodiscard]] eve::Result<void> applyTo(VehicleEntity* entity) const;
108
110 [[nodiscard]] eve::Result<eve::definition::ReloadOutcome> reload(eve::definition::ReloadPolicy policy);
111
114 const eve::SnapshotHashProvider& hashProvider) const;
116 [[nodiscard]] eve::Result<std::string> snapshotJson(eve::Revision revision, eve::SimulationTick tick,
117 const eve::SnapshotHashProvider& hashProvider) const;
122 [[nodiscard]] eve::Result<void> restore(const eve::SnapshotEnvelope& snapshot,
123 const eve::SnapshotHashProvider& hashProvider);
124
125private:
126 VehicleDefinitionRuntime(eve::definitions::DefinitionRegistry& registry,
127 eve::definition::RuntimeInstance<VehicleRuntimeState> runtime,
128 eve::definition::ReloadPolicy policy)
129 : registry_(&registry), runtime_(std::move(runtime)), policy_(policy) {}
130
131 eve::definitions::DefinitionRegistry* registry_ = nullptr; // borrowed
134};
135
136} // namespace eve::vehicle
bool & active
Common identity and hot-reload contract for typed runtime instances.
#define EVENGINE_API_DOMAINS
Definition Export.h:110
std::uint64_t revision
Shared SnapshotEnvelope codec for typed definition runtime instances.
Versioned, integrity-checked persistence envelopes.
LogicalId definition
SimulationTick tick
const UnitySourceAsset & source
const std::map< std::string, Value > & definitions
Stable definition reference backed by LogicalId.
Definition ResourceRef.h:85
Move-only operation result carrying either a value or Status.
Definition Result.h:155
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:112
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.