LEAP Documentation 40220
Documentation for the LEAP project
WeaponInstanceControlled.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 "WeaponInstanceControlled.generated.h"
8
14
15UCLASS(Blueprintable)
17{
18 GENERATED_UCLASS_BODY()
19
20public:
21 virtual void BeginPlay() override;
22 virtual bool CanEquip() const override;
23 virtual bool Equip() override;
24 virtual bool CanFire(EWeaponError& ErrorMessage, uint8 Mode) const override;
25 virtual bool Fire(uint8 Mode, float WorldTimeOverride) override;
26 virtual bool CanUnEquip(bool bTestOnly = false) const override;
27 virtual bool CanQueueUnEquip() const override;
28 virtual bool UnEquip(bool bForce = false) override;
29 virtual void UnEquipComplete() override;
30 virtual void OwnerDied() override;
31 virtual void StopAllActions() override;
32
33 UFUNCTION(BlueprintPure, Category = "Controlled Weapon")
34 FORCEINLINE bool IsControllingDeployable() const { return bIsControllingDeployable; }
35 UFUNCTION(BlueprintPure, Category = "Controlled Weapon")
36 FORCEINLINE bool IsWaitingForControlStop() const { return bIsWaitingForControlStop; }
37
38protected:
39 virtual void OnDeployableSpawned(ADeployable* DeployedActor) override;
40 virtual void OnDeployableDestroyed(ADeployable* DeployedActor) override;
41 virtual void FireComplete(uint8 Mode) override;
42
43 virtual void StartDeployableControl(ADeployable* const DeployableToControl);
44 virtual void OnStartDeployableControlFinished();
45 virtual void StopDeployableControl(bool bForcePrematureEnd = false);
46 virtual void OnStopDeployableControlFinished();
47 virtual void MoveDeployablesForward(float Value);
48 virtual void MoveDeployablesRight(float Value);
49 virtual void MoveDeployablesUp(float Value);
50
51 UFUNCTION()
52 void OnDeployableDeploymentComplete(ADeployable* Deployable);
53 UFUNCTION(BlueprintPure, Category = "Controlled Weapon")
54 ADeployableControllable* GetCurrentlyControlledDeployable() const { return CurrentlyControllingDeployable.IsValid()? CurrentlyControllingDeployable.Get() : NULL;}
55 UFUNCTION(BlueprintPure, Category = "Controlled Weapon")
56 UUserWidget* GetDeployableOverlayWidget() const { return DeployableOverlayWidget.IsValid() ? DeployableOverlayWidget.Get() : NULL;}
57 UFUNCTION(BlueprintCallable)
58 virtual void FinishDeathAnimation();
59 UFUNCTION(BlueprintImplementableEvent)
60 void K2_OnDeployableControlStarted(ADeployable* Deployable);
61 UFUNCTION(BlueprintImplementableEvent)
62 void K2_OnDeployableControlStop();
63 UFUNCTION(BlueprintImplementableEvent)
64 void K2_OnDeployableControlStopFinished();
65
66 UPROPERTY(EditDefaultsOnly, Category = "Controlled Weapon")
67 TArray<TSubclassOf<UAfflictionInstance>> AfflictionsToApplyToOwner;
68 UPROPERTY(EditDefaultsOnly, Category = "Controlled Weapon")
69 TSubclassOf<UUserWidget> DeployableOverlayWidgetClass = nullptr;
70 UPROPERTY(EditDefaultsOnly, Category = "Controlled Weapon")
71 float CameraBlendInTime = 0.f;
72 UPROPERTY(EditDefaultsOnly, Category = "Controlled Weapon")
73 float CameraBlendOutTime = 0.f;
74 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Controlled Weapon")
75 float DeathAnimationDuration = 2.f;
76 UPROPERTY(EditDefaultsOnly, Category = "Controlled Weapon")
77 bool bStopControllingOnRefire = false;
78 UPROPERTY(EditDefaultsOnly, Category = "Controlled Weapon")
79 bool bCanUnequipWhileDeploying = false;
80 bool bIsWaitingForControlStop = false;
81
82private:
83 TWeakObjectPtr<UUserWidget> DeployableOverlayWidget = nullptr;
84 TArray<TWeakObjectPtr<UAfflictionInstance>> AfflictionsApplied;
85 FRotator CachedRotator = FRotator::ZeroRotator;
86 /*This is replicated so the autonomous proxy has to wait for the server to update things correctly.
87 The weapon component has some race conditions going on that might leave the server-side unsynced which might be harmful on this weapon types as it could mean inputs getting discarded
88 Having this as replicated enforces that we wait for the server state to be able to control the spawned deployable */
89 UPROPERTY(Replicated)
90 bool bIsControllingDeployable = false;
91 TWeakObjectPtr<ADeployableControllable> CurrentlyControllingDeployable = nullptr;
92 FTimerHandle DeathAnimationTimerHandle;
93
94};
EWeaponError
Definition: WeaponComponent.h:15
Definition: DeployableControllable.h:30
virtual void BeginPlay() override
Definition: DeployableControllable.cpp:25
virtual void Fire()
Definition: DeployableControllable.h:39
Definition: Deployable.h:47
Definition: WeaponInstanceControlled.h:17
Definition: WeaponInstanceSpawnable.h:17