LEAP Documentation 40220
Documentation for the LEAP project
TelekenesisActor.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2018. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "GameFramework/Actor.h"
7#include "TelekenesisActor.generated.h"
8
9class AProjectile;
10class UParticleSystem;
11class UTelekenesisComponent;
12class ACharacter;
13
14UCLASS()
15class PROJECTX_API ATelekenesisActor : public AActor
16{
17 GENERATED_BODY()
18
19public:
21
22 /* Speed at which the telekenesis actor will follow the weapon's shot projectile. Too slow will make bounces look bad. Too fast will make the actor "snap" unrealistically when shot. */
23 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
24 float ProjectileFollowSpeed = 10.0f;
25 /* How fast the telekenesis actor pulls to the player. Too fast and it will snap to the player */
26 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
27 float PlayerPullSpeed = 10.0f;
28 /* How far in front of the player to hold the item */
29 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
30 FVector PlayerPullOffset = FVector(300.0f, 100.0f, 0.0f);
31 /* How much should we compensate for player velocity when the player moves, higher numbers will be more compensation */
32 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
33 float VelocityOffsetMultiplier = 20.0f;
34 /* Should we hide the original actor we pulled? This is obviously a duplicate of said item. If we have a valid component we'll hide that instead of the entire actor. */
35 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
36 bool bHideSelectedActor = false;
37 /* Sound to play on the actor as it pulls to the player */
38 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
39 USoundBase* PullSound = nullptr;
40 /* Sound to play on the actor as its flung forwards */
41 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
42 USoundBase* PushSound = nullptr;
43 /* Actor's debris to play when it contacts a surface */
44 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
45 UParticleSystem* DebrisEffect = nullptr;
46 /* Secondary effect to play when flung and contacting a surface */
47 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
48 UParticleSystem* SecondaryEffect = nullptr;
49 /* Effect to use when the actor is destroyed */
50 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
51 UParticleSystem* DestroyedEffect = nullptr;
52 /* Effect to use when damage is taken */
53 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
54 UParticleSystem* TakeDamageEffect = nullptr;
55
56 UFUNCTION(BlueprintPure)
57 bool HasTarget() const { return Target.IsValid(); }
58 UFUNCTION(BlueprintCallable)
59 virtual void SetCollisionComponent(UPrimitiveComponent* const InCollisionComponent);
60
61 UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnActorContextInfo", ScriptName = "OnActorContextInfo"))
62 void K2_OnActorContextInfo(AActor* Actor, UPrimitiveComponent* Component, int32 InstanceId);
63 UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnImpact", ScriptName = "OnImpact"))
64 void K2_OnImpact(const FHitResult& Hit);
65 UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnFollowProjectile", ScriptName = "OnFollowProjectile"))
66 void K2_OnFollowProjectile(AProjectile* Actor);
67 UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnDie", ScriptName = "OnDie"))
68 void K2_Die();
69
70 virtual void BeginPlay() override;
71 virtual void OnActorContextInfo(AActor* Actor, UPrimitiveComponent* Component, int32 InstanceId = INDEX_NONE);
72 virtual void PullToPlayer(ACharacter* const Character);
73 virtual void Follow(AProjectile* const Actor);
74 virtual void Tick(float DeltaTime) override;
75 virtual float TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
76 virtual void Die();
77 virtual void SetReleased();
78 virtual void ReleaseTimeout();
79
80 UFUNCTION()
81 virtual void OnImpact(const FHitResult& Hit);
82
83 virtual UTelekenesisComponent* GetOwningComponent() const;
84
85private:
86 TWeakObjectPtr<AProjectile> Target = nullptr;
87 TWeakObjectPtr<ACharacter> PlayerTarget = nullptr;
88 TWeakObjectPtr<AActor> SelectedActor = nullptr;
89 TWeakObjectPtr<UPrimitiveComponent> SelectedComponent = nullptr;
90 UPrimitiveComponent* CollisionComponent = nullptr;
91 bool bHasTarget = false;
92 bool bReleased = false;
93};
Definition: Projectile.h:18
Definition: TelekenesisActor.h:16