Skip to content

Commit 06b617a

Browse files
committed
Added 'active' state to the 'Pickup' class
1 parent fde371b commit 06b617a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Source/BatteryCollector/Pickup.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ APickup::APickup()
1010
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
1111
PrimaryActorTick.bCanEverTick = false;
1212

13+
// All pickup start active
14+
bIsActive = true;
15+
1316
// Create the static mesh component
1417
PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PickupMesh"));
1518
RootComponent = PickupMesh;
@@ -29,3 +32,14 @@ void APickup::Tick( float DeltaTime )
2932

3033
}
3134

35+
// Returns active state
36+
bool APickup::IsActive()
37+
{
38+
return bIsActive;
39+
}
40+
41+
// Changes active state
42+
void APickup::SetActive(bool NewPickupState)
43+
{
44+
bIsActive = NewPickupState;
45+
}

Source/BatteryCollector/Pickup.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ class BATTERYCOLLECTOR_API APickup : public AActor
2323
/** Return the mesh for the pickup */
2424
FORCEINLINE class UStaticMeshComponent* GetMesh() const { return PickupMesh; }
2525

26+
/** Return whether or not the pickup is active */
27+
UFUNCTION(BlueprintPure, Category = "Pickup")
28+
bool IsActive();
29+
30+
/** Allows other classes to safely change whether or not pickup is active*/
31+
UFUNCTION(BlueprintCallable, Category = "Pickup")
32+
void SetActive(bool NewPickupState);
33+
34+
35+
protected:
36+
/**True when the pickup can be used, and false when pickup is deactivated */
37+
bool bIsActive;
38+
2639
private:
2740
/** Static mesh to represent the pickup in the level*/
2841
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pickup", meta = (AllowPrivateAccess = "true"))

0 commit comments

Comments
 (0)