Skip to content

Commit 0d75a9e

Browse files
committed
Empty modifiers wont apply now
1 parent 59f36b7 commit 0d75a9e

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

Source/Attributes/Private/BaseAttr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ uint32 FBaseAttr::IdCount{ 0 };
99

1010
void FBaseAttr::AddModifier(const FAttrModifier& Modifier, const FAttrCategory& Category)
1111
{
12+
if (Modifier.IsEmpty())
13+
{
14+
return;
15+
}
16+
1217
if (Category == FAttrCategory::NoCategory)
1318
{
1419
BaseModifiers.Add(Modifier);

Source/Attributes/Private/Int32Attr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ void FInt32Attr::InternalRefreshValue(FAttributeChangeInfo&& ChangeInfo)
4343
}
4444

4545
Value = FMath::RoundToInt(TempValue);
46+
47+
// Notify changes
48+
OnModified.Broadcast(LastValue, ChangeInfo);
4649
}

Source/Attributes/Public/AttrModifier.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ struct ATTRIBUTES_API FAttrModifier
116116
}
117117

118118
bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess);
119+
120+
bool IsEmpty() const;
119121
};
120122

121123
template<>
@@ -166,3 +168,10 @@ inline bool FAttrModifier::NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bO
166168
bOutSuccess = true;
167169
return true;
168170
}
171+
172+
inline bool FAttrModifier::IsEmpty() const
173+
{
174+
return FMath::IsNearlyZero(Increment)
175+
&& FMath::IsNearlyZero(LastMultiplier)
176+
&& FMath::IsNearlyZero(BaseMultiplier);
177+
}

0 commit comments

Comments
 (0)