/// <summary> /// Should be called when a map is loaded. Sets up visgroups, object ids, gamedata, and textures. /// </summary> //public void PostLoadProcess(GameData.GameData gameData, Func<string, ITexture> textureAccessor, Func<string, float> textureOpacity) public void PostLoadProcess(GameData.GameData gameData, Func <string, ITexture> textureAccessor, Func <string, float> textureOpacity, bool DisableTransparent) { PartialPostLoadProcess(gameData, textureAccessor, textureOpacity, DisableTransparent); var all = WorldSpawn.FindAll(); // Set maximum ids var maxObjectId = all.Max(x => x.ID); var faces = all.OfType <Solid>().SelectMany(x => x.Faces).ToList(); var maxFaceId = faces.Any() ? faces.Max(x => x.ID) : 0; long maxMotionId = 0; foreach (Motion m in this.Motions) { if (maxMotionId < m.ID) { maxMotionId = m.ID; } } IDGenerator.Reset(maxObjectId, maxFaceId, maxMotionId); // todo visgroups // WorldSpawn.ForEach(x => x.IsVisgroupHidden, x => x.IsVisgroupHidden = true, true); // Auto visgroup var auto = AutoVisgroup.GetDefaultAutoVisgroup(); var quickHide = new AutoVisgroup { ID = int.MinValue, IsHidden = true, Name = "Autohide", Parent = auto, Visible = false }; auto.Children.Add(quickHide); Visgroups.Add(auto); UpdateAutoVisgroups(all, false); // Purge empty groups foreach (var emptyGroup in WorldSpawn.Find(x => x is Group && !x.HasChildren)) { emptyGroup.SetParent(null); } }
public static AutoVisgroup GetDefaultAutoVisgroup() { var filters = typeof(IVisgroupFilter).Assembly.GetTypes() .Where(x => typeof(IVisgroupFilter).IsAssignableFrom(x)) .Where(x => !x.IsInterface) .Select(Activator.CreateInstance) .OfType <IVisgroupFilter>(); var i = -1; var auto = new AutoVisgroup { ID = i--, IsHidden = false, Name = "Auto", Visible = true }; foreach (var f in filters) { var parent = auto.Children.OfType <AutoVisgroup>().FirstOrDefault(x => x.Name == f.Group); if (parent == null) { parent = new AutoVisgroup { ID = i--, IsHidden = false, Name = f.Group, Visible = true, Parent = auto }; auto.Children.Add(parent); } var vg = new AutoVisgroup { ID = i--, Filter = f.IsMatch, IsHidden = false, Name = f.Name, Visible = true, Parent = parent }; parent.Children.Add(vg); } return(auto); }