载入中...
搜索中...
未找到
Vehicle.cpp
浏览该文件的文档.
148 explicit ScriptVehicleDamageModifier(ScriptProviderHandle handle) : handle_(std::move(handle)) {}
153 float modifyDamage(VehicleEntity& v, float amount, const std::string& zone, int sourceId) override {
270 auto withdrawn = ScriptProviderRegistry::instance().removeCapability(IVehicleDamageModifier::capabilityName);
380void Vehicle::registerMobility(IVehicleMobility* mobility) { VehicleSystem::registerMobility(mobility); }
419 if (eve::weapon::Weapon* wmod = eve::ModuleManager::requireInstance<eve::weapon::Weapon>("Weapon")) {
424 wmod->mountSetLimits(m, md.yawMin, md.yawMax, md.pitchMin, md.pitchMax, md.rotSpeed, md.firingArc);
522float Vehicle::getHeading(VehicleEntity* v) { return v == nullptr ? 0.f : v->motion()->heading; }
541float Vehicle::getMaxHealth(VehicleEntity* v) { return v == nullptr ? 0.f : v->health()->maxHp; }
543std::string Vehicle::getFaction(VehicleEntity* v) { return v == nullptr ? std::string{} : v->identity()->faction; }
553void Vehicle::applyDamage(VehicleEntity* v, float amount, const std::string& zone, int sourceId) {
598bool Vehicle::isDestroyed(VehicleEntity* v) { return v != nullptr && v->stateFlags()->destroyed; }
604int Vehicle::getSeatCount(VehicleEntity* v) { return v == nullptr ? 0 : static_cast<int>(v->seats()->list.size()); }
660void Vehicle::setPlayerControls(int playerId, float throttle, float steer, float brake, bool fire, float aimYaw,
676void Vehicle::setInput(VehicleEntity* v, float throttle, float steer, float brake, bool handbrake) {
711int Vehicle::getMountCount(VehicleEntity* v) { return v == nullptr ? 0 : static_cast<int>(v->mounts()->list.size()); }
763 if (s.mountIndex >= 0 && static_cast<size_t>(s.mountIndex) < v.mounts()->list.size() && wmod != nullptr) {
782 if (cur == nullptr || (cur->type != VehicleOrderType::Attack && cur->type != VehicleOrderType::AttackMove)) {
823 return (index >= 0 && index < getEventCount()) ? vehicleEventTypeName(events_[index].type) : std::string{};
838float Vehicle::getEventX(int index) const { return (index >= 0 && index < getEventCount()) ? events_[index].x : 0.f; }
840float Vehicle::getEventY(int index) const { return (index >= 0 && index < getEventCount()) ? events_[index].y : 0.f; }
851 "VehicleEntity", std::function<VehicleEntity*()>([]() -> VehicleEntity* { return nullptr; }), false);
853 vCls.addFunc("getId", [](VehicleEntity* v) -> std::string { return v ? v->identity()->id : std::string{}; });
854 vCls.addFunc("getDefId", [](VehicleEntity* v) -> std::string { return v ? v->identity()->defId : std::string{}; });
862 vCls.addFunc("getHeading", [](VehicleEntity* v) -> float { return v ? v->motion()->heading : 0.f; });
863 vCls.addFunc("getSpeed", [](VehicleEntity* v) -> float { return v ? v->motion()->speed : 0.f; });
865 vCls.addFunc("getMaxHealth", [](VehicleEntity* v) -> float { return v ? v->health()->maxHp : 0.f; });
866 vCls.addFunc("isDestroyed", [](VehicleEntity* v) -> bool { return v != nullptr && v->stateFlags()->destroyed; });
867 vCls.addFunc("isArrived", [](VehicleEntity* v) -> bool { return v != nullptr && v->motion()->arrived; });
874 [](VehicleEntity* v) -> int { return v == nullptr ? 0 : static_cast<int>(v->mounts()->list.size()); });
890 cls.addFunc("getMobilityCount", [](Vehicle*) -> int { return VehicleSystem::mobilityCount(); });
std::vector< std::unique_ptr< ScriptClimbingEventSink > > live
Definition ClimbingServices.cpp:187
std::vector< std::unique_ptr< ScriptClimbingEventSink > > retired
Definition ClimbingServices.cpp:188
Persistent, thread-safe record of engine crash and problem events.
Owning, renderer-independent dynamic values.
Strongly typed Vehicle definition/entity runtime adapter.
void ignore(std::string_view reason={}) const noexcept
Explicitly discard this result after documenting the reason.
Definition Result.h:571
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Result< void > removeCapability(std::string_view capability)
Withdraw a declared seam when its owning module goes away.
Definition ScriptProvider.cpp:416
static ScriptProviderRegistry & instance()
Process-lifetime registry; clearAll is the only reset.
Definition ScriptProvider.cpp:318
Result< double > callNumber(const ScriptProviderHandle &handle, std::string_view method, double dt) const
Call method(dt) and read a numeric result.
Definition ScriptProvider.cpp:545
void declareCapability(std::string capability, ScriptCapabilityBinder binder, ScriptCapabilityUnbinder unbinder)
Declare that one native capability may be served by a script provider.
Definition ScriptProvider.cpp:404
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
eve::ResultRef< const Definition > resolve(const std::string &type, const std::string &id) const
Resolves a definition through the common registry API.
Definition Definitions.cpp:313
eve::Result< DefinitionHandle > insert(const std::string &type, const std::string &id, int version, const std::string &json)
Inserts a definition using the common generation-qualified registry.
Definition Definitions.cpp:257
eve::Result< DefinitionHandle > replace(const std::string &type, const std::string &id, int version, const std::string &json)
Replaces a live definition and invalidates its previous handle.
Definition Definitions.cpp:276
eve::Result< DefinitionHandle > remove(const std::string &type, const std::string &id)
Removes a definition and returns the retained tombstone handle.
Definition Definitions.cpp:295
int countType(const std::string &type) const
Returns the number of definitions registered for a type.
Definition Definitions.cpp:349
const Definition * atType(const std::string &type, int index) const
Returns a definition by id order within one type, or nullptr.
Definition Definitions.cpp:364
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:47
Box2D world wrapper (2D physics) with pixel-space coordinates. Handles stepping, gravity,...
Definition World.h:44
static constexpr const char * capabilityName
Definition VehicleTypes.h:374
virtual bool sample(VehicleEntity &v, int occupantId, VehicleInput &out)=0
采样 occupantId 乘客的控制;返回是否有效(有效则填充 out)。
static VehiclePhysicsStatus detach(VehicleEntity *v)
Destroy attached bodies if any.
Definition VehiclePhysics.cpp:201
static VehiclePhysicsStatus attach2D(VehicleEntity *v, eve::physics::World *world)
Attach a 2D dynamic body when physics is in the build.
Definition VehiclePhysics.cpp:149
static bool isAttached(VehicleEntity *v)
Whether the entity has a live, resolvable physics body.
Definition VehiclePhysics.cpp:211
static VehiclePhysicsStatus attach3D(VehicleEntity *v, eve::physics::World3D *world, float heightY)
Attach a 3D dynamic body when physics is in the build.
Definition VehiclePhysics.cpp:173
static float height(VehicleEntity *v)
3D body height, or 0 when no 3D body is attached.
Definition VehiclePhysics.cpp:215
static void update(VehicleEntity &v, float dt)
每帧推进:命令 → 输入 → 移动模型。自动瞄准由 Vehicle 模块完成。
Definition VehicleSystem.cpp:200
static eve::Result< void > pushOrder(VehicleEntity &v, const VehicleOrder &order)
追加一条命令;Move/AttackMove 会清空旧命令(RTS 习惯)。
Definition VehicleSystem.cpp:262
static void setPlayerControls(int playerId, const PlayerControl &control)
写入某玩家的控制状态(游戏每帧填充)。
Definition VehicleSystem.cpp:304
static IVehicleDriver * findDriver(const std::string &name)
按名字取驾驶者;未注册返回 nullptr。
Definition VehicleSystem.cpp:297
static const VehicleOrder * currentOrder(VehicleEntity &v)
当前命令;无命令返回 nullptr。
Definition VehicleSystem.cpp:285
static void setEventSink(VehicleEventSink sink)
注册事件汇(替换旧的;传 nullptr 清空)。
Definition VehicleSystem.cpp:198
static void registerMobility(IVehicleMobility *mobility)
注册移动模型实现;同名替换。
Definition VehicleSystem.cpp:186
static int findSeatByPlayer(VehicleEntity &v, int playerId)
Finds seat by player.
Definition VehicleSystem.cpp:325
static bool enterSeat(VehicleEntity &v, int seatIndex, int playerId)
座位:进入 / 离开 / 按玩家找座位。
Definition VehicleSystem.cpp:313
int getSeatOccupant(VehicleEntity *v, int seatIndex)
Returns the seat occupant.
Definition Vehicle.cpp:627
eve::weapon::WeaponMountEntity * getMount(VehicleEntity *v, int index)
Returns the mount.
Definition Vehicle.cpp:713
bool attachPhysics2D(VehicleEntity *v, eve::physics::World *world)
将载具绑定到 physics world 拥有的 2D 刚体。
Definition Vehicle.cpp:685
void applyDamage(VehicleEntity *v, float amount, const std::string &zone="", int sourceId=0)
伤害管线:修饰器 → 装甲区倍率 → 扣血 → 事件。
Definition Vehicle.cpp:553
float getArmorZoneMult(VehicleEntity *v, const std::string &zone)
装甲区倍率(未命中任何区返回 1)。
Definition Vehicle.cpp:590
VehicleEntity * newVehicle(const std::string &defId, float x, float y, float heading=0.f, const std::string &faction="")
工厂:按模板创建载具并挂载武器挂点(ECS 表持有,脚本持有句柄)。
Definition Vehicle.cpp:394
void setPlayerControls(int playerId, float throttle, float steer, float brake, bool fire, float aimYaw, float aimPitch)
写入玩家控制(归一化;角度为度)。
Definition Vehicle.cpp:660
std::string getSeatCameraMode(VehicleEntity *v, int seatIndex)
Returns the seat camera mode.
Definition Vehicle.cpp:613
std::string getVehicleDefinitionMobility(const std::string &id)
Returns the vehicle definition mobility.
Definition Vehicle.cpp:362
float getVehicleDefinitionMaxHealth(const std::string &id)
Returns the vehicle definition max health.
Definition Vehicle.cpp:371
std::string getSeatName(VehicleEntity *v, int seatIndex)
Returns the seat name.
Definition Vehicle.cpp:606
std::string getPhysicsSpace(VehicleEntity *v)
返回存活绑定的 "2d"/"3d";缺失或 stale 时返回空字符串。
Definition Vehicle.cpp:701
static void registerMobility(IVehicleMobility *mobility)
注册移动模型(C++ 插件/游戏侧扩展点;同名替换)。
Definition Vehicle.cpp:380
eve::weapon::WeaponMountEntity * getSeatMount(VehicleEntity *v, int seatIndex)
座位绑定的武器挂点(mountIndex 无效返回 nullptr)。
Definition Vehicle.cpp:634
bool attachPhysics3D(VehicleEntity *v, eve::physics::World3D *world, float heightY=1.f)
将载具绑定到 physics world 拥有的 3D 刚体。
Definition Vehicle.cpp:689
std::string getEventOrderType(int index) const
Returns the event order type.
Definition Vehicle.cpp:834
void setFaction(VehicleEntity *v, const std::string &faction)
Sets the faction.
Definition Vehicle.cpp:545
std::string getCurrentOrderType(VehicleEntity *v)
当前命令类型名("move" / "attack_move" / "attack" / "stop" / "hold" / "none")。
Definition Vehicle.cpp:510
std::string getEventVehicleId(int index) const
Returns the event vehicle id.
Definition Vehicle.cpp:826
int registerVehiclesFromJson(const std::string &json)
从 JSON 注册载具模板;返回成功注册数量。
Definition Vehicle.cpp:295
void setInput(VehicleEntity *v, float throttle, float steer, float brake=0.f, bool handbrake=false)
直接驾驶输入(FPS / 脚本驱动;RTS 命令也会写 input)。
Definition Vehicle.cpp:676
bool isSeatOccupied(VehicleEntity *v, int seatIndex)
True when seat occupied.
Definition Vehicle.cpp:620
bool fireAt(WeaponEntity *w, float x, float y, float z, int shooterId=0)
向目标点开火(自动生成 FireRequest)。
Definition Weapon.cpp:452
WeaponEntity * mountGetWeapon(WeaponMountEntity *m)
Returns the weapon mounted on a mount, or null when empty.
Definition Weapon.cpp:413
float getWeaponDefinitionRange(const std::string &id)
Returns the weapon definition range.
Definition Weapon.cpp:266
bool fire(WeaponEntity *w, const FireRequest &req)
武器操作(脚本便捷入口,转发 WeaponSystem)。
Definition Weapon.cpp:450
void mountAimAt(WeaponMountEntity *m, float yaw, float pitch)
按限位夹取目标角并写入挂载武器的瞄准目标(角度,度)。
Definition Weapon.cpp:426
WidgetDesc list(std::string listId, const std::vector< std::string > &items, const std::function< WidgetDesc(const std::string &, int)> &itemFn)
Expand a string list into a Group of item widgets. itemFn(label, index) builds each row; keys default...
Definition Widget.cpp:906
const char * vehicleOrderTypeName(VehicleOrderType type)
命令类型的字符串名("move" | "attack_move" | ...)。
Definition Vehicle.cpp:85
@ OrderCompleted
@ Destroyed
eve::Result< VehicleDefinition > parseVehicleDefinition(const eve::definitions::Definition &source)
Parse one canonical registry definition into a short-lived typed projection.
Definition VehicleDefinitionRuntime.cpp:93
@ AttackMove
@ NotFound
detail::StrongUint64< detail::SchemaVersionTag > SchemaVersion
Persistent data-format version; not a runtime replacement generation.
Definition SchemaVersion.h:13
void recordLogEvent(const std::string &level, const std::string &message)
Appends a timestamped event line to the crash/error log.
Definition CrashLog.cpp:70
void registerCppEntityView(const ssq::Class &cls, CppEntityViewFn fn)
Registers cpp entity view.
Definition ECS.cpp:1642
Definition Container.h:602
static ScriptArg fromInteger(std::int64_t value)
Definition ScriptProvider.cpp:280
static ScriptArg fromText(std::string value)
Definition ScriptProvider.cpp:301
static ScriptArg fromNumber(double value)
Definition ScriptProvider.cpp:287
Generation-qualified identity of one published script provider.
Definition ScriptProvider.h:27
One immutable view of a registered versioned JSON definition.
Definition Definitions.h:31
载具模板(registerVehiclesFromJson 注册,进程级注册表)。
Definition VehicleTypes.h:147
eve::weapon::WeaponMountEntity * mount
Definition VehicleTypes.h:290
一条 Vehicle 领域命令(生命周期由 Vehicle order adapter 执行)。
Definition VehicleTypes.h:61
一次攻击请求(C++ 系统 / 脚本发起)。角度均为度。 旧名 FireRequest 保留为别名,向后兼容。
Definition WeaponTypes.h:204