Made basic quest setup
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using Godot;
|
||||
namespace Babushka.scripts.CSharp.Common.Util;
|
||||
|
||||
public static class NodeExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Searches for a parent node of the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the parent node to search for. The search is successful, when <code>searchedNode is T</code></typeparam>
|
||||
/// <param name="self">The node from which to start the search.</param>
|
||||
/// <returns>The parent node of type T if found, otherwise throws an exception.</returns>
|
||||
public static T FindParentByType<T>(this Node self)
|
||||
{
|
||||
var parent = self.GetParent();
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent is T tParent)
|
||||
{
|
||||
return tParent;
|
||||
}
|
||||
parent = parent.GetParent();
|
||||
}
|
||||
throw new Exception($"Parent of type {typeof(T)} not found for node {self.Name}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bwisbh2f2ci6l
|
||||
Reference in New Issue
Block a user