LEAP Documentation 40220
Documentation for the LEAP project
TelekenesisComponent.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 "Components/ActorComponent.h"
7#include "TelekenesisComponent.generated.h"
8
9class USoundBase;
10class UPhysicalMaterial;
13class UAfflictionInstance;
14
15/*TODO: refactoring health from actor to struct because server doesnt have the actor */
16/*might not want to mutate the player damage and instead have the cube take the damage directly (give it a health interface? is that even necessary?) */
17USTRUCT(Blueprintable)
19{
20 GENERATED_USTRUCT_BODY()
21
22public:
23 /* Actor to represent the item being pulled */
24 UPROPERTY(EditDefaultsOnly)
25 TSubclassOf<ATelekenesisActor> TelekenesisActor;
26 /* Weapon to use when firing the TelekenesisActor. The TelekenesisActor will follow this weapon's projectile */
27 UPROPERTY(EditDefaultsOnly)
29 /* If this actor's health is > 0, it will absorb damage for the player. If health reaches zero, it will be destroyed */
30 UPROPERTY(EditDefaultsOnly)
31 float MaxHealth = 10.0f;
32 /* When the player pulls an object towards themselves, they cannot launch it until this amount of time has passed */
33 UPROPERTY(EditDefaultsOnly)
34 float MinTimeBeforeLaunch = 1.0f;
35 /* If true, the telekenesis actor will absorb all damage until maxhealth == 0. If false, the telekenesis actor will only absorb damage when it is shot directly */
36 UPROPERTY(EditDefaultsOnly)
37 bool bProvidesFullShield = false;
38
39 float Health = 0.0f;
40 TWeakObjectPtr<UWeaponInstanceProjectile> SpawnedWeaponInstance;
41};
42
43UCLASS(Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
44class PROJECTX_API UTelekenesisComponent : public UActorComponent
45{
46 GENERATED_BODY()
47
48public:
49 UTelekenesisComponent();
50
51 /* How much energy does it cost to pull something towards your player? */
52 UPROPERTY(EditDefaultsOnly)
53 float InitialEnergyCost = 10.0f;
54 /* How fast does energy drain while held? */
55 UPROPERTY(EditDefaultsOnly)
56 float HoldEnergyDrainRate = 5.0f;
57 /* Configuration for what surfaces generate certain telekenesis responses */
58 UPROPERTY(EditDefaultsOnly)
59 TMap<UPhysicalMaterial*, FTelekenesisInfo> TelekenesisData;
60 /* Sound played on the player when pulling items */
61 UPROPERTY(EditDefaultsOnly)
62 USoundBase* PullSound = nullptr;
63 /* Sound played onthe player when pushing items */
64 UPROPERTY(EditDefaultsOnly)
65 USoundBase* PushSound = nullptr;
66 /* Costs zero energy and doesn't release the projectile */
67 UPROPERTY(EditDefaultsOnly)
68 bool bDebugShielding = false;
69 /* afflictions that get removed when performing TK related actions*/
70 UPROPERTY(EditDefaultsOnly)
71 TArray<TSubclassOf<UAfflictionInstance>> InvalidAfflictions;
72
73 UFUNCTION(Server, Reliable)
74 virtual void Server_Release(bool bForce = false);
75 UFUNCTION()
76 virtual void TakeDamage(float& Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser);
77
78 TWeakObjectPtr<ATelekenesisActor> CurrentTelekensisActor = nullptr;
79protected:
80 virtual void BeginPlay() override;
81 virtual void Pull();
82 virtual void Pull(const FHitResult& HitResult);
83 virtual void Release();
84 virtual void SetActorFollowProjectileTarget(TWeakObjectPtr<ATelekenesisActor> Actor, TWeakObjectPtr<UWeaponInstanceProjectile> Weapon);
85 virtual void RemoveInvalidAfflictions();
86
87 UFUNCTION(Server, Reliable)
88 virtual void Server_Pull(const FHitResult& HitResult);
89 UFUNCTION(NetMulticast, Reliable)
90 virtual void Multicast_Pull(const FHitResult& HitResult);
91
92 UFUNCTION(NetMulticast, Reliable)
93 virtual void Multicast_Release(bool bForce = false);
94 UFUNCTION(NetMulticast, Reliable)
95 virtual void Multicast_TakeDamage(float Damage);
96 UFUNCTION(NetMulticast, Reliable)
97 virtual void Multicast_Die(float Damage);
98
99 int32 PullInterpolatorId = INDEX_NONE;
100 UPhysicalMaterial* ActivePhysicalMaterial = nullptr;
101 FTimerHandle ReleaseTimer;
102 FTimerHandle PullTimer;
103};
@ Release
Definition: TelekenesisComponent.cpp:166
Definition: TelekenesisActor.h:16
Definition: WeaponInstanceProjectile.h:36
Definition: TelekenesisComponent.h:19