载入中...
搜索中...
未找到
SpellFragmentCompiler.cpp
浏览该文件的文档.
31Result<std::optional<double>> optionalDouble(const Value::Object& object, const char* name, std::string_view path) {
36 return Result<std::optional<double>>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Expected finite number"), std::string(path), {},
43 return Result<std::optional<double>>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Expected finite number"), std::string(path), {},
47 return Result<std::optional<double>>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Expected number"), std::string(path), {},
51Result<std::optional<int>> optionalInt(const Value::Object& object, const char* name, std::string_view path) {
56 return Result<std::optional<int>>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Integer out of range"), std::string(path), {},
62 return Result<std::optional<int>>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Expected integer"), std::string(path), {},
66 return Result<std::optional<int>>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Integer out of range"), std::string(path), {},
70 return Result<std::optional<int>>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Expected integer"), std::string(path), {},
113Result<void> applyModifier(ModifierStack& stack, const Value::Object& object, std::string_view kind,
121 if (!(turn > 0.0)) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("homing turnRate must be positive"), std::string(path), {},
130 if (value < 0.0) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("gravity must be non-negative"), std::string(path), {},
139 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("accelerate requires non-negative acceleration"), std::string(path), {},
151 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("curve fragment requires non-negative amplitude"), std::string(path), {},
158 if (!(freq > 0.0)) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("curve frequency must be positive"), std::string(path), {},
173 if (value <= 0) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("count must be positive"), std::string(path), {},
183 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("restitution must be non-negative"), std::string(path), {},
196 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("modifier requires add and/or multiply"), std::string(path), {},
198 auto& ops = (kind == "damage") ? stack.damageOps : (kind == "speed") ? stack.speedOps : stack.lifetimeOps;
207 if (!readString(object, "value", stack.element) && !readString(object, "element", stack.element))
208 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("element requires value"), std::string(path), {},
213 if (!readString(object, "value", stack.damageType) && !readString(object, "damageType", stack.damageType))
214 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("damageType requires value"), std::string(path), {},
225 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("splash requires positive radius"), std::string(path), {},
237 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("fuse requires positive seconds"), std::string(path), {},
256 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("volley requires positive count"), std::string(path), {},
267 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Unknown fragment kind"), std::string(path + ".kind"), {},
271Result<CarrierRecipe> buildProjectile(const Value::Object& object, const ModifierStack& stack, std::string path) {
274 return Result<CarrierRecipe>::failure(Diagnostic::error(DiagnosticCode::Unsupported, std::string("Projectile fragments must use preset fields, not full-form motion/triggers/impacts"), std::string(path), {},
280 return Result<CarrierRecipe>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("projectile requires id"), std::string(path + ".id"), {},
287 return Result<CarrierRecipe>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("projectile speed must be positive"), std::string(path + ".speed"), {},
294 return Result<CarrierRecipe>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("projectile lifetime must be positive"), std::string(path + ".lifetime"), {},
324 if (merged.pierce <= 0 && pierceField.value().has_value()) merged.pierce = *pierceField.value();
327 if (merged.bounce <= 0 && bounceField.value().has_value()) merged.bounce = *bounceField.value();
359 if (!motion.empty() && motion.back().kind == CarrierMotionOpKind::IntegrateLinear) motion.pop_back();
393 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Fragments must be an array"), std::string(""), {},
396 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Fragments must not be empty"), std::string(""), {},
405 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Fragment must be an object"), std::string(path), {},
409 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Fragment requires kind"), std::string(path + ".kind"), {},
414 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Only one projectile fragment is supported per cast"), std::string(path), {},
423 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Modifiers must appear before the projectile fragment"), std::string(path), {},
431 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Fragment sequence requires one projectile fragment"), std::string(""), {},
Decode/encode CombatCarrier recipes from canonical eve::Value trees.
Stable, structured diagnostics shared by engine modules.
Compile Noita-style spell/modifier fragment sequences into carrier recipes.
Common time values and an injectable deterministic simulation clock.
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 Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:180
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:26
bool readString(const eve::Value::Object &object, const char *name, std::string &output)
Definition ArtifactProvider.cpp:20
const EditorValue * field(const EditorValue &value, const char *name)
Definition RoadNetworkEditTarget.cpp:15
载具模块入口(eve.Vehicle):定义注册 / 实体工厂 / RTS 命令 / 帧调度。 设计文档:docs/dev/通用载具系统设计.md
Definition RTSArchetype.h:10
@ CurveHelix
@ IntegrateLinear
@ CurveSway
Result< CarrierRecipe > decodeCarrierRecipe(const Value &value)
Decode one CarrierRecipe from an owning Value object.
Definition CarrierRecipeCodec.cpp:543
Result< SpellCastPlan > compileSpellFragmentsJson(const std::string &json)
Compile a JSON array string into one cast plan.
Definition SpellFragmentCompiler.cpp:440
Result< SpellCastPlan > compileSpellFragments(const Value &fragments)
Compile a fragment array Value into one cast plan.
Definition SpellFragmentCompiler.cpp:391
@ InvalidArgument
@ Unsupported
@ Multiply
One compiled cast unit ready to register and spawn.
Definition SpellFragmentCompiler.h:24
std::optional< CarrierVolleySpec > volley
Definition SpellFragmentCompiler.h:26