Exemple #1
0
 public static void Save(this FeatureContainer f, String path)
 {
     using (TextWriter writer = new StreamWriter(path))
     {
         FeatureContainer.Serializer.Serialize(writer, f);
     }
 }
Exemple #2
0
    public TerrainTriangulationData TriangulateHexTerrainEdge(
        Hex hex,
        Hex neighbor,
        TerrainTriangulationData triangulationData,
        Dictionary <HexDirections, Hex> neighbors,
        HexDirections direction,
        HexRiverData riverData,
        FeatureContainer features,
        Dictionary <HexDirections, bool> roadEdges,
        Dictionary <HexDirections, ElevationEdgeTypes> elevationEdgeTypes,
        float hexOuterRadius,
        int wrapSize
        )
    {
        triangulationData = TriangulateTerrainCenter(
            riverData,
            direction,
            hex,
            triangulationData,
            hexOuterRadius,
            wrapSize,
            this,
            features,
            roadEdges
            );

        if (direction <= HexDirections.Southeast)
        {
            triangulationData = TriangulateTerrainConnection(
                hex,
                neighbor,
                triangulationData,
                direction,
                riverData,
                roadEdges,
                elevationEdgeTypes,
                hexOuterRadius,
                wrapSize,
                this,
                features
                );

            // Adjust the other edge of the connection  if there is a river through
            // that edge.
            triangulationData = TryTriangulateNeighborTerrainCorner(
                hex,
                neighbor,
                triangulationData,
                direction,
                neighbors,
                hexOuterRadius,
                wrapSize,
                this,
                features
                );
        }

        return(triangulationData);
    }
Exemple #3
0
 public FeatureContainerForm(FeatureContainer container)
 {
     InitializeComponent();
     this.container       = container;
     userControl11.Editor = this;
     refresh();
     features1.HistoryManager = this;
 }
 public static T GetFeature <T>(this FeatureContainer result)
     where T : class, IRunResultFeature
 {
     if (result.Features.TryGetValue(typeof(T).Name, out var feature))
     {
         return(feature as T);
     }
     else
     {
         return(null);
     }
 }
Exemple #5
0
        public static bool Save(this FeatureContainer f, Boolean overwrite)
        {
            FileInfo file = SourceManager.GetFileName(f.Name, f.Source, f.category);

            if (file.Exists && (f.FileName == null || !f.FileName.Equals(file.FullName)) && !overwrite)
            {
                return(false);
            }
            using (TextWriter writer = new StreamWriter(file.FullName)) FeatureContainer.Serializer.Serialize(writer, f);
            f.FileName = file.FullName;
            return(true);
        }
Exemple #6
0
        public Steps(FeatureContainer container, ScenarioContext context)
        {
            Skip.If(context.ScenarioInfo.Tags.Contains("Draft"));

            this.container = container;
            this.context   = context;

            events = container.Resolve <IEventStreamAsync>();
            events
            .Of <MessageSent>()
            .Subscribe(e => messages.Add(e));
        }
Exemple #7
0
 private List <Feature> getCopy(int c)
 {
     if (c == 0)
     {
         return(Choices);
     }
     c--;
     while (c >= copies.Count)
     {
         copies.Add(FeatureContainer.MakeCopy(Choices));
     }
     return(copies[c]);
 }
        public void OfType_WithProvider_FeatureIsReturned()
        {
            var feature = new TestFeature();

            var provider = new Mock<IFeatureProvider>();
            provider.Setup(p => p.GetFeature<TestFeature>()).Returns(feature);

            var container = new FeatureContainer(provider.Object);

            var output = container.OfType<TestFeature>();

            (output as ConfigurationDrivenFeatureAdapter).Feature.Should().Equal(feature);
        }
Exemple #9
0
 public bool Redo()
 {
     if (RedoBuffer.Count > 0)
     {
         lastid = "";
         UndoBuffer.AddLast(container);
         container = RedoBuffer.Last.Value;
         RedoBuffer.RemoveLast();
         UnsavedChanges++;
         refresh();
         return(true);
     }
     return(false);
 }
