77 virtual void BeginPlay()
override;
79 void PreWorldOriginOffset(UWorld* InWorld, FIntVector InSrcOrigin, FIntVector InDstOrigin);
80 void PostWorldOriginOffset(UWorld* InWorld, FIntVector InSrcOrigin, FIntVector InDstOrigin);
82 void OnLevelAddedToWorld(ULevel* InLevel, UWorld* InWorld);
83 void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld);
87 void RegisterInitialObjects();
91 UFUNCTION(Category=
"Large Map Manager")
92 void OnActorDestroyed(
AActor* DestroyedActor);
97 UFUNCTION(BlueprintCallable, Category = "Large
Map Manager")
98 void GenerateMap(FString InAssetsPath);
100 UFUNCTION(BlueprintCallable, Category = "Large
Map Manager")
101 void GenerateLargeMap();
103 void GenerateMap(TArray<TPair<FString, FIntVector>> MapPathsIds);
105 UFUNCTION(BlueprintCallable, CallInEditor, Category = "Large
Map Manager")
106 void ClearWorldAndTiles();
108 UFUNCTION(BlueprintCallable, CallInEditor, Category = "Large
Map Manager")
109 void GenerateMap_Editor()
111 if (!LargeMapTilePath.IsEmpty()) GenerateMap(LargeMapTilePath);
114 void AddActorToUnloadedList(
const FCarlaActor& CarlaActor,
const FTransform& Transform);
116 UFUNCTION(BlueprintCallable, Category =
"Large Map Manager")
117 FIntVector GetNumTilesInXY() const;
119 UFUNCTION(BlueprintCallable, Category = "Large
Map Manager")
120 int GetNumTiles()
const
122 return MapTiles.Num();
125 UFUNCTION(BlueprintCallable, Category =
"Large Map Manager")
126 bool IsLevelOfTileLoaded(FIntVector InTileID) const;
130 return CurrentTilesLoaded.Contains(TileId);
135 return IsTileLoaded(GetTileID(Location));
140 return IsTileLoaded(GetTileID(Location));
143 FTransform GlobalToLocalTransform(
const FTransform& InTransform)
const;
144 FVector GlobalToLocalLocation(
const FVector& InLocation)
const;
146 FTransform LocalToGlobalTransform(
const FTransform& InTransform)
const;
147 FVector LocalToGlobalLocation(
const FVector& InLocation)
const;
149 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Large Map Manager")
150 FString LargeMapTilePath = "/Game/Carla/Maps/testmap";
151 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large
Map Manager")
152 FString LargeMapName = "testmap";
154 void SetTile0Offset(const FVector& Offset);
156 void SetTileSize(
float Size);
160 FVector GetTile0Offset();
162 void SetLayerStreamingDistance(
float Distance);
164 void SetActorStreamingDistance(
float Distance);
166 float GetLayerStreamingDistance() const;
168 float GetActorStreamingDistance() const;
170 UFUNCTION(BlueprintCallable, Category = "Large
Map Manager")
171 FIntVector GetTileVectorID(FVector TileLocation) const;
173 FIntVector GetTileVectorID(
FDVector TileLocation) const;
179 UFUNCTION(BlueprintCallable, Category = "Large
Map Manager")
180 FVector GetTileLocation(FIntVector TileVectorID) const;
184 FDVector GetTileLocationD(FIntVector TileVectorID) const;
187 TileID GetTileID(FVector TileLocation) const;
191 TileID GetTileID(FIntVector TileVectorID) const;
197 UFUNCTION(BlueprintCallable, Category = "Large
Map Manager")
208 bool SpectatorAsEgo = false;
209 void ConsiderSpectatorAsEgo(
bool _SpectatorAsEgo);
213 void RemoveLandscapeCollisionIfHaveTerraMechanics(ULevel* InLevel);
215 void UpdateTilesState();
217 void RemovePendingActorsToRemove();
222 void CheckActiveActors();
225 void ConvertActiveToDormantActors();
230 void CheckDormantActors();
233 void ConvertDormantToActiveActors();
235 void CheckIfRebaseIsNeeded();
237 void GetTilesToConsider(
238 const
AActor* ActorToConsider,
239 TSet<
TileID>& OutTilesToConsider);
241 void GetTilesThatNeedToChangeState(
242 const TSet<
TileID>& InTilesToConsider,
243 TSet<
TileID>& OutTilesToBeVisible,
244 TSet<
TileID>& OutTilesToHidde);
246 void UpdateTileState(
247 const TSet<
TileID>& InTilesToUpdate,
248 bool InShouldBlockOnLoad,
249 bool InShouldBeLoaded,
250 bool InShouldBeVisible);
252 void UpdateCurrentTilesLoaded(
253 const TSet<
TileID>& InTilesToBeVisible,
254 const TSet<
TileID>& InTilesToHidde);
256 UPROPERTY(VisibleAnywhere, Category = "Large
Map Manager")
262 UPROPERTY(VisibleAnywhere, Category = "Large
Map Manager")
265 UPROPERTY(VisibleAnywhere, Category = "Large
Map Manager")
280 UPROPERTY(VisibleAnywhere, Category = "Large
Map Manager")
281 TSet<uint64> CurrentTilesLoaded;
284 UPROPERTY(VisibleAnywhere, Category = "Large
Map Manager")
285 FIntVector CurrentOriginInt{ 0 };
289 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Large Map Manager")
290 FVector Tile0Offset = FVector(0,0,0);
292 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large
Map Manager")
293 float TickInterval = 0.0f;
295 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large
Map Manager")
296 float LayerStreamingDistance = 3.0f * 1000.0f * 100.0f;
298 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large
Map Manager")
299 float ActorStreamingDistance = 2.0f * 1000.0f * 100.0f;
301 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large
Map Manager")
302 float RebaseOriginDistance = 2.0f * 1000.0f * 100.0f;
304 float LayerStreamingDistanceSquared = LayerStreamingDistance * LayerStreamingDistance;
305 float ActorStreamingDistanceSquared = ActorStreamingDistance * ActorStreamingDistance;
306 float RebaseOriginDistanceSquared = RebaseOriginDistance * RebaseOriginDistance;
308 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large
Map Manager")
309 float TileSide = 2.0f * 1000.0f * 100.0f;
311 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large
Map Manager")
312 FVector LocalTileOffset = FVector(0,0,0);
314 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large
Map Manager")
315 bool ShouldTilesBlockOnLoad = false;
318 void RegisterTilesInWorldComposition();
324 void DumpTilesTable() const;
328 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large
Map Manager")
329 FString AssetsPath = "";
331 FString BaseTileMapPath = "/Game/Carla/Maps/LargeMap/EmptyTileBase";
333 FColor PositonMsgColor = FColor::Purple;
335 const int32 TilesDistMsgIndex = 100;
336 const int32 MaxTilesDistMsgIndex = TilesDistMsgIndex + 10;
338 const int32 ClientLocMsgIndex = 200;
339 const int32 MaxClientLocMsgIndex = ClientLocMsgIndex + 10;
341 UPROPERTY(EditAnywhere, Category = "Large
Map Manager")
342 float MsgTime = 1.0f;
344 UPROPERTY(EditAnywhere, Category = "Large
Map Manager")
347 UPROPERTY(EditAnywhere, Category = "Large
Map Manager")
348 bool bPrintErrors = false;
350 UPROPERTY(VisibleAnywhere, Category = "Large
Map Manager")
351 bool bHasTerramechanics = false;