Exemplo n.º 1
0
 public IEnumerable<Problem> Check(Map map, bool visibleOnly)
 {
     foreach (var invalid in map.WorldSpawn.Find(x => x is Solid && (!visibleOnly || (!x.IsVisgroupHidden && !x.IsCodeHidden)) && !((Solid)x).IsValid()))
     {
         yield return new Problem(GetType(), map, new[] { invalid }, Fix, "Invalid solid", "This solid is invalid. It is either not convex, has coplanar faces, or has off-plane vertices. Fixing the issue will delete the solid.");
     }
 }
Exemplo n.º 2
0
 public IEnumerable<Problem> Check(Map map)
 {
     foreach (var group in map.WorldSpawn
         .Find(x => x is Group).OfType<Group>()
         .Where(x => !x.GetChildren().Any()))
     {
         yield return new Problem(GetType(), map, new[] { @group }, Fix, "Group has no children", "This group is empty. A group must have contents. Fixing the problem will delete the group.");
     }
 }
Exemplo n.º 3
0
 public IEnumerable<Problem> Check(Map map)
 {
     foreach (var solid in map.WorldSpawn
         .Find(x => x is Solid).OfType<Solid>()
         .Where(x => x.Children.Any()))
     {
         yield return new Problem(GetType(), map, new[] { solid }, Fix, "Solid has children", "A solid with children was found. A solid cannot have any contents. Fixing the issue will move the children outside of the solid's group.");
     }
 }
Exemplo n.º 4
0
 public IEnumerable<Problem> Check(Map map)
 {
     foreach (var entity in map.WorldSpawn
         .Find(x => x is Entity).OfType<Entity>()
         .Where(x => x.GameData == null))
     {
         yield return new Problem(GetType(), map, new[] { entity }, Fix, "Entity class not found: " + entity.EntityData.Name, "This entity class was not found in the current game data. Ensure that the correct FGDs are loaded. Fixing the problem will delete the entities.");
     }
 }
Exemplo n.º 5
0
 public Problem(Type type, Map map, Func<Problem, IAction> fix, string message, string description)
 {
     Type = type;
     Map = map;
     Faces = new List<Face>();
     Objects = new List<MapObject>();
     Fix = fix;
     Message = message;
     Description = description;
 }
Exemplo n.º 6
0
 public Problem(Type type, Map map, IEnumerable<Face> faces, Func<Problem, IAction> fix, string message, string description)
 {
     Type = type;
     Map = map;
     Objects = new List<MapObject>();
     Faces = (faces ?? new Face[0]).ToList();
     Fix = fix;
     Message = message;
     Description = description;
 }
Exemplo n.º 7
0
 public IEnumerable<Problem> Check(Map map, bool visibleOnly)
 {
     foreach (var solid in map.WorldSpawn
         .Find(x => x is Solid && (!visibleOnly || (!x.IsVisgroupHidden && !x.IsCodeHidden)))
         .OfType<Solid>()
         .Where(x => x.HasChildren))
     {
         yield return new Problem(GetType(), map, new[] { solid }, Fix, "Solid has children", "A solid with children was found. A solid cannot have any contents. Fixing the issue will move the children outside of the solid's group.");
     }
 }
 public IEnumerable<Problem> Check(Map map)
 {
     foreach (var entity in map.WorldSpawn
         .Find(x => x is Entity).OfType<Entity>()
         .Where(x => x.GameData != null)
         .Where(x => x.GameData.ClassType != ClassType.Solid && x.GetChildren().Any()))
     {
         yield return new Problem(GetType(), map, new[] { entity }, Fix, "Point entity has children", "A point entity with children was found. A point entity cannot have any contents. Fixing the issue will move the children outside of the entity's group.");
     }
 }
 public IEnumerable<Problem> Check(Map map)
 {
     foreach (var entity in map.WorldSpawn
         .Find(x => x is Entity).OfType<Entity>()
         .Where(x => x.GameData != null)
         .Where(x => x.GameData.ClassType == ClassType.Solid)
         .Where(x => x.GetChildren().SelectMany(y => y.FindAll()).Any(y => !(y is Group) && !(y is Solid))))
     {
         yield return new Problem(GetType(), map, new[] { entity }, Fix, "Brush entity has child entities", "A brush entity with child entities was found. A brush entity must only have solid contents. Fixing the problem will move the child entities outside of the entity's group.");
     }
 }
