92 lines
3.5 KiB
C++
Executable file
92 lines
3.5 KiB
C++
Executable file
#pragma once
|
|
#include "CoreMinimal.h"
|
|
#include "UObject/NoExportTypes.h"
|
|
#include "Components/ActorComponent.h"
|
|
#include "Engine/EngineTypes.h"
|
|
#include "ReplicatedCharacterData.h"
|
|
#include "CharacterSightComponent.generated.h"
|
|
|
|
class AActor;
|
|
class APlayerCharacter;
|
|
class IHealth;
|
|
class UHealth;
|
|
class ITargetable;
|
|
class UTargetable;
|
|
class UCharacterSightSensorBase;
|
|
class UPawnAfflictionComponent;
|
|
class UPrimitiveComponent;
|
|
class USimpleObjectInfoComponent;
|
|
class UTemperatureComponent;
|
|
|
|
UCLASS(Blueprintable, ClassGroup=Custom, meta=(BlueprintSpawnableComponent))
|
|
class UCharacterSightComponent : public UActorComponent {
|
|
GENERATED_BODY()
|
|
public:
|
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FTargetChangedSignature, AActor*, NewTarget, UPrimitiveComponent*, NewPrimitive);
|
|
|
|
UPROPERTY(BlueprintAssignable, BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true))
|
|
FTargetChangedSignature OnTargetChanged;
|
|
|
|
protected:
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true))
|
|
float TargetMaxDistance;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true))
|
|
TEnumAsByte<ECollisionChannel> TraceChannel;
|
|
|
|
UPROPERTY(EditAnywhere, Transient, meta=(AllowPrivateAccess=true))
|
|
TArray<TWeakObjectPtr<AActor>> IgnoredActors;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Transient, meta=(AllowPrivateAccess=true))
|
|
APlayerCharacter* Character;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Transient, meta=(AllowPrivateAccess=true))
|
|
TWeakObjectPtr<AActor> TargetActor;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Export, Transient, meta=(AllowPrivateAccess=true))
|
|
TWeakObjectPtr<UPrimitiveComponent> TargetPrimitive;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Export, Transient, meta=(AllowPrivateAccess=true))
|
|
TWeakObjectPtr<USimpleObjectInfoComponent> TargetInfo;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Export, Transient, meta=(AllowPrivateAccess=true))
|
|
TWeakObjectPtr<UTemperatureComponent> TargetTemperature;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Export, Transient, meta=(AllowPrivateAccess=true))
|
|
TWeakObjectPtr<UPawnAfflictionComponent> TargetAfflictions;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Transient, meta=(AllowPrivateAccess=true))
|
|
TScriptInterface<IHealth> TargetHealth;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Transient, meta=(AllowPrivateAccess=true))
|
|
TScriptInterface<ITargetable> TargetTargetable;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Transient, meta=(AllowPrivateAccess=true))
|
|
float TargetTime;
|
|
|
|
UPROPERTY(EditAnywhere, Export, meta=(AllowPrivateAccess=true))
|
|
TArray<TWeakObjectPtr<UCharacterSightSensorBase>> TargetSensors;
|
|
|
|
UPROPERTY(BlueprintReadWrite, EditAnywhere, Replicated, Transient, meta=(AllowPrivateAccess=true))
|
|
FReplicatedCharacterData ReplicatedData;
|
|
|
|
public:
|
|
UCharacterSightComponent();
|
|
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
|
|
|
protected:
|
|
UFUNCTION(BlueprintCallable, Reliable, Server)
|
|
void Server_UpdateTarget(AActor* NewActor, UPrimitiveComponent* NewPrimitive);
|
|
|
|
public:
|
|
UFUNCTION(BlueprintCallable)
|
|
void RemoveIgnoreActor(AActor* InActor);
|
|
|
|
UFUNCTION(BlueprintCallable, BlueprintPure)
|
|
void GetSightStartAndEnd(float InMaxDistance, FVector& OutStartLocation, FVector& OutEndLocation) const;
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
void AddIgnoreActor(AActor* InActor);
|
|
|
|
};
|
|
|