UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ActorDescContainerInstanceCollection.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "UObject/Object.h"
9#include <type_traits>
10
11class UWorldPartition;
12
13template<class ActorDescContPtrType>
15{
16#if WITH_EDITOR
17public:
18 template<class> friend class TActorDescContainerInstanceCollection;
19
21
22 template<class U>
24
25 template<class U>
27
29
30 void AddContainer(ActorDescContPtrType Container);
32 bool Contains(const FName& ContainerPackageName) const;
33 ActorDescContPtrType FindContainer(const FName& ContainerPackageName) const;
34
35 template<class U>
37
38 void Empty();
39 bool IsEmpty() const { return ActorDescContainerInstanceCollection.IsEmpty(); }
41
44
45 const FWorldPartitionActorDescInstance* GetActorDescInstanceByPath(const FString& ActorPath) const;
48
51
52 bool RemoveActor(const FGuid& ActorGuid)
53 requires (!std::is_const_v<std::remove_pointer_t<ActorDescContPtrType>>);
54
56 requires (!std::is_const_v<std::remove_pointer_t<ActorDescContPtrType>>);
57
59 requires (!std::is_const_v<std::remove_pointer_t<ActorDescContPtrType>>);
60
63
66
69
70 void ForEachActorDescContainerInstanceBreakable(TFunctionRef<bool(ActorDescContPtrType)> Func, bool bRecursive = false);
71 void ForEachActorDescContainerInstanceBreakable(TFunctionRef<bool(ActorDescContPtrType)> Func, bool bRecursive = false) const;
72
73 void ForEachActorDescContainerInstance(TFunctionRef<void(ActorDescContPtrType)> Func, bool bRecursive = false);
74 void ForEachActorDescContainerInstance(TFunctionRef<void(ActorDescContPtrType)> Func, bool bRecursive = false) const;
75
76protected:
77 virtual void OnCollectionChanged() {};
78 virtual bool ShouldRegisterDelegates() const { return true; }
79
81
82private:
83 void RegisterDelegates(ActorDescContPtrType Container);
84 void UnregisterDelegates(ActorDescContPtrType Container);
85
89
90public:
91 template<bool bConst, class ActorType>
92 class TBaseIterator
93 {
94 static_assert(TIsDerivedFrom<ActorType, AActor>::IsDerived, "Type is not derived from AActor.");
95
96 protected:
97 typedef UActorDescContainerInstance ContainerType;
99 typedef std::conditional_t<bConst, typename ContainerCollectionType::TConstIterator, typename ContainerCollectionType::TIterator> ContainerIteratorType;
100 typedef std::conditional_t<bConst, typename ContainerType::TConstIterator<ActorType>, typename ContainerType::TIterator<ActorType>> ActDescIteratorType;
101
102 typedef FWorldPartitionActorDescInstance ValueType;
103 typedef std::conditional_t<bConst, const ValueType*, ValueType*> ReturnType;
104
105 public:
106 template<class T>
107 TBaseIterator(T* Collection)
108 : ContainerIterator(Collection->ActorDescContainerInstanceCollection)
109 {
111 {
113
114 if (!*ActorsIterator)
115 {
117 }
118 }
119 }
120
124 void operator++()
125 {
126 ++(*ActorsIterator);
127
128 if (!*ActorsIterator)
129 {
131 }
132 }
133
139 inline ReturnType operator*() const
140 {
142 }
143
149 inline ReturnType operator->() const
150 {
152 }
159 inline explicit operator bool() const
160 {
161 return ActorsIterator ? (bool)*ActorsIterator : false;
162 }
163
164 protected:
166 {
167 while (!(*ActorsIterator) && ContainerIterator)
168 {
171 {
173 }
174 }
175 }
176
179 };
180
181 template <class ActorType = AActor>
182 class TIterator : public TBaseIterator<false, ActorType>
183 {
184 typedef TBaseIterator<false, ActorType> BaseType;
185
186 public:
187 template<class T>
189 : BaseType(Collection)
190 {}
191 };
192
193 template <class ActorType = AActor>
194 class TConstIterator : public TBaseIterator<true, ActorType>
195 {
196 typedef TBaseIterator<true, ActorType> BaseType;
197
198 public:
199 template<class T>
201 : BaseType(Collection)
202 {}
203 };
204#endif
205};
206
207#if WITH_EDITOR
208
209template<class ActorDescContPtrType>
210template<class U>
213{
215 {
216 RegisterDelegates(ActorDescContainerInstance);
217 });
218}
219
220template<class ActorDescContPtrType>
221template<class U>
224{
226 {
227 RegisterDelegates(ActorDescContainerInstance);
228 });
229}
230
231template<class ActorDescContPtrType>
233{
234 Empty();
235}
236
237template<class ActorDescContPtrType>
239{
241 RegisterDelegates(Container);
242 OnCollectionChanged();
243}
244
245template<class ActorDescContPtrType>
247{
249 {
250 UnregisterDelegates(Container);
251 OnCollectionChanged();
252 return true;
253 }
254 return false;
255}
256
257template<class ActorDescContPtrType>
258template<class U>
260{
261 if (OtherCollection.IsEmpty())
262 {
263 return;
264 }
265
266 ActorDescContainerInstanceCollection.Append(OtherCollection.ActorDescContainerInstanceCollection);
267 int32 AppendedContainerIndex = ActorDescContainerInstanceCollection.Num() - OtherCollection.ActorDescContainerInstanceCollection.Num();
269 {
271 }
272
273 OnCollectionChanged();
274}
275
276template<class ActorDescContPtrType>
278{
279 return FindContainer(ContainerPackageName) != nullptr;
280}
281
282template<class ActorDescContPtrType>
284{
286 return ContainerPtr != nullptr ? *ContainerPtr : nullptr;
287}
288
289template<class ActorDescContPtrType>
291{
293 {
294 UnregisterDelegates(ActorDescContainerInstance);
295 });
296
298 OnCollectionChanged();
299}
300
301template<class ActorDescContPtrType>
303{
305 {
309 }
310}
311
312template<class ActorDescContPtrType>
314{
316 {
317 ConstCast(Container)->OnActorDescInstanceAddedEvent.RemoveAll(this);
318 ConstCast(Container)->OnActorDescInstanceRemovedEvent.RemoveAll(this);
319 ConstCast(Container)->OnActorReplacedEvent.RemoveAll(this);
320 }
321}
322
323template<class ActorDescContPtrType>
325{
328 {
329 ActorDescInstance = ActorDescContainerInstance->GetActorDescInstance(Guid);
330 return ActorDescInstance == nullptr;
331 });
332
333 return ActorDescInstance;
334}
335
336template<class ActorDescContPtrType>
338{
340}
341
342template<class ActorDescContPtrType>
344{
347 {
348 ActorDescInstance = ActorDescContainerInstance->GetActorDescInstanceByPath(ActorPath);
349 return ActorDescInstance == nullptr;
350 });
351
352 return ActorDescInstance;
353}
354
355template<class ActorDescContPtrType>
357{
360 {
361 ActorDescInstance = ActorDescContainerInstance->GetActorDescInstanceByPath(ActorPath);
362 return ActorDescInstance == nullptr;
363 });
364
365 return ActorDescInstance;
366}
367
368template<class ActorDescContPtrType>
370{
373 {
374 ActorDescInstance = ActorDescContainerInstance->GetActorDescInstanceByName(ActorName);
375 return ActorDescInstance == nullptr;
376 });
377
378 return ActorDescInstance;
379}
380
381template<class ActorDescContPtrType>
383{
386 {
387 if (InActorDescContainerInstance->GetActorDescInstance(ActorGuid) != nullptr)
388 {
389 ActorDescContainerInstance = InActorDescContainerInstance;
390 }
391 return ActorDescContainerInstance == nullptr;
392 });
393
395}
396
397template<class ActorDescContPtrType>
399{
400 // Actor is already in a container
402 {
404 }
405
406 // Actor is not yet stored in a container. Find which one should handle it.
409 {
410 if (InActorDescContainerInstance->IsActorDescHandled(Actor))
411 {
412 ActorDescContainerInstance = InActorDescContainerInstance;
413 }
414 return ActorDescContainerInstance == nullptr;
415 });
416
418}
419
420template<class ActorDescContPtrType>
422 requires (!std::is_const_v<std::remove_pointer_t<ActorDescContPtrType>>)
423{
424 bool bRemoved = false;
426 {
427 bRemoved = ContainerInstance->GetContainer()->RemoveActor(ActorGuid);
428 return !bRemoved;
429 });
430
431 return bRemoved;
432}
433
434template<class ActorDescContPtrType>
436 requires (!std::is_const_v<std::remove_pointer_t<ActorDescContPtrType>>)
437{
439 {
441 });
442}
443
444template<class ActorDescContPtrType>
446 requires (!std::is_const_v<std::remove_pointer_t<ActorDescContPtrType>>)
447{
449 {
450 ContainerInstance->LoadAllActors(OutReferences);
451 });
452}
453
454
455template<class ActorDescContPtrType>
457{
458 TFunction<bool(ActorDescContPtrType)> InvokeFunc = [&Func, &InvokeFunc, bRecursive](ActorDescContPtrType ActorDescContainerInstance)
459 {
461 {
462 return false;
463 }
464
465 if (bRecursive)
466 {
468 {
469 if (!InvokeFunc(ChildActorDescContainerInstance))
470 {
471 return false;
472 }
473 }
474 }
475
476 return true;
477 };
478
480 {
481 if (!InvokeFunc(ActorDescContainerInstance))
482 {
483 break;
484 }
485 }
486}
487
488template<class ActorDescContPtrType>
490{
492}
493
494template<class ActorDescContPtrType>
496{
498 {
499 Func(ActorDescContainerInstance); return true;
500 }, bRecursive);
501}
502
503template<class ActorDescContPtrType>
505{
506 const_cast<const TActorDescContainerInstanceCollection*>(this)->ForEachActorDescContainerInstance(Func, bRecursive);
507}
508
509template<class ActorDescContPtrType>
511{
513}
514
515template<class ActorDescContPtrType>
517{
519}
520
521template<class ActorDescContPtrType>
523{
525}
526
527#endif
528
UE_FORCEINLINE_HINT FLinearColor operator*(float Scalar, const FLinearColor &Color)
Definition Color.h:473
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_EVENT_OneParam(OwningType, EventName, Param1Type)
Definition DelegateCombinations.h:51
const bool
Definition NetworkReplayStreaming.h:178
FORCEINLINE decltype(auto) ConstCast(const TObjectPtr< T > &P)
Definition ObjectPtr.h:1778
TIndexedContainerIterator< const TArray< FPreviewAttachedObjectPair >, const FPreviewAttachedObjectPair, int32 > TConstIterator
Definition PreviewAssetAttachComponent.h:69
TIndexedContainerIterator< TArray< FPreviewAttachedObjectPair >, FPreviewAttachedObjectPair, int32 > TIterator
Definition PreviewAssetAttachComponent.h:68
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Actor.h:257
Definition NameTypes.h:617
Definition WorldPartitionActorDescInstance.h:18
Definition ActorDescContainerInstanceCollection.h:15
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition AndroidPlatformMisc.h:14
Definition Array.h:64
Definition UniquePtr.h:107
Definition ActorDescContainerInstance.h:23
Definition Package.h:216
Definition WorldPartition.h:142
void RemoveActor(FDatasmithSceneImpl *SceneImpl, ContainerType &ActorContainer, SharedPtrElementType &InActor, EDatasmithActorRemovalRule RemoveRule)
Definition DatasmithSceneElementsImpl.cpp:1312
Definition Guid.h:109
Definition SoftObjectPath.h:56
Definition UnrealTypeTraits.h:40