1
This commit is contained in:
parent
dc42d58485
commit
d9682382b9
@ -371,20 +371,38 @@ float Ability::GetFixedSped()
|
|||||||
|
|
||||||
AttrAdditionHandle Ability::AddAttr(int attr_id, float rate)
|
AttrAdditionHandle Ability::AddAttr(int attr_id, float rate)
|
||||||
{
|
{
|
||||||
|
if (IsValidHumanAttr(attr_id)) {
|
||||||
|
auto p = std::make_shared<AttrAddition>();
|
||||||
|
p->value = rate;
|
||||||
|
INIT_LIST_HEAD(&p->entry);
|
||||||
|
list_add_tail(&p->entry, &std::get<1>(attr_add_[attr_id]));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ability::RemoveAttrAddition(AttrAdditionHandle handler)
|
void Ability::RemoveAttrAddition(AttrAdditionHandle handle)
|
||||||
{
|
{
|
||||||
|
if (handle && !list_empty(&handle->entry)) {
|
||||||
|
list_del_init(&handle->entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrRuduceHandle Ability::DecAttr(int attr_id, float rate)
|
AttrRuduceHandle Ability::DecAttr(int attr_id, float rate)
|
||||||
{
|
{
|
||||||
|
if (IsValidHumanAttr(attr_id)) {
|
||||||
|
auto p = std::make_shared<AttrRuduce>();
|
||||||
|
p->value = rate;
|
||||||
|
INIT_LIST_HEAD(&p->entry);
|
||||||
|
list_add_tail(&p->entry, &std::get<1>(attr_dec_[attr_id]));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ability::RemoveAttrRuduce(AttrRuduceHandle handler)
|
void Ability::RemoveAttrRuduce(AttrRuduceHandle handle)
|
||||||
{
|
{
|
||||||
|
if (handle && !list_empty(&handle->entry)) {
|
||||||
|
list_del_init(&handle->entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#include "attrdefine.h"
|
#include "attrdefine.h"
|
||||||
#include "weakptr.h"
|
#include "weakptr.h"
|
||||||
|
|
||||||
typedef std::weak_ptr<struct AttrAddition> AttrAdditionHandle;
|
typedef std::shared_ptr<struct AttrAddition> AttrAdditionHandle;
|
||||||
typedef std::weak_ptr<struct AttrRuduce> AttrRuduceHandle;
|
typedef std::shared_ptr<struct AttrRuduce> AttrRuduceHandle;
|
||||||
|
|
||||||
class Room;
|
class Room;
|
||||||
class Human;
|
class Human;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user