Section 10: Outline and Glow Effects - Lecture 197
Set post process Highlight color from data table
This commit is contained in:
parent
b65f8e5540
commit
f7d1525e7e
Binary file not shown.
BIN
Content/_Game/HUD/PickupWidgetBP.uasset (Stored with Git LFS)
BIN
Content/_Game/HUD/PickupWidgetBP.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/_Game/Maps/DefaultMap.umap (Stored with Git LFS)
BIN
Content/_Game/Maps/DefaultMap.umap (Stored with Git LFS)
Binary file not shown.
BIN
Content/_Game/Weapons/BaseWeapon/BaseWeaponBP.uasset (Stored with Git LFS)
BIN
Content/_Game/Weapons/BaseWeapon/BaseWeaponBP.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -171,14 +171,56 @@ void AItem::InitializeCustomDepth()
|
|||
|
||||
void AItem::OnConstruction(const FTransform& Transform)
|
||||
{
|
||||
// Path to the Item Rarity Data Table
|
||||
FString RarityTablePath(TEXT("/Script/Engine.DataTable'/Game/_Game/DataTable/ItemRarityDataTable.ItemRarityDataTable'"));
|
||||
|
||||
// Load the data in the table
|
||||
UDataTable* RarityTableObject = Cast<UDataTable>(StaticLoadObject(UDataTable::StaticClass(), nullptr, *RarityTablePath));
|
||||
if (RarityTableObject)
|
||||
{
|
||||
FItemRarityTable* RarityRow = nullptr;
|
||||
switch (ItemRarity)
|
||||
{
|
||||
case EItemRarity::EIR_Common:
|
||||
RarityRow = RarityTableObject->FindRow<FItemRarityTable>(FName("Common"), TEXT(""));
|
||||
break;
|
||||
case EItemRarity::EIR_Uncommon:
|
||||
RarityRow = RarityTableObject->FindRow<FItemRarityTable>(FName("Uncommon"), TEXT(""));
|
||||
break;
|
||||
case EItemRarity::EIR_Rare:
|
||||
RarityRow = RarityTableObject->FindRow<FItemRarityTable>(FName("Rare"), TEXT(""));
|
||||
break;
|
||||
case EItemRarity::EIR_Legendary:
|
||||
RarityRow = RarityTableObject->FindRow<FItemRarityTable>(FName("Legendary"), TEXT(""));
|
||||
break;
|
||||
case EItemRarity::EIR_Damaged:
|
||||
default:
|
||||
RarityRow = RarityTableObject->FindRow<FItemRarityTable>(FName("Damaged"), TEXT(""));
|
||||
}
|
||||
|
||||
if (RarityRow)
|
||||
{
|
||||
GlowColor = RarityRow->GlowColor;
|
||||
LightColor = RarityRow->LightColor;
|
||||
DarkColor = RarityRow->DarkColor;
|
||||
NumberOfStars = RarityRow->NumberOfStars;
|
||||
IconBackground = RarityRow->IconBackground;
|
||||
if (GetItemMesh())
|
||||
{
|
||||
GetItemMesh()->SetCustomDepthStencilValue(RarityRow->CustomDepthStencil);
|
||||
}
|
||||
|
||||
if (MaterialInstance)
|
||||
{
|
||||
DynamicMaterialInstance = UMaterialInstanceDynamic::Create(MaterialInstance, this);
|
||||
DynamicMaterialInstance->SetVectorParameterValue(TEXT("FresnelColor"), GlowColor);
|
||||
ItemMesh->SetMaterial(MaterialIndex, DynamicMaterialInstance);
|
||||
}
|
||||
|
||||
EnableGlowMaterial();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AItem::UpdatePulse()
|
||||
{
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "Engine/DataTable.h"
|
||||
|
||||
#include "Item.generated.h"
|
||||
|
||||
class UBoxComponent;
|
||||
|
@ -13,6 +15,7 @@ class UCurveFloat;
|
|||
class AShooterCharacter;
|
||||
class USoundCue;
|
||||
class UCurveVector;
|
||||
class UDataTable;
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EItemRarity : uint8
|
||||
|
@ -47,6 +50,30 @@ enum class EItemType : uint8
|
|||
EIT_MAX UMETA(DisplayName = "DefaultMAX")
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FItemRarityTable : public FTableRowBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FLinearColor GlowColor;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FLinearColor LightColor;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FLinearColor DarkColor;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 NumberOfStars;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UTexture2D* IconBackground;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 CustomDepthStencil;
|
||||
};
|
||||
|
||||
UCLASS()
|
||||
class SHOOTER_API AItem : public AActor
|
||||
{
|
||||
|
@ -131,14 +158,6 @@ private:
|
|||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item Properties", meta = (AllowPrivateAccess = true))
|
||||
int32 ItemCount;
|
||||
|
||||
/* Item rarity - determines number of stars in Pickup Widget */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Item Properties", meta = (AllowPrivateAccess = true))
|
||||
EItemRarity ItemRarity;
|
||||
|
||||
/* Item rarity - determines number of stars in Pickup Widget */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Item Properties", meta = (AllowPrivateAccess = true))
|
||||
TArray<bool> ActiveStars;
|
||||
|
||||
/** State of the Item */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Item Properties", meta = (AllowPrivateAccess = true))
|
||||
EItemState ItemState;
|
||||
|
@ -236,10 +255,6 @@ private:
|
|||
UPROPERTY(VisibleAnywhere, Category = "Item Properties", meta = (AllowPrivateAccess = true))
|
||||
float FresnelReflectFraction;
|
||||
|
||||
/** Background for this item in the inventory */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = true))
|
||||
UTexture2D* IconBackground;
|
||||
|
||||
/** Icon for this item in the inventory */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = true))
|
||||
UTexture2D* IconItem;
|
||||
|
@ -256,6 +271,37 @@ private:
|
|||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = true))
|
||||
bool bCharacterInventoryFull;
|
||||
|
||||
/* Item rarity - determines number of stars in Pickup Widget */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Rarity, meta = (AllowPrivateAccess = true))
|
||||
EItemRarity ItemRarity;
|
||||
|
||||
/* Item rarity - determines number of stars in Pickup Widget */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Rarity, meta = (AllowPrivateAccess = true))
|
||||
TArray<bool> ActiveStars;
|
||||
|
||||
/** Item Rarity data table */
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Rarity, meta = (AllowPrivateAccess = true))
|
||||
UDataTable* ItemRarityDataTable;
|
||||
|
||||
/** Color in the glow material */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Rarity, meta = (AllowPrivateAccess = true))
|
||||
FLinearColor GlowColor;
|
||||
|
||||
/** Light color in the pickup widget */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Rarity, meta = (AllowPrivateAccess = true))
|
||||
FLinearColor LightColor;
|
||||
|
||||
/** Dark color in the pickup widget */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Rarity, meta = (AllowPrivateAccess = true))
|
||||
FLinearColor DarkColor;
|
||||
|
||||
/** Number of stars in the pickup widget */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Rarity, meta = (AllowPrivateAccess = true))
|
||||
int32 NumberOfStars;
|
||||
|
||||
/** Background icon for the inventory */
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Rarity, meta = (AllowPrivateAccess = true))
|
||||
UTexture2D* IconBackground;
|
||||
public:
|
||||
FORCEINLINE UWidgetComponent* GetPickupWidget() const { return PickupWidget; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue