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