コード例 #1
0
        /// <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)
        {
            PartialPostLoadProcess(gameData, textureAccessor, textureOpacity);

            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;

            IDGenerator.Reset(maxObjectId, maxFaceId);

            // 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);
            }
        }