载入中...
搜索中...
未找到
VehicleAttributes.cpp
浏览该文件的文档.
15 return name == VehicleAttributeAdapter::healthAttribute || name == VehicleAttributeAdapter::maxHealthAttribute ||
29 eve::Status::failure(bound.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle attribute owner could not be bound", "owner", {}, "vehicle.attributes")));
40 eve::Status::failure(initialized.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle attribute state could not be initialized", "attributes", {}, "vehicle.attributes")));
48 eve::Status::failure(ready.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle attributes are not available", "attributes", {}, "vehicle.attributes")));
51 eve::Status::failure(hp.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle health attribute could not be read", "health", {}, "vehicle.attributes")));
54 eve::Status::failure(maxHp.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle max health attribute could not be read", "max_health", {}, "vehicle.attributes")));
55 if (!std::isfinite(hp.value()) || !std::isfinite(maxHp.value()) || hp.value() < 0.0 || maxHp.value() < 0.0 ||
56 hp.value() > maxHp.value() || hp.value() > static_cast<double>(std::numeric_limits<float>::max()) ||
59 eve::Diagnostic::error(eve::DiagnosticCode::InvariantViolation, "vehicle health attributes are outside validated bounds", "health", {}, "vehicle.attributes"));
65eve::Result<double> VehicleAttributeAdapter::read(VehicleEntity& vehicle, std::string_view attribute) {
68 eve::DiagnosticCode::Unsupported, "vehicle attribute is outside the selective combat projection",
74 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle compatibility projection failed", "health", {},
79 value.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle attribute read failed",
84eve::Result<void> VehicleAttributeAdapter::setBase(VehicleEntity& vehicle, std::string_view attribute, double value) {
87 eve::Diagnostic::error(eve::DiagnosticCode::Unsupported, "vehicle attribute is outside the selective combat projection", "attribute", {}, "vehicle.attributes"));
90 eve::Status::failure(ready.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle attributes are not available", "attributes", {}, "vehicle.attributes")));
98 eve::attributes::AttributeOperation operation, double value, eve::attributes::ModifierPriority priority) {
101 eve::DiagnosticCode::InvalidArgument, "vehicle modifier requires a selected attribute and non-empty source",
106 ready.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle attributes are not available",
115 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle compatibility projection failed", "health", {},
120eve::Result<eve::attributes::AttributeProjectionSnapshot> VehicleAttributeAdapter::snapshot(VehicleEntity& vehicle) {
124 ready.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle attributes are not available",
135 eve::Status::failure(ready.code(), eve::Diagnostic::error(eve::DiagnosticCode::Failed, "vehicle attributes are not available", "attributes", {}, "vehicle.attributes")));
Selective canonical health and armor adapter for vehicles.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status failure(StatusCode code, Diagnostic diagnostic)
Construct a failed status with one diagnostic.
Definition Status.h:84
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
static constexpr std::string_view healthAttribute
Definition VehicleAttributes.h:28
static eve::Result< double > read(VehicleEntity &vehicle, std::string_view attribute)
Read a selected final combat attribute and refresh health projection.
Definition VehicleAttributes.cpp:65
static eve::Result< void > restore(VehicleEntity &vehicle, const eve::attributes::AttributeProjectionSnapshot &snapshot, eve::Revision expectedRevision)
Restore a vehicle attribute snapshot after owner/revision checks.
Definition VehicleAttributes.cpp:130
static eve::Result< void > ensure(VehicleEntity &vehicle)
Bind and seed selected combat attributes exactly once.
Definition VehicleAttributes.cpp:26
static eve::Result< void > setBase(VehicleEntity &vehicle, std::string_view attribute, double value)
Set a selected canonical base and refresh the compatibility health fields.
Definition VehicleAttributes.cpp:84
static eve::Result< void > project(VehicleEntity &vehicle)
Project canonical health values into VehicleEntity::Health.
Definition VehicleAttributes.cpp:45
static eve::Result< eve::attributes::AttributeProjectionSnapshot > snapshot(VehicleEntity &vehicle)
Capture health/max_health/armor with owner generation and revision.
Definition VehicleAttributes.cpp:120
static constexpr std::string_view maxHealthAttribute
Definition VehicleAttributes.h:29
static constexpr std::string_view armorAttribute
Definition VehicleAttributes.h:30
static eve::Result< eve::attributes::ModifierId > addModifier(VehicleEntity &vehicle, std::string id, std::string_view attribute, std::string source, eve::attributes::AttributeOperation operation, double value, eve::attributes::ModifierPriority priority=eve::attributes::priority::runtime)
Add a modifier using the shared operation/priority/sequence contract.
Definition VehicleAttributes.cpp:96
AttributeOperation
Built-in calculation operation for an attribute modifier.
Definition AttributeSet.h:25
@ InvalidArgument
@ Unsupported
@ InvariantViolation
@ Failed
@ NoOp
@ Applied
One canonical runtime modifier applied to one named attribute.
Definition AttributeSet.h:96
Transaction-safe snapshot of selected attributes and their modifiers.
Definition AttributeProjection.h:40
One base value captured by an attribute projection snapshot.
Definition AttributeProjection.h:28