Exemplo n.º 1
0
            public VmfEntity(SerialisedObject obj) : base(obj)
            {
                Objects = new List <VmfObject>();
                foreach (var so in obj.Children)
                {
                    var o = Deserialise(so);
                    if (o != null)
                    {
                        Objects.Add(o);
                    }
                }

                var ed = new EntityData();

                foreach (var kv in obj.Properties)
                {
                    if (kv.Key == null || ExcludedKeys.Contains(kv.Key.ToLower()))
                    {
                        continue;
                    }
                    ed.Set(kv.Key, kv.Value);
                }
                ed.Name    = obj.Get("classname", "");
                ed.Flags   = obj.Get("spawnflags", 0);
                EntityData = ed;

                if (obj.Properties.Any(x => x.Key == "origin"))
                {
                    Origin = obj.Get("origin", Vector3.Zero);
                }
            }
Exemplo n.º 2
0
 public EntitySprite(SerialisedObject obj)
 {
     Name  = obj.Get <string>("Name");
     Scale = obj.Get <float>("Scale");
     Color = obj.GetColor("Color");
     Size  = new SizeF(obj.Get <float>("Width"), obj.Get <float>("Height"));
 }
Exemplo n.º 3
0
            public VmfSide(SerialisedObject obj)
            {
                ID              = obj.Get("ID", 0L);
                LightmapScale   = obj.Get("lightmapscale", 0);
                SmoothingGroups = obj.Get("smoothing_groups", "");

                if (ParseDoubleArray(obj.Get("plane", ""), new[] { ' ', '(', ')' }, 9, out double[] pl))
Exemplo n.º 4
0
        public CordonBounds(SerialisedObject obj)
        {
            Enabled = obj.Get <bool>("Enabled");
            var start = obj.Get <Vector3>("Start");
            var end   = obj.Get <Vector3>("End");

            Box = new Box(start, end);
        }
Exemplo n.º 5
0
 public Visgroup(SerialisedObject obj)
 {
     Objects = new ThreadSafeSet <IMapObject>();
     ID      = obj.Get <long>("ID");
     Name    = obj.Get <string>("Name");
     Visible = obj.Get <bool>("Visible");
     Colour  = obj.GetColor("Colour");
 }
Exemplo n.º 6
0
        public Path(SerialisedObject obj)
        {
            Name      = obj.Get("Name", "");
            Type      = obj.Get("Type", "");
            Direction = obj.Get("Direction", PathDirection.OneWay);

            var children = obj.Children.Where(x => x.Name == "Node");

            Nodes = children.Select(x => new PathNode(x)).ToList();
        }
Exemplo n.º 7
0
        public static CompilePreset Parse(SerialisedObject gs)
        {
            var args = gs.Children.FirstOrDefault(x => x.Name == "Arguments") ?? new SerialisedObject("Arguments");

            return(new CompilePreset
            {
                Name = gs.Get("Name", ""),
                Description = gs.Get("Description", ""),
                Arguments = args.Properties.ToDictionary(x => x.Key, x => x.Value)
            });
        }
Exemplo n.º 8
0
 protected BaseMapObject(SerialisedObject obj)
 {
     if (SerialisedName != obj.Name)
     {
         throw new Exception($"Tried to deserialise a {obj.Name} into a {SerialisedName}.");
     }
     ID          = obj.Get <long>("ID");
     IsSelected  = obj.Get <bool>("IsSelected");
     Data        = new MapObjectDataCollection();
     Hierarchy   = new MapObjectHierarchy(this);
     BoundingBox = Box.Empty;
     SetCustomSerialisedData(obj);
 }
Exemplo n.º 9
0
        private async Task LoadViewSettings(Map map, SerialisedObject viewsettings, IEnvironment environment)
        {
            if (viewsettings == null)
            {
                return;
            }

            var snapToGrid  = viewsettings.Get("bSnapToGrid", 1) == 1;
            var show2DGrid  = viewsettings.Get("bShowGrid", 1) == 1;
            var show3DGrid  = viewsettings.Get("bShow3DGrid", 0) == 1; // todo, I guess
            var gridSpacing = viewsettings.Get("nGridSpacing", 64);

            var grid = show2DGrid ? await _squareGridFactory.Create(environment) : new NoGrid();

            if (grid is SquareGrid sg)
            {
                sg.Step = gridSpacing;
            }

            map.Data.Add(new GridData(grid)
            {
                SnapToGrid = snapToGrid
            });

            var ignoreGrouping = viewsettings.Get("bIgnoreGrouping", 0) == 1;

            map.Data.Add(new SelectionOptions
            {
                IgnoreGrouping = ignoreGrouping
            });

            var hideFaceMask = viewsettings.Get("bHideFaceMask", 0) == 1;

            map.Data.Add(new HideFaceMask
            {
                Hidden = hideFaceMask
            });

            var hideNullTextures = viewsettings.Get("bHideNullTextures", 0) == 1;

            map.Data.Add(new DisplayFlags
            {
                HideNullTextures       = hideNullTextures,
                HideDisplacementSolids = false
            });

            var textureLock        = viewsettings.Get("bTextureLock", 1) == 1;
            var textureScalingLock = viewsettings.Get("bTextureScalingLock", 0) == 1;

            map.Data.Add(new TransformationFlags
            {
                TextureLock      = textureLock,
                TextureScaleLock = textureScalingLock
            });
        }
Exemplo n.º 10
0
        public static CompileTool Parse(SerialisedObject gs)
        {
            var tool = new CompileTool
            {
                Name        = gs.Get("Name", ""),
                Description = gs.Get("Description", ""),
                Order       = gs.Get("Order", 0),
                Enabled     = gs.Get("Enabled", true)
            };
            var parameters = gs.Children.Where(x => x.Name == "Parameter");

            tool.Parameters.AddRange(parameters.Select(CompileParameter.Parse));
            return(tool);
        }
Exemplo n.º 11
0
        private void LoadCordon(Map map, SerialisedObject cordon)
        {
            if (cordon == null)
            {
                return;
            }

            var start = cordon.Get("mins", Vector3.One * -1024);
            var end   = cordon.Get("maxs", Vector3.One * 1024);

            map.Data.Add(new CordonBounds
            {
                Box     = new Box(start, end),
                Enabled = cordon.Get("active", 0) > 0
            });
        }
Exemplo n.º 12
0
        public static CompileSpecification Parse(SerialisedObject gs)
        {
            var spec = new CompileSpecification
            {
                ID     = gs.Get("ID", ""),
                Name   = gs.Get("Name", ""),
                Engine = gs.Get("Engine", "")
            };
            var tools = gs.Children.Where(x => x.Name == "Tool");

            spec.Tools.AddRange(tools.Select(CompileTool.Parse));
            var presets = gs.Children.Where(x => x.Name == "Preset");

            spec.Presets.AddRange(presets.Select(CompilePreset.Parse));
            return(spec);
        }
Exemplo n.º 13
0
            public PathNode(SerialisedObject obj)
            {
                ID       = obj.Get("ID", 0);
                Name     = obj.Get("Name", "");
                Position = obj.Get <Vector3>("Position");

                Properties = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase);
                foreach (var prop in obj.Properties)
                {
                    if (prop.Key == "ID" || prop.Key == "Name" || prop.Key == "Position")
                    {
                        continue;
                    }
                    Properties[prop.Key] = prop.Value;
                }
            }
