2018-07-20 06:27:47 +00:00
|
|
|
namespace Godot
|
|
|
|
{
|
|
|
|
public partial class Node
|
|
|
|
{
|
2018-10-05 13:06:05 +00:00
|
|
|
public T GetNode<T>(NodePath path) where T : class
|
2018-07-20 06:27:47 +00:00
|
|
|
{
|
2018-10-05 17:39:11 +00:00
|
|
|
return (T)(object)GetNode(path);
|
2018-07-20 06:27:47 +00:00
|
|
|
}
|
2018-03-06 14:39:01 +00:00
|
|
|
|
2018-10-05 13:06:05 +00:00
|
|
|
public T GetNodeOrNull<T>(NodePath path) where T : class
|
2018-03-06 14:39:01 +00:00
|
|
|
{
|
|
|
|
return GetNode(path) as T;
|
|
|
|
}
|
|
|
|
|
2018-10-05 13:06:05 +00:00
|
|
|
public T GetChild<T>(int idx) where T : class
|
2018-03-06 14:39:01 +00:00
|
|
|
{
|
2018-10-05 17:39:11 +00:00
|
|
|
return (T)(object)GetChild(idx);
|
2018-03-06 14:39:01 +00:00
|
|
|
}
|
|
|
|
|
2018-10-05 13:06:05 +00:00
|
|
|
public T GetChildOrNull<T>(int idx) where T : class
|
2018-03-06 14:39:01 +00:00
|
|
|
{
|
|
|
|
return GetChild(idx) as T;
|
|
|
|
}
|
|
|
|
|
2018-10-05 13:06:05 +00:00
|
|
|
public T GetOwner<T>() where T : class
|
2018-03-06 14:39:01 +00:00
|
|
|
{
|
2019-05-21 17:09:00 +00:00
|
|
|
return (T)(object)Owner;
|
2018-03-06 14:39:01 +00:00
|
|
|
}
|
|
|
|
|
2018-10-05 13:06:05 +00:00
|
|
|
public T GetOwnerOrNull<T>() where T : class
|
2018-03-06 14:39:01 +00:00
|
|
|
{
|
2019-05-21 17:09:00 +00:00
|
|
|
return Owner as T;
|
2018-03-06 14:39:01 +00:00
|
|
|
}
|
|
|
|
|
2018-10-05 13:06:05 +00:00
|
|
|
public T GetParent<T>() where T : class
|
2018-03-06 14:39:01 +00:00
|
|
|
{
|
2018-10-05 17:39:11 +00:00
|
|
|
return (T)(object)GetParent();
|
2018-03-06 14:39:01 +00:00
|
|
|
}
|
|
|
|
|
2018-10-05 13:06:05 +00:00
|
|
|
public T GetParentOrNull<T>() where T : class
|
2018-03-06 14:39:01 +00:00
|
|
|
{
|
|
|
|
return GetParent() as T;
|
|
|
|
}
|
2018-07-20 06:27:47 +00:00
|
|
|
}
|
|
|
|
}
|