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); } }
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")); }
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))
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); }
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"); }
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(); }
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) }); }
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); }
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 }); }
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); }
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 }); }
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); }
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; } }
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 }); } }
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"); }
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); }
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))
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 }); } }
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))
public SelectionOptions(SerialisedObject obj) { IgnoreGrouping = obj.Get <bool>("IgnoreGrouping"); }
public Camera(SerialisedObject obj) { EyePosition = obj.Get <Vector3>("EyePosition"); LookPosition = obj.Get <Vector3>("LookPosition"); IsActive = obj.Get <bool>("IsActive"); }
public EntityDecal(SerialisedObject obj) { Name = obj.Get <string>("Name"); Geometry = new List <Face>(); }
public VisgroupID(SerialisedObject obj) { ID = obj.Get <long>("ID"); }
public EntityModel(SerialisedObject obj) { Name = obj.Get <string>("Name"); }
public HideFaceMask(SerialisedObject obj) { Hidden = obj.Get <bool>("Hidden"); }
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); }
protected VmfObject(SerialisedObject obj) { ID = obj.Get("id", 0L); Editor = new VmfEditor(obj.Children.FirstOrDefault(x => x.Name == "editor")); }
public VisgroupHidden(SerialisedObject obj) { IsHidden = obj.Get("IsHidden", false); }
public DisplayFlags(SerialisedObject obj) { HideNullTextures = obj.Get <bool>("HideNullTextures"); HideDisplacementSolids = obj.Get <bool>("HideDisplacementSolids"); }
public ActiveTexture(SerialisedObject obj) { Name = obj.Get <string>("Name"); }