2018-07-20 08:27:47 +02:00
|
|
|
namespace Godot
|
|
|
|
{
|
|
|
|
public partial class Node
|
|
|
|
{
|
2018-10-05 15:06:05 +02:00
|
|
|
public T GetNode<T>(NodePath path) where T : class
|
2018-07-20 08:27:47 +02:00
|
|
|
{
|
|
|
|
return (T)GetNode(path);
|
|
|
|
}
|
2018-03-06 15:39:01 +01:00
|
|
|
|
2018-10-05 15:06:05 +02:00
|
|
|
public T GetNodeOrNull<T>(NodePath path) where T : class
|
2018-03-06 15:39:01 +01:00
|
|
|
{
|
|
|
|
return GetNode(path) as T;
|
|
|
|
}
|
|
|
|
|
2018-10-05 15:06:05 +02:00
|
|
|
public T GetChild<T>(int idx) where T : class
|
2018-03-06 15:39:01 +01:00
|
|
|
{
|
|
|
|
return (T)GetChild(idx);
|
|
|
|
}
|
|
|
|
|
2018-10-05 15:06:05 +02:00
|
|
|
public T GetChildOrNull<T>(int idx) where T : class
|
2018-03-06 15:39:01 +01:00
|
|
|
{
|
|
|
|
return GetChild(idx) as T;
|
|
|
|
}
|
|
|
|
|
2018-10-05 15:06:05 +02:00
|
|
|
public T GetOwner<T>() where T : class
|
2018-03-06 15:39:01 +01:00
|
|
|
{
|
|
|
|
return (T)GetOwner();
|
|
|
|
}
|
|
|
|
|
2018-10-05 15:06:05 +02:00
|
|
|
public T GetOwnerOrNull<T>() where T : class
|
2018-03-06 15:39:01 +01:00
|
|
|
{
|
|
|
|
return GetOwner() as T;
|
|
|
|
}
|
|
|
|
|
2018-10-05 15:06:05 +02:00
|
|
|
public T GetParent<T>() where T : class
|
2018-03-06 15:39:01 +01:00
|
|
|
{
|
|
|
|
return (T)GetParent();
|
|
|
|
}
|
|
|
|
|
2018-10-05 15:06:05 +02:00
|
|
|
public T GetParentOrNull<T>() where T : class
|
2018-03-06 15:39:01 +01:00
|
|
|
{
|
|
|
|
return GetParent() as T;
|
|
|
|
}
|
2018-07-20 08:27:47 +02:00
|
|
|
}
|
|
|
|
}
|