public WorldInstance GetPlayerWorld(WorldInstance parent) { if (parent.Entities.Any(x => x.PlayerControlled)) { return(parent); } foreach (WorldInstance world in parent.Areas.Values) { return(GetPlayerWorld(world)); } return(null); }
public List <WorldInstance> GetWorlds(WorldInstance parent) { List <WorldInstance> worlds = new List <WorldInstance>(); worlds.Add(parent); for (int i = 0; i < worlds.Count; i++) { foreach (WorldInstance world in worlds[i].m_Areas.Values) { List <WorldInstance> newWorlds = GetWorlds(world); for (int j = 0; j < newWorlds.Count; j++) { if (!worlds.Contains(newWorlds[j])) { worlds.Add(newWorlds[j]); } } } } return(worlds); }
public void AddArea(Vector2Int key, WorldInstance value) { value.Parent = this; m_Areas.Add(key, value); }