载入中...
搜索中...
未找到
eve::rpg::VitalsSystem类 参考

当前资源系统:读写 RPGActor::Vitals 并发出事件。 @thread 调用线程应与 RPGActor 的 ECS 线程一致。 更多...

#include <VitalsSystem.h>

静态 Public 成员函数

static double getCurrent (RPGActor *actor, const std::string &resource)
 当前值(无 vitals/资源时 0)。
 
static double getMax (RPGActor *actor, const std::string &resource)
 上限:取 actor 同名最终属性(getFinalAttribute),无则 0。
 
static void setCurrent (RPGActor *actor, const std::string &resource, double value)
 直接设定当前值,夹在 [0, max]。
 
static double takeDamage (RPGActor *actor, const std::string &resource, double amount, const std::string &source="")
 造成伤害:current -= amount,下限 0;归零时发 death 事件。
 
static double heal (RPGActor *actor, const std::string &resource, double amount)
 治疗:current += amount,上限 max。返回实际治疗量。
 
static void publishSettledChange (RPGActor *actor, const std::string &resource, const std::string &action, double amount, const std::string &source="")
 Publish resource events for a state change already committed by Settlement.
 
static void revive (RPGActor *actor, const std::string &resource, double amount=-1.0)
 复活:把资源设为 amount(默认当前上限),并清掉死亡状态。
 
static bool isDead (RPGActor *actor, const std::string &resource)
 是否死亡:max > 0 且 current <= 0。
 
static void pollEvents (std::vector< VitalsEvent > &out)
 取出并清空自上次调用以来累积的资源事件(push/poll 风格)。
 

详细描述

当前资源系统:读写 RPGActor::Vitals 并发出事件。 @thread 调用线程应与 RPGActor 的 ECS 线程一致。

在文件 VitalsSystem.h 第 38 行定义.

成员函数说明

◆ getCurrent()

double eve::rpg::VitalsSystem::getCurrent ( RPGActor *  actor,
const std::string &  resource 
)
static

当前值(无 vitals/资源时 0)。

在文件 VitalsSystem.cpp 第 30 行定义.

引用了 resource.

被这些函数引用 eve::rpg::RPGActor::getCurrent(), heal(), isDead(), publishSettledChange() , 以及 takeDamage().

◆ getMax()

double eve::rpg::VitalsSystem::getMax ( RPGActor *  actor,
const std::string &  resource 
)
static

上限:取 actor 同名最终属性(getFinalAttribute),无则 0。

在文件 VitalsSystem.cpp 第 36 行定义.

引用了 eve::rpg::AttributeSystem::getFinal() , 以及 resource.

被这些函数引用 eve::rpg::RPGActor::getMax(), heal(), isDead(), publishSettledChange(), revive(), setCurrent() , 以及 takeDamage().

◆ heal()

double eve::rpg::VitalsSystem::heal ( RPGActor *  actor,
const std::string &  resource,
double  amount 
)
static

治疗:current += amount,上限 max。返回实际治疗量。

在文件 VitalsSystem.cpp 第 62 行定义.

引用了 current, getCurrent(), getMax(), max , 以及 resource.

被这些函数引用 eve::rpg::RPGActor::heal().

◆ isDead()

bool eve::rpg::VitalsSystem::isDead ( RPGActor *  actor,
const std::string &  resource 
)
static

是否死亡:max > 0 且 current <= 0。

在文件 VitalsSystem.cpp 第 94 行定义.

引用了 getCurrent(), getMax(), max , 以及 resource.

被这些函数引用 eve::rpg::Battle::executeNextAction(), eve::rpg::Battle::isActorAlive() , 以及 eve::rpg::RPGActor::isDead().

◆ pollEvents()

void eve::rpg::VitalsSystem::pollEvents ( std::vector< VitalsEvent > &  out)
static

取出并清空自上次调用以来累积的资源事件(push/poll 风格)。

在文件 VitalsSystem.cpp 第 99 行定义.

被这些函数引用 eve::rpg::RPG::update().

◆ publishSettledChange()

void eve::rpg::VitalsSystem::publishSettledChange ( RPGActor *  actor,
const std::string &  resource,
const std::string &  action,
double  amount,
const std::string &  source = "" 
)
static

Publish resource events for a state change already committed by Settlement.

参数
actorActor whose authoritative Vitals state has already changed.
resourceResource that changed.
actionEither damage or heal.
amountApplied non-negative magnitude.
sourceOptional damage source identifier.
备注
This does not mutate resource state. Call only after the settlement transaction succeeds. @thread Call on the actor's owning simulation thread. @reentrancy Does not invoke callbacks.

在文件 VitalsSystem.cpp 第 74 行定义.

引用了 action, current, getCurrent(), getMax(), maximum, resource , 以及 source.

被这些函数引用 eve::rpg::Battle::settleStatusTick().

◆ revive()

void eve::rpg::VitalsSystem::revive ( RPGActor *  actor,
const std::string &  resource,
double  amount = -1.0 
)
static

复活:把资源设为 amount(默认当前上限),并清掉死亡状态。

在文件 VitalsSystem.cpp 第 85 行定义.

引用了 current, getMax(), max, resource , 以及 value.

被这些函数引用 eve::rpg::RPGActor::revive().

◆ setCurrent()

void eve::rpg::VitalsSystem::setCurrent ( RPGActor *  actor,
const std::string &  resource,
double  value 
)
static

直接设定当前值,夹在 [0, max]。

在文件 VitalsSystem.cpp 第 40 行定义.

引用了 getMax(), max, resource , 以及 value.

被这些函数引用 eve::rpg::RPGActor::setCurrent().

◆ takeDamage()

double eve::rpg::VitalsSystem::takeDamage ( RPGActor *  actor,
const std::string &  resource,
double  amount,
const std::string &  source = "" 
)
static

造成伤害:current -= amount,下限 0;归零时发 death 事件。

返回
实际生效的伤害量(夹在 [0, currentBefore])。

在文件 VitalsSystem.cpp 第 46 行定义.

引用了 current, getCurrent(), getMax(), max, resource , 以及 source.

被这些函数引用 eve::rpg::RPGActor::takeDamage().


该类的文档由以下文件生成: