A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
GrippableBoxComponent.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "VRBPDatatypes.h"
8#include "VRGripInterface.h"
10#include "GameplayTagContainer.h"
11#include "Components/BoxComponent.h"
12#include "GameplayTagAssetInterface.h"
14#include "Engine/ActorChannel.h"
15#include "GrippableBoxComponent.generated.h"
16
21UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (VRExpansionPlugin))
22class VREXPANSIONPLUGIN_API UGrippableBoxComponent : public UBoxComponent, public IVRGripInterface, public IGameplayTagAssetInterface
23{
24 GENERATED_BODY()
26public:
27 UGrippableBoxComponent(const FObjectInitializer& ObjectInitializer);
28
29
31 virtual void BeginPlay() override;
32 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
33
34 UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface")
35 TArray<class UVRGripScriptBase *> GripLogicScripts;
36
37 // If true then the grip script array will be considered for replication, if false then it will not
38 // This is an optimization for when you have a lot of grip scripts in use, you can toggle this off in cases
39 // where the object will never have a replicating script
40 UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface")
41 bool bReplicateGripScripts;
42
43 bool ReplicateSubobjects(UActorChannel* Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override;
45 // Sets the Deny Gripping variable on the FBPInterfaceSettings struct
46 UFUNCTION(BlueprintCallable, Category = "VRGripInterface")
47 void SetDenyGripping(bool bDenyGripping);
48
49 // Sets the grip priority on the FBPInterfaceSettings struct
50 UFUNCTION(BlueprintCallable, Category = "VRGripInterface")
51 void SetGripPriority(int NewGripPriority);
52
53 // Called when a object is gripped
54 // If you override the OnGrip event then you will need to call the parent implementation or this event will not fire!!
55 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
56 FVROnGripSignature OnGripped;
57
58 // Called when a object is dropped
59 // If you override the OnGrip event then you will need to call the parent implementation or this event will not fire!!
60 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
61 FVROnDropSignature OnDropped;
62
63 // Called when an object we hold is secondary gripped
64 // If you override the OnGrip event then you will need to call the parent implementation or this event will not fire!!
65 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
66 FVROnGripSignature OnSecondaryGripAdded;
67
68 // Called when an object we hold is secondary dropped
69 // If you override the OnGrip event then you will need to call the parent implementation or this event will not fire!!
70 UPROPERTY(BlueprintAssignable, Category = "Grip Events")
71 FVROnGripSignature OnSecondaryGripRemoved;
72
73 // ------------------------------------------------
74 // Gameplay tag interface
75 // ------------------------------------------------
76
78 virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override
79 {
80 TagContainer = GameplayTags;
81 }
82
84 UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags")
85 FGameplayTagContainer GameplayTags;
86
87 // End Gameplay Tag Interface
88
89 virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override;
90
91
93 // Clean up our objects so that they aren't sitting around for GC
94 virtual void PreDestroyFromReplication() override;
96 virtual void GetSubobjectsWithStableNamesForNetworking(TArray<UObject*> &ObjList) override;
97
98 // This one is for components to clean up
99 virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override;
100
101 // Requires bReplicates to be true for the component
102 UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication")
103 bool bRepGripSettingsAndGameplayTags;
104
105 // Overrides the default of : true and allows for controlling it like in an actor, should be default of off normally with grippable components
106 UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication")
107 bool bReplicateMovement;
108
109 bool bOriginalReplicatesMovement;
111 UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface")
112 FBPInterfaceProperties VRGripInterfaceSettings;
113
114 // Set up as deny instead of allow so that default allows for gripping
115 // The GripInitiator is not guaranteed to be valid, check it for validity
116 virtual bool DenyGripping_Implementation(UGripMotionControllerComponent * GripInitiator = nullptr) override;
117
118 // How an interfaced object behaves when teleporting
119 virtual EGripInterfaceTeleportBehavior TeleportBehavior_Implementation() override;
120
121 // Should this object simulate on drop
122 virtual bool SimulateOnDrop_Implementation() override;
123
124 // Grip type to use
125 virtual EGripCollisionType GetPrimaryGripType_Implementation(bool bIsSlot) override;
126
127 // Secondary grip type
128 virtual ESecondaryGripType SecondaryGripType_Implementation() override;
129
130 // Define which movement repliation setting to use
131 virtual EGripMovementReplicationSettings GripMovementReplicationType_Implementation() override;
132
133 // Define the late update setting
134 virtual EGripLateUpdateSettings GripLateUpdateSetting_Implementation() override;
135
136 // What grip stiffness and damping to use if using a physics constraint
137 virtual void GetGripStiffnessAndDamping_Implementation(float& GripStiffnessOut, float& GripDampingOut) override;
138
139 // Get the advanced physics settings for this grip
140 virtual FBPAdvGripSettings AdvancedGripSettings_Implementation() override;
141
142 // What distance to break a grip at (only relevent with physics enabled grips
143 virtual float GripBreakDistance_Implementation() override;
144
145 // Get closest primary slot in range
146 virtual void ClosestGripSlotInRange_Implementation(FVector WorldLocation, bool bSecondarySlot, bool& bHadSlotInRange, FTransform& SlotWorldTransform, FName& SlotName, UGripMotionControllerComponent* CallingController = nullptr, FName OverridePrefix = NAME_None) override;
147
148 // Check if an object allows multiple grips at one time
149 virtual bool AllowsMultipleGrips_Implementation() override;
150
151 // Returns if the object is held and if so, which controllers are holding it
152 virtual void IsHeld_Implementation(TArray<FBPGripPair>& HoldingControllers, bool& bIsHeld) override;
153
154 // Sets is held, used by the plugin
155 virtual void SetHeld_Implementation(UGripMotionControllerComponent* HoldingController, uint8 GripID, bool bIsHeld) override;
157 // Interface function used to throw the delegates that is invisible to blueprints so that it can't be overridden
158 virtual void Native_NotifyThrowGripDelegates(UGripMotionControllerComponent* Controller, bool bGripped, const FBPActorGripInformation& GripInformation, bool bWasSocketed = false) override;
159
160 // Returns if the object wants to be socketed
161 virtual bool RequestsSocketing_Implementation(USceneComponent*& ParentToSocketTo, FName& OptionalSocketName, FTransform_NetQuantize& RelativeTransform) override;
162
163 // Get grip scripts
164 virtual bool GetGripScripts_Implementation(TArray<UVRGripScriptBase*>& ArrayReference) override;
165
166 // Events //
167
168 // Event triggered each tick on the interfaced object when gripped, can be used for custom movement or grip based logic
169 virtual void TickGrip_Implementation(UGripMotionControllerComponent* GrippingController, const FBPActorGripInformation& GripInformation, float DeltaTime) override;
170
171 // Event triggered on the interfaced object when gripped
172 virtual void OnGrip_Implementation(UGripMotionControllerComponent* GrippingController, const FBPActorGripInformation& GripInformation) override;
173
174 // Event triggered on the interfaced object when grip is released
175 virtual void OnGripRelease_Implementation(UGripMotionControllerComponent* ReleasingController, const FBPActorGripInformation& GripInformation, bool bWasSocketed = false) override;
176
177 // Event triggered on the interfaced object when child component is gripped
178 virtual void OnChildGrip_Implementation(UGripMotionControllerComponent* GrippingController, const FBPActorGripInformation& GripInformation) override;
179
180 // Event triggered on the interfaced object when child component is released
181 virtual void OnChildGripRelease_Implementation(UGripMotionControllerComponent* ReleasingController, const FBPActorGripInformation& GripInformation, bool bWasSocketed = false) override;
182
183 // Event triggered on the interfaced object when secondary gripped
184 virtual void OnSecondaryGrip_Implementation(UGripMotionControllerComponent* GripOwningController, USceneComponent* SecondaryGripComponent, const FBPActorGripInformation& GripInformation) override;
185
186 // Event triggered on the interfaced object when secondary grip is released
187 virtual void OnSecondaryGripRelease_Implementation(UGripMotionControllerComponent* GripOwningController, USceneComponent* ReleasingSecondaryGripComponent, const FBPActorGripInformation& GripInformation) override;
188
189 // Interaction Functions
190
191 // Call to use an object
192 virtual void OnUsed_Implementation() override;
193
194 // Call to stop using an object
195 virtual void OnEndUsed_Implementation() override;
196
197 // Call to use an object
198 virtual void OnSecondaryUsed_Implementation() override;
199
200 // Call to stop using an object
201 virtual void OnEndSecondaryUsed_Implementation() override;
202
203 // Call to send an action event to the object
204 virtual void OnInput_Implementation(FKey Key, EInputEvent KeyEvent) override;
205
206};
EGripMovementReplicationSettings
UENUM(Blueprintable)
ESecondaryGripType
UENUM(Blueprintable)
EGripCollisionType
UENUM(Blueprintable)
EGripLateUpdateSettings
UENUM(Blueprintable)
EGripInterfaceTeleportBehavior
UENUM(Blueprintable)
virtual void Native_NotifyThrowGripDelegates(UGripMotionControllerComponent *Controller, bool bGripped, const FBPActorGripInformation &GripInformation, bool bWasSocketed=false)
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = MotionController)
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = (VRExpansionPlugin))
bool bReplicateMovement
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication")
FVROnGripSignature OnSecondaryGripRemoved
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
TArray< class UVRGripScriptBase * > GripLogicScripts
UPROPERTY(EditAnywhere, Replicated, BlueprintReadOnly, Instanced, Category = "VRGripInterface")
bool bRepGripSettingsAndGameplayTags
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface|Replication")
FGameplayTagContainer GameplayTags
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "GameplayTags")
FVROnDropSignature OnDropped
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
FVROnGripSignature OnSecondaryGripAdded
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
bool bReplicateGripScripts
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface")
virtual void GetOwnedGameplayTags(FGameplayTagContainer &TagContainer) const override
FVROnGripSignature OnGripped
UPROPERTY(BlueprintAssignable, Category = "Grip Events")
FBPInterfaceProperties VRGripInterfaceSettings
UPROPERTY(EditAnywhere, Replicated, BlueprintReadWrite, Category = "VRGripInterface")
UCLASS(NotBlueprintable, BlueprintType, EditInlineNew, DefaultToInstanced, Abstract,...
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
USTRUCT(BlueprintType, Category = "VRExpansionLibrary|TransformNetQuantize", meta = (HasNativeMake = ...