Exemple #10
0
        public void OfType_WithProvider_FeatureIsReturned()
        {
            var feature = new TestFeature();

            var provider = new Mock <IFeatureProvider>();

            provider.Setup(p => p.GetFeature <TestFeature>()).Returns(feature);

            var container = new FeatureContainer(provider.Object);

            var output = container.OfType <TestFeature>();

            (output as ConfigurationDrivenFeatureAdapter).Feature.Should().Equal(feature);
        }
Exemple #11
0
        private void FeatCollection_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (FeatCollection.SelectedItem == null)
            {
                return;
            }
            FeatureContainer selected = (FeatureContainer)FeatCollection.SelectedItem;

            if (selected != null)
            {
                preview.Navigate("about:blank");
                preview.Document.OpenNew(true);
                preview.Document.Write(selected.ToHTML());
                preview.Refresh();
            }
        }
Exemple #12
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (FeatCats.SelectedItem == null)
            {
                return;
            }
            FeatureContainer f = new FeatureContainer()
            {
                Source   = Program.Context.Config.DefaultSource,
                category = (string)FeatCats.SelectedItem
            };
            FeatureContainerForm r = new FeatureContainerForm(f);

            r.Saved += ContainerSaved;
            r.Show();
        }
Exemple #13
0
        private void editContainer(object sender, EventArgs e)
        {
            if (FeatCollection.SelectedItem == null)
            {
                return;
            }
            FeatureContainer selected = (FeatureContainer)FeatCollection.SelectedItem;

            if (selected != null)
            {
                string sel             = selected.Name;
                FeatureContainerForm r = new FeatureContainerForm(selected.Clone());
                r.Saved += ContainerSaved;
                r.Show();
            }
        }
    public TerrainTriangulationData TriangulateHexRoadEdge(
        Hex hex,
        Hex neighbor,
        TerrainTriangulationData triangulationData,
        HexDirections direction,
        HexRiverData riverData,
        FeatureContainer features,
        Dictionary <HexDirections, bool> roadEdges,
        Dictionary <HexDirections, ElevationEdgeTypes> elevationEdgeTypes,
        float hexOuterRadius,
        int wrapSize
        )
    {
        triangulationData = TriangulateCenterRiverRoad(
            riverData,
            direction,
            hex,
            triangulationData,
            hexOuterRadius,
            wrapSize,
            this,
            roadEdges,
            features
            );

        if (direction <= HexDirections.Southeast)
        {
            triangulationData = TriangulateTerrainConnectionRoads(
                hex,
                neighbor,
                triangulationData,
                direction,
                riverData,
                roadEdges,
                elevationEdgeTypes,
                hexOuterRadius,
                wrapSize,
                this
                );
        }

        return(triangulationData);
    }
        public void GetAllFeatures_WithProvider_FeaturesAreReturned()
        {
            var features = new[] { new TestFeature(), new TestFeature2(), new TestFeature3() };

            var provider = new Mock<IFeatureProvider>();
            provider.Setup(p => p.GetAllFeatures()).Returns(features);

            var container = new FeatureContainer(provider.Object);

            var featureSet = container.GetAllFeatures()
                .Select(f => (f as ConfigurationDrivenFeatureAdapter).Feature).ToList();

            featureSet.Should().Count.Exactly(features.Length);

            foreach (var feature in features)
            {
                featureSet.Should().Contain.Item(feature);
            }
        }
Exemple #16
0
        public void GetAllFeatures_WithProvider_FeaturesAreReturned()
        {
            var features = new[] { new TestFeature(), new TestFeature2(), new TestFeature3() };

            var provider = new Mock <IFeatureProvider>();

            provider.Setup(p => p.GetAllFeatures()).Returns(features);

            var container = new FeatureContainer(provider.Object);

            var featureSet = container.GetAllFeatures()
                             .Select(f => (f as ConfigurationDrivenFeatureAdapter).Feature).ToList();

            featureSet.Should().Count.Exactly(features.Length);

            foreach (var feature in features)
            {
                featureSet.Should().Contain.Item(feature);
            }
        }
