Files
RobustToolbox/Robust.Shared/GameObjects/IEntityLoadContext.cs
Fildrance 121b58ee9a feat: added generic method for getting component from ComponentRegistry (#6082)
* feat: added generic method for getting component from ComponentRegistry

* refactor: corrected xml-doc

* refactor: moved emthod to ComponentRegistry

* Fix release notes entry.

Wording + it was in the template.

* Fix doc comments

* Do not use inappropriate fallible cast.

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-08-02 18:55:49 +02:00

41 lines
1.8 KiB
C#

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Robust.Shared.GameObjects
{
/// <summary>
/// Interface used to allow the map loader to override prototype data with map data.
/// </summary>
internal interface IEntityLoadContext
{
/// <summary>Tries getting the data of the given component.</summary>
/// <param name="componentName">Name of component to find.</param>
/// <param name="component">Found component or null.</param>
/// <returns>True if the component was found, false otherwise.</returns>
/// <seealso cref="TryGetComponent{T}"/>
bool TryGetComponent(string componentName, [NotNullWhen(true)] out IComponent? component);
/// <summary>Tries getting the data of the given component.</summary>
/// <typeparam name="TComponent">Type of component to be found.</typeparam>
/// <param name="componentFactory">Component factory required for the lookup.</param>
/// <param name="component">Found component or null.</param>
/// <returns>True if the component was found, false otherwise.</returns>
/// <seealso cref="TryGetComponent"/>
bool TryGetComponent<TComponent>(
IComponentFactory componentFactory,
[NotNullWhen(true)] out TComponent? component
) where TComponent : class, IComponent, new();
/// <summary>
/// Gets all components registered for the entityloadcontext, overrides as well as extra components
/// </summary>
IEnumerable<string> GetExtraComponentTypes();
/// <summary>
/// Checks whether a given component should be added to an entity.
/// Used to prevent certain prototype components from being added while spawning an entity.
/// </summary>
bool ShouldSkipComponent(string compName);
}
}