Agrarsense
SensorManager.h
Go to the documentation of this file.
1// Copyright (c) 2024 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "Subsystems/GameInstanceSubsystem.h"
10
12
13#include "SensorManager.generated.h"
14
15class ASensor;
16
17DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSensorSpawnedDelegate, ASensor*, SensorPtr);
18DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSensorDestroyedDelegate, ASensor*, SensorPtr);
19
26UCLASS()
27class AGRARSENSE_API USensorManager : public UGameInstanceSubsystem
28{
29 GENERATED_BODY()
30
31public:
32
33 virtual void Initialize(FSubsystemCollectionBase& Collection) override;
34
35 virtual void Deinitialize() override;
36
37 /*
38 * Get SensorManager subsystem pointer.
39 */
40 static USensorManager* Get();
41
46 UFUNCTION(BlueprintCallable)
47 TArray<ASensor*> GetAllSensors() const;
48
54 UFUNCTION(BlueprintCallable)
55 TArray<ASensor*> GetAllSensorsOfType(ESensorTypes SensorType) const;
56
60 UPROPERTY(BlueprintAssignable)
61 FSensorSpawnedDelegate OnSensorSpawned;
62
67 UPROPERTY(BlueprintAssignable)
68 FSensorDestroyedDelegate OnSensorDestroyed;
69
70private:
71
72 friend class ASensor;
73
74 static void AddSensor(ASensor* SensorPtr);
75
76 static void RemoveSensor(ASensor* SensorPtr);
77
78 static USensorManager* SensorManagerPtr;
79
80 UPROPERTY()
81 TArray<ASensor*> Sensors;
82};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSensorSpawnedDelegate, ASensor *, SensorPtr)
ESensorTypes
Definition: SensorTypes.h:15
Definition: Sensor.h:44