Exemple #17
0
    private TerrainTriangulationData TryTriangulateNeighborTerrainCorner(
        Hex source,
        Hex neighbor,
        TerrainTriangulationData data,
        HexDirections direction,
        Dictionary <HexDirections, Hex> neighbors,
        float hexOuterRadius,
        int wrapSize,
        MapMeshChunkLayer terrain,
        FeatureContainer features
        )
    {
        Hex nextNeighbor;

        if (
            neighbors.TryGetValue(
                direction.NextClockwise(),
                out nextNeighbor
                ) &&
            direction <= HexDirections.East
            )
        {
            TriangulateNeighborTerrainCorner(
                source,
                neighbor,
                nextNeighbor,
                direction,
                data,
                hexOuterRadius,
                wrapSize,
                terrain,
                features
                );
        }

        return(data);
    }
Exemple #18
0
 public void Apply(FeatureContainer result)
 {
 }
Exemple #19
0
    private TerrainTriangulationData TriangulateTerrainConnection(
        Hex source,
        Hex neighbor,
        TerrainTriangulationData data,
        HexDirections direction,
        HexRiverData riverData,
        Dictionary <HexDirections, bool> roadEdges,
        Dictionary <HexDirections, ElevationEdgeTypes> elevationEdgeTypes,
        float hexOuterRadius,
        int wrapSize,
        MapMeshChunkLayer terrain,
        FeatureContainer features
        )
    {
        if (riverData.HasRiverInDirection(direction))
        {
            data.connectionEdgeVertices.vertex3.y = neighbor.StreamBedY;
        }

        bool hasRoad = roadEdges[direction];

        if (
//            hex.GetEdgeType(direction) == ElevationEdgeTypes.Slope
            elevationEdgeTypes[direction] == ElevationEdgeTypes.Slope
            )
        {
            TriangulateEdgeTerracesTerrain(
                data.centerEdgeVertices,
                source,
                data.connectionEdgeVertices,
                neighbor,
                hexOuterRadius,
                wrapSize,
                terrain
                );
        }
        else
        {
            TriangulateEdgeStripTerrain(
                data.centerEdgeVertices,
                _weights1,
                source.Index,
                data.connectionEdgeVertices,
                _weights2,
                neighbor.Index,
                hexOuterRadius,
                wrapSize,
                terrain
                );
        }

        features.AddWall(
            data.centerEdgeVertices,
            source,
            data.connectionEdgeVertices,
            neighbor,
            riverData.HasRiverInDirection(direction),
            hasRoad,
            hexOuterRadius,
            wrapSize
            );

        return(data);
    }
