载具模块(eve.Vehicle)。 更多...
#include <Vehicle.h>
Public 成员函数 | |
| Module_REG (Vehicle) | |
| Vehicle () | |
| Vehicle. | |
| ~Vehicle () override | |
| Vehicle. | |
| int | registerVehiclesFromJson (const std::string &json) |
| 从 JSON 注册载具模板;返回成功注册数量。 | |
| void | clearVehicleDefinitions () |
| 清空全部载具模板。 | |
| int | getVehicleDefinitionCount () |
| 已注册载具模板数量。 | |
| bool | hasVehicleDefinition (const std::string &id) |
| 载具模板查询。 | |
| std::string | getVehicleDefinitionMobility (const std::string &id) |
| Returns the vehicle definition mobility. | |
| float | getVehicleDefinitionMaxHealth (const std::string &id) |
| Returns the vehicle definition max health. | |
| eve::definitions::DefinitionRegistry & | definitionRegistry () noexcept |
| Return the canonical common registry for vehicle definitions. | |
| VehicleEntity * | newVehicle (const std::string &defId, float x, float y, float heading=0.f, const std::string &faction="") |
| 工厂:按模板创建载具并挂载武器挂点(ECS 表持有,脚本持有句柄)。 | |
| void | moveTo (VehicleEntity *v, float x, float y) |
| RTS 命令。 | |
| void | attackMove (VehicleEntity *v, float x, float y) |
| Attack move. | |
| void | attack (VehicleEntity *v, float x, float y, int targetId=0) |
| Attack. | |
| void | stop (VehicleEntity *v) |
| Stops . | |
| void | hold (VehicleEntity *v) |
| Hold. | |
| void | clearOrders (VehicleEntity *v) |
| Clears orders. | |
| int | orderCount (VehicleEntity *v) |
| Order count. | |
| std::string | getCurrentOrderType (VehicleEntity *v) |
| 当前命令类型名("move" / "attack_move" / "attack" / "stop" / "hold" / "none")。 | |
| void | setInput (VehicleEntity *v, float throttle, float steer, float brake=0.f, bool handbrake=false) |
| 直接驾驶输入(FPS / 脚本驱动;RTS 命令也会写 input)。 | |
| float | getX (VehicleEntity *v) |
| 状态查询 / 设置。 | |
| float | getY (VehicleEntity *v) |
| Returns the y. | |
| float | getHeading (VehicleEntity *v) |
| Returns the heading. | |
| float | getSpeed (VehicleEntity *v) |
| Returns the speed. | |
| void | setPosition (VehicleEntity *v, float x, float y) |
| Sets the position. | |
| void | setHeading (VehicleEntity *v, float deg) |
| Sets the heading. | |
| bool | isArrived (VehicleEntity *v) |
| True when arrived. | |
| float | getHealth (VehicleEntity *v) |
| Returns the health. | |
| void | setHealth (VehicleEntity *v, float hp) |
| Sets the health. | |
| float | getMaxHealth (VehicleEntity *v) |
| Returns the max health. | |
| std::string | getFaction (VehicleEntity *v) |
| Returns the faction. | |
| void | setFaction (VehicleEntity *v, const std::string &faction) |
| Sets the faction. | |
| bool | attachPhysics2D (VehicleEntity *v, eve::physics::World *world) |
| 将载具绑定到 physics world 拥有的 2D 刚体。 | |
| bool | attachPhysics3D (VehicleEntity *v, eve::physics::World3D *world, float heightY=1.f) |
| 将载具绑定到 physics world 拥有的 3D 刚体。 | |
| bool | detachPhysics (VehicleEntity *v) |
| 解除绑定,并在 world 仍存活时销毁由载具创建的刚体。 | |
| bool | hasPhysics (VehicleEntity *v) |
| 查询当前绑定是否仍能解析为存活刚体。 | |
| std::string | getPhysicsSpace (VehicleEntity *v) |
| 返回存活绑定的 "2d"/"3d";缺失或 stale 时返回空字符串。 | |
| float | getHeight (VehicleEntity *v) |
| 3D 车身高度(无 3D 物理时返回 0)。 | |
| void | applyDamage (VehicleEntity *v, float amount, const std::string &zone="", int sourceId=0) |
| 伤害管线:修饰器 → 装甲区倍率 → 扣血 → 事件。 | |
| float | getArmorZoneMult (VehicleEntity *v, const std::string &zone) |
| 装甲区倍率(未命中任何区返回 1)。 | |
| bool | isDestroyed (VehicleEntity *v) |
| 是否已摧毁。 | |
| int | getSeatCount (VehicleEntity *v) |
| 座位(FPS 面)。 | |
| std::string | getSeatName (VehicleEntity *v, int seatIndex) |
| Returns the seat name. | |
| std::string | getSeatCameraMode (VehicleEntity *v, int seatIndex) |
| Returns the seat camera mode. | |
| bool | isSeatOccupied (VehicleEntity *v, int seatIndex) |
| True when seat occupied. | |
| int | getSeatOccupant (VehicleEntity *v, int seatIndex) |
| Returns the seat occupant. | |
| eve::weapon::WeaponMountEntity * | getSeatMount (VehicleEntity *v, int seatIndex) |
| 座位绑定的武器挂点(mountIndex 无效返回 nullptr)。 | |
| bool | enterSeat (VehicleEntity *v, int seatIndex, int playerId) |
| Enter seat. | |
| bool | exitSeat (VehicleEntity *v, int seatIndex) |
| Exit seat. | |
| int | exitSeatByPlayer (VehicleEntity *v, int playerId) |
| Exit seat by player. | |
| void | setPlayerControls (int playerId, float throttle, float steer, float brake, bool fire, float aimYaw, float aimPitch) |
| 写入玩家控制(归一化;角度为度)。 | |
| int | getMountCount (VehicleEntity *v) |
| 挂点查询(返回 weapon 模块的挂点实体)。 | |
| eve::weapon::WeaponMountEntity * | getMount (VehicleEntity *v, int index) |
| Returns the mount. | |
| void | update (float dt) |
| 每帧推进全部载具(命令 → 移动 → RTS 自动瞄准)。 | |
| void | clearEvents () |
| 事件队列(order_completed 等,上一次 update 产生)。 | |
| int | getEventCount () const |
| Returns the event count. | |
| std::string | getEventType (int index) const |
| Returns the event type. | |
| std::string | getEventVehicleId (int index) const |
| Returns the event vehicle id. | |
| std::string | getEventDefId (int index) const |
| Returns the event def id. | |
| std::string | getEventOrderType (int index) const |
| Returns the event order type. | |
| float | getEventX (int index) const |
| Returns the event x. | |
| float | getEventY (int index) const |
| Returns the event y. | |
Public 成员函数 继承自 eve::Module | |
| virtual | ~Module () |
| Module. | |
| virtual std::string | getName () const =0 |
| Returns the name. | |
静态 Public 成员函数 | |
| static void | registerMobility (IVehicleMobility *mobility) |
| 注册移动模型(C++ 插件/游戏侧扩展点;同名替换)。 | |
| static int | getMobilityCount () |
| 已注册移动模型数量(内置 kinematic 起步)。 | |
详细描述
构造及析构函数说明
◆ Vehicle()
| eve::vehicle::Vehicle::Vehicle | ( | ) |
◆ ~Vehicle()
|
override |
成员函数说明
◆ applyDamage()
| void eve::vehicle::Vehicle::applyDamage | ( | VehicleEntity * | v, |
| float | amount, | ||
| const std::string & | zone = "", |
||
| int | sourceId = 0 |
||
| ) |
伤害管线:修饰器 → 装甲区倍率 → 扣血 → 事件。
在文件 Vehicle.cpp 第 388 行定义.
引用了 eve::vehicle::Damaged, eve::vehicle::VehicleEvent::defId, eve::vehicle::Destroyed, m, sourceId, eve::vehicle::VehicleEvent::type, v, eve::vehicle::VehicleEvent::vehicleId, eve::vehicle::VehicleEvent::x, eve::vehicle::VehicleEvent::y , 以及 z.
◆ attachPhysics2D()
| bool eve::vehicle::Vehicle::attachPhysics2D | ( | VehicleEntity * | v, |
| eve::physics::World * | world | ||
| ) |
将载具绑定到 physics world 拥有的 2D 刚体。
- 返回
- physics 可用且刚体与 generation link 均创建成功时返回 true。
- 备注
- 重复绑定会先解除旧绑定;world 先销毁时 link 自动失效。
在文件 Vehicle.cpp 第 520 行定义.
引用了 eve::vehicle::Applied, eve::vehicle::VehiclePhysics::attach2D(), v , 以及 world.
◆ attachPhysics3D()
| bool eve::vehicle::Vehicle::attachPhysics3D | ( | VehicleEntity * | v, |
| eve::physics::World3D * | world, | ||
| float | heightY = 1.f |
||
| ) |
将载具绑定到 physics world 拥有的 3D 刚体。
- 返回
- physics 可用且刚体与 generation link 均创建成功时返回 true。
- 备注
- 载具不保留跨帧刚体指针;所有解析均在 owner thread 上检查 world 生命期与 generation。
在文件 Vehicle.cpp 第 524 行定义.
引用了 eve::vehicle::Applied, eve::vehicle::VehiclePhysics::attach3D(), v , 以及 world.
◆ attack()
| void eve::vehicle::Vehicle::attack | ( | VehicleEntity * | v, |
| float | x, | ||
| float | y, | ||
| int | targetId = 0 |
||
| ) |
◆ attackMove()
| void eve::vehicle::Vehicle::attackMove | ( | VehicleEntity * | v, |
| float | x, | ||
| float | y | ||
| ) |
Attack move.
在文件 Vehicle.cpp 第 300 行定义.
引用了 eve::vehicle::AttackMove, eve::vehicle::VehicleSystem::pushOrder(), queued, eve::vehicle::VehicleOrder::type, v, x, eve::vehicle::VehicleOrder::x, y , 以及 eve::vehicle::VehicleOrder::y.
◆ clearEvents()
| void eve::vehicle::Vehicle::clearEvents | ( | ) |
事件队列(order_completed 等,上一次 update 产生)。
在文件 Vehicle.cpp 第 653 行定义.
◆ clearOrders()
| void eve::vehicle::Vehicle::clearOrders | ( | VehicleEntity * | v | ) |
◆ clearVehicleDefinitions()
| void eve::vehicle::Vehicle::clearVehicleDefinitions | ( | ) |
◆ definitionRegistry()
|
inlinenoexcept |
Return the canonical common registry for vehicle definitions.
- 备注
- The returned registry is borrowed, owner-thread affine, and is the binding point for VehicleDefinitionRuntime adapters.
◆ detachPhysics()
| bool eve::vehicle::Vehicle::detachPhysics | ( | VehicleEntity * | v | ) |
解除绑定,并在 world 仍存活时销毁由载具创建的刚体。
在文件 Vehicle.cpp 第 528 行定义.
引用了 eve::vehicle::Applied, eve::vehicle::VehiclePhysics::detach() , 以及 v.
◆ enterSeat()
| bool eve::vehicle::Vehicle::enterSeat | ( | VehicleEntity * | v, |
| int | seatIndex, | ||
| int | playerId | ||
| ) |
◆ exitSeat()
| bool eve::vehicle::Vehicle::exitSeat | ( | VehicleEntity * | v, |
| int | seatIndex | ||
| ) |
◆ exitSeatByPlayer()
| int eve::vehicle::Vehicle::exitSeatByPlayer | ( | VehicleEntity * | v, |
| int | playerId | ||
| ) |
Exit seat by player.
在文件 Vehicle.cpp 第 488 行定义.
引用了 eve::vehicle::VehicleSystem::exitSeat(), eve::vehicle::VehicleSystem::findSeatByPlayer(), idx , 以及 v.
◆ getArmorZoneMult()
| float eve::vehicle::Vehicle::getArmorZoneMult | ( | VehicleEntity * | v, |
| const std::string & | zone | ||
| ) |
◆ getCurrentOrderType()
| std::string eve::vehicle::Vehicle::getCurrentOrderType | ( | VehicleEntity * | v | ) |
当前命令类型名("move" / "attack_move" / "attack" / "stop" / "hold" / "none")。
在文件 Vehicle.cpp 第 345 行定义.
引用了 eve::vehicle::VehicleSystem::currentOrder(), eve::vehicle::VehicleOrder::type, v , 以及 eve::vehicle::vehicleOrderTypeName().
◆ getEventCount()
| int eve::vehicle::Vehicle::getEventCount | ( | ) | const |
Returns the event count.
在文件 Vehicle.cpp 第 655 行定义.
被这些函数引用 getEventDefId(), getEventOrderType(), getEventType(), getEventVehicleId(), getEventX() , 以及 getEventY().
◆ getEventDefId()
| std::string eve::vehicle::Vehicle::getEventDefId | ( | int | index | ) | const |
◆ getEventOrderType()
| std::string eve::vehicle::Vehicle::getEventOrderType | ( | int | index | ) | const |
◆ getEventType()
| std::string eve::vehicle::Vehicle::getEventType | ( | int | index | ) | const |
Returns the event type.
在文件 Vehicle.cpp 第 657 行定义.
引用了 getEventCount(), index, type , 以及 eve::vehicle::vehicleEventTypeName().
◆ getEventVehicleId()
| std::string eve::vehicle::Vehicle::getEventVehicleId | ( | int | index | ) | const |
◆ getEventX()
| float eve::vehicle::Vehicle::getEventX | ( | int | index | ) | const |
◆ getEventY()
| float eve::vehicle::Vehicle::getEventY | ( | int | index | ) | const |
◆ getFaction()
| std::string eve::vehicle::Vehicle::getFaction | ( | VehicleEntity * | v | ) |
◆ getHeading()
| float eve::vehicle::Vehicle::getHeading | ( | VehicleEntity * | v | ) |
◆ getHealth()
| float eve::vehicle::Vehicle::getHealth | ( | VehicleEntity * | v | ) |
◆ getHeight()
| float eve::vehicle::Vehicle::getHeight | ( | VehicleEntity * | v | ) |
3D 车身高度(无 3D 物理时返回 0)。
在文件 Vehicle.cpp 第 540 行定义.
引用了 eve::vehicle::VehiclePhysics::height() , 以及 v.
◆ getMaxHealth()
| float eve::vehicle::Vehicle::getMaxHealth | ( | VehicleEntity * | v | ) |
◆ getMobilityCount()
|
static |
已注册移动模型数量(内置 kinematic 起步)。
在文件 Vehicle.cpp 第 220 行定义.
◆ getMount()
| eve::weapon::WeaponMountEntity * eve::vehicle::Vehicle::getMount | ( | VehicleEntity * | v, |
| int | index | ||
| ) |
◆ getMountCount()
| int eve::vehicle::Vehicle::getMountCount | ( | VehicleEntity * | v | ) |
挂点查询(返回 weapon 模块的挂点实体)。
- 返回
- Borrowed nullable weapon-mount entity owned by the ECS world. @ownership The weapon module/ECS owns the mount; Vehicle never transfers or deletes it. @lifetime Valid until mount or world destruction; use its generation handle across frames. @thread Call on the Vehicle module's owning ECS thread. @reentrancy The query invokes no callbacks; do not retain the pointer across mutation.
在文件 Vehicle.cpp 第 546 行定义.
引用了 v.
◆ getPhysicsSpace()
| std::string eve::vehicle::Vehicle::getPhysicsSpace | ( | VehicleEntity * | v | ) |
返回存活绑定的 "2d"/"3d";缺失或 stale 时返回空字符串。
在文件 Vehicle.cpp 第 536 行定义.
引用了 eve::vehicle::VehiclePhysics::isAttached() , 以及 v.
◆ getSeatCameraMode()
| std::string eve::vehicle::Vehicle::getSeatCameraMode | ( | VehicleEntity * | v, |
| int | seatIndex | ||
| ) |
◆ getSeatCount()
| int eve::vehicle::Vehicle::getSeatCount | ( | VehicleEntity * | v | ) |
◆ getSeatMount()
| eve::weapon::WeaponMountEntity * eve::vehicle::Vehicle::getSeatMount | ( | VehicleEntity * | v, |
| int | seatIndex | ||
| ) |
座位绑定的武器挂点(mountIndex 无效返回 nullptr)。
- 返回
- Borrowed nullable weapon-mount entity owned by the ECS world. @ownership The weapon module/ECS owns the mount; Vehicle never transfers or deletes it. @lifetime Valid until mount or world destruction; a stored cross-frame reference must be a generation handle. @thread Call on the Vehicle module's owning ECS thread. @reentrancy The query invokes no callbacks; do not retain the pointer across seat or ECS mutation.
在文件 Vehicle.cpp 第 469 行定义.
◆ getSeatName()
| std::string eve::vehicle::Vehicle::getSeatName | ( | VehicleEntity * | v, |
| int | seatIndex | ||
| ) |
◆ getSeatOccupant()
| int eve::vehicle::Vehicle::getSeatOccupant | ( | VehicleEntity * | v, |
| int | seatIndex | ||
| ) |
◆ getSpeed()
| float eve::vehicle::Vehicle::getSpeed | ( | VehicleEntity * | v | ) |
◆ getVehicleDefinitionCount()
| int eve::vehicle::Vehicle::getVehicleDefinitionCount | ( | ) |
◆ getVehicleDefinitionMaxHealth()
| float eve::vehicle::Vehicle::getVehicleDefinitionMaxHealth | ( | const std::string & | id | ) |
Returns the vehicle definition max health.
在文件 Vehicle.cpp 第 209 行定义.
◆ getVehicleDefinitionMobility()
| std::string eve::vehicle::Vehicle::getVehicleDefinitionMobility | ( | const std::string & | id | ) |
Returns the vehicle definition mobility.
在文件 Vehicle.cpp 第 200 行定义.
◆ getX()
| float eve::vehicle::Vehicle::getX | ( | VehicleEntity * | v | ) |
◆ getY()
| float eve::vehicle::Vehicle::getY | ( | VehicleEntity * | v | ) |
◆ hasPhysics()
| bool eve::vehicle::Vehicle::hasPhysics | ( | VehicleEntity * | v | ) |
查询当前绑定是否仍能解析为存活刚体。
在文件 Vehicle.cpp 第 532 行定义.
引用了 eve::vehicle::VehiclePhysics::isAttached() , 以及 v.
◆ hasVehicleDefinition()
| bool eve::vehicle::Vehicle::hasVehicleDefinition | ( | const std::string & | id | ) |
◆ hold()
| void eve::vehicle::Vehicle::hold | ( | VehicleEntity * | v | ) |
Hold.
在文件 Vehicle.cpp 第 329 行定义.
引用了 eve::vehicle::Hold, eve::vehicle::VehicleSystem::pushOrder(), queued, eve::vehicle::VehicleOrder::type , 以及 v.
◆ isArrived()
| bool eve::vehicle::Vehicle::isArrived | ( | VehicleEntity * | v | ) |
◆ isDestroyed()
| bool eve::vehicle::Vehicle::isDestroyed | ( | VehicleEntity * | v | ) |
◆ isSeatOccupied()
| bool eve::vehicle::Vehicle::isSeatOccupied | ( | VehicleEntity * | v, |
| int | seatIndex | ||
| ) |
◆ Module_REG()
| eve::vehicle::Vehicle::Module_REG | ( | Vehicle | ) |
◆ moveTo()
| void eve::vehicle::Vehicle::moveTo | ( | VehicleEntity * | v, |
| float | x, | ||
| float | y | ||
| ) |
RTS 命令。
在文件 Vehicle.cpp 第 290 行定义.
引用了 eve::vehicle::Move, eve::vehicle::VehicleSystem::pushOrder(), queued, eve::vehicle::VehicleOrder::type, v, x, eve::vehicle::VehicleOrder::x, y , 以及 eve::vehicle::VehicleOrder::y.
◆ newVehicle()
| VehicleEntity * eve::vehicle::Vehicle::newVehicle | ( | const std::string & | defId, |
| float | x, | ||
| float | y, | ||
| float | heading = 0.f, |
||
| const std::string & | faction = "" |
||
| ) |
工厂:按模板创建载具并挂载武器挂点(ECS 表持有,脚本持有句柄)。
- 返回
- Borrowed nullable pointer to the ECS-owned vehicle; null means validation or creation failed. @ownership The ECS world owns the entity; callers must not delete it. @lifetime Valid until ECS destroys the entity or world; retain its generation handle across frames. @thread Call on the Vehicle module's owning ECS thread. @reentrancy Creation does not invoke user callbacks; do not mutate the ECS world re-entrantly while using the result.
在文件 Vehicle.cpp 第 232 行定义.
引用了 eve::vehicle::VehicleEntity::MountSlot::aimMode, eve::vehicle::VehicleEntity::SeatSlot::cameraMode, eve::vehicle::VehicleEntity::createVehicle(), eve::vehicle::VehicleEntity::SeatSlot::driver, heading, m, eve::vehicle::VehicleDefinition::maxHealth, eve::vehicle::VehicleEntity::MountSlot::mount, eve::vehicle::VehicleEntity::SeatSlot::mountIndex, eve::vehicle::VehicleDefinition::mounts, eve::vehicle::VehicleEntity::SeatSlot::name, requireModInst, eve::vehicle::VehicleDefinition::seats, v, w, x , 以及 y.
◆ orderCount()
| int eve::vehicle::Vehicle::orderCount | ( | VehicleEntity * | v | ) |
◆ registerMobility()
|
static |
注册移动模型(C++ 插件/游戏侧扩展点;同名替换)。
在文件 Vehicle.cpp 第 218 行定义.
◆ registerVehiclesFromJson()
| int eve::vehicle::Vehicle::registerVehiclesFromJson | ( | const std::string & | json | ) |
从 JSON 注册载具模板;返回成功注册数量。
在文件 Vehicle.cpp 第 133 行定义.
引用了 current, exists, eve::Value::fromJson(), eve::Value::getIf(), eve::definitions::DefinitionRegistry::insert(), n, name, eve::NotFound, eve::vehicle::parseVehicleDefinition(), eve::definitions::DefinitionRegistry::replace(), eve::definitions::DefinitionRegistry::resolve(), source, stored, eve::definitions::Definition::type , 以及 value.
◆ setFaction()
| void eve::vehicle::Vehicle::setFaction | ( | VehicleEntity * | v, |
| const std::string & | faction | ||
| ) |
◆ setHeading()
| void eve::vehicle::Vehicle::setHeading | ( | VehicleEntity * | v, |
| float | deg | ||
| ) |
◆ setHealth()
| void eve::vehicle::Vehicle::setHealth | ( | VehicleEntity * | v, |
| float | hp | ||
| ) |
◆ setInput()
| void eve::vehicle::Vehicle::setInput | ( | VehicleEntity * | v, |
| float | throttle, | ||
| float | steer, | ||
| float | brake = 0.f, |
||
| bool | handbrake = false |
||
| ) |
◆ setPlayerControls()
| void eve::vehicle::Vehicle::setPlayerControls | ( | int | playerId, |
| float | throttle, | ||
| float | steer, | ||
| float | brake, | ||
| bool | fire, | ||
| float | aimYaw, | ||
| float | aimPitch | ||
| ) |
写入玩家控制(归一化;角度为度)。
在文件 Vehicle.cpp 第 495 行定义.
引用了 c, eve::vehicle::VehicleSystem::setPlayerControls() , 以及 eve::vehicle::PlayerControl::throttle.
◆ setPosition()
| void eve::vehicle::Vehicle::setPosition | ( | VehicleEntity * | v, |
| float | x, | ||
| float | y | ||
| ) |
◆ stop()
| void eve::vehicle::Vehicle::stop | ( | VehicleEntity * | v | ) |
Stops .
在文件 Vehicle.cpp 第 321 行定义.
引用了 eve::vehicle::VehicleSystem::pushOrder(), queued, eve::vehicle::Stop, eve::vehicle::VehicleOrder::type , 以及 v.
◆ update()
| void eve::vehicle::Vehicle::update | ( | float | dt | ) |
每帧推进全部载具(命令 → 移动 → RTS 自动瞄准)。
在文件 Vehicle.cpp 第 559 行定义.
引用了 h, eve::vehicle::VehicleSystem::update() , 以及 v.
该类的文档由以下文件生成:
- src/modules/vehicle/Vehicle.h
- src/modules/vehicle/Vehicle.cpp
Public 成员函数 继承自