private static ComponentInstance InstantiateLayout(SpaceConfiguration configs, double width, double length, Polygon rectangle, Transform xform) { ContentConfiguration selectedConfig = null; var orderedKeys = configs.OrderByDescending(kvp => kvp.Value.CellBoundary.Depth * kvp.Value.CellBoundary.Width).Select(kvp => kvp.Key); foreach (var key in orderedKeys) { var config = configs[key]; if (config.CellBoundary.Width < width && config.CellBoundary.Depth < length) { selectedConfig = config; break; } } if (selectedConfig == null) { return(null); } var baseRectangle = Polygon.Rectangle(selectedConfig.CellBoundary.Min, selectedConfig.CellBoundary.Max); var rules = selectedConfig.Rules(); var componentDefinition = new ComponentDefinition(rules, selectedConfig.Anchors()); var instance = componentDefinition.Instantiate(ContentConfiguration.AnchorsFromRect(rectangle.TransformedPolygon(xform))); var allPlacedInstances = instance.Instances; foreach (var item in allPlacedInstances) { if (item is ElementInstance ei && !rectangle.Contains(ei.Transform.Origin)) { } } return(instance); }
private static ComponentInstance InstantiateLayout(SpaceConfiguration configs, double width, double length, Polygon rectangle, Transform xform) { ContentConfiguration selectedConfig = null; var orderedKeys = configs.OrderBy(k => rand.NextDouble()).Select(k => k.Key); foreach (var key in orderedKeys) { var config = configs[key]; if (config.CellBoundary.Width < width && config.CellBoundary.Depth < length) { selectedConfig = config; break; } } if (selectedConfig == null) { return(null); } var baseRectangle = Polygon.Rectangle(selectedConfig.CellBoundary.Min, selectedConfig.CellBoundary.Max); var rules = selectedConfig.Rules(); var componentDefinition = new ComponentDefinition(rules, selectedConfig.Anchors()); var instance = componentDefinition.Instantiate(ContentConfiguration.AnchorsFromRect(rectangle.TransformedPolygon(xform))); return(instance); }
public void Export(ContentConfiguration configuration) { // Has to be done this way so we can use the patterns for priority in case of conflicts foreach (var pattern in configuration.ResourcePatterns) { ExportMatches(configuration, pattern); } }
bool ParseContentXMLFile(string path) { bool runningResult = true; XElement doc = XElement.Load(path, LoadOptions.SetBaseUri); while (doc != null) { switch (doc.Name.LocalName) { case "colors": if (ColorConfiguration == null) { ColorConfiguration = ContentConfiguration <ColorContent> .GetFromRootElement(doc, "color"); } ColorConfiguration.AddSingleContentConfig(doc); break; case "materialTextures": if (MaterialTextureConfiguration == null) { MaterialTextureConfiguration = ContentConfiguration <TextureContent> .GetFromRootElement(doc, "materialTexture"); } MaterialTextureConfiguration.AddSingleContentConfig(doc, materialTextureStorage); break; case "shapeTextures": if (ShapeTextureConfiguration == null) { ShapeTextureConfiguration = ContentConfiguration <NormalContent> .GetFromRootElement(doc, "shapeTexture"); } ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "tileMeshes": if (TileMeshConfiguration == null) { TileMeshConfiguration = ContentConfiguration <MeshContent> .GetFromRootElement(doc, "tileMesh"); } TileMeshConfiguration.AddSingleContentConfig(doc); break; case "materialLayers": if (MaterialLayerConfiguration == null) { MaterialLayerConfiguration = ContentConfiguration <LayerContent> .GetFromRootElement(doc, "materialLayer"); } MaterialLayerConfiguration.AddSingleContentConfig(doc); break; default: break; } doc = doc.NextNode as XElement; } return(runningResult); }
private void ExportMatches(ContentConfiguration configuration, Regex pattern) { foreach (var file in _files) { if (!pattern.IsMatch(file.FullName)) { continue; } ExportFile(configuration, file); } }
protected override void ParseElementConditions(XElement elemtype, ContentConfiguration <T> .Content content) { var elemItems = elemtype.Elements("item"); foreach (XElement elemItem in elemItems) { XAttribute elemToken = elemItem.Attribute("token"); if (elemToken != null) { itemMatcher[elemToken.Value] = content; } } }
private bool ExistsContentConfiguration(ContentWidget content, out ContentConfiguration contentConfig) { //foreach (ContentConfiguration contentConfiguration in PageConfig.Contents) //{ // if (contentConfiguration.Id != content.ViewPart.TypeId) // { // continue; // } // contentConfig = contentConfiguration; // return true; //} contentConfig = null; return(false); }
bool ParseContentXMLFile(string path) { bool runningResult = true; XElement doc = XElement.Load(path, LoadOptions.SetBaseUri); while (doc != null) { switch (doc.Name.LocalName) { case "colors": if (colorConfiguration == null) { colorConfiguration = ContentConfiguration <ColorContent> .GetFromRootElement(doc, "color"); } colorConfiguration.AddSingleContentConfig(doc); break; case "materialTextures": if (materialTextureConfiguration == null) { materialTextureConfiguration = ContentConfiguration <IndexContent> .GetFromRootElement(doc, "materialTexture"); } materialTextureConfiguration.AddSingleContentConfig(doc); break; case "tileTextures": if (tileTextureConfiguration == null) { tileTextureConfiguration = ContentConfiguration <IndexContent> .GetFromRootElement(doc, "tileTexture"); } tileTextureConfiguration.AddSingleContentConfig(doc); break; case "tileMeshes": if (tileMeshConfiguration == null) { tileMeshConfiguration = ContentConfiguration <MeshContent> .GetFromRootElement(doc, "tileMesh"); } tileMeshConfiguration.AddSingleContentConfig(doc); break; default: break; } doc = doc.NextNode as XElement; } return(runningResult); }
private static ComponentInstance InstantiateLayout(SpaceConfiguration configs, double width, double length, Polygon rectangle, Transform xform) { var orderedKeys = configs.OrderByDescending(kvp => kvp.Value.CellBoundary.Depth * kvp.Value.CellBoundary.Width).Select(kvp => kvp.Key); var configsThatFitWell = new List <ContentConfiguration>(); foreach (var key in orderedKeys) { var config = configs[key]; // if it fits if (config.CellBoundary.Width < width && config.CellBoundary.Depth < length) { if (configsThatFitWell.Count == 0) { configsThatFitWell.Add(config); } else { var firstFittingConfig = configsThatFitWell.First(); // check if there's another config that's roughly the same size if (config.CellBoundary.Width.ApproximatelyEquals(firstFittingConfig.CellBoundary.Width, 1.0) && config.CellBoundary.Depth.ApproximatelyEquals(firstFittingConfig.CellBoundary.Depth, 1.0)) { configsThatFitWell.Add(config); } } } } if (configsThatFitWell.Count == 0) { return(null); } var selectedConfig = configsThatFitWell[varietyCounter % configsThatFitWell.Count]; var baseRectangle = Polygon.Rectangle(selectedConfig.CellBoundary.Min, selectedConfig.CellBoundary.Max); var rules = selectedConfig.Rules(); varietyCounter++; var componentDefinition = new ComponentDefinition(rules, selectedConfig.Anchors()); var instance = componentDefinition.Instantiate(ContentConfiguration.AnchorsFromRect(rectangle.TransformedPolygon(xform))); var allPlacedInstances = instance.Instances; return(instance); }
protected override void ParseElementConditions(XElement elemtype, ContentConfiguration <T> .Content content) { var elemRamps = elemtype.Elements("ramp"); foreach (XElement elemRamp in elemRamps) { XAttribute indexAttr = elemRamp.Attribute("index"); if (indexAttr == null) { continue; } int index = 0; if (!int.TryParse(indexAttr.Value, out index)) { continue; } if (index > 26) { continue; } rampList[index - 1] = content; } }
private void ExportFile(ContentConfiguration configuration, ReleaseManifestFileEntry file) { // Load and convert var inibin = _manager.ReadInibin(file.FullName); var item = ContentFile.FromInibin(inibin, configuration); // Find save path var savePath = string.Format( "{0}/{1}", OutputDirectory, configuration.GetTargetName(file.FullName) ); // Create save directory if one doesn't exist var saveDirectory = Path.GetDirectoryName(savePath); if (!Directory.Exists(saveDirectory)) { Directory.CreateDirectory(saveDirectory); } // Save the converted data File.WriteAllText(savePath, item.Serialize()); }
protected override void ParseElementConditions(System.Xml.Linq.XElement elemtype, ContentConfiguration <T> .Content content) { var elemRandoms = elemtype.Elements("random"); foreach (XElement elemRandom in elemRandoms) { //right now, we don't actuallyu care about any parameters int seed = items.Count; RandomItem item = new RandomItem(); XAttribute elemScale = elemRandom.Attribute("scale"); if (elemScale != null) { float scale = 1; float.TryParse(elemScale.Value, out scale); item.scale_x = scale; item.scale_y = scale; item.scale_z = scale; } XAttribute elemScaleX = elemRandom.Attribute("scale_x"); if (elemScaleX != null) { float scale = 1; float.TryParse(elemScaleX.Value, out scale); item.scale_x = scale; } XAttribute elemScaleY = elemRandom.Attribute("scale_y"); if (elemScaleY != null) { float scale = 1; float.TryParse(elemScaleY.Value, out scale); item.scale_y = scale; } XAttribute elemScaleZ = elemRandom.Attribute("scale_z"); if (elemScaleZ != null) { float scale = 1; float.TryParse(elemScaleZ.Value, out scale); item.scale_z = scale; } XAttribute elemIntensity = elemRandom.Attribute("intensity"); if (elemIntensity != null) { float scale = 1; float.TryParse(elemIntensity.Value, out scale); item.intensity = scale; } item.content = content; item.noise = new OpenSimplexNoise(seed); items.Add(item); } }
public void SetUp() { _contentServerConfiguration = ContentConfiguration.MemoryStore(); _sut = new ContentClient(_contentServerConfiguration); }
public override bool Initialize(string region) { var versions = new Versions(Game.ProgramCode); var cdns = new CDNs(Game.ProgramCode); if (!cdns.Records.TryGetValue(region, out ServerInfo)) { return(false); } Versions.Record versionInfo; if (!versions.Records.TryGetValue(region, out versionInfo)) { return(false); } BuildConfig = new BuildConfiguration(ServerInfo.Hosts[0], versionInfo.BuildConfig); ContentConfig = new ContentConfiguration(ServerInfo.Hosts[0], versionInfo.CDNConfig); _rootKey = BuildConfig.Root.ToByteArray(); _encodingKey = BuildConfig.Encoding[1].ToByteArray(); using (var encodingClient = new AsyncClient(ServerInfo.Hosts[0])) { encodingClient.Send($"/{ServerInfo.Path}/data/{_encodingKey[0]:x2}/{_encodingKey[1]:x2}/{_encodingKey}"); if (!encodingClient.Failed) { using (var encodingPack = new BLTE(encodingClient.Stream, 0, encodingClient.ContentLength)) if (!LoadEncoding(encodingPack)) { throw new InvalidOperationException("Unable to find encoding!"); } } } for (var i = 0; i < ContentConfig.Archives.Length; ++i) { var archiveHash = ContentConfig.Archives[i]; using (var archiveClient = new AsyncClient(ServerInfo.Hosts[0])) { archiveClient.Send($"/{ServerInfo.Path}/data/{archiveHash[0]:x2}/{archiveHash[1]:x2}/{archiveHash.ToHexString()}.index"); if (!archiveClient.Failed) { LoadIndex(archiveClient.Stream, archiveClient.ContentLength, i); } } } if (!_encodingEntries.ContainsKey(_rootKey)) { throw new InvalidOperationException("Root entry not found in encoding!"); } var encodingEntry = _encodingEntries[_rootKey]; foreach (var rootEncodingEntry in encodingEntry) { using (var rootClient = new AsyncClient(ServerInfo.Hosts[0])) { rootClient.Send($"/{ServerInfo.Path}/data/{rootEncodingEntry.Item2[0]:x2}/{rootEncodingEntry.Item2[1]:x2}/{rootEncodingEntry.Item2.ToHexString()}"); if (rootClient.Failed) { continue; } using (var rootBlte = new BLTE(rootClient.Stream, 0, rootClient.ContentLength)) if (LoadRoot(rootBlte)) { break; } } } return(_rootEntries.Count != 0); }
public PaginatedContentCoordinator(IBogApiClient apiClient, IOptions <ContentConfiguration> contentConfiguration) { _apiClient = apiClient; _contentConfiguration = contentConfiguration.Value; }
protected override void ParseElementConditions(XElement elemtype, ContentConfiguration <T> .Content content) { this.content = content; }
bool ParseContentXMLFile(string path) { bool runningResult = true; XElement doc = XElement.Load(path, LoadOptions.SetBaseUri); while (doc != null) { switch (doc.Name.LocalName) { case "colors": if(ColorConfiguration == null) ColorConfiguration = ContentConfiguration<ColorContent>.GetFromRootElement(doc, "color"); ColorConfiguration.AddSingleContentConfig(doc); break; case "materialTextures": if(MaterialTextureConfiguration == null) MaterialTextureConfiguration = ContentConfiguration<TextureContent>.GetFromRootElement(doc, "materialTexture"); MaterialTextureConfiguration.AddSingleContentConfig(doc, materialTextureStorage); break; case "shapeTextures": if(ShapeTextureConfiguration == null) ShapeTextureConfiguration = ContentConfiguration<NormalContent>.GetFromRootElement(doc, "shapeTexture"); ShapeTextureConfiguration.AddSingleContentConfig(doc, shapeTextureStorage); break; case "tileMeshes": if (TileMeshConfiguration == null) TileMeshConfiguration = ContentConfiguration<MeshContent>.GetFromRootElement(doc, "tileMesh"); TileMeshConfiguration.AddSingleContentConfig(doc); break; case "materialLayers": if (MaterialLayerConfiguration == null) MaterialLayerConfiguration = ContentConfiguration<LayerContent>.GetFromRootElement(doc, "materialLayer"); MaterialLayerConfiguration.AddSingleContentConfig(doc); break; default: break; } doc = doc.NextNode as XElement; } return runningResult; }
public BogApiClient(JsonSerializerOptions jsonOptions, IOptions <ContentConfiguration> contentConfiguration) { _jsonOptions = jsonOptions; _contentConfiguration = contentConfiguration.Value; }