private void DecreaseItemLayer(GameEntity entity, LayerComponent layer)
    {
        var layerValue = layer.Value;

        entity.ReplaceLayer(Mathf.Max(0, layerValue - 1));

        if (layerValue > 0)
        {
            return;
        }

        if (entity.hasLayerResetting)
        {
            entity.ReplaceLayer(entity.layerResetting.OriginalLayer);
        }
        else
        {
            DestroyItem(entity);
        }

        if (entity.hasGenerator)
        {
            entity.isWillGenerate = true;
        }
    }
Exemple #2
0
 public Renderer(Game game)
 {
     this.game      = game;
     entity         = new Entity("VL Renderer");
     layerComponent = new LayerComponent();
     entity.Add(layerComponent);
     game.SceneSystem.SceneInstance.RootScene.Entities.Add(entity);
 }
Exemple #3
0
        public static void sliceTrianglesIntoLayers()
        {
            Logger.logProgress("Slicing triangles into layers");

            //If in plotting mode we do not work with triangles
            if (Global.Values.materialType == MaterialType.Pen)
            {
                return;
            }

            long zPoint;
            List <LineSegment>    lineList;
            Dictionary <int, int> faceToLineIndex;

            for (int i = 0; i < Global.Values.layerCount; i++)
            {
                lineList        = new List <LineSegment>();
                faceToLineIndex = new Dictionary <int, int>();

                zPoint = i * Global.Values.layerHeight + (Global.Values.layerHeight / 2);

                for (int j = 0; j < Global.Values.initialTriangleList.Count; j++)
                {
                    var triangle = Global.Values.initialTriangleList[j];

                    if (triangle.checkIfContainsZ(zPoint))
                    {
                        //We do not want dots
                        var temp = triangle.calculateZSLicePoints(zPoint);
                        if (!temp.Point1.Equals(temp.Point2))
                        {
                            faceToLineIndex.Add(j, lineList.Count);
                            temp.triangleIndex = j;
                            lineList.Add(temp);
                        }
                    }
                }

                var layerComponent = new LayerComponent(i);
                layerComponent.initialLineList = lineList;
                layerComponent.faceToLineIndex = faceToLineIndex;
                Global.Values.layerComponentList.Add(layerComponent);
            }
        }
        public static void generateRaft()
        {
            Logger.logProgress("Generating raft");

            if (!Global.Values.shouldRaft || Global.Values.raftCount < 1)
            {
                return;
            }

            Polygons raftOutlines = generateRaftOutline();

            //Global.Values.layerComponentList = newLayerList;
            Global.Values.layerCount += Global.Values.raftCount;

            //To calculate the raft we will trim the vertical and horisontal grids with the raft density using a calculated raft outline

            var raftGrid = generateRaftGrid(raftOutlines, Global.Values.raftDensity);//Global.Values.infillGrids[0.3f];

            var lLines = InfillGenerator.clipLinesInPolygons(raftGrid.leftLines, raftOutlines);
            var rLines = InfillGenerator.clipLinesInPolygons(raftGrid.rightLines, raftOutlines);

            for (ushort i = 0; i < Global.Values.raftCount; i++)
            {
                LayerComponent raftLayer   = new LayerComponent(i);
                Island         raftIsland  = new Island();
                LayerSegment   raftSegment = new LayerSegment(SegmentType.RaftSegment);
                raftSegment.segmentSpeed = (i == 0) ? Global.Values.initialLayerSpeed : Global.Values.raftSpeed;
                raftSegment.fillLines    = new List <LineSegment>();
                raftSegment.fillLines.AddRange(lLines);
                raftSegment.fillLines.AddRange(rLines);
                raftSegment.outlinePolygons = raftOutlines;
                raftIsland.segmentList.Add(raftSegment);
                raftIsland.outlinePolygons = raftOutlines; //This is so that the skirt can still be calculated
                raftLayer.islandList.Add(raftIsland);

                Global.Values.layerComponentList.Insert(i, raftLayer);
            }
        }