public void Read(GenericStructure gs) { ID = gs.PropertyInteger("ID"); Name = gs["Name"]; Engine = (Engine)Enum.Parse(typeof(Engine), gs["EngineID"]); BuildID = gs.PropertyInteger("BuildID"); SteamInstall = gs.PropertyBoolean("SteamInstall"); WonGameDir = gs["WonGameDir"]; SteamGameDir = gs["SteamGameDir"]; ModDir = gs["ModDir"]; UseHDModels = gs.PropertyBoolean("UseHDModels", true); BaseDir = gs["BaseDir"]; Executable = gs["Executable"]; ExecutableParameters = gs["ExecutableParameters"]; MapDir = gs["MapDir"]; Autosave = gs.PropertyBoolean("Autosave"); UseCustomAutosaveDir = gs.PropertyBoolean("UseCustomAutosaveDir"); AutosaveDir = gs["AutosaveDir"]; AutosaveTime = gs.PropertyInteger("AutosaveTime"); AutosaveLimit = gs.PropertyInteger("AutosaveLimit"); AutosaveOnlyOnChanged = gs.PropertyBoolean("AutosaveOnlyOnChanged", true); AutosaveTriggerFileSave = gs.PropertyBoolean("AutosaveTriggerFileChange", true); DefaultPointEntity = gs["DefaultPointEntity"]; DefaultBrushEntity = gs["DefaultBrushEntity"]; DefaultTextureScale = gs.PropertyDecimal("DefaultTextureScale"); DefaultLightmapScale = gs.PropertyDecimal("DefaultLightmapScale"); IncludeFgdDirectoriesInEnvironment = gs.PropertyBoolean("IncludeFgdDirectoriesInEnvironment", true); OverrideMapSize = gs.PropertyBoolean("OverrideMapSize"); OverrideMapSizeLow = gs.PropertyInteger("OverrideMapSizeLow"); OverrideMapSizeHigh = gs.PropertyInteger("OverrideMapSizeHigh"); var additional = gs.Children.FirstOrDefault(x => x.Name == "AdditionalPackages"); if (additional != null) { foreach (var key in additional.GetPropertyKeys()) { AdditionalPackages.Add(additional[key]); } } PackageBlacklist = (gs["PackageBlacklist"] ?? "").Replace(";", "\r\n"); PackageWhitelist = (gs["PackageWhitelist"] ?? "").Replace(";", "\r\n"); var fgds = gs.Children.FirstOrDefault(x => x.Name == "Fgds"); if (fgds != null) { foreach (var key in fgds.GetPropertyKeys()) { Fgds.Add(new Fgd { Path = fgds[key] }); } } }
private static Face ReadFace(GenericStructure side, IDGenerator generator) { var id = side.PropertyLong("id"); if (id == 0) { id = generator.GetNextFaceID(); } var dispinfo = side.GetChildren("dispinfo").FirstOrDefault(); var ret = dispinfo != null?ReadDisplacement(id, dispinfo) : new Face(id); // id, plane, material, uaxis, vaxis, rotation, lightmapscale, smoothing_groups var uaxis = side.PropertyTextureAxis("uaxis"); var vaxis = side.PropertyTextureAxis("vaxis"); ret.Texture.Name = side["material"]; ret.Texture.UAxis = uaxis.Item1; ret.Texture.XShift = uaxis.Item2; ret.Texture.XScale = uaxis.Item3; ret.Texture.VAxis = vaxis.Item1; ret.Texture.YShift = vaxis.Item2; ret.Texture.YScale = vaxis.Item3; ret.Texture.Rotation = side.PropertyDecimal("rotation"); ret.Plane = side.PropertyPlane("plane"); //NOTE(SVK) Paste RF data ret.Texture.Flags = (FaceFlags)side.PropertyInteger("flags"); ret.Texture.Translucency = (int)side.PropertyDecimal("translucency"); ret.Texture.Opacity = side.PropertyDecimal("opacity"); ret.Texture.PositionRF = side.PropertyCoordinate("positionrf"); ret.Texture.TransformAngleRF = side.PropertyMatrix("transformanglerf"); var verts = side.Children.FirstOrDefault(x => x.Name == "vertex"); if (verts != null) { var count = verts.PropertyInteger("count"); for (var i = 0; i < count; i++) { ret.Vertices.Add(new Vertex(verts.PropertyCoordinate("vertex" + i), ret)); } } return(ret); }
public static CompileParameter Parse(GenericStructure gs) { var param = new CompileParameter { Name = gs["Name"] ?? "", Flag = gs["Flag"] ?? "", Description = gs["Description"] ?? "", Enabled = gs.PropertyBoolean("Enabled"), Value = gs["Value"] ?? "", Type = gs.PropertyEnum("Type", CompileParameterType.Checkbox), Min = gs.PropertyDecimal("Min", Decimal.MinValue), Max = gs.PropertyDecimal("Max", Decimal.MaxValue), Precision = gs.PropertyInteger("Precision", 1), Options = (gs["Options"] ?? "").Split(',').ToList(), OptionValues = (gs["OptionValues"] ?? "").Split(',').ToList(), Filter = gs["Filter"] ?? "" }; return(param); }
private static Displacement ReadDisplacement(long id, GenericStructure dispinfo) { var disp = new Displacement(id); // power, startposition, flags, elevation, subdiv, normals{}, distances{}, // offsets{}, offset_normals{}, alphas{}, triangle_tags{}, allowed_verts{} disp.SetPower(dispinfo.PropertyInteger("power", 3)); disp.StartPosition = dispinfo.PropertyCoordinate("startposition"); disp.Elevation = dispinfo.PropertyDecimal("elevation"); disp.SubDiv = dispinfo.PropertyInteger("subdiv") > 0; var size = disp.Resolution + 1; var normals = dispinfo.GetChildren("normals").FirstOrDefault(); var distances = dispinfo.GetChildren("distances").FirstOrDefault(); var offsets = dispinfo.GetChildren("offsets").FirstOrDefault(); var offsetNormals = dispinfo.GetChildren("offset_normals").FirstOrDefault(); var alphas = dispinfo.GetChildren("alphas").FirstOrDefault(); //var triangleTags = dispinfo.GetChildren("triangle_tags").First(); //var allowedVerts = dispinfo.GetChildren("allowed_verts").First(); for (var i = 0; i < size; i++) { var row = "row" + i; var norm = normals != null?normals.PropertyCoordinateArray(row, size) : Enumerable.Range(0, size).Select(x => Coordinate.Zero).ToArray(); var dist = distances != null?distances.PropertyDecimalArray(row, size) : Enumerable.Range(0, size).Select(x => 0m).ToArray(); var offn = offsetNormals != null?offsetNormals.PropertyCoordinateArray(row, size) : Enumerable.Range(0, size).Select(x => Coordinate.Zero).ToArray(); var offs = offsets != null?offsets.PropertyDecimalArray(row, size) : Enumerable.Range(0, size).Select(x => 0m).ToArray(); var alph = alphas != null?alphas.PropertyDecimalArray(row, size) : Enumerable.Range(0, size).Select(x => 0m).ToArray(); for (var j = 0; j < size; j++) { disp.Points[i, j].Displacement = new Vector(norm[j], dist[j]); disp.Points[i, j].OffsetDisplacement = new Vector(offn[j], offs[j]); disp.Points[i, j].Alpha = alph[j]; } } return(disp); }
private static Face ReadFace(GenericStructure side, IDGenerator generator) { var id = side.PropertyLong("id"); if (id == 0) id = generator.GetNextFaceID(); var dispinfo = side.GetChildren("dispinfo").FirstOrDefault(); var ret = dispinfo != null ? ReadDisplacement(id, dispinfo) : new Face(id); // id, plane, material, uaxis, vaxis, rotation, lightmapscale, smoothing_groups var uaxis = side.PropertyTextureAxis("uaxis"); var vaxis = side.PropertyTextureAxis("vaxis"); ret.Texture.Name = side["material"]; ret.Texture.UAxis = uaxis.Item1; ret.Texture.XShift = uaxis.Item2; ret.Texture.XScale = uaxis.Item3; ret.Texture.VAxis = vaxis.Item1; ret.Texture.YShift = vaxis.Item2; ret.Texture.YScale = vaxis.Item3; ret.Texture.Rotation = side.PropertyDecimal("rotation"); ret.Plane = side.PropertyPlane("plane"); var verts = side.Children.FirstOrDefault(x => x.Name == "vertex"); if (verts != null) { var count = verts.PropertyInteger("count"); for (var i = 0; i < count; i++) { ret.Vertices.Add(new Vertex(verts.PropertyCoordinate("vertex"+i), ret)); } } return ret; }
private static Displacement ReadDisplacement(long id, GenericStructure dispinfo) { var disp = new Displacement(id); // power, startposition, flags, elevation, subdiv, normals{}, distances{}, // offsets{}, offset_normals{}, alphas{}, triangle_tags{}, allowed_verts{} disp.SetPower(dispinfo.PropertyInteger("power", 3)); disp.StartPosition = dispinfo.PropertyCoordinate("startposition"); disp.Elevation = dispinfo.PropertyDecimal("elevation"); disp.SubDiv = dispinfo.PropertyInteger("subdiv") > 0; var size = disp.Resolution + 1; var normals = dispinfo.GetChildren("normals").FirstOrDefault(); var distances = dispinfo.GetChildren("distances").FirstOrDefault(); var offsets = dispinfo.GetChildren("offsets").FirstOrDefault(); var offsetNormals = dispinfo.GetChildren("offset_normals").FirstOrDefault(); var alphas = dispinfo.GetChildren("alphas").FirstOrDefault(); //var triangleTags = dispinfo.GetChildren("triangle_tags").First(); //var allowedVerts = dispinfo.GetChildren("allowed_verts").First(); for (var i = 0; i < size; i++) { var row = "row" + i; var norm = normals != null ? normals.PropertyCoordinateArray(row, size) : Enumerable.Range(0, size).Select(x => Coordinate.Zero).ToArray(); var dist = distances != null ? distances.PropertyDecimalArray(row, size) : Enumerable.Range(0, size).Select(x => 0m).ToArray(); var offn = offsetNormals != null ? offsetNormals.PropertyCoordinateArray(row, size) : Enumerable.Range(0, size).Select(x => Coordinate.Zero).ToArray(); var offs = offsets != null ? offsets.PropertyDecimalArray(row, size) : Enumerable.Range(0, size).Select(x => 0m).ToArray(); var alph = alphas != null ? alphas.PropertyDecimalArray(row, size) : Enumerable.Range(0, size).Select(x => 0m).ToArray(); for (var j = 0; j < size; j++) { disp.Points[i, j].Displacement = new Vector(norm[j], dist[j]); disp.Points[i, j].OffsetDisplacement = new Vector(offn[j], offs[j]); disp.Points[i, j].Alpha = alph[j]; } } return disp; }