Barotrauma Server
Loading...
Searching...
No Matches
Barotrauma.PrefabCollection< T > Class Template Reference
Inheritance diagram for Barotrauma.PrefabCollection< T >:

Public Member Functions

 PrefabCollection ()
 Default constructor.
 
 PrefabCollection (Action< T, bool >? onAdd, Action< T >? onRemove, Action? onSort, Action< ContentFile >? onAddOverrideFile, Action< ContentFile >? onRemoveOverrideFile)
 Constructor with OnAdd and OnRemove callbacks provided.
 
 PrefabCollection (Action? onSort)
 Constructor with only the OnSort callback provided.
 
bool TryGet (Identifier identifier, [NotNullWhen(true)] out T? result)
 Returns true if a prefab with the identifier exists, false otherwise.
 
bool TryGet (string identifier, out T? result)
 
T? Find (Predicate< T > predicate)
 Finds the first active prefab that returns true given the predicate, or null if no such prefab is found.
 
bool ContainsKey (Identifier identifier)
 Returns true if a prefab with the given identifier exists, false otherwise.
 
bool ContainsKey (string k)
 
bool IsOverride (T prefab)
 Determines whether a prefab is implemented as an override or not.
 
void Add (T prefab, bool isOverride)
 Add a prefab to the collection. If not marked as an override, fail if a prefab with the same identifier already exists. Otherwise, add to the corresponding list, without making any changes to the base prefab.
 
void Remove (T prefab)
 Removes a prefab from the collection.
 
void RemoveByFile (ContentFile file)
 Removes all prefabs that were loaded from a certain file.
 
void AddOverrideFile (ContentFile file)
 Adds an override file to the collection.
 
void RemoveOverrideFile (ContentFile file)
 Removes an override file from the collection.
 
void SortAll ()
 Sorts all prefabs in the collection based on the content package load order.
 
IEnumerator< T > GetEnumerator ()
 GetEnumerator implementation to enable foreach.
 

Properties

IEnumerable< KeyValuePair< Identifier, PrefabSelector< T > > > AllPrefabs [get]
 AllPrefabs exposes all prefabs instead of just the active ones.
 
this[Identifier identifier] [get]
 Returns the active prefab with the given identifier.
 
this[string identifier] [get]
 
IEnumerable< Identifier > Keys [get]
 

Constructor & Destructor Documentation

◆ PrefabCollection() [1/3]

Default constructor.

◆ PrefabCollection() [2/3]

Barotrauma.PrefabCollection< T >.PrefabCollection ( Action< T, bool >? onAdd,
Action< T >? onRemove,
Action? onSort,
Action< ContentFile >? onAddOverrideFile,
Action< ContentFile >? onRemoveOverrideFile )

Constructor with OnAdd and OnRemove callbacks provided.

◆ PrefabCollection() [3/3]

Constructor with only the OnSort callback provided.

Member Function Documentation

◆ Add()

void Barotrauma.PrefabCollection< T >.Add ( T prefab,
bool isOverride )

Add a prefab to the collection. If not marked as an override, fail if a prefab with the same identifier already exists. Otherwise, add to the corresponding list, without making any changes to the base prefab.

Parameters
prefabPrefab
isOverrideIs marked as override

◆ AddOverrideFile()

void Barotrauma.PrefabCollection< T >.AddOverrideFile ( ContentFile file)

Adds an override file to the collection.

◆ ContainsKey() [1/2]

bool Barotrauma.PrefabCollection< T >.ContainsKey ( Identifier identifier)

Returns true if a prefab with the given identifier exists, false otherwise.

Parameters
identifierPrefab identifier
Returns
Whether a prefab with the given identifier exists or not

◆ ContainsKey() [2/2]

bool Barotrauma.PrefabCollection< T >.ContainsKey ( string k)

◆ Find()

T? Barotrauma.PrefabCollection< T >.Find ( Predicate< T > predicate)

Finds the first active prefab that returns true given the predicate, or null if no such prefab is found.

Parameters
predicatePredicate to perform the search with.
Returns

◆ GetEnumerator()

IEnumerator< T > Barotrauma.PrefabCollection< T >.GetEnumerator ( )

GetEnumerator implementation to enable foreach.

Returns
IEnumerator

◆ IsOverride()

bool Barotrauma.PrefabCollection< T >.IsOverride ( T prefab)

Determines whether a prefab is implemented as an override or not.

Parameters
prefabPrefab in this collection
Returns
Whether a prefab is implemented as an override or not

◆ Remove()

void Barotrauma.PrefabCollection< T >.Remove ( T prefab)

Removes a prefab from the collection.

Parameters
prefabPrefab

◆ RemoveByFile()

void Barotrauma.PrefabCollection< T >.RemoveByFile ( ContentFile file)

Removes all prefabs that were loaded from a certain file.

◆ RemoveOverrideFile()

void Barotrauma.PrefabCollection< T >.RemoveOverrideFile ( ContentFile file)

Removes an override file from the collection.

◆ SortAll()

void Barotrauma.PrefabCollection< T >.SortAll ( )

Sorts all prefabs in the collection based on the content package load order.

◆ TryGet() [1/2]

bool Barotrauma.PrefabCollection< T >.TryGet ( Identifier identifier,
[NotNullWhen(true)] out T? result )

Returns true if a prefab with the identifier exists, false otherwise.

Parameters
identifierPrefab identifier
resultThe matching prefab (if one is found)
Returns
Whether a prefab with the identifier exists or not

◆ TryGet() [2/2]

bool Barotrauma.PrefabCollection< T >.TryGet ( string identifier,
out T? result )

Property Documentation

◆ AllPrefabs

IEnumerable<KeyValuePair<Identifier, PrefabSelector<T> > > Barotrauma.PrefabCollection< T >.AllPrefabs
get

AllPrefabs exposes all prefabs instead of just the active ones.

◆ Keys

IEnumerable<Identifier> Barotrauma.PrefabCollection< T >.Keys
get

◆ this[Identifier identifier]

T Barotrauma.PrefabCollection< T >.this[Identifier identifier]
get

Returns the active prefab with the given identifier.

Parameters
identifierPrefab identifier
Returns
Active prefab with the given identifier

◆ this[string identifier]

T Barotrauma.PrefabCollection< T >.this[string identifier]
get

The documentation for this class was generated from the following file: