载入中...
搜索中...
未找到
SmartObject.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Result.h"
7#include "npc_ai/NpcAi.h"
8
9#include <array>
10#include <cstdint>
11#include <functional>
12#include <map>
13#include <optional>
14#include <string>
15#include <string_view>
16#include <vector>
17
18namespace eve::npc_ai {
19
26
28enum class SmartObjectRemoval : std::uint8_t { RejectClaimed, CancelClaims };
29
32 std::string id;
33 std::string activity;
34 std::vector<std::string> tags;
35 std::array<double, 3> position{};
36};
37
40 std::string logicalId;
41 std::vector<SmartObjectSlotDefinition> slots;
42};
43
46 std::string activity;
47 std::vector<std::string> requiredTags;
48 std::array<double, 3> origin{};
49 double maxDistance = 0.0;
50};
51
55 std::string logicalId;
56 std::string slotId;
57 std::array<double, 3> position{};
58 double distance = 0.0;
59};
60
69
72 std::uint32_t claimsExpired = 0;
73};
74
77 std::string logicalId;
78 std::string slotId;
80 std::uint64_t tick = 0;
81 std::string reason;
82};
83
94public:
98 [[nodiscard]] Result<void> removeObject(SmartObjectHandle object, SmartObjectRemoval policy);
100 [[nodiscard]] Result<std::vector<SmartObjectCandidate>> query(const SmartObjectQuery& query) const;
102 [[nodiscard]] Result<SmartObjectClaimHandle> claim(AgentHandle agent, SmartObjectHandle object,
103 std::string_view slotId, std::uint64_t currentTick,
104 std::uint64_t leaseTicks);
106 [[nodiscard]] Result<void> renew(SmartObjectClaimHandle claim, AgentHandle agent, std::uint64_t currentTick,
107 std::uint64_t leaseTicks);
109 [[nodiscard]] Result<void> release(SmartObjectClaimHandle claim, AgentHandle agent);
111 [[nodiscard]] Result<std::uint32_t> releaseAgentClaims(AgentHandle agent);
113 [[nodiscard]] Result<SmartObjectExpirationReport> expire(std::uint64_t currentTick);
117 [[nodiscard]] int vacancyCount() const noexcept;
119 [[nodiscard]] Result<SmartObjectVacancy> vacancyAt(int index) const;
121 void clearVacancies() noexcept;
122
123private:
124 struct Object {
126 std::map<std::string, SmartObjectClaimHandle> claimsBySlot;
127 };
128 struct Claim {
130 std::string slotId;
131 AgentHandle agent;
132 std::uint64_t expiresAtTick = 0;
133 };
134 struct ObjectSlot {
135 std::uint32_t generation = 1;
136 std::optional<Object> value;
137 };
138 struct ClaimSlot {
139 std::uint32_t generation = 1;
140 std::optional<Claim> value;
141 };
142
144 [[nodiscard]] Result<std::reference_wrapper<const Object>> resolveObject(SmartObjectHandle handle) const;
147 void releaseClaimUnchecked(SmartObjectClaimHandle handle, std::string_view reason, std::uint64_t tick) noexcept;
148
149 std::vector<ObjectSlot> objects_;
150 std::vector<std::uint32_t> freeObjects_;
151 std::vector<ClaimSlot> claims_;
152 std::vector<std::uint32_t> freeClaims_;
153 std::map<std::string, SmartObjectHandle> objectsByLogicalId_;
154 std::vector<SmartObjectVacancy> vacancies_;
155};
156
157} // namespace eve::npc_ai
Generation generation
Definition ECS.cpp:40
EnvironmentTest definition
#define EVENGINE_API_PLATFORM
Definition Export.h:107
Snapshot snapshot
PrimitiveHandle handle
Object::Ptr value
Move-only, checked operation results for the common layer.
Strong generation-qualified handles for non-ECS runtime registries.
SimulationTick tick
Json object
uint32_t index
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Authoritative registry and lease manager for reservable world interactions.
Definition SmartObject.h:93
SmartObjectRemoval
SmartObjectRemoval public API.
Definition SmartObject.h:28
SmartObjectCandidate public API.
Definition SmartObject.h:53
std::array< double, 3 > position
Definition SmartObject.h:57
SmartObjectClaimHandleTag public API.
Definition SmartObject.h:23
SmartObjectClaimSnapshot public API.
Definition SmartObject.h:62
SmartObjectDefinition public API.
Definition SmartObject.h:39
std::vector< SmartObjectSlotDefinition > slots
Definition SmartObject.h:41
SmartObjectExpirationReport public API.
Definition SmartObject.h:71
SmartObjectHandleTag public API.
Definition SmartObject.h:21
SmartObjectQuery public API.
Definition SmartObject.h:45
std::array< double, 3 > origin
Definition SmartObject.h:48
std::vector< std::string > requiredTags
Definition SmartObject.h:47
SmartObjectSlotDefinition public API.
Definition SmartObject.h:31
std::vector< std::string > tags
Definition SmartObject.h:34
std::array< double, 3 > position
Definition SmartObject.h:35
One freed smart-object seat after release, expiry, cancel, or agent cleanup.
Definition SmartObject.h:76
std::string reason
"release" | "expire" | "cancel" | "agent"
Definition SmartObject.h:81