载入中...
搜索中...
未找到
SpellFragmentCompiler.cpp
浏览该文件的文档.
32Result<std::optional<double>> optionalDouble(const Value::Object& object, const char* name, std::string_view path) {
36Result<std::optional<int>> optionalInt(const Value::Object& object, const char* name, std::string_view path) {
79Result<void> applyModifier(ModifierStack& stack, const Value::Object& object, std::string_view kind,
87 if (!(turn > 0.0)) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("homing turnRate must be positive"), std::string(path), {},
96 if (value < 0.0) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("gravity must be non-negative"), std::string(path), {},
105 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("accelerate requires non-negative acceleration"), std::string(path), {},
117 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("curve fragment requires non-negative amplitude"), std::string(path), {},
124 if (!(freq > 0.0)) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("curve frequency must be positive"), std::string(path), {},
139 if (value <= 0) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("count must be positive"), std::string(path), {},
149 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("restitution must be non-negative"), std::string(path), {},
162 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("modifier requires add and/or multiply"), std::string(path), {},
164 auto& ops = (kind == "damage") ? stack.damageOps : (kind == "speed") ? stack.speedOps : stack.lifetimeOps;
173 if (!readString(object, "value", stack.element) && !readString(object, "element", stack.element))
174 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("element requires value"), std::string(path), {},
179 if (!readString(object, "value", stack.damageType) && !readString(object, "damageType", stack.damageType))
180 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("damageType requires value"), std::string(path), {},
191 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("splash requires positive radius"), std::string(path), {},
203 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("fuse requires positive seconds"), std::string(path), {},
222 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("volley requires positive count"), std::string(path), {},
233 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Unknown fragment kind"), std::string(path + ".kind"), {},
237Result<CarrierRecipe> buildProjectile(const Value::Object& object, const ModifierStack& stack, std::string path) {
240 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), {},
246 return Result<CarrierRecipe>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("projectile requires id"), std::string(path + ".id"), {},
253 return Result<CarrierRecipe>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("projectile speed must be positive"), std::string(path + ".speed"), {},
260 return Result<CarrierRecipe>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("projectile lifetime must be positive"), std::string(path + ".lifetime"), {},
290 if (merged.pierce <= 0 && pierceField.value().has_value()) merged.pierce = *pierceField.value();
293 if (merged.bounce <= 0 && bounceField.value().has_value()) merged.bounce = *bounceField.value();
325 if (!motion.empty() && motion.back().kind == CarrierMotionOpKind::IntegrateLinear) motion.pop_back();
359 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Fragments must be an array"), std::string(""), {},
362 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Fragments must not be empty"), std::string(""), {},
371 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Fragment must be an object"), std::string(path), {},
375 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Fragment requires kind"), std::string(path + ".kind"), {},
380 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Only one projectile fragment is supported per cast"), std::string(path), {},
389 return Result<SpellCastPlan>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, std::string("Modifiers must appear before the projectile fragment"), std::string(path), {},
397 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={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:177
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:209
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
Definition BuildingSnapshot.cpp:96
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
bool readString(const eve::Value::Object &object, const char *name, std::string &output)
Definition ArtifactProvider.cpp:21
ForceVector add(ForceVector a, ForceVector b)
Definition ForceMath.h:13
Result< std::optional< double > > readOptionalDouble(const Value::Object &object, std::string_view name, std::string_view path, std::string_view source)
Decode an optional finite number for the weapon codecs.
Definition NumericRead.h:24
Result< std::optional< int > > readOptionalInt(const Value::Object &object, std::string_view name, std::string_view path, std::string_view source)
Decode an optional native int, also accepting integral finite Doubles, for the weapon codecs.
Definition NumericRead.h:49
载具模块入口(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:594
Result< SpellCastPlan > compileSpellFragmentsJson(const std::string &json)
Compile a JSON array string into one cast plan.
Definition SpellFragmentCompiler.cpp:406
Result< SpellCastPlan > compileSpellFragments(const Value &fragments)
Compile a fragment array Value into one cast plan.
Definition SpellFragmentCompiler.cpp:357
@ InvalidArgument
@ Unsupported
@ Multiply
Result< std::string > readStringMember(const Value::Object &object, std::string_view name)
Read a required string field, including an empty string, as an owning value.
Definition Value.cpp:25
One compiled cast unit ready to register and spawn.
Definition SpellFragmentCompiler.h:24