void FGameplayAttribute::SetNumericValueChecked(float NewValue, class UAttributeSet* Dest) const { UNumericProperty *NumericProperty = CastChecked<UNumericProperty>(Attribute); void* ValuePtr = NumericProperty->ContainerPtrToValuePtr<void>(Dest); Dest->PreAttributeChange(*this, NewValue); NumericProperty->SetFloatingPointPropertyValue(ValuePtr, NewValue); }
void UARAttributeBaseComponent::SetFloatValue(float InValue, FName AttributeName) { if (AttributeName.IsNone()) return; UNumericProperty* NumericProperty = CastChecked<UNumericProperty>(GetAttribute(AttributeName)); void* pValue = NumericProperty->ContainerPtrToValuePtr<void>(this); NumericProperty->SetFloatingPointPropertyValue(pValue, InValue); }
void URPGAttributeComponent::SetNumericValue(float value, FName AttributeName) { if (!AttributeName.IsNone()) { UNumericProperty* NumericProperty = CastChecked<UNumericProperty>(GetAttribute(AttributeName, this->GetClass())); void* ValuePtr = NumericProperty->ContainerPtrToValuePtr<void>(this); NumericProperty->SetFloatingPointPropertyValue(ValuePtr, value); OnAttributeChange.Broadcast(AttributeName, value); } }
void FGameplayAttribute::SetNumericValueChecked(float NewValue, class UAttributeSet* Dest) const { UNumericProperty *NumericProperty = CastChecked<UNumericProperty>(Attribute); void* ValuePtr = NumericProperty->ContainerPtrToValuePtr<void>(Dest); float OldValue = *static_cast<float*>(ValuePtr); Dest->PreAttributeChange(*this, NewValue); NumericProperty->SetFloatingPointPropertyValue(ValuePtr, NewValue); #if ENABLE_VISUAL_LOG // draw a graph of the changes to the attribute in the visual logger AActor* OwnerActor = Dest->GetOwningAbilitySystemComponent()->OwnerActor; if (OwnerActor) { ABILITY_VLOG_ATTRIBUTE_GRAPH(OwnerActor, Log, GetName(), OldValue, NewValue); } #endif }
float UGAAttributesBase::SetFloatValue(const FGAAttribute& AttributeIn, float ValueIn) { if ((AttributeIn.AttributeName == LastAttributeName)) { if (CachedFloatPropety) { void* ValuePtr = CachedFloatPropety->ContainerPtrToValuePtr<void>(this); CachedFloatPropety->SetFloatingPointPropertyValue(ValuePtr, ValueIn); return CachedFloatPropety->GetFloatingPointPropertyValue(ValuePtr); } } //LastAttributeName = AttributeIn.AttributeName; UNumericProperty* NumericProperty = CastChecked<UNumericProperty>(FindProperty(AttributeIn)); CachedFloatPropety = NumericProperty; void* ValuePtr = CachedFloatPropety->ContainerPtrToValuePtr<void>(this); NumericProperty->SetFloatingPointPropertyValue(ValuePtr, ValueIn); return CachedFloatPropety->GetFloatingPointPropertyValue(ValuePtr); return 0; }
void UAttributeSet::InitFromMetaDataTable(const UDataTable* DataTable) { static const FString Context = FString(TEXT("UAttribute::BindToMetaDataTable")); for( TFieldIterator<UProperty> It(GetClass(), EFieldIteratorFlags::IncludeSuper) ; It ; ++It ) { UProperty* Property = *It; UNumericProperty *NumericProperty = Cast<UNumericProperty>(Property); if (NumericProperty) { FString RowNameStr = FString::Printf(TEXT("%s.%s"), *Property->GetOuter()->GetName(), *Property->GetName()); FAttributeMetaData * MetaData = DataTable->FindRow<FAttributeMetaData>(FName(*RowNameStr), Context, false); if (MetaData) { void *Data = NumericProperty->ContainerPtrToValuePtr<void>(this); NumericProperty->SetFloatingPointPropertyValue(Data, MetaData->BaseValue); } } } PrintDebug(); }