Exemplo n.º 10
0
 public IEnumerable<Problem> Check(Map map)
 {
     foreach (var entity in map.WorldSpawn
         .Find(x => x is Entity).OfType<Entity>()
         .Where(x => x.GameData != null)
         .Where(x => x.GameData.ClassType == ClassType.Solid)
         .Where(x => !x.Children.SelectMany(y => y.FindAll()).Any(y => y is Solid)))
     {
         yield return new Problem(GetType(), map, new[] { entity }, Fix, "Brush entity has no solid children", "A brush entity with no solid children was found. A brush entity must have solid contents. Fixing the problem will delete the entity.");
     }
 }
 public IEnumerable<Problem> Check(Map map)
 {
     var faces = map.WorldSpawn
         .Find(x => x is Solid).OfType<Solid>()
         .SelectMany(x => x.Faces)
         .ToList();
     foreach (var face in faces)
     {
         var normal = face.Texture.GetNormal();
         if (DMath.Abs(face.Plane.Normal.Dot(normal)) <= 0.0001m) yield return new Problem(GetType(), map, new [] { face }, Fix, "Texture axis perpendicular to face", "The texture axis of this face is perpendicular to the face plane. This occurs when manipulating objects with texture lock off, as well as various other operations. Re-align the texture to the face to repair. Fixing the problem will reset the textures to the face plane.");
     }
 }
Exemplo n.º 12
0
 public IEnumerable<Problem> Check(Map map)
 {
     var entities = map.WorldSpawn
         .Find(x => x is Entity).OfType<Entity>()
         .Where(x => x.GameData != null).ToList();
     foreach (var entity in entities.Where(x => !String.IsNullOrWhiteSpace(x.EntityData.GetPropertyValue("target"))))
     {
         var target = entity.EntityData.GetPropertyValue("target");
         var tname = entities.FirstOrDefault(x => x.EntityData.GetPropertyValue("targetname") == target);
         if (tname == null) yield return new Problem(GetType(), map, new[] { entity }, Fix, "Entity target has no matching named entity", "This entity's target value doesn't have an matching named entity. Each target should have a matching target name. Fixing the problem will reset the target's value to a blank string.");
     }
 }
Exemplo n.º 13
0
 public IEnumerable<Problem> Check(Map map)
 {
     var dupes = from o in map.WorldSpawn.FindAll()
                 group o by o.ID
                 into g
                 where g.Count() > 1
                 select g;
     foreach (var dupe in dupes)
     {
         yield return new Problem(GetType(), map, dupe, Fix, "Multiple objects have the same ID", "More than one object has the same ID. Each object ID should be unique. Fixing the problem will assign the duplicates new IDs.");
     }
 }
Exemplo n.º 14
0
 public IEnumerable<Problem> Check(Map map)
 {
     var faces = map.WorldSpawn
         .Find(x => x is Solid).OfType<Solid>()
         .SelectMany(x => x.Faces)
         .Where(x => x.Texture.Texture == null)
         .ToList();
     foreach (var name in faces.Select(x => x.Texture.Name).Distinct())
     {
         yield return new Problem(GetType(), map, faces.Where(x => x.Texture.Name == name).ToList(), Fix, "Texture not found: " + name, "This texture was not found in the currently loaded texture packages. Ensure that the correct texture packages are loaded. Fixing the problems will reset the face textures to the default texture.");
     }
 }
Exemplo n.º 15
0
 public IEnumerable<Problem> Check(Map map)
 {
     var dupes = from o in map.WorldSpawn.FindAll().OfType<Solid>().SelectMany(x => x.Faces)
                 group o by o.ID
                 into g
                 where g.Count() > 1
                 select g;
     foreach (var dupe in dupes)
     {
         yield return new Problem(GetType(), map, dupe, Fix, "Multiple faces have the same ID", "More than one face was found with the same ID. Each face ID should be unique. Fixing this problem will assign the duplicated faces a new ID.");
     }
 }
