LEAP Documentation 40220
Documentation for the LEAP project
WeaponInstanceToggleable.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 "WeaponInstanceToggleable.generated.h"
8
9class UAfflictionInstance;
10class UInteractableComponent;
11class UPrimitiveComponent;
12class APlayerController;
13
14UENUM(BlueprintType)
15enum class EToggleTrigger : uint8
16{
17 Fire = 0,
18 EquipStart = 1,
19 EquipComplete = 2,
20 Custom = 3
21};
22
23
24UCLASS()
25class PROJECTX_API UWeaponInstanceToggleable : public UWeaponInstance
26{
27 GENERATED_UCLASS_BODY()
28
29//~ Begin UActorComponent Interface.
30public:
31 virtual void BeginPlay() override;
32 virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
33//~ End UActorComponent Interface.
34
35//~ Begin UWeaponInstance Interface.
36public:
37 virtual bool CanFire(EWeaponError& ErrorMessage, uint8 Mode) const override;
38 virtual bool Fire(uint8 Mode, float WorldTimeOverride = -1.f) override;
39 virtual void StopAllActions() override;
40 virtual void CoolDownStart(uint8 Mode);
41 virtual bool Equip() override;
42protected:
43 virtual void FireComplete(uint8 Mode) override;
44 virtual void EquipComplete() override;
45 UFUNCTION()
46 virtual void OnEnabledAfflictionEnded();
47 virtual void ActiveTimeComplete() override;
48//~ End UWeaponInstance Interface.
49
50protected:
51 UFUNCTION(BlueprintImplementableEvent, Category = Weapon, meta = (DisplayName = "On Activate", ScriptName = "ToggleOn"))
52 void K2_ToggleOn();
53
54 UFUNCTION(BlueprintImplementableEvent, Category = Weapon, meta = (DisplayName = "On Deactivate", ScriptName = "ToggleOff"))
55 void K2_ToggleOff();
56
57 UFUNCTION(BlueprintCallable, Category = Weapon)
58 virtual void ToggleWeapon(bool bEnable);
59
60 UFUNCTION(Client, Reliable)
61 void Client_Reliable_ToggleOff(float FailWorldTime);
62 UFUNCTION(Client, Reliable)
63 void Client_Reliable_OnEnabledAfflictionEnded();
64 UFUNCTION(Server, Reliable)
65 void Server_Reliable_ForceToggle(bool bEnable);
66
67 UFUNCTION()
68 virtual void OnRep_Enabled();
69
70 UFUNCTION()
71 virtual void OnWeaponFire(uint8 Mode);
72 UFUNCTION()
73 virtual void OnHoldInteraction(UInteractableComponent* Interactable, UPrimitiveComponent* Component, float HoldTime, APlayerController* Sender);
74
75protected:
76 UPROPERTY()
77 float LastEnableTime = -1.f;
78
79 UPROPERTY(ReplicatedUsing = OnRep_Enabled)
80 bool bIsEnabled = false;
81
82protected:
83 /*What initially triggers the toggle state of this weapon? */
84 UPROPERTY(EditDefaultsOnly, Category = "Weapon|CoolDown")
85 EToggleTrigger InitialToggleTrigger = EToggleTrigger::Fire;
86 //Should this weapon instance toggle itself off when another weapon fires?
87 UPROPERTY(EditDefaultsOnly, Category = "Toggleable Weapon")
88 bool bToggleOffOnOtherWeaponFire = false;
89 //Should this weapon instance toggle itself off when interacting with objects?
90 UPROPERTY(EditDefaultsOnly, Category = "Toggleable Weapon")
91 bool bToggleOffOnInteraction = false;
92 /*Can Manually Toggle Off*/
93 UPROPERTY(EditDefaultsOnly, Category = "Toggleable Weapon")
94 bool bCanToggleOffManually = false;
95 UPROPERTY(EditDefaultsOnly, Category = "Toggleable Weapon")
96 bool bTickWhenActive = false;
97 //Consume ammo on tick.
98 UPROPERTY(EditDefaultsOnly, Category = "Toggleable Weapon", meta = (EditCondition = "bTickWhenActive"))
99 bool bConsumeOnTick = false;
100
101 /* Affliction to be applied when weapon is active*/
102 UPROPERTY(EditDefaultsOnly, Category = "Toggleable Weapon")
103 TSubclassOf<UAfflictionInstance> EnabledAffliction;
104};
EWeaponError
Definition: WeaponComponent.h:15
EToggleTrigger
Definition: WeaponInstanceToggleable.h:16
Definition: WeaponInstance.h:220
Definition: WeaponInstanceToggleable.h:26