You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
587 B
24 lines
587 B
using Godot; |
|
|
|
public static class Extensions |
|
{ |
|
public static Game GetGame(this Node node) |
|
=> node.GetTree().Root.GetChild<Game>(0); |
|
public static Client GetClient(this Node node) |
|
=> node.GetGame() as Client; |
|
public static Server GetServer(this Node node) |
|
=> node.GetGame() as Server; |
|
|
|
public static T Init<T>(this PackedScene @this) |
|
where T : Node |
|
{ |
|
var instance = (T)@this.Instance(); |
|
(instance as IInitializer)?.Initialize(); |
|
return instance; |
|
} |
|
} |
|
|
|
public interface IInitializer |
|
{ |
|
void Initialize(); |
|
}
|
|
|