From 3f75cb5db9970a98281f6f4046a7b4e487d9076e Mon Sep 17 00:00:00 2001 From: baz Date: Wed, 19 Mar 2025 01:42:36 +0000 Subject: [PATCH] Replace Pickup Sprite Component with Static Mesh Component --- Content/Materials/M_EXPGlow.uasset | 3 ++ Content/Materials/M_GoldGlow.uasset | 3 ++ Content/Meshes/SM_Coin.uasset | 3 ++ Content/Meshes/SM_EXP.uasset | 3 ++ Content/Pickups/EXP/BP_BlueEXPPickup.uasset | 4 +-- Content/Pickups/EXP/BP_PickupTemplate.uasset | 4 +-- Content/Pickups/EXP/DA_BlueEXPPickup.uasset | 4 +-- Content/Pickups/Gold/BP_GoldPickup.uasset | 4 +-- Source/vampires/Pickup.cpp | 31 ++++++-------------- Source/vampires/Pickup.h | 4 +-- Source/vampires/PickupDataAsset.h | 4 +-- 11 files changed, 31 insertions(+), 36 deletions(-) create mode 100644 Content/Materials/M_EXPGlow.uasset create mode 100644 Content/Materials/M_GoldGlow.uasset create mode 100644 Content/Meshes/SM_Coin.uasset create mode 100644 Content/Meshes/SM_EXP.uasset diff --git a/Content/Materials/M_EXPGlow.uasset b/Content/Materials/M_EXPGlow.uasset new file mode 100644 index 0000000..4811543 --- /dev/null +++ b/Content/Materials/M_EXPGlow.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54edcf2362363a49a5d1704bb15aac1197cab672bcd620edeb409915354031e8 +size 13344 diff --git a/Content/Materials/M_GoldGlow.uasset b/Content/Materials/M_GoldGlow.uasset new file mode 100644 index 0000000..25b5a94 --- /dev/null +++ b/Content/Materials/M_GoldGlow.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2f8b196d740bdea44883d31e24788f3584d42af2d74533f22adb7a8b693f57f +size 13366 diff --git a/Content/Meshes/SM_Coin.uasset b/Content/Meshes/SM_Coin.uasset new file mode 100644 index 0000000..bf86602 --- /dev/null +++ b/Content/Meshes/SM_Coin.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa2b9c841788ba939684b1890de3d88b2920595127379d9ff6cffbd1a7bc3348 +size 28146 diff --git a/Content/Meshes/SM_EXP.uasset b/Content/Meshes/SM_EXP.uasset new file mode 100644 index 0000000..faefeb5 --- /dev/null +++ b/Content/Meshes/SM_EXP.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2a3c031dab74d3afc8e950372fb2c2d21c7aa8724b92302fd4c22b66dd5c590 +size 21316 diff --git a/Content/Pickups/EXP/BP_BlueEXPPickup.uasset b/Content/Pickups/EXP/BP_BlueEXPPickup.uasset index 420722b..732a1e5 100644 --- a/Content/Pickups/EXP/BP_BlueEXPPickup.uasset +++ b/Content/Pickups/EXP/BP_BlueEXPPickup.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:470294c5fdf4ae77a95e3b238c2081fd7873ba5f0bcfa7ee5af7809fd33124c7 -size 26029 +oid sha256:95b802dc8631eaa78d3d0f29e18a73d3c438947b01eab1b87e8309c00ea1098e +size 24934 diff --git a/Content/Pickups/EXP/BP_PickupTemplate.uasset b/Content/Pickups/EXP/BP_PickupTemplate.uasset index ebee1b5..55645e6 100644 --- a/Content/Pickups/EXP/BP_PickupTemplate.uasset +++ b/Content/Pickups/EXP/BP_PickupTemplate.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:08ccd14cf99ce60e7838e3a5ce6b7ebb879b2b17789301705b653c7e2f454cba -size 24435 +oid sha256:eb30783d633a6f999da506bfff2521fa4fa4914cdafecf9c2651bfd42dff9401 +size 24513 diff --git a/Content/Pickups/EXP/DA_BlueEXPPickup.uasset b/Content/Pickups/EXP/DA_BlueEXPPickup.uasset index c42d877..015e847 100644 --- a/Content/Pickups/EXP/DA_BlueEXPPickup.uasset +++ b/Content/Pickups/EXP/DA_BlueEXPPickup.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f2fcdaa7edbd58b15160ca419b9eba5587ac03d13bab804f0bc97757dab7bcbe -size 2047 +oid sha256:2cbf6056dac6228d69e5fa20c7c93fde18081d904ab953f599e0162c93b608d9 +size 2014 diff --git a/Content/Pickups/Gold/BP_GoldPickup.uasset b/Content/Pickups/Gold/BP_GoldPickup.uasset index 02349aa..f97eb9a 100644 --- a/Content/Pickups/Gold/BP_GoldPickup.uasset +++ b/Content/Pickups/Gold/BP_GoldPickup.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8d4701416e59b92800856f821ee5a8465b4c576893b69085158955c856435ec9 -size 24994 +oid sha256:36bd6dcf623807d3b18df1f57ef68ecbc6b472d54218259318a11a81319c5052 +size 34394 diff --git a/Source/vampires/Pickup.cpp b/Source/vampires/Pickup.cpp index d0c66e6..3d37b92 100644 --- a/Source/vampires/Pickup.cpp +++ b/Source/vampires/Pickup.cpp @@ -7,7 +7,6 @@ #include "PlayerCharacter.h" #include "Components/SphereComponent.h" #include "Kismet/GameplayStatics.h" -#include "PaperSpriteComponent.h" #include "PickupDataAsset.h" #include "GameFramework/GameModeBase.h" #include "Interfaces/Pools.h" @@ -27,11 +26,11 @@ APickup::APickup() OuterSphereComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform); OuterSphereComponent->SetSphereRadius(250.0f); - SpriteComponent = CreateDefaultSubobject(TEXT("Sprite Component")); - SpriteComponent->SetRelativeRotation(FRotator(0.0f, 90.0f, -90.0f)); - SpriteComponent->SetRelativeScale3D(FVector(.5f, .5f, .5f)); - SpriteComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision); - SpriteComponent->SetupAttachment(RootComponent); + StaticMeshComponent = CreateDefaultSubobject(TEXT("Static Mesh Component")); + StaticMeshComponent->SetRelativeRotation(FRotator(0.0f, 90.0f, 0.0f)); + StaticMeshComponent->SetRelativeScale3D(FVector(.5f, .5f, .5f)); + StaticMeshComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision); + StaticMeshComponent->SetupAttachment(RootComponent); TimelineComponent = CreateDefaultSubobject(TEXT("Timeline Component")); TimelineComponent->SetDirectionPropertyName(FName("TimelineDirection")); @@ -64,7 +63,7 @@ void APickup::LoadDataFromDataAsset_Implementation(UPickupDataAsset* PickupDataA if (PickupDataAsset != nullptr) { PickupValue = PickupDataAsset->PickupValue; - SpriteComponent->SetSprite(PickupDataAsset->PickupSprite); + StaticMeshComponent->SetStaticMesh(PickupDataAsset->PickupStaticMesh); PickupSoundBase = PickupDataAsset->PickupSoundBase; CurveFloat = PickupDataAsset->CurveFloat; @@ -79,7 +78,7 @@ void APickup::LoadDataFromDataAsset_Implementation(UPickupDataAsset* PickupDataA void APickup::ResetData_Implementation() { PickupValue = 0; - SpriteComponent->SetSprite(nullptr); + StaticMeshComponent->SetStaticMesh(nullptr); PickupSoundBase = nullptr; CurveFloat = nullptr; @@ -123,19 +122,7 @@ void APickup::OnOuterBeginOverlap(UPrimitiveComponent* OverlappedComponent, AAct UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) { - if (APlayerCharacter* PlayerCharacter = Cast(OtherActor)) - { - PickupLocation = GetActorLocation(); - PlayTimeLine(); - - double dist = FVector::Distance(GetActorLocation(), PlayerCharacter->GetActorLocation()); - - if (dist < OuterSphereComponent->GetScaledSphereRadius()) - { - double ratio = FMath::Abs((dist / OuterSphereComponent->GetScaledSphereRadius()) - 1.0f); - TimelineComponent->SetNewTime(ratio); - } - } + PlayTimeLine(); } void APickup::TimelineCallback(float val) @@ -152,5 +139,5 @@ void APickup::TimelineFinishedCallback() void APickup::PlayTimeLine() { - TimelineComponent->Play(); + TimelineComponent->PlayFromStart(); } diff --git a/Source/vampires/Pickup.h b/Source/vampires/Pickup.h index ffe824d..66b0cd3 100644 --- a/Source/vampires/Pickup.h +++ b/Source/vampires/Pickup.h @@ -11,7 +11,6 @@ class UPickupDataAsset; class UTimelineComponent; class USphereComponent; -class UPaperSpriteComponent; UCLASS() class VAMPIRES_API APickup : public AActor, public IPickupable @@ -28,9 +27,8 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) USphereComponent* OuterSphereComponent = nullptr; - // TODO: Replace with static mesh UPROPERTY(EditAnywhere) - UPaperSpriteComponent* SpriteComponent = nullptr; + UStaticMeshComponent* StaticMeshComponent = nullptr; UPROPERTY(EditDefaultsOnly) USoundBase* PickupSoundBase = nullptr; diff --git a/Source/vampires/PickupDataAsset.h b/Source/vampires/PickupDataAsset.h index 6e50503..4140390 100644 --- a/Source/vampires/PickupDataAsset.h +++ b/Source/vampires/PickupDataAsset.h @@ -7,7 +7,6 @@ #include "PickupDataAsset.generated.h" class UTimelineComponent; -class UPaperSprite; /** * */ @@ -20,9 +19,8 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pickup Properties") int PickupValue = 1; - // TODO: Replace with static mesh UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pickup Properties") - TObjectPtr PickupSprite = nullptr; + TObjectPtr PickupStaticMesh = nullptr; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pickup Properties") TObjectPtr PickupSoundBase = nullptr;