Utility extensions and a tiny global holder. Adds GameObject extension methods to find a named child or to search a GameObjectDirectory by exact name, and defines a _game static class with a CurrentlySelectedMap string defaulting to "despawn.fate".
using Sandbox;
public static class GameObject_Extensions
{
public static GameObject GetChild(this GameObject go, string n)
{
foreach (var c in go.Children)
{
if (c.Name == n)
return c;
}
return null;
}
}
public static class _game {
public static string CurrentlySelectedMap {get;set;} = "despawn.fate";
}
public static class Directory_Extensions {
public static GameObject FindbyName(this GameObjectDirectory Directory, string Name) {
foreach (var obj in Directory.FindByName(Name)) {
if (obj.Name == Name)
return obj;
}
return null;
}
}