武器模块(eve.Weapon)。 更多...
#include <Weapon.h>
Public 成员函数 | |
| Module_REG (Weapon) | |
| Weapon () | |
| Weapon. | |
| ~Weapon () override | |
| Weapon. | |
| int | registerWeaponsFromJson (const std::string &json) |
| 从 JSON 注册武器模板;返回成功注册数量。 | |
| void | clearWeaponDefinitions () |
| 清空全部武器模板。 | |
| int | getWeaponDefinitionCount () |
| 已注册武器模板数量。 | |
| bool | hasWeaponDefinition (const std::string &id) |
| 武器模板查询。 | |
| std::string | getWeaponDefinitionLogic (const std::string &id) |
| Returns the weapon definition logic. | |
| float | getWeaponDefinitionDamage (const std::string &id) |
| Returns the weapon definition damage. | |
| float | getWeaponDefinitionRange (const std::string &id) |
| Returns the weapon definition range. | |
| eve::definitions::DefinitionRegistry & | definitionRegistry () noexcept |
| Return the common registry backing legacy weapon definitions. | |
| WeaponEntity * | newWeapon (const std::string &defId) |
| 工厂:对象由 ECS 表持有,脚本持有的是非拥有句柄。 | |
| WeaponMountEntity * | newMount (const std::string &id, const std::string &type="turret") |
| 创建一个挂点(炮塔/机枪座等)。 | |
| WeaponRigEntity * | newRig (const std::string &id, const std::string &wield="right_hand") |
| 创建一个手持位(ARPG/RPG 角色手持武器)。 | |
| bool | rigAttachWeapon (WeaponRigEntity *rig, WeaponEntity *w) |
| 手持位操作:挂武器 / 取武器 / 设置持有位姿。 | |
| WeaponEntity * | rigGetWeapon (WeaponRigEntity *rig) |
| Rig get weapon. | |
| void | rigSetPose (WeaponRigEntity *rig, float px, float py, float pz, float rx, float ry, float rz) |
| Rig set pose. | |
| AmmoPoolEntity * | newAmmoPool (const std::string &id, const std::string &ammoType, int max=-1) |
| 共享弹药池操作:创建 / 补弹 / 查询 / 绑定武器 / 解绑 / 取绑定池。 | |
| void | ammoPoolAdd (AmmoPoolEntity *pool, int n) |
| Ammo pool add. | |
| int | ammoPoolGetCount (AmmoPoolEntity *pool) |
| Ammo pool get count. | |
| bool | bindAmmoPool (WeaponEntity *w, AmmoPoolEntity *pool) |
| Binds ammo pool. | |
| void | unbindAmmoPool (WeaponEntity *w) |
| Unbinds ammo pool. | |
| AmmoPoolEntity * | getAmmoPool (WeaponEntity *w) |
| Returns the weapon's shared ammunition pool, or null when unbound. | |
| bool | mountAttachWeapon (WeaponMountEntity *m, WeaponEntity *w) |
| 挂点操作:挂武器 / 取武器 / 限位 / 瞄准 / 击毁。 | |
| WeaponEntity * | mountGetWeapon (WeaponMountEntity *m) |
| Returns the weapon mounted on a mount, or null when empty. | |
| void | mountSetLimits (WeaponMountEntity *m, float yawMin, float yawMax, float pitchMin, float pitchMax, float rotSpeed, float firingArc) |
| Mounts set limits. | |
| void | mountAimAt (WeaponMountEntity *m, float yaw, float pitch) |
| 按限位夹取目标角并写入挂载武器的瞄准目标(角度,度)。 | |
| void | mountDestroy (WeaponMountEntity *m) |
| 标记挂点被击毁(炮塔被打掉);已毁挂点不再瞄准/开火。 | |
| bool | fire (WeaponEntity *w, const FireRequest &req) |
| 武器操作(脚本便捷入口,转发 WeaponSystem)。 | |
| bool | fireAt (WeaponEntity *w, float x, float y, float z, int shooterId=0) |
| 向目标点开火(自动生成 FireRequest)。 | |
| bool | attack (WeaponEntity *w, float yaw, float pitch, int shooterId=0) |
| 触发展开攻击(近战/法杖/导弹走阶段机;热武器等价 fire)。 | |
| bool | canFire (WeaponEntity *w) |
| Can fire. | |
| void | startReload (WeaponEntity *w) |
| Starts reload. | |
| void | cancelReload (WeaponEntity *w) |
| Cancel reload. | |
| void | setAim (WeaponEntity *w, float yaw, float pitch) |
| Sets the aim. | |
| bool | setFireMode (WeaponEntity *w, const std::string &mode) |
| 运行时射击模式切换(safe/semi/auto)。 | |
| std::string | getFireMode (WeaponEntity *w) |
| 当前射击模式名("single"|"burst"|"auto")。 | |
| int | getSelectableModeCount (WeaponEntity *w) |
| 可选射击模式数量 / 第 index 个模式名。 | |
| std::string | getSelectableMode (WeaponEntity *w, int index) |
| Returns the selectable mode. | |
| bool | setAiming (WeaponEntity *w, bool aiming) |
| 开镜(ADS):切换 aiming 状态并推 aim_in/aim_out 事件。 | |
| bool | isAiming (WeaponEntity *w) |
| True when aiming. | |
| float | getZoomFov (WeaponEntity *w) |
| 开镜缩放 FOV(模板 zoomFov)。 | |
| float | getSpread (WeaponEntity *w) |
| 手感查询:当前散布 / 未回正后坐。 | |
| float | getRecoilPitch (WeaponEntity *w) |
| Returns the recoil pitch. | |
| float | getRecoilYaw (WeaponEntity *w) |
| Returns the recoil yaw. | |
| void | update (float dt) |
| 每帧推进全部武器与挂点。 | |
| void | clearEvents () |
| 事件队列(fire/reload/empty,上一次 update 产生)。 | |
| int | getEventCount () const |
| Returns the event count. | |
| std::string | getEventType (int index) const |
| Returns the event type. | |
| std::string | getEventWeaponId (int index) const |
| Returns the event weapon id. | |
| std::string | getEventDefId (int index) const |
| Returns the event def id. | |
| std::string | getEventMountId (int index) const |
| Returns the event mount id. | |
| int | getEventAmmoLeft (int index) const |
| Returns the event ammo left. | |
| float | getEventArc (int index) const |
| 近战命中弧(仅 fire 事件)。 | |
| float | getEventAoe (int index) const |
| 法术/导弹爆炸半径(仅 fire 事件)。 | |
| float | getEventSpread (int index) const |
| P0 手感/伤害事件载荷(仅 fire 事件)。 | |
| int | getEventPellets (int index) const |
| Returns the event pellets. | |
| float | getEventRecoilPitch (int index) const |
| Returns the event recoil pitch. | |
| float | getEventRecoilYaw (int index) const |
| Returns the event recoil yaw. | |
| std::string | getEventDamageType (int index) const |
| Returns the event damage type. | |
| std::string | getEventElement (int index) const |
| Returns the event element. | |
| std::string | getStage (WeaponEntity *w) const |
| 武器当前阶段("idle"|"windup"|"active"|"recover")。 | |
| float | getResourceValue (WeaponEntity *w) const |
| 武器当前资源值(弹药/法力/充能/体力)。 | |
Public 成员函数 继承自 eve::Module | |
| virtual | ~Module () |
| Module. | |
| virtual std::string | getName () const =0 |
| Returns the name. | |
静态 Public 成员函数 | |
| static void | registerLogic (IWeaponLogic *logic) |
| 注册武器逻辑(C++ 插件/游戏侧扩展点;同名替换)。 | |
| static int | getLogicCount () |
| 已注册逻辑数量(内置 hitscan / projectile 起步)。 | |
详细描述
构造及析构函数说明
◆ Weapon()
| eve::weapon::Weapon::Weapon | ( | ) |
◆ ~Weapon()
|
override |
成员函数说明
◆ ammoPoolAdd()
| void eve::weapon::Weapon::ammoPoolAdd | ( | AmmoPoolEntity * | pool, |
| int | n | ||
| ) |
◆ ammoPoolGetCount()
| int eve::weapon::Weapon::ammoPoolGetCount | ( | AmmoPoolEntity * | pool | ) |
Ammo pool get count.
在文件 Weapon.cpp 第 387 行定义.
◆ attack()
| bool eve::weapon::Weapon::attack | ( | WeaponEntity * | w, |
| float | yaw, | ||
| float | pitch, | ||
| int | shooterId = 0 |
||
| ) |
触发展开攻击(近战/法杖/导弹走阶段机;热武器等价 fire)。
在文件 Weapon.cpp 第 461 行定义.
引用了 eve::weapon::AttackRequest::aoeRadius, eve::weapon::AttackRequest::arcAngle, d, pitch, eve::weapon::AttackRequest::pitch, eve::weapon::AttackRequest::shooterId, eve::weapon::WeaponSystem::tryFire(), w, yaw , 以及 eve::weapon::AttackRequest::yaw.
◆ bindAmmoPool()
| bool eve::weapon::Weapon::bindAmmoPool | ( | WeaponEntity * | w, |
| AmmoPoolEntity * | pool | ||
| ) |
◆ cancelReload()
| void eve::weapon::Weapon::cancelReload | ( | WeaponEntity * | w | ) |
◆ canFire()
| bool eve::weapon::Weapon::canFire | ( | WeaponEntity * | w | ) |
◆ clearEvents()
| void eve::weapon::Weapon::clearEvents | ( | ) |
事件队列(fire/reload/empty,上一次 update 产生)。
在文件 Weapon.cpp 第 562 行定义.
◆ clearWeaponDefinitions()
| void eve::weapon::Weapon::clearWeaponDefinitions | ( | ) |
◆ definitionRegistry()
|
inlinenoexcept |
Return the common registry backing legacy weapon definitions.
- 返回
- A borrowed owner-thread-affine registry used by WeaponDefinitionRuntime. The module owns it. @ownership Borrowed; this module retains ownership. @lifetime Valid until this Weapon module is destroyed.
◆ fire()
| bool eve::weapon::Weapon::fire | ( | WeaponEntity * | w, |
| const FireRequest & | req | ||
| ) |
武器操作(脚本便捷入口,转发 WeaponSystem)。
在文件 Weapon.cpp 第 448 行定义.
引用了 eve::weapon::WeaponSystem::tryFire() , 以及 w.
◆ fireAt()
| bool eve::weapon::Weapon::fireAt | ( | WeaponEntity * | w, |
| float | x, | ||
| float | y, | ||
| float | z, | ||
| int | shooterId = 0 |
||
| ) |
向目标点开火(自动生成 FireRequest)。
在文件 Weapon.cpp 第 450 行定义.
引用了 eve::weapon::AttackRequest::hasTarget, eve::weapon::AttackRequest::shooterId, eve::weapon::AttackRequest::targetX, eve::weapon::AttackRequest::targetY, eve::weapon::AttackRequest::targetZ, eve::weapon::WeaponSystem::tryFire(), w, x, y , 以及 z.
◆ getAmmoPool()
| AmmoPoolEntity * eve::weapon::Weapon::getAmmoPool | ( | WeaponEntity * | w | ) |
Returns the weapon's shared ammunition pool, or null when unbound.
- 返回
- Borrowed nullable ECS-owned pool. @ownership The ECS world owns the pool; this query transfers no ownership. @lifetime Valid until pool/world destruction or unbinding; use its generation handle across frames. @thread Call on the owning ECS thread. @reentrancy The query invokes no callbacks and is invalid across ECS mutation.
在文件 Weapon.cpp 第 399 行定义.
引用了 w.
◆ getEventAmmoLeft()
| int eve::weapon::Weapon::getEventAmmoLeft | ( | int | index | ) | const |
◆ getEventAoe()
| float eve::weapon::Weapon::getEventAoe | ( | int | index | ) | const |
◆ getEventArc()
| float eve::weapon::Weapon::getEventArc | ( | int | index | ) | const |
◆ getEventCount()
| int eve::weapon::Weapon::getEventCount | ( | ) | const |
Returns the event count.
在文件 Weapon.cpp 第 564 行定义.
被这些函数引用 getEventAmmoLeft(), getEventAoe(), getEventArc(), getEventDamageType(), getEventDefId(), getEventElement(), getEventMountId(), getEventPellets(), getEventRecoilPitch(), getEventRecoilYaw(), getEventSpread(), getEventType() , 以及 getEventWeaponId().
◆ getEventDamageType()
| std::string eve::weapon::Weapon::getEventDamageType | ( | int | index | ) | const |
◆ getEventDefId()
| std::string eve::weapon::Weapon::getEventDefId | ( | int | index | ) | const |
◆ getEventElement()
| std::string eve::weapon::Weapon::getEventElement | ( | int | index | ) | const |
◆ getEventMountId()
| std::string eve::weapon::Weapon::getEventMountId | ( | int | index | ) | const |
◆ getEventPellets()
| int eve::weapon::Weapon::getEventPellets | ( | int | index | ) | const |
◆ getEventRecoilPitch()
| float eve::weapon::Weapon::getEventRecoilPitch | ( | int | index | ) | const |
◆ getEventRecoilYaw()
| float eve::weapon::Weapon::getEventRecoilYaw | ( | int | index | ) | const |
◆ getEventSpread()
| float eve::weapon::Weapon::getEventSpread | ( | int | index | ) | const |
◆ getEventType()
| std::string eve::weapon::Weapon::getEventType | ( | int | index | ) | const |
Returns the event type.
在文件 Weapon.cpp 第 566 行定义.
引用了 getEventCount(), index, type , 以及 eve::weapon::weaponEventTypeName().
◆ getEventWeaponId()
| std::string eve::weapon::Weapon::getEventWeaponId | ( | int | index | ) | const |
◆ getFireMode()
| std::string eve::weapon::Weapon::getFireMode | ( | WeaponEntity * | w | ) |
◆ getLogicCount()
|
static |
已注册逻辑数量(内置 hitscan / projectile 起步)。
在文件 Weapon.cpp 第 275 行定义.
◆ getRecoilPitch()
| float eve::weapon::Weapon::getRecoilPitch | ( | WeaponEntity * | w | ) |
◆ getRecoilYaw()
| float eve::weapon::Weapon::getRecoilYaw | ( | WeaponEntity * | w | ) |
◆ getResourceValue()
| float eve::weapon::Weapon::getResourceValue | ( | WeaponEntity * | w | ) | const |
◆ getSelectableMode()
| std::string eve::weapon::Weapon::getSelectableMode | ( | WeaponEntity * | w, |
| int | index | ||
| ) |
Returns the selectable mode.
在文件 Weapon.cpp 第 514 行定义.
引用了 d, eve::weapon::fireModeName(), index , 以及 w.
◆ getSelectableModeCount()
| int eve::weapon::Weapon::getSelectableModeCount | ( | WeaponEntity * | w | ) |
◆ getSpread()
| float eve::weapon::Weapon::getSpread | ( | WeaponEntity * | w | ) |
◆ getStage()
| std::string eve::weapon::Weapon::getStage | ( | WeaponEntity * | w | ) | const |
武器当前阶段("idle"|"windup"|"active"|"recover")。
在文件 Weapon.cpp 第 618 行定义.
引用了 eve::weapon::attackStageName() , 以及 w.
◆ getWeaponDefinitionCount()
| int eve::weapon::Weapon::getWeaponDefinitionCount | ( | ) |
◆ getWeaponDefinitionDamage()
| float eve::weapon::Weapon::getWeaponDefinitionDamage | ( | const std::string & | id | ) |
Returns the weapon definition damage.
在文件 Weapon.cpp 第 255 行定义.
◆ getWeaponDefinitionLogic()
| std::string eve::weapon::Weapon::getWeaponDefinitionLogic | ( | const std::string & | id | ) |
Returns the weapon definition logic.
在文件 Weapon.cpp 第 246 行定义.
◆ getWeaponDefinitionRange()
| float eve::weapon::Weapon::getWeaponDefinitionRange | ( | const std::string & | id | ) |
Returns the weapon definition range.
在文件 Weapon.cpp 第 264 行定义.
◆ getZoomFov()
| float eve::weapon::Weapon::getZoomFov | ( | WeaponEntity * | w | ) |
开镜缩放 FOV(模板 zoomFov)。
在文件 Weapon.cpp 第 533 行定义.
引用了 d, w , 以及 eve::weapon::WeaponDefinition::zoomFov.
◆ hasWeaponDefinition()
| bool eve::weapon::Weapon::hasWeaponDefinition | ( | const std::string & | id | ) |
◆ isAiming()
| bool eve::weapon::Weapon::isAiming | ( | WeaponEntity * | w | ) |
◆ Module_REG()
| eve::weapon::Weapon::Module_REG | ( | Weapon | ) |
◆ mountAimAt()
| void eve::weapon::Weapon::mountAimAt | ( | WeaponMountEntity * | m, |
| float | yaw, | ||
| float | pitch | ||
| ) |
◆ mountAttachWeapon()
| bool eve::weapon::Weapon::mountAttachWeapon | ( | WeaponMountEntity * | m, |
| WeaponEntity * | w | ||
| ) |
◆ mountDestroy()
| void eve::weapon::Weapon::mountDestroy | ( | WeaponMountEntity * | m | ) |
◆ mountGetWeapon()
| WeaponEntity * eve::weapon::Weapon::mountGetWeapon | ( | WeaponMountEntity * | m | ) |
Returns the weapon mounted on a mount, or null when empty.
- 返回
- Borrowed nullable ECS-owned weapon. @ownership The ECS world owns the weapon; this query transfers no ownership. @lifetime Valid until weapon/world destruction or unmounting; use its generation handle across frames. @thread Call on the owning ECS thread. @reentrancy The query invokes no callbacks and is invalid across ECS mutation.
在文件 Weapon.cpp 第 411 行定义.
引用了 m.
◆ mountSetLimits()
| void eve::weapon::Weapon::mountSetLimits | ( | WeaponMountEntity * | m, |
| float | yawMin, | ||
| float | yawMax, | ||
| float | pitchMin, | ||
| float | pitchMax, | ||
| float | rotSpeed, | ||
| float | firingArc | ||
| ) |
◆ newAmmoPool()
| AmmoPoolEntity * eve::weapon::Weapon::newAmmoPool | ( | const std::string & | id, |
| const std::string & | ammoType, | ||
| int | max = -1 |
||
| ) |
共享弹药池操作:创建 / 补弹 / 查询 / 绑定武器 / 解绑 / 取绑定池。
Creates an ECS-owned shared ammunition pool.
- 返回
- Borrowed nullable ECS-owned pool; null means creation failed. @ownership The ECS world owns the pool; callers must not delete it. @lifetime Valid until pool/world destruction; retain its generation handle across frames. @thread Call on the owning ECS thread. @reentrancy Creation invokes no external callbacks; do not re-enter structural ECS mutation.
在文件 Weapon.cpp 第 369 行定义.
引用了 eve::weapon::AmmoPoolEntity::createPool(), id, max , 以及 p.
◆ newMount()
| WeaponMountEntity * eve::weapon::Weapon::newMount | ( | const std::string & | id, |
| const std::string & | type = "turret" |
||
| ) |
创建一个挂点(炮塔/机枪座等)。
- 返回
- Borrowed nullable ECS-owned mount; null means creation failed. @ownership The ECS world owns the entity; callers must not delete it. @lifetime Valid until entity/world destruction; retain its generation handle across frames. @thread Call on the owning ECS thread. @reentrancy Creation invokes no external callbacks; do not re-enter structural ECS mutation.
在文件 Weapon.cpp 第 327 行定义.
引用了 eve::weapon::WeaponMountEntity::createMount(), id, m , 以及 type.
◆ newRig()
| WeaponRigEntity * eve::weapon::Weapon::newRig | ( | const std::string & | id, |
| const std::string & | wield = "right_hand" |
||
| ) |
创建一个手持位(ARPG/RPG 角色手持武器)。
- 返回
- Borrowed nullable ECS-owned rig; null means creation failed. @ownership The ECS world owns the entity; callers must not delete it. @lifetime Valid until entity/world destruction; retain its generation handle across frames. @thread Call on the owning ECS thread. @reentrancy Creation invokes no external callbacks; do not re-enter structural ECS mutation.
在文件 Weapon.cpp 第 335 行定义.
引用了 eve::weapon::WeaponRigEntity::createRig(), id , 以及 r.
◆ newWeapon()
| WeaponEntity * eve::weapon::Weapon::newWeapon | ( | const std::string & | defId | ) |
工厂:对象由 ECS 表持有,脚本持有的是非拥有句柄。
- 返回
- Borrowed nullable ECS-owned weapon; null means validation or creation failed. @ownership The ECS world owns the entity; callers must not delete it. @lifetime Valid until entity/world destruction; retain its generation handle across frames. @thread Call on the owning ECS thread. @reentrancy Creation invokes no external callbacks; do not re-enter structural ECS mutation.
在文件 Weapon.cpp 第 287 行定义.
引用了 eve::weapon::Ammo, eve::weapon::AttackResource::cost, eve::weapon::WeaponEntity::createWeapon(), d, eve::weapon::WeaponDefinition::fireMode, eve::weapon::AttackResource::infinite, eve::weapon::AttackResource::kind, eve::weapon::WeaponDefinition::kind, eve::weapon::Resource::kind, eve::weapon::WeaponDefinition::magSize, eve::weapon::AttackResource::max, r, eve::weapon::Ranged, eve::weapon::AttackResource::regen, eve::weapon::WeaponDefinition::reserveSize, eve::weapon::WeaponDefinition::resource, eve::weapon::WeaponDefinition::spreadMin , 以及 w.
◆ registerLogic()
|
static |
注册武器逻辑(C++ 插件/游戏侧扩展点;同名替换)。
在文件 Weapon.cpp 第 273 行定义.
◆ registerWeaponsFromJson()
| int eve::weapon::Weapon::registerWeaponsFromJson | ( | const std::string & | json | ) |
从 JSON 注册武器模板;返回成功注册数量。
在文件 Weapon.cpp 第 182 行定义.
引用了 current, exists, eve::Value::fromJson(), eve::definitions::DefinitionRegistry::insert(), n, name, eve::NotFound, eve::weapon::parseWeaponDefinition(), eve::definitions::DefinitionRegistry::replace(), eve::definitions::DefinitionRegistry::resolve(), root, source, stored, eve::definitions::Definition::type , 以及 value.
◆ rigAttachWeapon()
| bool eve::weapon::Weapon::rigAttachWeapon | ( | WeaponRigEntity * | rig, |
| WeaponEntity * | w | ||
| ) |
◆ rigGetWeapon()
| WeaponEntity * eve::weapon::Weapon::rigGetWeapon | ( | WeaponRigEntity * | rig | ) |
Rig get weapon.
在文件 Weapon.cpp 第 353 行定义.
◆ rigSetPose()
| void eve::weapon::Weapon::rigSetPose | ( | WeaponRigEntity * | rig, |
| float | px, | ||
| float | py, | ||
| float | pz, | ||
| float | rx, | ||
| float | ry, | ||
| float | rz | ||
| ) |
◆ setAim()
| void eve::weapon::Weapon::setAim | ( | WeaponEntity * | w, |
| float | yaw, | ||
| float | pitch | ||
| ) |
◆ setAiming()
| bool eve::weapon::Weapon::setAiming | ( | WeaponEntity * | w, |
| bool | aiming | ||
| ) |
开镜(ADS):切换 aiming 状态并推 aim_in/aim_out 事件。
在文件 Weapon.cpp 第 520 行定义.
引用了 eve::weapon::AimIn, eve::weapon::AimOut, d, eve::weapon::WeaponEvent::defId, eve::weapon::WeaponSystem::emitEvent(), eve::weapon::WeaponEvent::type, w , 以及 eve::weapon::WeaponEvent::weaponId.
◆ setFireMode()
| bool eve::weapon::Weapon::setFireMode | ( | WeaponEntity * | w, |
| const std::string & | mode | ||
| ) |
运行时射击模式切换(safe/semi/auto)。
在文件 Weapon.cpp 第 490 行定义.
引用了 d, eve::weapon::fireModeFromName(), m , 以及 w.
◆ startReload()
| void eve::weapon::Weapon::startReload | ( | WeaponEntity * | w | ) |
◆ unbindAmmoPool()
| void eve::weapon::Weapon::unbindAmmoPool | ( | WeaponEntity * | w | ) |
◆ update()
| void eve::weapon::Weapon::update | ( | float | dt | ) |
该类的文档由以下文件生成:
- src/modules/weapon/Weapon.h
- src/modules/weapon/Weapon.cpp
Public 成员函数 继承自