CARLA
 
载入中...
搜索中...
未找到
ActorWithRandomEngine.h
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include "GameFramework/Actor.h"
10
11#include "ActorWithRandomEngine.generated.h"
12
13class URandomEngine;
14
15/// Base class for actors containing a random engine with a fixed seed.
16UCLASS(Abstract)
17class CARLA_API AActorWithRandomEngine : public AActor
18{
19 GENERATED_BODY()
20
21public:
22
23 AActorWithRandomEngine(const FObjectInitializer& ObjectInitializer);
24
25protected:
26
27 virtual void OnConstruction(const FTransform &Transform) override;
28
29#if WITH_EDITOR
30 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
31#endif // WITH_EDITOR
32
33public:
34
35 UFUNCTION(BlueprintCallable)
36 URandomEngine *GetRandomEngine()
37 {
38 return RandomEngine;
39 }
40
41 UFUNCTION(BlueprintCallable)
42 int32 GetSeed() const
43 {
44 return Seed;
45 }
46
47 UFUNCTION(BlueprintCallable)
48 void SetSeed(int32 InSeed);
49
50private:
51
52 /** Set a random seed. */
53 UPROPERTY(Category = "Random Engine", EditAnywhere)
54 bool bGenerateRandomSeed = false;
55
56 /** Seed of the pseudo-random engine. */
57 UPROPERTY(Category = "Random Engine", EditAnywhere)
58 int32 Seed = 123456789;
59
60 UPROPERTY()
61 URandomEngine *RandomEngine;
62};
Base class for actors containing a random engine with a fixed seed.
void Seed(int32 InSeed)
Seed the random engine.
std::minstd_rand Engine