9#include "Kismet/GameplayStatics.h"
27 auto LightId = CarlaLight->GetId();
28 if (
Lights.Contains(LightId))
30 UE_LOG(LogCarla, Warning, TEXT(
"Light Id overlapping"));
33 Lights.Add(LightId, CarlaLight);
42 Lights.Remove(CarlaLight->GetId());
61 std::vector<carla::rpc::LightState> result;
67 UCarlaLight* CarlaLight = Light.Value;
69 result.push_back(CarlaLight->GetLightState());
76 std::vector<carla::rpc::LightState> LightsToSet,
82 for(
auto& LightState : LightsToSet) {
83 UCarlaLight* CarlaLight =
Lights.FindRef(LightState._id);
85 CarlaLight->SetLightState(LightState);
108 TArray<AActor*> WeatherActors;
109 UGameplayStatics::GetAllActorsOfClass(GetWorld(), AWeather::StaticClass(), WeatherActors);
110 if (WeatherActors.Num())
112 if (
AWeather* WeatherActor = Cast<AWeather>(WeatherActors[0]))
114 WeatherActor->SetDayNightCycle(active);
123 if(Client.Key != ClientThatUpdate)
void SetClientStatesdirty(FString ClientThatUpdate)
void Initialize(FSubsystemCollectionBase &Collection) override
TMap< int, UCarlaLight * > Lights
TMap< int, UCarlaLight * > & GetLights()
void Deinitialize() override
TMap< FString, bool > ClientStates
void SetLights(FString Client, std::vector< carla::rpc::LightState > LightsToSet, bool DiscardClient=false)
void RegisterLight(UCarlaLight *CarlaLight)
void UnregisterLight(UCarlaLight *CarlaLight)
void SetDayNightCycle(const bool active)
bool IsUpdatePending() const
UCarlaLight * GetLight(int Id)