Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
 private void ExportMatches(ContentConfiguration configuration, Regex pattern)
 {
     foreach (var file in _files)
     {
         if (!pattern.IsMatch(file.FullName))
         {
             continue;
         }
         ExportFile(configuration, file);
     }
 }
Ejemplo n.º 6
0
    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;
            }
        }
    }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
    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);
    }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
    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;
        }
    }
Ejemplo n.º 11
0
        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);
        }
    }
Ejemplo n.º 13
0
 public void SetUp()
 {
     _contentServerConfiguration = ContentConfiguration.MemoryStore();
     _sut = new ContentClient(_contentServerConfiguration);
 }
Ejemplo n.º 14
0
        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;
 }
Ejemplo n.º 16
0
 protected override void ParseElementConditions(XElement elemtype, ContentConfiguration <T> .Content content)
 {
     this.content = content;
 }
Ejemplo n.º 17
0
 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;
 }
Ejemplo n.º 18
0
 public BogApiClient(JsonSerializerOptions jsonOptions, IOptions <ContentConfiguration> contentConfiguration)
 {
     _jsonOptions          = jsonOptions;
     _contentConfiguration = contentConfiguration.Value;
 }