Exemple #20
0
        public static void ImportStandaloneFeatures(this OGLContext context)
        {
            if (context == null || context.Config == null)
            {
                return;
            }
            context.FeatureCollections.Clear();
            context.FeatureContainers.Clear();
            context.FeatureCategories.Clear();
            context.Boons.Clear();
            context.Features.Clear();
            context.BoonsSimple.Clear();
            var files = SourceManager.EnumerateFiles(context, context.Config.Features_Directory);

            foreach (var f in files)
            {
                try
                {
                    Uri source             = new Uri(SourceManager.GetDirectory(f.Value, context.Config.Features_Directory).FullName);
                    Uri target             = new Uri(f.Key.DirectoryName);
                    FeatureContainer cont  = LoadFeatureContainer(f.Key.FullName);
                    List <Feature>   feats = cont.Features;
                    string           cat   = FeatureCleanname(context, Uri.UnescapeDataString(source.MakeRelativeUri(target).ToString()));
                    if (!context.FeatureContainers.ContainsKey(cat))
                    {
                        context.FeatureContainers.Add(cat, new List <FeatureContainer>());
                    }
                    cont.FileName = f.Key.FullName;
                    cont.category = cat;
                    cont.Name     = Path.GetFileNameWithoutExtension(f.Key.FullName);
                    cont.Source   = f.Value;
                    context.FeatureContainers[cat].Add(cont);
                    foreach (Feature feat in feats)
                    {
                        feat.Source = cont.Source;
                        foreach (Keyword kw in feat.Keywords)
                        {
                            kw.check();
                        }
                        feat.Category = cat;
                        if (!context.FeatureCategories.ContainsKey(cat))
                        {
                            context.FeatureCategories.Add(cat, new List <Feature>());
                        }
                        Feature other = context.FeatureCategories[cat].Where(ff => string.Equals(ff.Name, feat.Name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                        if (other != null)
                        {
                            other.ShowSource = true;
                            feat.ShowSource  = true;
                        }
                        context.FeatureCategories[cat].Add(feat);
                        if (cat.Equals("Feats/Boons", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (context.BoonsSimple.ContainsKey(feat.Name))
                            {
                                context.BoonsSimple[feat.Name].ShowSource = true;
                                feat.ShowSource = true;
                            }
                            else
                            {
                                context.BoonsSimple.Add(feat.Name, feat);
                            }
                            if (context.Boons.ContainsKey(feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source))
                            {
                                ConfigManager.LogError("Duplicate Boon: " + feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source);
                            }
                            else
                            {
                                context.Boons[feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source] = feat;
                            }
                        }
                    }
                    foreach (Feature feat in feats)
                    {
                        context.Features.Add(feat);
                    }
                }
                catch (Exception e)
                {
                    ConfigManager.LogError("Error reading " + f.ToString(), e);
                }
            }
        }
Exemple #21
0
 public void Apply(FeatureContainer result)
 {
     result.AddProperty(name, value);
 }
Exemple #22
0
    private void TriangulateTerrainCorner(
        Vector3 begin,
        Hex beginHex,
        Vector3 left,
        Hex leftHex,
        Vector3 right,
        Hex rightHex,
        float hexOuterRadius,
        int wrapSize,
        MapMeshChunkLayer terrain,
        FeatureContainer features
        )
    {
        ElevationEdgeTypes leftEdgeType  = beginHex.GetEdgeType(leftHex);
        ElevationEdgeTypes rightEdgeType = beginHex.GetEdgeType(rightHex);

        if (leftEdgeType == ElevationEdgeTypes.Slope)
        {
            if (rightEdgeType == ElevationEdgeTypes.Slope)
            {
// Corner is also a terrace. Slope-Slope-Flat.
                TriangulateCornerTerraces(
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    right,
                    rightHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }

// If the right edge is flat, must terrace from left instead of bottom.
// Slope-Flat-Slope
            else if (rightEdgeType == ElevationEdgeTypes.Flat)
            {
                TriangulateCornerTerraces(
                    left,
                    leftHex,
                    right,
                    rightHex,
                    begin,
                    beginHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
            else
            {
/* At least one edge is a cliff. Slope-Cliff-Slope or Slope-Cliff-Cliff. Standard case
 * because slope on left and flat on right.
 */
                TriangulateCornerTerracesCliff(
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    right,
                    rightHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
        }
        else if (rightEdgeType == ElevationEdgeTypes.Slope)
        {
            if (leftEdgeType == ElevationEdgeTypes.Flat)
            {
/* If the right edge is a slope, and the left edge is flat, must terrace from right instead
 * of bottom. Flat-Slope-Slope.
 */
                TriangulateCornerTerraces(
                    right,
                    rightHex,
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
            else
            {
/* At least one edge is a cliff. Slope-Cliff-Slope or Slope-Cliff-Cliff. Mirror case because
 * slope on right and flat on left.
 */
                TriangulateCornerCliffTerraces(
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    right,
                    rightHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
        }

/* Neither the left or right hex edge type is a slope. If the right hex type of the left hex
 * is a slope, then terraces must be calculated for a corner between two cliff edges.
 * Cliff-Cliff-Slope Right, or Cliff-Cliff-Slope Left.
 */
        else if (leftHex.GetEdgeType(rightHex) == ElevationEdgeTypes.Slope)
        {
// If Cliff-Cliff-Slope-Left
            if (leftHex.elevation < rightHex.elevation)
            {
                TriangulateCornerCliffTerraces(
                    right,
                    rightHex,
                    begin,
                    beginHex,
                    left,
                    leftHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }

// If Cliff-Cliff-Slope-Right
            else
            {
                TriangulateCornerTerracesCliff(
                    left,
                    leftHex,
                    right,
                    rightHex,
                    begin,
                    beginHex,
                    hexOuterRadius,
                    wrapSize,
                    terrain
                    );
            }
        }

// Else all edges are cliffs. Simply draw a triangle.
        else
        {
            terrain.AddTrianglePerturbed(
                begin,
                left,
                right,
                hexOuterRadius,
                wrapSize
                );

            Vector3 indices;
            indices.x = beginHex.Index;
            indices.y = leftHex.Index;
            indices.z = rightHex.Index;

            terrain.AddTriangleHexData(
                indices,
                _weights1,
                _weights2,
                _weights3
                );
        }

        features.AddWall(
            begin,
            beginHex,
            left,
            leftHex,
            right,
            rightHex,
            hexOuterRadius,
            wrapSize
            );
    }
Exemple #23
0
    private TerrainTriangulationData TriangulateTerrainCenter(
        HexRiverData riverData,
        HexDirections direction,
        Hex source,
        TerrainTriangulationData data,
        float hexOuterRadius,
        int wrapSize,
        MapMeshChunkLayer terrain,
        FeatureContainer features,
        Dictionary <HexDirections, bool> roadEdges
        )
    {
        if (riverData.HasRiver)
        {
            if (riverData.HasRiverInDirection(direction))
            {
                data.centerEdgeVertices.vertex3.y = source.StreamBedY;

                if (riverData.HasRiverStartOrEnd)
                {
                    data = TriangulateRiverBeginOrEndTerrain(
                        source,
                        data,
                        hexOuterRadius,
                        wrapSize,
                        terrain
                        );
                }
                else
                {
                    data = TriangulateRiverBanks(
                        data,
                        riverData,
                        direction,
                        hexOuterRadius
                        );

                    data = TriangulateRiverTerrain(
                        source,
                        data,
                        hexOuterRadius,
                        wrapSize,
                        terrain
                        );
                }
            }
            else
            {
                data = TriangulateTerrainAdjacentToRiver(
                    source,
                    direction,
                    data,
                    roadEdges,
                    riverData,
                    hexOuterRadius,
                    wrapSize,
                    terrain,
                    features
                    );
            }
        }
        else
        {
            // Triangulate terrain center without river, basic edge fan.
            TriangulateEdgeFan(
                data.terrainCenter,
                data.centerEdgeVertices,
                source.Index,
                hexOuterRadius,
                wrapSize,
                terrain
                );

            if (
                !source.IsUnderwater &&
                !roadEdges[direction]
                )
            {
                features.AddFeature(
                    source,
                    (
                        data.terrainCenter +
                        data.centerEdgeVertices.vertex1 +
                        data.centerEdgeVertices.vertex5
                    ) * (1f / 3f),
                    hexOuterRadius,
                    wrapSize
                    );
            }
        }

        return(data);
    }
Exemple #24
0
 public void Apply(FeatureContainer result)
 {
     result.AddProperty("instrumentation", ProgramStates);
 }
Exemple #25
0
    private TerrainTriangulationData TriangulateNeighborTerrainCorner(
        Hex source,
        Hex neighbor,
        Hex nextNeighbor,
        HexDirections direction,
        TerrainTriangulationData data,
        float hexOuterRadius,
        int wrapSize,
        MapMeshChunkLayer terrain,
        FeatureContainer features
        )
    {
// Create a 5th vertex and assign it with the elevation of the neighbor
// under consideration. This will be used as the final vertex in the
// triangle which fills the gap between bridges.
        Vector3 vertex5 =
            data.centerEdgeVertices.vertex5 + HexagonPoint.GetBridge(
                direction.NextClockwise(),
                hexOuterRadius
                );

        vertex5.y = nextNeighbor.Position.y;

        if (source.elevation <= neighbor.elevation)
        {
            if (source.elevation <= nextNeighbor.elevation)
            {
// This hex has lowest elevation, no rotation.
                TriangulateTerrainCorner(
                    data.centerEdgeVertices.vertex5,
                    source,
                    data.connectionEdgeVertices.vertex5,
                    neighbor,
                    vertex5,
                    nextNeighbor,
                    hexOuterRadius,
                    wrapSize,
                    terrain,
                    features
                    );
            }
            else
            {
// Next neighbor has lowest elevation, rotate counter-clockwise.
                TriangulateTerrainCorner(
                    vertex5,
                    nextNeighbor,
                    data.centerEdgeVertices.vertex5,
                    source,
                    data.connectionEdgeVertices.vertex5,
                    neighbor,
                    hexOuterRadius,
                    wrapSize,
                    terrain,
                    features
                    );
            }
        }
        else if (neighbor.elevation <= nextNeighbor.elevation)
        {
// Neighbor is lowest hex, rotate triangle clockwise.
            TriangulateTerrainCorner(
                data.connectionEdgeVertices.vertex5,
                neighbor,
                vertex5,
                nextNeighbor,
                data.centerEdgeVertices.vertex5,
                source,
                hexOuterRadius,
                wrapSize,
                terrain,
                features
                );
        }
        else
        {
// Next neighbor has lowest elevation, rotate counter-clockwise.
            TriangulateTerrainCorner(
                vertex5,
                nextNeighbor,
                data.centerEdgeVertices.vertex5,
                source,
                data.connectionEdgeVertices.vertex5,
                neighbor,
                hexOuterRadius,
                wrapSize,
                terrain,
                features
                );
        }

        return(data);
    }
Exemple #26
0
        public static async Task ImportStandaloneFeaturesAsync(this OGLContext context)
        {
            context.FeatureCollections.Clear();
            context.FeatureContainers.Clear();
            context.FeatureCategories.Clear();
            context.Boons.Clear();
            context.Features.Clear();
            context.BoonsSimple.Clear();
            var files = await PCLSourceManager.EnumerateFilesAsync(context, context.Config.Features_Directory, true).ConfigureAwait(false);

            foreach (var f in files)
            {
                try
                {
                    Uri source            = new Uri(PCLSourceManager.GetDirectory(f.Value, context.Config.Features_Directory));
                    Uri target            = new Uri(PCLSourceManager.Parent(f.Key));
                    FeatureContainer cont = await LoadFeatureContainerAsync(f.Key);

                    List <Feature> feats = cont.Features;
                    string         cat   = FeatureCleanname(context, Uri.UnescapeDataString(source.MakeRelativeUri(target).ToString()));
                    if (!context.FeatureContainers.ContainsKey(cat))
                    {
                        context.FeatureContainers.Add(cat, new List <FeatureContainer>());
                    }
                    cont.filename = f.Key.Path;
                    cont.category = cat;
                    cont.Name     = f.Key.Name;
                    int i = cont.Name.LastIndexOf('.');
                    if (i > 0)
                    {
                        cont.Name = cont.Name.Substring(0, i);
                    }
                    cont.Source = f.Value;
                    context.FeatureContainers[cat].Add(cont);
                    foreach (Feature feat in feats)
                    {
                        feat.Source = cont.Source;
                        foreach (Keyword kw in feat.Keywords)
                        {
                            kw.check();
                        }
                        feat.Category = cat;
                        if (!context.FeatureCategories.ContainsKey(cat))
                        {
                            context.FeatureCategories.Add(cat, new List <Feature>());
                        }
                        Feature other = context.FeatureCategories[cat].Where(ff => string.Equals(ff.Name, feat.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                        if (other != null)
                        {
                            other.ShowSource = true;
                            feat.ShowSource  = true;
                        }
                        context.FeatureCategories[cat].Add(feat);
                        if (cat.Equals("Feats/Boons", StringComparison.OrdinalIgnoreCase))
                        {
                            if (context.BoonsSimple.ContainsKey(feat.Name))
                            {
                                context.BoonsSimple[feat.Name].ShowSource = true;
                                feat.ShowSource = true;
                            }
                            else
                            {
                                context.BoonsSimple.Add(feat.Name, feat);
                            }
                            if (context.Boons.ContainsKey(feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source))
                            {
                                ConfigManager.LogError("Duplicate Boon: " + feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source);
                            }
                            else
                            {
                                context.Boons[feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source] = feat;
                            }
                        }
                    }
                    foreach (Feature feat in feats)
                    {
                        context.Features.Add(feat);
                    }
                }
                catch (Exception e)
                {
                    ConfigManager.LogError("Error reading " + Path(f.Key.Path), e);
                }
            }
        }
 public static List <Feature> LoadString(String text)
 {
     return(FeatureContainer.LoadString(text).Features);
 }
    public static FeatureContainer GetFeatureContainer(MapMeshChunkLayer walls) {
        GameObject resultObj = new GameObject("Feature Container");
        FeatureContainer resultMono = resultObj.AddComponent<FeatureContainer>();
        resultMono.urbanCollections = new FeatureCollection[3];
        resultMono.farmCollections = new FeatureCollection[3];
        resultMono.plantCollections = new FeatureCollection[3];
        resultMono.special = new Transform[3];
        resultMono.walls = walls;

        resultMono.wallTower = Resources.Load<Transform>("Wall Tower");
        resultMono.bridge = Resources.Load<Transform>("Bridge");
        
        resultMono.urbanCollections[0] = new FeatureCollection(
            new Transform[] {
                Resources.Load<Transform>("Urban High 1"),
                Resources.Load<Transform>("Urban High 2")
            }
        );

        resultMono.urbanCollections[1] = new FeatureCollection(
            new Transform[] {
                Resources.Load<Transform>("Urban Medium 1"),
                Resources.Load<Transform>("Urban Medium 2")
            }
        );

        resultMono.urbanCollections[2] = new FeatureCollection(
            new Transform[] {
                Resources.Load<Transform>("Urban Low 1"),
                Resources.Load<Transform>("Urban Low 2")
            }
        );

        resultMono.farmCollections[0] = new FeatureCollection(
            new Transform[] {
                Resources.Load<Transform>("Farm High 1"),
                Resources.Load<Transform>("Farm High 2")
            }
        );

        resultMono.farmCollections[1] = new FeatureCollection(
            new Transform[] {
                Resources.Load<Transform>("Farm Medium 1"),
                Resources.Load<Transform>("Farm Medium 2")
            }
        );

        resultMono.farmCollections[2] = new FeatureCollection(
            new Transform[] {
                Resources.Load<Transform>("Farm Low 1"),
                Resources.Load<Transform>("Farm Low 2")
            }
        );

        resultMono.plantCollections[0] = new FeatureCollection(
            new Transform[] {
                Resources.Load<Transform>("Plant High 1"),
                Resources.Load<Transform>("Plant High 2")
            }
        );

        resultMono.plantCollections[1] = new FeatureCollection(
            new Transform[] {
                Resources.Load<Transform>("Plant Medium 1"),
                Resources.Load<Transform>("Plant Medium 2")
            }
        );

        resultMono.plantCollections[2] = new FeatureCollection(
            new Transform[] {
                Resources.Load<Transform>("Plant Low 1"),
                Resources.Load<Transform>("Plant Low 2")
            }
        );

        resultMono.special[0] = Resources.Load<Transform>("Castle");
        resultMono.special[1] = Resources.Load<Transform>("Ziggurat");
        resultMono.special[2] = Resources.Load<Transform>("Megaflora");

        return resultMono;
    }
Exemple #29
0
    public static MapMeshChunk CreateEmpty()
    {
        GameObject   resultObj  = new GameObject("Map Mesh Chunk");
        MapMeshChunk resultMono = resultObj.AddComponent <MapMeshChunk>();

        resultMono.Hexes = new Hex[
            HexMeshConstants.CHUNK_SIZE_X *
            HexMeshConstants.CHUNK_SIZE_Z
                           ];

        GameObject resultCanvasObj = new GameObject(
            "World Space UI Canvas"
            );

        Canvas resultCanvasMono =
            resultCanvasObj.AddComponent <Canvas>();

        CanvasScaler resultCanvasScalerMono =
            resultCanvasObj.AddComponent <CanvasScaler>();

        resultCanvasObj.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono.WorldSpaceUICanvas = resultCanvasMono;
        resultCanvasScalerMono.dynamicPixelsPerUnit = 10f;

        resultCanvasObj.transform.rotation = Quaternion.Euler(
            90,
            0,
            0
            );

        resultCanvasObj.transform.position += Vector3.up * .005f;

        resultMono._terrainLayer = TerrainChunkLayer.CreateEmpty(
            Resources.Load <Material>("Terrain"),
            true,
            true,
            false,
            false
            );

        resultMono._terrainLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._riversLayer = RiversChunkLayer.CreateEmpty(
            Resources.Load <Material>("River"),
            false,
            true,
            true,
            false
            );

        resultMono._riversLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._roadsLayer = RoadsChunkLayer.CreateEmpty(
            Resources.Load <Material>("Road"),
            false,
            true,
            true,
            false
            );

        resultMono._roadsLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._openWaterLayer =
            OpenWaterChunkLayer.CreateEmpty(
                Resources.Load <Material>("Water"),
                false,
                true,
                false,
                false
                );

        resultMono._openWaterLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._waterShoreLayer =
            WaterShoreChunkLayer.CreateEmpty(
                Resources.Load <Material>("WaterShore"),
                false,
                true,
                true,
                false
                );

        resultMono._waterShoreLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._estuariesLayer = EstuariesChunkLayer.CreateEmpty(
            Resources.Load <Material>("Estuary"),
            false,
            true,
            true,
            true
            );

        resultMono._estuariesLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        MapMeshChunkLayer walls = MapMeshChunkLayer.CreateEmpty(
            Resources.Load <Material>("Urban"),
            false,
            false,
            false,
            false
            );

        walls.name = "Walls Layer";
        walls.transform.SetParent(resultObj.transform, false);

        resultMono._features = FeatureContainer.GetFeatureContainer(
            walls
            );

        resultMono._features.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._features.name = "Features Layer";

        return(resultMono);
    }
Exemple #30
0
    private TerrainTriangulationData TriangulateTerrainAdjacentToRiver(
        Hex source,
        HexDirections direction,
        TerrainTriangulationData triangulationData,
        Dictionary <HexDirections, bool> roadEdges,
        HexRiverData riverData,
        float hexOuterRadius,
        int wrapSize,
        MapMeshChunkLayer terrain,
        FeatureContainer features
        )
    {
        if (riverData.HasRiverInDirection(direction.NextClockwise()))
        {
/* If the direction has a river on either side, it has a slight curve.
 * The center vertex of river-adjacent triangle needs to be moved toward
 * the edge so they don't overlap the river.
 */
//            if (hex.HasRiverThroughEdge(direction.Previous())) {
            if (
                riverData.HasRiverInDirection(direction.PreviousClockwise())
                )
            {
                triangulationData.terrainCenter += HexagonPoint.GetSolidEdgeMiddle(
                    direction,
                    hexOuterRadius
                    ) * (HexagonConstants.INNER_TO_OUTER_RATIO * 0.5f);
            }

/* If the hex has a river through the previous previous direction,
 * it has a river flowing through the hex. Move the center vertex
 * of the river-adjacent triangle so that it does not overlap the river.
 */
            else if (
                riverData.HasRiverInDirection(
                    direction.PreviousClockwise2()
                    )
                )
            {
                triangulationData.terrainCenter +=
                    HexagonPoint.GetFirstSolidCorner(
                        direction,
                        hexOuterRadius
                        ) * 0.25f;
            }
        }

/* Second case of straight-river-adjacent triangle. Need to move center
 * so it doesn't overlap the river.
 */
        else if (
            riverData.HasRiverInDirection(direction.PreviousClockwise()) &&
            riverData.HasRiverInDirection(direction.NextClockwise2())
            )
        {
            triangulationData.terrainCenter += HexagonPoint.GetSecondSolidCorner(
                direction,
                hexOuterRadius
                ) * 0.25f;
        }

        EdgeVertices middle = new EdgeVertices(
            Vector3.Lerp(
                triangulationData.terrainCenter,
                triangulationData.centerEdgeVertices.vertex1,
                0.5f
                ),
            Vector3.Lerp(
                triangulationData.terrainCenter,
                triangulationData.centerEdgeVertices.vertex5,
                0.5f
                )
            );

        TriangulateEdgeStripTerrain(
            middle,
            _weights1,
            source.Index,
            triangulationData.centerEdgeVertices,
            _weights1,
            source.Index,
            hexOuterRadius,
            wrapSize,
            terrain
            );

        TriangulateEdgeFan(
            triangulationData.terrainCenter,
            middle,
            source.Index,
            hexOuterRadius,
            wrapSize,
            terrain
            );

        if (!source.IsUnderwater && roadEdges[direction])
        {
            features.AddFeature(
                source,
                (
                    triangulationData.terrainCenter +
                    triangulationData.centerEdgeVertices.vertex1 +
                    triangulationData.centerEdgeVertices.vertex5
                ) * (1f / 3f),
                hexOuterRadius,
                wrapSize
                );
        }

        return(triangulationData);
    }
Exemple #31
0
 public void Apply(FeatureContainer result)
 {
     result.AddProperty("variableLocations", VariableLocations);
 }
Exemple #32
0
 public void Apply(FeatureContainer result)
 {
     result.AddProperty("testResults", Results);
 }