Skip to content

Commit

Permalink
Empty modifiers wont apply now
Browse files Browse the repository at this point in the history
  • Loading branch information
muit committed Oct 25, 2019
1 parent 59f36b7 commit 0d75a9e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/Attributes/Private/BaseAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ uint32 FBaseAttr::IdCount{ 0 };

void FBaseAttr::AddModifier(const FAttrModifier& Modifier, const FAttrCategory& Category)
{
if (Modifier.IsEmpty())
{
return;
}

if (Category == FAttrCategory::NoCategory)
{
BaseModifiers.Add(Modifier);
Expand Down
3 changes: 3 additions & 0 deletions Source/Attributes/Private/Int32Attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ void FInt32Attr::InternalRefreshValue(FAttributeChangeInfo&& ChangeInfo)
}

Value = FMath::RoundToInt(TempValue);

// Notify changes
OnModified.Broadcast(LastValue, ChangeInfo);
}
9 changes: 9 additions & 0 deletions Source/Attributes/Public/AttrModifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ struct ATTRIBUTES_API FAttrModifier
}

bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess);

bool IsEmpty() const;
};

template<>
Expand Down Expand Up @@ -166,3 +168,10 @@ inline bool FAttrModifier::NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bO
bOutSuccess = true;
return true;
}

inline bool FAttrModifier::IsEmpty() const
{
return FMath::IsNearlyZero(Increment)
&& FMath::IsNearlyZero(LastMultiplier)
&& FMath::IsNearlyZero(BaseMultiplier);
}

0 comments on commit 0d75a9e

Please sign in to comment.