载入中...
搜索中...
未找到
CombatLocomotion.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
7#include "common/Result.h"
8#include "common/SubjectRef.h"
9#include "common/Time.h"
10
11#include <map>
12#include <optional>
13#include <string>
14#include <vector>
15
16namespace eve::combat {
17
20 double x = 0.0;
21 double z = 0.0;
22};
23
27 std::string ownerId;
29 double maximumSpeed = 0.0;
30 double acceleration = 0.0;
31
33 [[nodiscard]] Result<void> validate() const;
34};
35
41
55
57enum class CombatNavigationPhase : std::uint8_t { Moving, Arrived };
58
65
74public:
76 virtual ~ICombatNavigationProvider() = default;
77
86 const CombatNavigationGoal& goal,
88};
89
99
101enum class CombatLocomotionEventKind : std::uint8_t { Moved, Arrived };
102
111
115 std::vector<CombatLocomotionEvent> events;
116};
117
126public:
130 explicit CombatLocomotionRuntime(ICombatNavigationProvider& provider) : navigation_(&provider) {}
131
133 void setNavigationProvider(ICombatNavigationProvider& provider) noexcept { navigation_ = &provider; }
135 void clearNavigationProvider() noexcept { navigation_ = nullptr; }
137 [[nodiscard]] Result<void> registerSubject(CombatLocomotionDefinition definition);
139 [[nodiscard]] Result<void> unregisterSubject(SubjectRef subject);
148 [[nodiscard]] Result<void> setMoveIntent(SubjectRef subject, CombatVector2 direction,
149 double speedFraction);
151 [[nodiscard]] Result<void> navigateTo(SubjectRef subject, CombatNavigationGoal goal);
153 [[nodiscard]] Result<void> stop(SubjectRef subject);
155 [[nodiscard]] Result<CombatLocomotionAdvance> advance(const SimulationStep& step);
157 [[nodiscard]] std::vector<CombatLocomotionState> states() const;
158
159private:
160 std::map<std::string, CombatLocomotionState, std::less<>> states_;
161 ICombatNavigationProvider* navigation_ = nullptr;
162 SimulationTick lastTick_ = SimulationTick::zero();
163};
164
165} // namespace eve::combat
int subject
Definition AnimSmr.cpp:163
#define EVENGINE_API_BACKENDS
Definition Export.h:108
Move-only, checked operation results for the common layer.
RoadLaneDirection direction
Stable reference to a runtime gameplay subject.
LogicalId definition
SimulationTick tick
Common time values and an injectable deterministic simulation clock.
float step
Definition TreeMesh.cpp:314
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Strong, domain-neutral reference to a runtime subject.
Definition SubjectRef.h:26
Owner-thread combat locomotion authority shared by player and navigation commands.
CombatLocomotionRuntime(ICombatNavigationProvider &provider)
Construct borrowing a provider that must outlive this runtime or be cleared.
void clearNavigationProvider() noexcept
Remove the borrowed provider; advancing an active goal then fails observably.
void setNavigationProvider(ICombatNavigationProvider &provider) noexcept
Install a borrowed provider; active goals remain owned by this runtime.
CombatLocomotionRuntime()=default
Construct without an installed navigation provider.
Straight-line obstacle-free provider useful for arenas and deterministic tests.
Optional synchronous navigation boundary consumed by combat locomotion.
virtual Result< CombatNavigationSteering > steer(const CombatLocomotionState &state, const CombatNavigationGoal &goal, SimulationTick tick)=0
Resolve steering for one subject without mutating locomotion state.
virtual ~ICombatNavigationProvider()=default
Releases ICombatNavigationProvider resources.
static constexpr StrongUint64 zero() noexcept
Returns the zero value for this strong type.
CombatLocomotionEventKind
Observable committed locomotion event.
CombatNavigationPhase
Navigation steering status for the current deterministic step.
One deterministic fixed-step emitted by SimulationClock.
Definition Time.h:158
Complete owning result of one committed locomotion frame.
std::vector< CombatLocomotionEvent > events
Immutable registration data for one locomotion subject.
Result< void > validate() const
Validate identity and finite positive movement limits.
Owning event emitted after a successful complete locomotion frame.
Owning read-only projection of one registered combat subject.
std::optional< CombatNavigationGoal > navigationGoal
Owning navigation goal retained by the locomotion authority.
Owning output produced by an optional navigation adapter.
Finite position or direction in the horizontal combat plane.