Exemplo n.º 16
0
        public Document(string mapFile, Map map, Game game)
        {
            MapFile = mapFile;
            Map = map;
            Game = game;
            MapFileName = mapFile == null
                              ? DocumentManager.GetUntitledDocumentName()
                              : Path.GetFileName(mapFile);

            _subscriptions = new DocumentSubscriptions(this);

            _memory = new DocumentMemory();

            var cam = Map.GetActiveCamera();
            if (cam != null) _memory.SetCamera(cam.EyePosition, cam.LookPosition);

            Selection = new SelectionManager(this);
            History = new HistoryManager(this);
            if (Map.GridSpacing <= 0)
            {
                Map.GridSpacing = Grid.DefaultSize;
            }

            try
            {
                GameData =  GameDataProvider.GetGameDataFromFiles(game.Fgds.Select(f => f.Path));
            }
            catch(ProviderException)
            {
                // TODO: Error logging
                GameData = new GameData();
            }

            TextureCollection = TextureProvider.CreateCollection(game.Wads.Select(x => x.Path).Distinct());
            var texList = Map.GetAllTextures();
            var items = TextureCollection.GetItems(texList);
            TextureCollection.LoadTextureItems(items);

            Map.PostLoadProcess(GameData, GetTexture, SettingsManager.GetSpecialTextureOpacity);

            HelperManager = new HelperManager(this);
            Renderer = new RenderManager(this);

            if (MapFile != null) Mediator.Publish(EditorMediator.FileOpened, MapFile);

            // Autosaving
            if (Game.Autosave)
            {
                var at = Math.Max(1, Game.AutosaveTime);
                Scheduler.Schedule(this, Autosave, TimeSpan.FromMinutes(at));
            }
        }
Exemplo n.º 17
0
 public IEnumerable<Problem> Check(Map map)
 {
     var entities = map.WorldSpawn.Find(x => x is Entity).OfType<Entity>().ToList();
     foreach (var entity in entities)
     {
         var dupes = from p in entity.EntityData.Properties
                     group p by p.Key.ToLowerInvariant()
                     into g
                     where g.Count() > 1
                     select g;
         if (dupes.Any())
         {
             yield return new Problem(GetType(), map, new[] { entity }, Fix, "Entity has duplicate keys", "This entity has the same key specified multiple times. Entity keys should be unique. Fixing the problem will remove the duplicate key.");
         }
     }
 }
Exemplo n.º 18
0
 public IEnumerable<Problem> Check(Map map)
 {
     // MultiManagers require invalid key/values to work, exclude them from the search
     var entities = map.WorldSpawn
         .Find(x => x is Entity).OfType<Entity>()
         .Where(x => x.GameData != null)
         .Where(x => !String.Equals(x.EntityData.Name, "multi_manager", StringComparison.InvariantCultureIgnoreCase))
         .ToList();
     foreach (var entity in entities)
     {
         var valid = true;
         foreach (var prop in entity.EntityData.Properties)
         {
             if (!entity.GameData.Properties.Any(x => String.Equals(x.Name, prop.Key, StringComparison.InvariantCultureIgnoreCase)))
             {
                 valid = false;
             }
         }
         if (!valid) yield return new Problem(GetType(), map, new[] { entity }, Fix, "Entity has invalid key/value pairs", "There are key/value pairs that are not specified in the game data. Ensure the latest FGDs are loaded. Fixing the problem will remove the invalid keys.");
     }
 }
Exemplo n.º 19
0
 private Map GenerateInvalidSolidMap(decimal variance, decimal startLocation, decimal cubeSize)
 {
     var map = new Map();
     var block = new BlockBrush();
     var st = Coordinate.One * startLocation;
     var brush = block.Create(map.IDGenerator, new Box(st, st + Coordinate.One * cubeSize), null, 0).OfType<Solid>().First();
     var verts = brush.Faces.SelectMany(x => x.Vertices).Where(x => x.Location == st).ToList();
     verts.ForEach(x => x.Location.X -= variance);
     brush.SetParent(map.WorldSpawn);
     return map;
 }
Exemplo n.º 20
0
 public ArrayManager(Map map)
 {
     var all = GetAllVisible(map.WorldSpawn);
     _array = new SolidVertexArray(all);
     _decalArray = new DecalFaceVertexArray(all);
 }
