载入中...
搜索中...
未找到
eve::sensing::SensingWorld类 参考

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.

在文件 Sensing.h 第 197 行定义.

构造及析构函数说明

◆ SensingWorld() [1/3]

eve::sensing::SensingWorld::SensingWorld ( )
default

◆ ~SensingWorld()

eve::sensing::SensingWorld::~SensingWorld ( )

Sensing world.

在文件 Sensing.cpp 第 142 行定义.

◆ SensingWorld() [2/3]

eve::sensing::SensingWorld::SensingWorld ( const SensingWorld &  )
delete

◆ SensingWorld() [3/3]

eve::sensing::SensingWorld::SensingWorld ( SensingWorld &&  )
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.

参数
sortPolicyOne 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

◆ debugLastQueryJson()

std::string eve::sensing::SensingWorld::debugLastQueryJson ( ) const

Deterministic JSON dump of the last successful query for MCP/debug overlays.

返回
Schema eve.sensing.lastQuery with 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().

参数
presetIdStable preset id (e.g. "sensing.builtin.coneSelect").
originXOrigin X used as QueryOrigin and cone apex.
originYOrigin Y used as QueryOrigin and cone apex.
dirXForward X for cone filter tasks (normalized on use).
dirYForward 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()

SpatialIndexKind eve::sensing::SensingWorld::indexKind ( ) const
noexcept

Current broad-phase selection, independent of query distance semantics.

在文件 Sensing.cpp 第 427 行定义.

◆ operator=() [1/2]

SensingWorld & eve::sensing::SensingWorld::operator= ( const SensingWorld &  )
delete

◆ operator=() [2/2]

SensingWorld & eve::sensing::SensingWorld::operator= ( SensingWorld &&  )
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 行定义.

引用了 origin , 以及 query().

被这些函数引用 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 
)

◆ queryPositions()

Result< Value > eve::sensing::SensingWorld::queryPositions ( float  originX,
float  originY,
float  targetX,
float  targetY,
float  radius,
int  samples,
int  limit,
bool  requireLineOfSight 
)

◆ 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)

◆ 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.

参数
idExisting subject id.
pathProgressFinite route progress (higher = closer to exit / First).
strengthFinite 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).

参数
enabledWhen true, rebuilds the index from current subjects.
cellSizeUniform 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.

参数
idSubject id that must already be registered.
zonesCsvComma-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

Exports deterministic JSON.

在文件 Sensing.cpp 第 952 行定义.

引用了 first, quote , 以及 s.

◆ spatialIndexEnabled()

bool eve::sensing::SensingWorld::spatialIndexEnabled ( ) const
noexcept

Reports whether the optional spatial broadphase is active.

在文件 Sensing.cpp 第 428 行定义.

被这些函数引用 debugLastQueryJson() , 以及 upsertPosition().

◆ subjects()

const std::map< std::string, Subject > & eve::sensing::SensingWorld::subjects ( ) const
inlinenoexcept

Returns a borrowed view of stored subjects for adapters; valid until mutation.

在文件 Sensing.h 第 345 行定义.

被这些函数引用 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().


该类的文档由以下文件生成: