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

面向 RPGActor 的属性操作静态入口。数据本身存放在 RPGActor::Attributes 组件里, 这里只是围绕组件的一组无状态操作函数(+ 一张全局自定义 op 表)。 更多...

#include <AttributeSystem.h>

静态 Public 成员函数

static AttributeOpTablecustomOps ()
 全局自定义 op 注册表(进程生命周期内有效)。
 
static void setBase (RPGActor *actor, const std::string &attribute, double value)
 设置基础值(不存在则创建该属性)。
 
static double getBase (RPGActor *actor, const std::string &attribute)
 
static void modifyBase (RPGActor *actor, const std::string &attribute, double delta)
 增量修改基础值(如自然回蓝、升级加点)。
 
static bool hasAttribute (RPGActor *actor, const std::string &attribute)
 
static std::string addModifier (RPGActor *actor, const std::string &attribute, const std::string &source, const std::string &op, double value, int priority=0)
 添加一条修改器,返回自动生成的唯一 id(用于之后精确移除)。 空字符串 id 表示失败(actor 为空)。
 
static bool removeModifier (RPGActor *actor, const std::string &attribute, const std::string &modifierId)
 按 id 精确移除;返回是否命中。
 
static int removeModifiersBySource (RPGActor *actor, const std::string &attribute, const std::string &source)
 按来源标签批量移除某个属性上的修改器;返回移除数量。
 
static int removeAllModifiersBySource (RPGActor *actor, const std::string &source)
 按来源标签批量移除该 actor 所有属性上的修改器;返回移除数量。
 
static double getFinal (RPGActor *actor, const std::string &attribute)
 计算并返回最终值(内部带缓存,属性未变化时不会重复计算)。
 
static void invalidate (RPGActor *actor, const std::string &attribute)
 标记某个属性需要在下次 getFinal 时重新计算(内部使用;一般不需要手动调用)。
 

详细描述

面向 RPGActor 的属性操作静态入口。数据本身存放在 RPGActor::Attributes 组件里, 这里只是围绕组件的一组无状态操作函数(+ 一张全局自定义 op 表)。

在文件 AttributeSystem.h39 行定义.

成员函数说明

◆ addModifier()

std::string eve::rpg::AttributeSystem::addModifier ( RPGActor actor,
const std::string &  attribute,
const std::string &  source,
const std::string &  op,
double  value,
int  priority = 0 
)
static

添加一条修改器,返回自动生成的唯一 id(用于之后精确移除)。 空字符串 id 表示失败(actor 为空)。

在文件 AttributeSystem.cpp102 行定义.

引用了 eve::rpg::AttributeModifier::id, id, eve::rpg::AttributeModifier::op, priority, eve::rpg::AttributeModifier::priority, eve::rpg::AttributeModifier::source, value , 以及 eve::rpg::AttributeModifier::value.

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

◆ customOps()

AttributeOpTable & eve::rpg::AttributeSystem::customOps ( )
static

全局自定义 op 注册表(进程生命周期内有效)。

在文件 AttributeSystem.cpp65 行定义.

被这些函数引用 getFinal().

◆ getBase()

double eve::rpg::AttributeSystem::getBase ( RPGActor actor,
const std::string &  attribute 
)
static

在文件 AttributeSystem.cpp82 行定义.

引用了 values.

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

◆ getFinal()

double eve::rpg::AttributeSystem::getFinal ( RPGActor actor,
const std::string &  attribute 
)
static

计算并返回最终值(内部带缓存,属性未变化时不会重复计算)。

在文件 AttributeSystem.cpp168 行定义.

引用了 eve::rpg::computeAttributeValue() , 以及 customOps().

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

◆ hasAttribute()

bool eve::rpg::AttributeSystem::hasAttribute ( RPGActor actor,
const std::string &  attribute 
)
static

在文件 AttributeSystem.cpp96 行定义.

引用了 values.

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

◆ invalidate()

void eve::rpg::AttributeSystem::invalidate ( RPGActor actor,
const std::string &  attribute 
)
static

标记某个属性需要在下次 getFinal 时重新计算(内部使用;一般不需要手动调用)。

在文件 AttributeSystem.cpp178 行定义.

引用了 values.

◆ modifyBase()

void eve::rpg::AttributeSystem::modifyBase ( RPGActor actor,
const std::string &  attribute,
double  delta 
)
static

增量修改基础值(如自然回蓝、升级加点)。

在文件 AttributeSystem.cpp89 行定义.

被这些函数引用 eve::rpg::StatusSystem::apply() , 以及 eve::rpg::RPGActor::modifyBaseAttribute().

◆ removeAllModifiersBySource()

int eve::rpg::AttributeSystem::removeAllModifiersBySource ( RPGActor actor,
const std::string &  source 
)
static

按来源标签批量移除该 actor 所有属性上的修改器;返回移除数量。

在文件 AttributeSystem.cpp150 行定义.

引用了 m , 以及 removed.

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

◆ removeModifier()

bool eve::rpg::AttributeSystem::removeModifier ( RPGActor actor,
const std::string &  attribute,
const std::string &  modifierId 
)
static

按 id 精确移除;返回是否命中。

在文件 AttributeSystem.cpp119 行定义.

引用了 m , 以及 values.

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

◆ removeModifiersBySource()

int eve::rpg::AttributeSystem::removeModifiersBySource ( RPGActor actor,
const std::string &  attribute,
const std::string &  source 
)
static

按来源标签批量移除某个属性上的修改器;返回移除数量。

在文件 AttributeSystem.cpp134 行定义.

引用了 m, removed , 以及 values.

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

◆ setBase()

void eve::rpg::AttributeSystem::setBase ( RPGActor actor,
const std::string &  attribute,
double  value 
)
static

设置基础值(不存在则创建该属性)。

在文件 AttributeSystem.cpp75 行定义.

引用了 value.

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


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