LEAP Documentation 40220
Documentation for the LEAP project
MapBoundsModifier.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"
7#include "MapBoundsModifier.generated.h"
8
10
11DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCharacterCrossBoundsSignature, AProjectXCharacter*, Character);
12DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBoundsChangingSignature);
13
14USTRUCT(Blueprintable)
16{
17 GENERATED_BODY()
18
19 /* Scale the box over time from its initial scale to this scale value. */
20 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Interpolation)
21 FVector Scale = FVector(0.0f, 0.0f, 0.0f);
22 /* Time to animate the scale from it's initial position to the new specified scale.*/
23 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Interpolation)
24 float Time = 1.0f;
25 /* Time to wait before modifying the box' scale. */
26 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Interpolation)
27 float Delay = 1.0f;
28 /* First entry will be ignored if a RandomConvergenceRegion (Triggerbox) is selected. Subsequent entries will pick a new spot within itself and move there while modifying scale. */
29 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Interpolation)
30 bool bPickRandomMoveLocationWithinBounds;
31};
32
33UCLASS()
34class PROJECTX_API AMapBoundsModifier : public AActor, public IReactsToMatchEvents
35{
36 GENERATED_BODY()
37
38public:
39 /* List of interpolation stages the box will make over time. */
40 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = MapBounds)
41 TArray<FObjectInterpolation> ObjectInterpolations;
42 /* How often to deal damage to characters outside of the box. (In seconds) */
43 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = MapBounds, meta = (ClampMin = 0.05, ClampMax = 10.0))
44 float DamageCharactersInterval = 1.0f;
45 /* How much characters receive when outside the box per DamageCharactersInterval. */
46 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = MapBounds)
47 float DamageCharactersAmount = 1.0f;
48 /* Specific region that the box will choose a random point inside and move to on its first interpolation. */
49 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = MapBounds)
50 class ATriggerBox* RandomConvergenceRegion;
51 /* Display debug information regarding this object's interpolation. */
52 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = MapBounds)
53 bool bDebug;
54
55 /* Defined space of where characters are considered safe. */
56 UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = MapBounds)
57 class UBoxComponent* BoxComponent;
58
59 UPROPERTY(BlueprintAssignable, Category = Events)
60 FCharacterCrossBoundsSignature OnCharacterOutsideBounds;
61 UPROPERTY(BlueprintAssignable, Category = Events)
62 FCharacterCrossBoundsSignature OnCharacterInsideBounds;
63 UPROPERTY(BlueprintAssignable, Category = Events)
64 FBoundsChangingSignature OnBoundsChangeStart;
65 UPROPERTY(BlueprintAssignable, Category = Events)
66 FBoundsChangingSignature OnBoundsChangeComplete;
67
68 virtual void BeginPlay() override;
69 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason);
70 virtual void MatchStarted() override;
71 virtual void Tick(float DeltaSeconds) override;
72
73private:
74 uint32 MovementInterpolationID = INDEX_NONE;
75 uint32 ScaleInterpolationID = INDEX_NONE;
76 int32 CurrentInterpolationIndex = 0;
77 FVector OriginalObjectScale;
78 FVector OriginalObjectPosition;
79 TArray<AProjectXCharacter*> CharactersOutsideBox;
80
82
83 FVector GetRandomPointInActorBounds(const AActor* Actor = nullptr) const;
84
85 void Interpolate();
86 void OutsideBounds(class AProjectXCharacter* Character);
87 void InsideBounds(class AProjectXCharacter* Character);
88 void DamageActors();
89
90 UFUNCTION(NetMulticast, Reliable)
91 void Multicast_Move(const FVector_NetQuantize& MoveLocation, const uint8 InCurrentInterpolationIndex);
92 UFUNCTION(NetMulticast, Unreliable)
93 void Multicast_NetCorrectInterpolation(const uint8 Stage, const float MovementTimeElapsed, const float ScaleTimeElapsed);
94 UFUNCTION(NetMulticast, Unreliable)
95 void Multicast_DebugNetCorrections(const FVector_NetQuantize& Origin, const FVector_NetQuantize& BoxExtent);
96};
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBoundsChangingSignature)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCharacterCrossBoundsSignature, AProjectXCharacter *, Character)
Definition: MapBoundsModifier.h:35
Definition: ProjectXCharacter.h:128
virtual void BeginPlay() override
Definition: ProjectXCharacter.cpp:179
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
Definition: ProjectXCharacter.cpp:1207
Definition: ReactsToMatchEvents.h:16
virtual void MatchStarted()
Definition: ReactsToMatchEvents.cpp:11
Definition: MapBoundsModifier.h:16