NVIDIA DeepLearning Dataset Synthesizer (NDDS)
 All Classes Namespaces Functions Variables Typedefs Pages
RandomComponentBase.h
1 /*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10 
11 #pragma once
12 
13 #include "DomainRandomizationDNNPCH.h"
14 #include "GameFramework/Actor.h"
15 #include "Components/ActorComponent.h"
16 #include "RandomComponentBase.generated.h"
17 
18 UCLASS(Blueprintable, Abstract, HideCategories = (Replication, ComponentReplication, Cooking, Events, ComponentTick, Actor, Input, Rendering, Collision, PhysX, Activation, Sockets, Tags))
19 class DOMAINRANDOMIZATIONDNN_API URandomComponentBase : public UActorComponent
20 {
21  GENERATED_BODY()
22 
23 public:
25 
26  bool ShouldRandomize() const;
27  void Randomize();
28  void StartRandomizing();
29  void StopRandomizing();
30 
31 protected:
32  virtual void PostLoad() override;
33  virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
34  virtual void BeginPlay() override;
35  virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
36 
37  UFUNCTION(BlueprintNativeEvent, Category = Randomization)
38  void OnRandomization();
39  virtual void OnRandomization_Implementation();
40 
41  virtual void OnFinishedRandomization();
42 
43 protected: // Editor properties
44  UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Randomization)
45  bool bShouldRandomize;
46 
47  // How long (in seconds) does the component wait between randomizations
48  // NOTE: If the UpperBound of RandomizationDuration is <= 0 then this component doesnt update at all
49  // If LowerBound different from UpperBound then the component will choose a random duration to wait inside that range in between randomization update
50  // DEPRECATED_FORGAME(4.16, "Use RandomizationDurationInterval instead")
51  UPROPERTY()
52  FFloatRange RandomizationDurationRange;
53 
54  // How long (in seconds) does the component wait between randomizations
55  // NOTE: If the Max value of RandomizationDurationInterval is < 0 then this component doesnt update at all
56  // If the Max value of RandomizationDurationInterval is = 0 then this component update every frame
57  // If the Min value different from the Max value then the component will choose a random duration to wait inside that range in between randomization update
58  UPROPERTY(EditAnywhere, Category = Randomization, meta = (EditCondition = bShouldRandomize))
59  FFloatInterval RandomizationDurationInterval;
60 
61  // If true, this component only randomize once in the begining
62  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Randomization)
63  bool bOnlyRandomizeOnce;
64 
65 protected: // Transient properties
66  UPROPERTY(Transient)
67  float CountdownUntilNextRandomization;
68  UPROPERTY(Transient)
69  bool bAlreadyRandomized;
70 
71 private:
72  void UpdateRandomization();
73 };