载入中...
搜索中...
未找到
ClimbingECS.cpp
浏览该文件的文档.
2
3#include <algorithm>
4
5namespace eve::climbing {
6namespace {
7
8} // namespace
9
10eve::Result<void> ClimbingCandidateBuffer::replace(std::span<const ClimbingCandidate> candidates,
12 if (candidates.size() > Capacity)
14 "climbing candidate buffer capacity exceeded",
15 "candidates", {}, "climbing.ecs"));
16 ClimbingCandidateSet replacement;
17 for (const ClimbingCandidate& candidate : candidates) replacement.consider(candidate);
18 replacement.sortAndLimit(Capacity);
19 values_.swap(replacement);
20 tick_ = tick;
22}
23
26 auto probed = runtime.probeInto(world, pose, values_, tick);
27 if (!probed) return eve::Result<void>::failure(probed.status());
28 tick_ = tick;
30}
31
39
41 if (!runtime.isValid())
43 "climbing state has no runtime to release",
44 "state.runtime", {}, "climbing.ecs"));
45 auto released = Climbing::release(runtime);
46 if (!released) return eve::Result<void>::failure(released.status());
47 runtime = {};
48 lastAdvance = {};
51}
52
55 if (events.size() > Capacity)
57 "climbing event batch capacity exceeded", "events", {},
58 "climbing.ecs"));
59 std::array<ClimbingEvent, Capacity> replacement{};
60 std::copy(events.begin(), events.end(), replacement.begin());
61 values_ = std::move(replacement);
62 size_ = events.size();
63 tick_ = tick;
65}
66
67std::span<const ClimbingSystemContract> climbingSystemContracts() noexcept {
68 static constexpr ClimbingSystemContract contracts[] = {
69 {"climbing.input", "caller-selected existing domain root",
70 "View<EntityRoot, ClimbingIntent>", "owning command queue; SimulationTick", "ClimbingIntent",
71 "none", "none", "SimulationStep", "input", "bit-exact for identical command streams"},
72 {"climbing.probe", "caller-selected existing domain root",
73 "View<EntityRoot, ClimbingBody, ClimbingIntent, ClimbingState, ClimbingLinks, ClimbingCandidateBuffer>",
74 "Body; Intent; State runtime; Links; Physics world", "ClimbingCandidateBuffer", "none", "none",
75 "Physics owning queries; SimulationTick", "pre_physics",
76 "stable identity/order; geometry tolerance-bounded"},
77 {"climbing.selection", "caller-selected existing domain root",
78 "View<EntityRoot, ClimbingBody, ClimbingIntent, ClimbingState, ClimbingLinks>",
79 "Body; Intent; definitions; Physics world", "Intent consumed edge; State runtime", "none",
80 "ClimbingStarted queued only after commit", "Physics; definitions; optional resource adapters",
81 "pre_physics", "quantized cost and stable identity tie-break"},
82 {"climbing.motion", "caller-selected existing domain root",
83 "View<EntityRoot, ClimbingBody, ClimbingIntent, ClimbingState, ClimbingLinks>",
84 "State execution; Body; Intent; Links; animation desired root delta",
85 "Body; State runtime; linked Physics body",
86 "none", "contact/land/cancel to bounded runtime queue", "Physics mover; SimulationStep", "physics",
87 "fixed-tick replay stable; Physics contacts tolerance-bounded"},
88 {"climbing.pose", "caller-selected existing domain root",
89 "View<EntityRoot, ClimbingState, ClimbingPoseProjection, ClimbingEventBatch>",
90 "State actual motion and contact anchors", "derived pose projection; owning event batch", "none",
91 "drain only; external dispatch occurs after View closes", "Animation; optional IK", "post_physics",
92 "gameplay state independent of final skin pose"},
93 };
94 return contracts;
95}
96
97} // namespace eve::climbing
eve::EntitySpatialPose pose
Composition-only ECS components and fixed-phase climbing systems.
World3D * world
int created
Battle::Events events
SimulationTick tick
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static constexpr std::size_t Capacity
Definition ClimbingECS.h:68
eve::Result< void > replace(std::span< const ClimbingCandidate > candidates, eve::SimulationTick tick)
Atomically replace the buffer; oversize input leaves the old contents unchanged.
eve::Result< void > probe(ClimbingRuntime &runtime, physics::World3D &world, const ClimbingPose &pose, eve::SimulationTick tick)
Fill retained storage through the allocation-free production probe path.
eve::SimulationTick tick() const noexcept
Tick that produced the current projection.
Definition ClimbingECS.h:83
Fixed-capacity owning candidate set used by the production probe hot path.
Definition Climbing.h:329
void consider(ClimbingCandidate candidate)
Consider one candidate and retain it only when it belongs to the best fixed-capacity set.
Definition Climbing.cpp:23
void swap(ClimbingCandidateSet &other) noexcept
Exchange complete owning slot storage without allocating.
Definition Climbing.cpp:60
void sortAndLimit(std::size_t limit)
Sort by canonical deterministic selection key and clamp to a validated limit.
Definition Climbing.cpp:55
eve::SimulationTick tick() const noexcept
Simulation tick at which the runtime queue was drained.
eve::Result< void > replace(std::span< const ClimbingEvent > events, eve::SimulationTick tick)
Atomically replace the event batch or reject an impossible oversize input.
static constexpr std::size_t Capacity
Owner-thread climbing planner and executor for one character.
Definition Climbing.h:653
static eve::Result< void > release(ClimbingRuntimeHandleRef reference)
Releases a module-owned runtime and invalidates its reference.
static eve::Result< ClimbingRuntimeHandleRef > newRuntime()
Creates a module-owned runtime and returns its generation-qualified reference.
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:63
std::span< const ClimbingSystemContract > climbingSystemContracts() noexcept
Return immutable process-lifetime contracts for the four climbing ECS phases.
Owning, replayable climbing candidate; contains no borrowed query pointers.
Definition Climbing.h:290
Input pose used for one deterministic candidate probe.
Definition Climbing.h:275
Hot authoritative execution component holding the module-owned runtime identity.
Definition ClimbingECS.h:96
ClimbingRuntimeHandleRef runtime
Definition ClimbingECS.h:97
eve::Result< void > releaseRuntime()
Release the runtime once and clear this component's handle.
eve::SimulationTick lastAdvanceTick
Definition ClimbingECS.h:99
ClimbingAdvance lastAdvance
Definition ClimbingECS.h:98
static eve::Result< ClimbingState > create()
Create the canonical module-owned runtime referenced by this component.
Static review/tooling description of one concrete climbing ECS phase.
constexpr bool isValid() const noexcept
Returns whether both the handle and its registry epoch are set.