Exemplo n.º 21
0
 public IEnumerable<Problem> Check(Map map)
 {
     if (map.WorldSpawn.Find(x => x is Entity && x.GetEntityData() != null && string.Equals(x.GetEntityData().Name, "info_player_start", StringComparison.InvariantCultureIgnoreCase)).Any()) yield break;
     yield return new Problem(GetType(), map, Fix, "This map has no player start", "There is no info_player_start entity in this map. The player will spawn at the origin instead. This may place the player inside geometry or in the void. Fixing the issue will place a player start entity at the map origin. It is recommended that you fix this problem manually.");
 }
Exemplo n.º 22
0
 public void Update(Map map)
 {
     var all = GetAllVisible(map.WorldSpawn);
     _array.Update(all);
     _decalArray.Update(all);
 }
Exemplo n.º 23
0
        private void SaveWithCordon(string file)
        {
            var map = _document.Map;
            if (_document.Map.Cordon)
            {
                map = new Map();
                map.WorldSpawn.EntityData = _document.Map.WorldSpawn.EntityData.Clone();
                var entities = _document.Map.WorldSpawn.GetAllNodesContainedWithin(_document.Map.CordonBounds);
                foreach (var mo in entities)
                {
                    var clone = mo.Clone();
                    clone.SetParent(map.WorldSpawn);
                }
                var outside = new Box(map.WorldSpawn.Children.Select(x => x.BoundingBox).Union(new[] {_document.Map.CordonBounds}));
                outside = new Box(outside.Start - Coordinate.One, outside.End + Coordinate.One);
                var inside = _document.Map.CordonBounds;

                var brush = new Brushes.BlockBrush();

                var cordon = (Solid) brush.Create(map.IDGenerator, outside, null).First();
                var carver = (Solid) brush.Create(map.IDGenerator, inside, null).First();
                cordon.Faces.ForEach(x => x.Texture.Name = "BLACK");

                // Do a carve (TODO: move carve into helper method?)
                foreach (var plane in carver.Faces.Select(x => x.Plane))
                {
                    Solid back, front;
                    if (!cordon.Split(plane, out back, out front, map.IDGenerator)) continue;
                    front.SetParent(map.WorldSpawn);
                    cordon = back;
                }

            }
            MapProvider.SaveMapToFile(file, map);
        }
Exemplo n.º 24
0
        private string SaveCordonMap(Document document, string folder)
        {
            var filename = Path.ChangeExtension(document.MapFileName, ".map");
            var map = document.Map;
            if (document.Map.Cordon)
            {
                map = new Map();
                map.WorldSpawn.EntityData = document.Map.WorldSpawn.EntityData.Clone();
                var entities = document.Map.WorldSpawn.GetAllNodesContainedWithin(document.Map.CordonBounds);
                foreach (var mo in entities)
                {
                    var clone = mo.Clone();
                    clone.SetParent(map.WorldSpawn);
                }
                var outside = new Box(map.WorldSpawn.Children.Select(x => x.BoundingBox).Union(new[] {document.Map.CordonBounds}));
                outside = new Box(outside.Start - Coordinate.One, outside.End + Coordinate.One);
                var inside = document.Map.CordonBounds;

                var brush = new Brushes.BlockBrush();

                var cordon = (Solid) brush.Create(map.IDGenerator, outside, null, 0).First();
                var carver = (Solid) brush.Create(map.IDGenerator, inside, null, 0).First();
                cordon.Faces.ForEach(x => x.Texture.Name = "BLACK");

                // Do a carve (TODO: move carve into helper method?)
                foreach (var plane in carver.Faces.Select(x => x.Plane))
                {
                    Solid back, front;
                    if (!cordon.Split(plane, out back, out front, map.IDGenerator)) continue;
                    front.SetParent(map.WorldSpawn);
                    cordon = back;
                }

                if (document.MapFileName.EndsWith(".map"))
                {
                    filename = Path.GetFileNameWithoutExtension(filename) + "_cordon.map";
                }
            }
            map.WorldSpawn.EntityData.SetPropertyValue("wad", string.Join(";", Game.Wads.Select(x => x.Path)));
            filename = Path.Combine(folder, filename);
            MapProvider.SaveMapToFile(filename, map);
            return filename;
        }
Exemplo n.º 25
0
 private void LoadMap(Map map)
 {
     treeMap.Nodes.Clear();
     LoadMapNode(null, map.WorldSpawn);
 }