Add find actor by type and tag to level and actor classes. Move find actor by tag code to be by other find actor methods.

This commit is contained in:
Chandler Cox
2023-07-05 14:00:07 -05:00
parent bd0bc42adc
commit d88b93d56b
6 changed files with 240 additions and 137 deletions

View File

@@ -739,6 +739,14 @@ public:
/// <returns>Actor instance if found, null otherwise.</returns>
API_FUNCTION() Actor* FindActor(API_PARAM(Attributes="TypeReference(typeof(Actor))") const MClass* type, const StringView& name) const;
/// <summary>
/// Tries to find the actor of the given type and tag in this actor hierarchy.
/// </summary>
/// <param name="type">Type of the actor to search for. Includes any actors derived from the type.</param>
/// <param name="tag">The tag of the actor to search for.</param>
/// <returns>Actor instance if found, null otherwise.</returns>
API_FUNCTION() Actor* FindActor(API_PARAM(Attributes="TypeReference(typeof(Actor))") const MClass* type, const Tag& tag) const;
/// <summary>
/// Tries to find the actor of the given type in this actor hierarchy (checks this actor and all children hierarchy).
/// </summary>
@@ -759,6 +767,17 @@ public:
{
return (T*)FindActor(T::GetStaticClass(), name);
}
/// <summary>
/// Tries to find the actor of the given type and tag in this actor hierarchy (checks this actor and all children hierarchy).
/// </summary>
/// <param name="tag">The tag of the actor to search for.</param>
/// <returns>Actor instance if found, null otherwise.</returns>
template<typename T>
FORCE_INLINE T* FindActor(const Tag& tag) const
{
return (T*)FindActor(T::GetStaticClass(), tag);
}
/// <summary>
/// Tries to find the script of the given type in this actor hierarchy (checks this actor and all children hierarchy).