载入中...
搜索中...
未找到
LineOfSight.h
浏览该文件的文档.
1#pragma once
2
26#include "common/Result.h"
27#include "tactics/TacticsPath.h"
29
30#include <memory>
31#include <string_view>
32#include <vector>
33
34#include "common/Export.h"
35
36namespace eve::tactics {
37
39inline constexpr std::string_view kSightBlockerTag = "sight_blocker";
40
42enum class CoverLevel : std::uint8_t {
44 None,
46 Half,
48 Full,
49};
50
52[[nodiscard]] EVENGINE_API_DOMAINS std::string_view coverLevelName(CoverLevel level) noexcept;
53
62public:
64 static constexpr const char* capabilityName = "eve.tactics.ILineOfSightPolicy";
65
67 virtual ~ILineOfSightPolicy() = default;
68
70 [[nodiscard]] virtual std::string_view id() const noexcept = 0;
71
79 [[nodiscard]] virtual Result<bool> visible(const BoardState& board, Cell from, Cell to) const = 0;
80};
81
90public:
92 static constexpr const char* capabilityName = "eve.tactics.ICoverPolicy";
93
95 virtual ~ICoverPolicy() = default;
96
98 [[nodiscard]] virtual std::string_view id() const noexcept = 0;
99
104 [[nodiscard]] virtual Result<CoverLevel> cover(const BoardState& board, Cell attacker, Cell target) const = 0;
105};
106
124public:
126 [[nodiscard]] std::string_view id() const noexcept override { return "grid_line_of_sight"; }
127
129 [[nodiscard]] Result<bool> visible(const BoardState& board, Cell from, Cell to) const override;
130};
131
141public:
143 [[nodiscard]] std::string_view id() const noexcept override { return "grid_cover"; }
144
146 [[nodiscard]] Result<CoverLevel> cover(const BoardState& board, Cell attacker, Cell target) const override;
147};
148
156[[nodiscard]] EVENGINE_API_DOMAINS std::shared_ptr<ILineOfSightPolicy> gridLineOfSightPolicy();
158[[nodiscard]] EVENGINE_API_DOMAINS std::shared_ptr<ICoverPolicy> gridCoverPolicy();
159
179 const ILineOfSightPolicy& policy,
180 Cell origin, int minimum, int maximum,
181 CellRangeMetric metric);
182
183} // namespace eve::tactics
LogicalId target
std::string from
#define EVENGINE_API_DOMAINS
Definition Export.h:110
float maximum[3]
float minimum[3]
HexCoordinates to
Cell the unit walks towards on this segment.
Definition HexUnits.cpp:64
int level
Move-only, checked operation results for the common layer.
V3 origin
Definition RoadBake.cpp:138
Deterministic fixed-cost tactics path queries.
BoardState board
Deterministic board values and short-root ECS entities for tactics.
bool visible
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Authoritative board facts and occupancy indexes for one battle.
The built-in cover policy: blockers adjacent to the target, prioritising the line.
std::string_view id() const noexcept override
Id.
The built-in grid policy: a straight-line trace over the board's own topology.
std::string_view id() const noexcept override
Id.
Answers "how much cover does @p target have against @p attacker".
Definition LineOfSight.h:89
virtual ~ICoverPolicy()=default
Releases ICoverPolicy resources.
virtual std::string_view id() const noexcept=0
Stable id of this implementation.
Answers "can @p from see @p to" for one board.
Definition LineOfSight.h:61
virtual ~ILineOfSightPolicy()=default
Releases ILineOfSightPolicy resources.
static constexpr const char * capabilityName
Capability name a provider registers under.
Definition LineOfSight.h:64
virtual std::string_view id() const noexcept=0
Stable id of this implementation, for diagnostics and configuration.
std::string_view coverLevelName(CoverLevel level) noexcept
Stable protocol spelling of a cover level.
Result< std::vector< Cell > > visibleCellsInRange(const BoardState &board, const ILineOfSightPolicy &policy, Cell origin, int minimum, int maximum, CellRangeMetric metric)
Cells within a metric range of origin that policy can actually see.
@ None
Nothing to do: the click landed somewhere with no meaning in this state.
std::shared_ptr< ILineOfSightPolicy > gridLineOfSightPolicy()
The process-wide built-in line-of-sight policy.
CellRangeMetric
Deterministic logical distance used by cellsInRange.
Definition TacticsPath.h:15
constexpr std::string_view kSightBlockerTag
Cell tag that makes a cell block line of sight.
Definition LineOfSight.h:39
CoverLevel
How much protection a cell gives against an attacker.
Definition LineOfSight.h:42
@ Full
Full protection: a blocker sits between the attacker and the target.
@ Half
Partial protection: an adjacent blocker, but not on the incoming line.
std::shared_ptr< ICoverPolicy > gridCoverPolicy()
The process-wide built-in cover policy (same ownership remarks as above).
Logical board coordinate independent of rendering projection.