71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/Actor.h"
|
|
#include "Weapon.generated.h"
|
|
|
|
UENUM(BlueprintType)
|
|
enum class EWeaponState : uint8
|
|
{
|
|
EWS_Initial UMETA(DisplayName = "Initial State"),
|
|
EWS_Equipped UMETA(DisplayName = "Equipped"),
|
|
EWS_Dropped UMETA(DisplayName = "Dropped"),
|
|
|
|
EWS_MAX UMETA(DisplayName = "DefaultMAX")
|
|
};
|
|
|
|
UCLASS()
|
|
class BLASTER_API AWeapon : public AActor
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
AWeapon();
|
|
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
|
void ShowPickupWidget(bool bShowWidget);
|
|
|
|
protected:
|
|
virtual void BeginPlay() override;
|
|
|
|
UFUNCTION()
|
|
virtual void OnSphereOverlap(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
int32 OtherBodyIndex,
|
|
bool bFromSweep,
|
|
const FHitResult& SweepResult
|
|
);
|
|
|
|
UFUNCTION()
|
|
virtual void OnSphereEndOverlap(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
int32 OtherBodyIndex
|
|
);
|
|
|
|
private:
|
|
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
|
|
USkeletalMeshComponent* WeaponMesh;
|
|
|
|
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
|
|
class USphereComponent* AreaSphere;
|
|
|
|
UPROPERTY(ReplicatedUsing = OnRep_WeaponState, VisibleAnywhere, Category="Weapon Properties")
|
|
EWeaponState WeaponState;
|
|
|
|
UFUNCTION()
|
|
void OnRep_WeaponState();
|
|
|
|
UPROPERTY(VisibleAnywhere, Category="Weapon Properties")
|
|
class UWidgetComponent* PickupWidget;
|
|
|
|
public:
|
|
void SetWeaponState(EWeaponState State);
|
|
FORCEINLINE USphereComponent* GetAreaSphere() const { return AreaSphere; }
|
|
FORCEINLINE USkeletalMeshComponent* GetWeaponMesh() const { return WeaponMesh; };
|
|
};
|