Mirrored world positions and query composition; consumers decide gameplay actions from results. 更多...
#include <Sensing.h>
Public 成员函数 | |
| Result< void > | upsertPosition (std::string_view id, float x, float y, float z, std::string_view faction, std::string_view tagsCsv, std::string_view visibleToCsv) |
| Inserts actual XYZ coordinates and metadata; owns copies, no retained arguments. | |
| eve::Result< void > | upsert (std::string_view id, float x, float y, std::string_view faction, std::string_view tagsCsv, std::string_view visibleToCsv) |
| Compatibility-only XY insertion; delegates to upsertPosition with Z zero. | |
| eve::Result< void > | remove (std::string_view id) |
| Removes mirrored facts, or returns NotFound when the id is absent. | |
| eve::Result< void > | setZones (std::string_view id, std::string_view zonesCsv) |
| Replaces logical zone membership for an existing subject. | |
| eve::Result< void > | setMetrics (std::string_view id, float pathProgress, float strength) |
| Updates route/threat metrics used by TD-style SortKey policies. | |
| eve::Result< void > | setSpatialIndexEnabled (bool enabled, float cellSize=64.f) |
| Enables or disables an compatibility-only XY broadphase; delegates to rebuildIndex (off by default). | |
| Result< void > | rebuildIndex (SpatialIndexKind kind, float cellSize) |
| Rebuilds the derived index from owned facts; no coordinate conversion is stored. | |
| SpatialIndexKind | indexKind () const noexcept |
| Current broad-phase selection, independent of query distance semantics. | |
| bool | spatialIndexEnabled () const noexcept |
| Reports whether the optional spatial broadphase is active. | |
| eve::Result< CandidateQueryResult > | query (const QueryOrigin &origin, const QuerySpec &spec) |
| Runs a configurable candidate query. | |
| Result< CandidateQueryResult > | query (const QueryOrigin &origin, const QuerySpec &spec, OptionalRef< const ILineOfSightQuery > lineOfSight) |
| Runs the same query with an explicitly injected LOS backend, before result limits. @ownership Provider is borrowed only until return; results own coordinates and ids. @thread Simulation thread; provider must not mutate or re-enter this world. @cost Candidate scan plus one LOS call per accepted candidate; reuse the configured index. Scales with accepted candidates, not with a full unit-array walk. | |
| eve::Result< CandidateCollection > | collectCandidates (const QueryOrigin &origin, const QuerySpec &spec) const |
| Collects matching facts without sorting, truncation or result-cache mutation. | |
| Result< EnvironmentRequest > | environmentInput (const QueryOrigin &origin, const QuerySpec &spec) const |
| Snapshots matching subjects as typed input for a compiled environment query. @cost One bounded broad-phase scan and owning projection per request; no result publication. | |
| Result< EnvironmentQueryResult > | executeEnvironmentQuery (const EnvironmentQueryPlan &plan, EnvironmentRequest request, const EnvironmentServices &services) |
| Runs a prepared environment query and publishes its diagnostic trace for MCP. @ownership Inputs are owned values; services are borrowed only until return. @thread Simulation thread; does not mutate facts or the legacy resultAt cache. @reentrancy Provider callbacks must not re-enter this world. @cost Executes the compiled candidate/test plan once; retain plans between calls. | |
| Result< Value > | queryPositions (float originX, float originY, float targetX, float targetY, float radius, int samples, int limit, bool requireLineOfSight) |
| Script convenience for ring positions ranked by distance from the origin. | |
| eve::Result< int > | circle (float x, float y, float radius, std::string_view requireTagsCsv, std::string_view excludeTagsCsv, std::string_view includeFactionsCsv, std::string_view excludeFactionsCsv, std::string_view visibleTo, int limit) |
| Queries a circle. Filters are CSV; empty fields disable that filter. | |
| eve::Result< int > | circleSorted (float x, float y, float radius, std::string_view requireTagsCsv, std::string_view excludeTagsCsv, std::string_view includeFactionsCsv, std::string_view excludeFactionsCsv, std::string_view visibleTo, int limit, std::string_view sortPolicy) |
| Circle query with an explicit targeting sort policy. | |
| eve::Result< int > | box (float minX, float minY, float maxX, float maxY, std::string_view requireTagsCsv, std::string_view excludeTagsCsv, std::string_view includeFactionsCsv, std::string_view excludeFactionsCsv, std::string_view visibleTo, int limit) |
| Queries an axis-aligned box with the same filters as circle(). | |
| eve::Result< int > | executePreset (std::string_view presetId, float originX, float originY, float dirX, float dirY) |
| Runs a registered TargetingPreset against this world and refreshes resultAt(). | |
| eve::OptionalRef< const Candidate > | resultAt (int index) const |
| Returns a candidate from the most recent query, or null for an invalid index. | |
| std::string | debugLastQueryJson () const |
| Deterministic JSON dump of the last successful query for MCP/debug overlays. | |
| std::string | snapshotJson () const |
| Exports deterministic JSON. | |
| eve::Result< void > | restoreJson (const std::string &json) |
| Restores a snapshot transactionally. | |
| const std::map< std::string, Subject > & | subjects () const noexcept |
| Returns a borrowed view of stored subjects for adapters; valid until mutation. | |
| SensingWorld () | |
| ~SensingWorld () | |
| Sensing world. | |
| SensingWorld (const SensingWorld &)=delete | |
| SensingWorld & | operator= (const SensingWorld &)=delete |
| SensingWorld (SensingWorld &&) noexcept | |
| Sensing world. | |
| SensingWorld & | operator= (SensingWorld &&) noexcept |
| Operator =. | |
详细描述
Mirrored world positions and query composition; consumers decide gameplay actions from results.
构造及析构函数说明
◆ SensingWorld() [1/3]
|
default |
◆ ~SensingWorld()
| eve::sensing::SensingWorld::~SensingWorld | ( | ) |
Sensing world.
在文件 Sensing.cpp 第 142 行定义.
◆ SensingWorld() [2/3]
|
delete |
◆ SensingWorld() [3/3]
|
defaultnoexcept |
Sensing world.
成员函数说明
◆ box()
| eve::Result< int > eve::sensing::SensingWorld::box | ( | float | minX, |
| float | minY, | ||
| float | maxX, | ||
| float | maxY, | ||
| std::string_view | requireTagsCsv, | ||
| std::string_view | excludeTagsCsv, | ||
| std::string_view | includeFactionsCsv, | ||
| std::string_view | excludeFactionsCsv, | ||
| std::string_view | visibleTo, | ||
| int | limit | ||
| ) |
Queries an axis-aligned box with the same filters as circle().
在文件 Sensing.cpp 第 891 行定义.
引用了 a, b, c, d, eve::Result< T >::failure(), limit, query(), r, result, size, eve::Result< T >::success() , 以及 v.
◆ circle()
| eve::Result< int > eve::sensing::SensingWorld::circle | ( | float | x, |
| float | y, | ||
| float | radius, | ||
| std::string_view | requireTagsCsv, | ||
| std::string_view | excludeTagsCsv, | ||
| std::string_view | includeFactionsCsv, | ||
| std::string_view | excludeFactionsCsv, | ||
| std::string_view | visibleTo, | ||
| int | limit | ||
| ) |
Queries a circle. Filters are CSV; empty fields disable that filter.
在文件 Sensing.cpp 第 868 行定义.
引用了 eve::Result< T >::failure(), limit, query(), r, radius, result, size, eve::Result< T >::success(), v, x , 以及 y.
◆ circleSorted()
| eve::Result< int > eve::sensing::SensingWorld::circleSorted | ( | float | x, |
| float | y, | ||
| float | radius, | ||
| std::string_view | requireTagsCsv, | ||
| std::string_view | excludeTagsCsv, | ||
| std::string_view | includeFactionsCsv, | ||
| std::string_view | excludeFactionsCsv, | ||
| std::string_view | visibleTo, | ||
| int | limit, | ||
| std::string_view | sortPolicy | ||
| ) |
Circle query with an explicit targeting sort policy.
- 参数
-
sortPolicy One of: closest, furthest, first, last, strongest, weakest, distance, none.
在文件 Sensing.cpp 第 877 行定义.
引用了 eve::Result< T >::failure(), limit, query(), r, radius, result, size, eve::Result< T >::success(), v, value, x , 以及 y.
◆ collectCandidates()
| eve::Result< CandidateCollection > eve::sensing::SensingWorld::collectCandidates | ( | const QueryOrigin & | origin, |
| const QuerySpec & | spec | ||
| ) | const |
Collects matching facts without sorting, truncation or result-cache mutation.
- 返回
- Owning candidates and broad-phase counters; invalid input is rejected. @cost Scans the broad-phase set once per request; use a bounded shape and reuse its output. @thread World simulation thread; no callbacks and no retained input references.
在文件 Sensing.cpp 第 671 行定义.
引用了 accepts, eve::sensing::QuerySpec::axes, candidates, distance, eve::sensing::RankedCandidate::distance, eve::Diagnostic::error(), eve::Result< T >::failure(), finite, eve::sensing::RankedCandidate::id, eve::InvalidArgument, eve::sensing::QuerySpec::maxRange, origin, ox, oy, eve::sensing::RankedCandidate::pathProgress, eve::sensing::RankedCandidate::score, eve::sensing::RankedCandidate::scoreReason, eve::sensing::QuerySpec::shape, eve::sensing::RankedCandidate::space, eve::sensing::RankedCandidate::strength, subject, eve::Result< T >::success(), sx, sy, valid, eve::sensing::QuerySpec::validate(), eve::sensing::World2D, eve::sensing::World3D, eve::sensing::RankedCandidate::x, eve::sensing::XY, eve::sensing::XYZ, eve::sensing::RankedCandidate::y , 以及 eve::sensing::RankedCandidate::z.
被这些函数引用 environmentInput() , 以及 query().
◆ debugLastQueryJson()
| std::string eve::sensing::SensingWorld::debugLastQueryJson | ( | ) | const |
Deterministic JSON dump of the last successful query for MCP/debug overlays.
- 返回
- Schema
eve.sensing.lastQuerywith origin, shape, spatial stats, and ranked scores.
- 备注
- Empty ranked list when no query has succeeded yet. Does not assign primary.
在文件 Sensing.cpp 第 929 行定义.
引用了 eve::sensing::coordinateSpaceName(), first, quote , 以及 spatialIndexEnabled().
◆ environmentInput()
| Result< EnvironmentRequest > eve::sensing::SensingWorld::environmentInput | ( | const QueryOrigin & | origin, |
| const QuerySpec & | spec | ||
| ) | const |
Snapshots matching subjects as typed input for a compiled environment query. @cost One bounded broad-phase scan and owning projection per request; no result publication.
在文件 SensingEnvironment.cpp 第 8 行定义.
引用了 a, b, candidates, collectCandidates(), eve::Result< T >::failure(), origin, request, eve::Result< T >::success(), eve::sensing::WorldPoint::world2D(), eve::sensing::World3D , 以及 eve::sensing::WorldPoint::world3D().
◆ executeEnvironmentQuery()
| Result< EnvironmentQueryResult > eve::sensing::SensingWorld::executeEnvironmentQuery | ( | const EnvironmentQueryPlan & | plan, |
| EnvironmentRequest | request, | ||
| const EnvironmentServices & | services | ||
| ) |
Runs a prepared environment query and publishes its diagnostic trace for MCP. @ownership Inputs are owned values; services are borrowed only until return. @thread Simulation thread; does not mutate facts or the legacy resultAt cache. @reentrancy Provider callbacks must not re-enter this world. @cost Executes the compiled candidate/test plan once; retain plans between calls.
在文件 SensingEnvironment.cpp 第 25 行定义.
引用了 eve::Result< T >::failure(), ok, request, result, eve::sensing::EnvironmentTrace::state , 以及 trace.
被这些函数引用 queryPositions().
◆ executePreset()
| eve::Result< int > eve::sensing::SensingWorld::executePreset | ( | std::string_view | presetId, |
| float | originX, | ||
| float | originY, | ||
| float | dirX, | ||
| float | dirY | ||
| ) |
Runs a registered TargetingPreset against this world and refreshes resultAt().
- 参数
-
presetId Stable preset id (e.g. "sensing.builtin.coneSelect"). originX Origin X used as QueryOrigin and cone apex. originY Origin Y used as QueryOrigin and cone apex. dirX Forward X for cone filter tasks (normalized on use). dirY Forward Y for cone filter tasks (normalized on use).
- 返回
- Number of ranked candidates, or a structured failure. @thread Call on the sensing world's owning simulation thread.
在文件 Sensing.cpp 第 902 行定义.
引用了 context, count, eve::sensing::TargetingPipeline::executePreset(), eve::Result< T >::failure(), eve::sensing::TargetingPipeline::sharedBuiltins(), eve::Result< T >::success(), eve::sensing::TargetingSourceContext::world , 以及 eve::sensing::World2D.
◆ indexKind()
|
noexcept |
Current broad-phase selection, independent of query distance semantics.
在文件 Sensing.cpp 第 427 行定义.
◆ operator=() [1/2]
|
delete |
◆ operator=() [2/2]
|
defaultnoexcept |
Operator =.
◆ query() [1/2]
| eve::Result< CandidateQueryResult > eve::sensing::SensingWorld::query | ( | const QueryOrigin & | origin, |
| const QuerySpec & | spec | ||
| ) |
Runs a configurable candidate query.
- 返回
- Owning ranked candidates, or a structured failure.
- 备注
- Also refreshes the resultAt() cache to match ranked() order. @thread Call on the sensing world's owning simulation thread. @cost Scales with broad-phase hits and maxCount (and optional LOS), not with full world size when a spatial index is configured. Prefer this over scanning every unit.
在文件 Sensing.cpp 第 725 行定义.
被这些函数引用 box(), circle(), circleSorted(), query() , 以及 eve::sensing::SensingWorldCandidateProvider::query().
◆ query() [2/2]
| Result< CandidateQueryResult > eve::sensing::SensingWorld::query | ( | const QueryOrigin & | origin, |
| const QuerySpec & | spec, | ||
| OptionalRef< const ILineOfSightQuery > | lineOfSight | ||
| ) |
Runs the same query with an explicitly injected LOS backend, before result limits. @ownership Provider is borrowed only until return; results own coordinates and ids. @thread Simulation thread; provider must not mutate or re-enter this world. @cost Candidate scan plus one LOS call per accepted candidate; reuse the configured index. Scales with accepted candidates, not with a full unit-array walk.
在文件 Sensing.cpp 第 729 行定义.
引用了 a, b, collectCandidates(), eve::sensing::QuerySpec::countPolicy, eve::sensing::DistanceAscending, eve::sensing::DistanceDescending, error, eve::Diagnostic::error(), EV_PROFILE_MODULE, eve::Failed, eve::Result< T >::failure(), from, eve::sensing::QuerySpec::maxCount, eve::sensing::QuerySpec::minCount, eve::sensing::None, origin, eve::sensing::PathProgressAscending, eve::sensing::PathProgressDescending, eve::PreconditionViolation, eve::sensing::QuerySpec::requireLineOfSight, eve::sensing::QuerySpec::shape, eve::sensing::QuerySpec::sortKey, eve::sensing::StrengthAscending, eve::sensing::StrengthDescending, eve::Result< T >::success(), to, eve::sensing::TruncateToMax, eve::Unsupported, value, visible, eve::sensing::WorldPoint::world2D(), eve::sensing::World3D , 以及 eve::sensing::WorldPoint::world3D().
◆ queryPositions()
| Result< Value > eve::sensing::SensingWorld::queryPositions | ( | float | originX, |
| float | originY, | ||
| float | targetX, | ||
| float | targetY, | ||
| float | radius, | ||
| int | samples, | ||
| int | limit, | ||
| bool | requireLineOfSight | ||
| ) |
Script convenience for ring positions ranked by distance from the origin.
- 返回
- Versioned owning result data, or structured input/provider failure. @cost Compiles and runs a ring query per call; C++ repeated callers should retain a plan. @thread Simulation thread; optional LOS is resolved at this composition boundary.
在文件 SensingEnvironment.cpp 第 49 行定义.
引用了 eve::sensing::All, eve::sensing::Best, eve::sensing::EnvironmentQueryPlan::compile(), eve::sensing::EnvironmentGenerator::context, eve::sensing::EnvironmentTest::context, eve::sensing::EnvironmentRequest::contexts, eve::sensing::Detailed, distance, eve::Diagnostic::error(), executeEnvironmentQuery(), eve::Result< T >::failure(), eve::sensing::Filter, eve::sensing::EnvironmentOption::generator, eve::sensing::EnvironmentTest::id, eve::sensing::EnvironmentOption::id, eve::InvalidArgument, eve::sensing::EnvironmentGenerator::kind, limit, eve::sensing::EnvironmentServices::lineOfSight, eve::sensing::LineOfSight, eve::sensing::EnvironmentTest::maximum, eve::sensing::EnvironmentTest::metric, eve::sensing::EnvironmentTest::minimum, origin, eve::sensing::EnvironmentTest::purpose, radius, eve::sensing::EnvironmentGenerator::radius, request, result, eve::sensing::Ring, eve::sensing::EnvironmentGenerator::samples, eve::sensing::Score, eve::Result< T >::success(), target, targetX, eve::sensing::EnvironmentOption::tests , 以及 eve::sensing::WorldPoint::world2D().
◆ rebuildIndex()
| Result< void > eve::sensing::SensingWorld::rebuildIndex | ( | SpatialIndexKind | kind, |
| float | cellSize | ||
| ) |
Rebuilds the derived index from owned facts; no coordinate conversion is stored.
- 返回
- InvalidArgument for an invalid kind, size or unrepresentable indexed coordinate. @cost Linear in subject count per explicit rebuild; configure outside query loops. @thread Simulation thread; no callbacks. Validation failure preserves the existing index.
在文件 Sensing.cpp 第 430 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), finite, eve::InvalidArgument, kind, eve::sensing::None, subject, eve::Status::success(), eve::Result< T >::success() , 以及 eve::sensing::XYZ.
被这些函数引用 setSpatialIndexEnabled().
◆ remove()
| eve::Result< void > eve::sensing::SensingWorld::remove | ( | std::string_view | id | ) |
Removes mirrored facts, or returns NotFound when the id is absent.
在文件 Sensing.cpp 第 376 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), key, eve::NotFound, eve::Status::success() , 以及 eve::Result< T >::success().
◆ restoreJson()
| eve::Result< void > eve::sensing::SensingWorld::restoreJson | ( | const std::string & | json | ) |
Restores a snapshot transactionally.
在文件 Sensing.cpp 第 965 行定义.
引用了 a, d, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, n, eve::json::Document::parse(), eve::ParseError, size, subject, eve::Result< T >::success() , 以及 v.
◆ resultAt()
| eve::OptionalRef< const Candidate > eve::sensing::SensingWorld::resultAt | ( | int | index | ) | const |
Returns a candidate from the most recent query, or null for an invalid index.
- 返回
- Borrowed nullable candidate owned by the query result cache. @ownership SensingWorld owns the candidate cache; callers must not delete or mutate it. @lifetime Valid until the next query/circle/box, restore, or world destruction; copy it for later use. @thread Call on the sensing world's owning simulation thread. @reentrancy Do not retain across a callback or another query.
在文件 Sensing.cpp 第 925 行定义.
◆ setMetrics()
| eve::Result< void > eve::sensing::SensingWorld::setMetrics | ( | std::string_view | id, |
| float | pathProgress, | ||
| float | strength | ||
| ) |
Updates route/threat metrics used by TD-style SortKey policies.
- 参数
-
id Existing subject id. pathProgress Finite route progress (higher = closer to exit / First). strength Finite strength / HP proxy (higher = Strongest).
- 返回
- Applied on success, NotFound when absent, InvalidArgument for non-finite values. @thread Sensing world owner thread; no callbacks.
在文件 Sensing.cpp 第 408 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), finite, eve::InvalidArgument, key, eve::NotFound, strength, eve::Status::success() , 以及 eve::Result< T >::success().
◆ setSpatialIndexEnabled()
| eve::Result< void > eve::sensing::SensingWorld::setSpatialIndexEnabled | ( | bool | enabled, |
| float | cellSize = 64.f |
||
| ) |
Enables or disables an compatibility-only XY broadphase; delegates to rebuildIndex (off by default).
- 参数
-
enabled When true, rebuilds the index from current subjects. cellSize Uniform grid cell size; must be finite and > 0 when enabling.
- 返回
- Applied on success, or InvalidArgument when cellSize is invalid.
- 备注
- Filtering/sorting remain QuerySpec-owned; the hash only culls candidates. @thread Call on the sensing world's owning simulation thread.
在文件 Sensing.cpp 第 423 行定义.
引用了 enabled, eve::sensing::None, rebuildIndex() , 以及 eve::sensing::XY.
◆ setZones()
| eve::Result< void > eve::sensing::SensingWorld::setZones | ( | std::string_view | id, |
| std::string_view | zonesCsv | ||
| ) |
Replaces logical zone membership for an existing subject.
- 参数
-
id Subject id that must already be registered. zonesCsv Comma-separated LogicalId texts (e.g. "arena:central"); empty clears membership.
- 返回
- Applied on success, NotFound when absent, or InvalidArgument for empty/invalid zone ids. @thread Call on the sensing world's owning simulation thread.
在文件 Sensing.cpp 第 387 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, key, eve::NotFound, eve::LogicalId::parse(), eve::Status::success() , 以及 eve::Result< T >::success().
◆ snapshotJson()
| std::string eve::sensing::SensingWorld::snapshotJson | ( | ) | const |
◆ spatialIndexEnabled()
|
noexcept |
Reports whether the optional spatial broadphase is active.
在文件 Sensing.cpp 第 428 行定义.
被这些函数引用 debugLastQueryJson() , 以及 upsertPosition().
◆ subjects()
|
inlinenoexcept |
Returns a borrowed view of stored subjects for adapters; valid until mutation.
被这些函数引用 eve::sensing::SensingWorldCandidateProvider::query().
◆ upsert()
| eve::Result< void > eve::sensing::SensingWorld::upsert | ( | std::string_view | id, |
| float | x, | ||
| float | y, | ||
| std::string_view | faction, | ||
| std::string_view | tagsCsv, | ||
| std::string_view | visibleToCsv | ||
| ) |
Compatibility-only XY insertion; delegates to upsertPosition with Z zero.
在文件 Sensing.cpp 第 329 行定义.
引用了 f, t, upsertPosition(), v, x , 以及 y.
被这些函数引用 eve::rts::CombatFireSystem::step().
◆ upsertPosition()
| Result< void > eve::sensing::SensingWorld::upsertPosition | ( | std::string_view | id, |
| float | x, | ||
| float | y, | ||
| float | z, | ||
| std::string_view | faction, | ||
| std::string_view | tagsCsv, | ||
| std::string_view | visibleToCsv | ||
| ) |
Inserts actual XYZ coordinates and metadata; owns copies, no retained arguments.
- 返回
- InvalidArgument for nonfinite positions or an empty id; failure leaves facts unchanged. @thread Simulation thread; invokes no callbacks. Cost is one fact and its index entry.
在文件 Sensing.cpp 第 334 行定义.
引用了 eve::Applied, eve::Diagnostic::error(), f, eve::Result< T >::failure(), finite, found, eve::InvalidArgument, key, eve::sensing::Subject::pathProgress, spatialIndexEnabled(), subject, eve::Status::success(), eve::Result< T >::success(), t, v, x, y , 以及 z.
被这些函数引用 upsert().
该类的文档由以下文件生成:
- src/modules/sensing/Sensing.h
- src/modules/sensing/Sensing.cpp
- src/modules/sensing/SensingEnvironment.cpp