示例#1
0
 /// <summary>
 /// Load the shapes that have not yet been loaded.
 /// </summary>
 /// <param name="loader">The ShapeLoader to use to load the shapes.</param>
 /// <param name="builder">The builder to use to construct the shapes.</param>
 public void loadShapes(ShapeLoader loader, ShapeBuilder builder)
 {
     Log.Info("Loading shape group {0}", Name);
     foreach (ShapeLocation location in shapeLocations.Values)
     {
         if (!location.Loaded)
         {
             loadShape(location, loader, builder);
         }
     }
     loaded = true;
 }
示例#2
0
        /// <summary>
        /// Helper function to scan a directory for all shape files present.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="loader"></param>
        /// <param name="builder"></param>
        private void scanDirectory(ShapeLocation location, ShapeLoader loader, ShapeBuilder builder, VirtualFileSystem vfs)
        {
            IEnumerable <String> files = vfs.listFiles(location.LocName, location.Recursive);

            foreach (String path in files)
            {
                if (loader.canLoadShape(path, vfs))
                {
                    loader.loadShapes(builder, path, vfs);
                }
            }
        }
示例#3
0
 /// <summary>
 /// Add a shape location to this group.
 /// </summary>
 /// <param name="location">The location to add.</param>
 /// <param name="loader">The loader to use if the shapes need to be built in the file.</param>
 /// <param name="builder">The builder to use.</param>
 public void addShapeLocation(ShapeLocation location, ShapeLoader loader, ShapeBuilder builder)
 {
     if (!shapeLocations.ContainsKey(location.LocName))
     {
         shapeLocations.Add(location.LocName, location);
         if (loaded)
         {
             loadShape(location, loader, builder);
         }
     }
     else
     {
         Log.Default.sendMessage("Added duplicate shape resource {0}, ignored.", LogLevel.Warning, "ShapeLoading", location.LocName);
     }
 }
示例#4
0
        /// <summary>
        /// Helper function to load the shapes at the specified location.
        /// </summary>
        /// <param name="location">The location to load.</param>
        /// <param name="loader">The loader to use.</param>
        /// <param name="builder">The builder to use.</param>
        private void loadShape(ShapeLocation location, ShapeLoader loader, ShapeBuilder builder)
        {
            VirtualFileSystem vfs = VirtualFileSystem.Instance;

            builder.setCurrentShapeLocation(location);
            if (vfs.isDirectory(location.LocName))
            {
                scanDirectory(location, loader, builder, vfs);
            }
            else
            {
                if (loader.canLoadShape(location.LocName, vfs))
                {
                    loader.loadShapes(builder, location.LocName, vfs);
                }
                else
                {
                    Logging.Log.Default.sendMessage("Cannot load collision file {0}.", LogLevel.Error, "ShapeLoading", location.LocName);
                }
            }
            location.Loaded = true;
            //catch (FileNotFoundException)
            //{
            //    Logging.Log.Default.sendMessage("Cannot load collision file {0}.  Location does not exist.", LogLevel.Error, "ShapeLoading", location.LocName);
            //}
            //catch (DirectoryNotFoundException)
            //{
            //    Logging.Log.Default.sendMessage("Cannot load collision directory {0}.  Location does not exist.", LogLevel.Error, "ShapeLoading", location.LocName);
            //}
            //catch (NotSupportedException)
            //{
            //    Logging.Log.Default.sendMessage("The given path format is not supported {0}.", LogLevel.Error, "ShapeLoading", location.LocName);
            //}
            //catch (IOException e)
            //{
            //    Logging.Log.Default.sendMessage("General IO error loading collision {0}.\n{1}", LogLevel.Error, "ShapeLoading", location.LocName, e.Message);
            //}
        }