コード例 #1
0
ファイル: AttributeSet.cpp プロジェクト: kidaa/UnrealEngineVR
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);
}
コード例 #2
0
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);
}
コード例 #3
0
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);
	}
}
コード例 #4
0
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
}
コード例 #5
0
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;
}
コード例 #6
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();
}