Exemplo n.º 14
0
        void LoadCameras(MapFile map, SerialisedObject so)
        {
            int activeCam = so.Get("activecamera", 0);

            List <SerialisedObject> cams = so.Children.Where(x => string.Equals(x.Name, "camera", StringComparison.InvariantCultureIgnoreCase)).ToList();

            for (int i = 0; i < cams.Count; i++)
            {
                SerialisedObject cm = cams[i];
                map.Cameras.Add(new Camera
                {
                    EyePosition  = cm.Get("position", Vector3.Zero),
                    LookPosition = cm.Get("look", Vector3.UnitX),
                    IsActive     = activeCam == i
                });
            }
        }
Exemplo n.º 15
0
 public LoadedDocument(SerialisedObject pointer)
 {
     Metadata = new Dictionary <string, string>();
     Loader   = pointer.Name;
     foreach (var pp in pointer.Properties)
     {
         Metadata[pp.Key] = pp.Value;
     }
     FileName = pointer.Get <string>("FileName");
 }
Exemplo n.º 16
0
        public VmfEntity(SerialisedObject obj) : base(obj)
        {
            Objects = new List <VmfObject>();
            foreach (var so in obj.Children)
            {
                var o = Deserialise(so);
                if (o != null)
                {
                    Objects.Add(o);
                }
            }

            Properties = new Dictionary <string, string>();
            foreach (var kv in obj.Properties)
            {
                if (kv.Key == null || ExcludedKeys.Contains(kv.Key.ToLower()))
                {
                    continue;
                }
                Properties[kv.Key] = kv.Value;
            }
            ClassName  = obj.Get("classname", "");
            SpawnFlags = obj.Get("spawnflags", 0);
        }
Exemplo n.º 17
0
 public VmfSide(SerialisedObject obj)
 {
     ID   = obj.Get("ID", 0L);
     Face = new Face
     {
         TextureName     = obj.Get("material", ""),
         Rotation        = obj.Get("rotation", 0f),
         LightmapScale   = obj.Get("lightmapscale", 0),
         SmoothingGroups = obj.Get("smoothing_groups", "")
     };
     if (Util.ParseFloatArray(obj.Get("plane", ""), new[] { ' ', '(', ')' }, 9, out float[] pl))
Exemplo n.º 18
0
        private void LoadCameras(Map map, SerialisedObject cameras)
        {
            if (cameras == null)
            {
                return;
            }
            var activeCam = cameras.Get("activecamera", 0);

            var cams = cameras.Children.Where(x => x.Name?.ToLower() == "camera").ToList();

            for (var i = 0; i < cams.Count; i++)
            {
                var cm = cams[i];
                map.Data.Add(new Camera
                {
                    EyePosition  = cm.Get("position", Vector3.Zero),
                    LookPosition = cm.Get("look", Vector3.UnitX),
                    IsActive     = activeCam == i
                });
            }
        }
Exemplo n.º 19
0
 public VmfSide(SerialisedObject obj)
 {
     ID   = obj.Get("ID", 0L);
     Face = new Face
     {
         TextureName     = obj.Get("material", ""),
         Rotation        = obj.Get("rotation", 0f),
         LightmapScale   = obj.Get("lightmapscale", 0),
         SmoothingGroups = obj.Get("smoothing_groups", "")
     };
     if (Util.ParseFloatArray(obj.Get("plane", ""), new[] { ' ', '(', ')' }, 9, out var pl))
     {
         Face.Plane = NumericsExtensions.PlaneFromVertices(
             new Vector3(pl[0], pl[1], pl[2]).Round(),
             new Vector3(pl[3], pl[4], pl[5]).Round(),
             new Vector3(pl[6], pl[7], pl[8]).Round()
             );
     }
     else
     {
         Face.Plane = new Plane(Vector3.UnitZ, 0);
     }
     if (Util.ParseFloatArray(obj.Get("uaxis", ""), new[] { ' ', '[', ']' }, 5, out float[] ua))
Exemplo n.º 20
0
 public SelectionOptions(SerialisedObject obj)
 {
     IgnoreGrouping = obj.Get <bool>("IgnoreGrouping");
 }
Exemplo n.º 21
0
 public Camera(SerialisedObject obj)
 {
     EyePosition  = obj.Get <Vector3>("EyePosition");
     LookPosition = obj.Get <Vector3>("LookPosition");
     IsActive     = obj.Get <bool>("IsActive");
 }
Exemplo n.º 22
0
 public EntityDecal(SerialisedObject obj)
 {
     Name     = obj.Get <string>("Name");
     Geometry = new List <Face>();
 }
Exemplo n.º 23
0
 public VisgroupID(SerialisedObject obj)
 {
     ID = obj.Get <long>("ID");
 }
Exemplo n.º 24
0
 public EntityModel(SerialisedObject obj)
 {
     Name = obj.Get <string>("Name");
 }
Exemplo n.º 25
0
 public HideFaceMask(SerialisedObject obj)
 {
     Hidden = obj.Get <bool>("Hidden");
 }
Exemplo n.º 26
0
        public static CompileParameter Parse(SerialisedObject gs)
        {
            var param = new CompileParameter
            {
                Name         = gs.Get("Name", ""),
                Flag         = gs.Get("Flag", ""),
                Description  = gs.Get("Description", ""),
                Enabled      = gs.Get("Enabled", true),
                Value        = gs.Get("Value", ""),
                Type         = gs.Get("Type", CompileParameterType.Checkbox),
                Min          = gs.Get("Min", Decimal.MinValue),
                Max          = gs.Get("Max", Decimal.MaxValue),
                Precision    = gs.Get("Precision", 1),
                Options      = gs.Get("Options", "").Split(',').ToList(),
                OptionValues = gs.Get("OptionValues", "").Split(',').ToList(),
                Filter       = gs.Get("Filter", "")
            };

            return(param);
        }
Exemplo n.º 27
0
 protected VmfObject(SerialisedObject obj)
 {
     ID     = obj.Get("id", 0L);
     Editor = new VmfEditor(obj.Children.FirstOrDefault(x => x.Name == "editor"));
 }
Exemplo n.º 28
0
 public VisgroupHidden(SerialisedObject obj)
 {
     IsHidden = obj.Get("IsHidden", false);
 }
Exemplo n.º 29
0
 public DisplayFlags(SerialisedObject obj)
 {
     HideNullTextures       = obj.Get <bool>("HideNullTextures");
     HideDisplacementSolids = obj.Get <bool>("HideDisplacementSolids");
 }
Exemplo n.º 30
0
 public ActiveTexture(SerialisedObject obj)
 {
     Name = obj.Get <string>("Name");
 }