载入中...
搜索中...
未找到
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
85public:
89 [[nodiscard]] Result<void> removeObject(SmartObjectHandle object, SmartObjectRemoval policy);
91 [[nodiscard]] Result<std::vector<SmartObjectCandidate>> query(const SmartObjectQuery& query) const;
93 [[nodiscard]] Result<SmartObjectClaimHandle> claim(AgentHandle agent, SmartObjectHandle object,
94 std::string_view slotId, std::uint64_t currentTick,
95 std::uint64_t leaseTicks);
97 [[nodiscard]] Result<void> renew(SmartObjectClaimHandle claim, AgentHandle agent, std::uint64_t currentTick,
98 std::uint64_t leaseTicks);
100 [[nodiscard]] Result<void> release(SmartObjectClaimHandle claim, AgentHandle agent);
102 [[nodiscard]] Result<std::uint32_t> releaseAgentClaims(AgentHandle agent);
104 [[nodiscard]] Result<SmartObjectExpirationReport> expire(std::uint64_t currentTick);
106 [[nodiscard]] Result<SmartObjectClaimSnapshot> snapshot(SmartObjectClaimHandle claim) const;
107
108private:
109 struct Object {
111 std::map<std::string, SmartObjectClaimHandle> claimsBySlot;
112 };
113 struct Claim {
115 std::string slotId;
116 AgentHandle agent;
117 std::uint64_t expiresAtTick = 0;
118 };
119 struct ObjectSlot {
120 std::uint32_t generation = 1;
121 std::optional<Object> value;
122 };
123 struct ClaimSlot {
124 std::uint32_t generation = 1;
125 std::optional<Claim> value;
126 };
127
129 [[nodiscard]] Result<std::reference_wrapper<const Object>> resolveObject(SmartObjectHandle handle) const;
132 void releaseClaimUnchecked(SmartObjectClaimHandle handle) noexcept;
133
134 std::vector<ObjectSlot> objects_;
135 std::vector<std::uint32_t> freeObjects_;
136 std::vector<ClaimSlot> claims_;
137 std::vector<std::uint32_t> freeClaims_;
138 std::map<std::string, SmartObjectHandle> objectsByLogicalId_;
139};
140
141} // namespace eve::npc_ai
double value
#define EVENGINE_API_PLATFORM
Definition Export.h:107
std::uint32_t generation
PrimitiveHandle handle
std::function< eve::Result< void >()> release
Definition Procgen.cpp:86
Move-only, checked operation results for the common layer.
Strong generation-qualified handles for non-ECS runtime registries.
LogicalId definition
Json object
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Authoritative registry and lease manager for reservable world interactions.
Definition SmartObject.h:84
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