Ejemplo n.º 1
0
        public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
        {
            int blockid = Terrain.ExtractContents(raycastResult.Value);
            int id      = ILibrary.getItemId(raycastResult.Value);

            switch (blockid)
            {
            case 1006:
                switch (id)
                {
                case 500:
                    componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage("", false, false);
                    break;
                }

                break;

            case 1007:
                switch (id)
                {
                case 39:
                    subsystemItemElectricBehavior.OnInteract(raycastResult, componentMiner);
                    break;

                case 102: break;
                }
                break;
            }
            return(false);
        }
Ejemplo n.º 2
0
        public override void Update(EditorWorldRaycastResult intersection, float deltaTime)
        {
            if (intersection.HitTerrain)
            {
                TerrainRaycastResult terrainIntersection = intersection.TerrainResult;

                if (!TerrainEditor.IsSelecting)
                {
                    lastNonSelectingNormal = terrainIntersection.IntersectionCubeSide.Value;
                }

                if (TerrainEditor.IsSelecting && Input.GetMouseButtonUp(MouseButton.Left))
                {
                    ApplyActionToSelection(TerrainEditor.SelectionBox,
                                           (chunk, blockPos) =>
                    {
                        Block block = Block.CUSTOM;
                        Color color = TerrainEditor.BlockColor;
                        block.R     = color.R;
                        block.G     = color.G;
                        block.B     = color.B;

                        TerrainEditor.SetBlock(chunk, block, blockPos);
                    });
                }
            }
        }
Ejemplo n.º 3
0
        public override void Draw(EditorWorldRaycastResult intersection)
        {
            if (intersection.HitTerrain && !GUISystem.HandledMouseOver)
            {
                TerrainRaycastResult terrainIntersection = intersection.TerrainResult;

                Vector3 blockCoords = TerrainEditor.IsSelecting
                    ? TerrainEditor.SelectionBox.Center()
                    : GetGlobalBlockCoords(terrainIntersection.Chunk.IndexPosition, terrainIntersection.BlockIndex.Value)
                                      * Block.CUBE_3D_SIZE
                                      + Maths.CubeSideToSurfaceNormal(terrainIntersection.IntersectionCubeSide.Value) * Block.CUBE_3D_SIZE;

                Vector3 scale = TerrainEditor.IsSelecting
                    ? TerrainEditor.SelectionBox.Size().ToVector3() + Vector3.UnitScale
                    : Vector3.UnitScale;

                cursorCube.Position = blockCoords;
                cursorCube.VoxelObject.MeshScale = scale;
                cursorCube.RenderAsWireframe     = false;
                Color color = TerrainEditor.BlockColor;
                color.A = 128;
                cursorCube.ColorOverlay = color;

                entRenderer.Batch(cursorCube);
            }
        }
Ejemplo n.º 4
0
        public void OnUse(TerrainRaycastResult terrainRaycastResult)
        {
            Point3          position = terrainRaycastResult.CellFace.Point;
            ComponentPlayer Player   = this.componentMiner.ComponentPlayer;

            if (!OnTouch.Touch(this, position))
            {
                return;
            }
            int cellValue = GameManager.Project.FindSubsystem <SubsystemTerrain>(true).Terrain.GetCellValue(position.X, position.Y, position.Z);
            int light     = Terrain.ExtractLight(cellValue);
            int data      = Terrain.ExtractData(cellValue);
            int contents  = Terrain.ExtractContents(cellValue);

            if (BlocksManager.Blocks[contents] != null)
            {
                if (numberPoint == NumberPoint.One)
                {
                    this.Position[0] = position;
                    Player.ComponentGui.DisplaySmallMessage($"坐标1设置完成\n X:{position.X} ,Y:{position.Y} ,Z:{position.Z}\n方块ID : {contents}\n方块完整值 : {cellValue}\n特殊值一 : {light} , 特殊值二 : {data} \n", true, false);
                    if (amountPoint != numberPoint)
                    {
                        numberPoint = NumberPoint.Two;
                    }
                }
                else if (numberPoint == NumberPoint.Two)
                {
                    this.Position[1] = position;
                    Player.ComponentGui.DisplaySmallMessage($"坐标2设置完成\n X:{position.X} ,Y:{position.Y} ,Z:{position.Z}\n方块ID : {contents}\n方块完整值 : {cellValue}\n特殊值一 : {light} , 特殊值二 : {data}\n", true, false);
                    if (amountPoint == numberPoint)
                    {
                        numberPoint = NumberPoint.One;
                    }
                    else
                    {
                        numberPoint = NumberPoint.Three;
                    }
                }
                else if (numberPoint == NumberPoint.Three)
                {
                    this.Position[2] = position;
                    Player.ComponentGui.DisplaySmallMessage($"坐标3设置完成\n X:{position.X} ,Y:{position.Y} ,Z:{position.Z}\n方块ID : {contents}\n方块完整值 : {cellValue}\n特殊值一 : {light} , 特殊值二 : {data}\n", true, false);
                    if (amountPoint == numberPoint)
                    {
                        numberPoint = NumberPoint.One;
                    }
                    else
                    {
                        numberPoint = NumberPoint.Four;
                    }
                }
                else if (numberPoint == NumberPoint.Four)
                {
                    this.Position[3] = position;
                    Player.ComponentGui.DisplaySmallMessage($"坐标4设置完成\n X:{position.X} ,Y:{position.Y} ,Z:{position.Z}\n方块ID : {contents}\n方块完整值 : {cellValue}\n特殊值一 : {light} , 特殊值二 : {data}\n", true, false);
                    numberPoint = NumberPoint.One;
                }
            }
        }
Ejemplo n.º 5
0
        void PickColor()
        {
            TerrainRaycastResult result = World.TerrainPhysics.Raycast(
                new Ray(Camera.Position, Camera.ViewMatrix.Forward()), true, PLACE_RANGE);

            if (result.Intersects)
            {
                IndexPosition blockIndex = result.BlockIndex.Value;
                BlockColor = result.Chunk[blockIndex].GetColor();
            }
        }
Ejemplo n.º 6
0
        protected override void OnPrimaryFire()
        {
            if (GlobalNetwork.IsConnected)
            {
                World.FireBullet(OwnerPlayer, Camera.Position, Camera.LookVector,
                                 Vector3.Zero, 0, PLAYER_DAMAGE, MODIFY_RANGE);
            }

            TerrainRaycastResult result = World.TerrainPhysics.Raycast(
                new Ray(Camera.Position, Camera.LookVector), true, MODIFY_RANGE);

            if (result.Intersects)
            {
                hitBlockAudioSource?.Play();

                if (GlobalNetwork.IsServer || !GlobalNetwork.IsConnected)
                {
                    Block block = result.Chunk[result.BlockIndex.Value];

                    if (block.Health <= 3)
                    {
                        OwnerPlayer.NumBlocks++;
                    }

                    if (!GlobalNetwork.IsConnected)
                    {
                        result.Chunk.DamageBlock(result.BlockIndex.Value, 3);
                    }
                    else
                    {
                        byte newHealth = (byte)MathHelper.Clamp(block.Health - 3, 0, 255);

                        if (newHealth > 0)
                        {
                            block.Data.SetUpper(newHealth);
                            World.SetBlock(result.Chunk.IndexPosition, result.BlockIndex.Value, block, false);
                        }
                        else
                        {
                            World.SetBlock(result.Chunk.IndexPosition, result.BlockIndex.Value, Block.AIR, false);
                        }
                    }
                }
            }
            else
            {
                missAudioSource?.Play();
            }

            cooldown = Config.PrimaryFireDelay;
            base.OnPrimaryFire();
        }
Ejemplo n.º 7
0
        protected override void OnPrimaryFire()
        {
            if (GlobalNetwork.IsServer || OwnerPlayer.NumBlocks <= 0)
            {
                return;
            }

            TerrainRaycastResult result = World.TerrainPhysics.Raycast(
                new Ray(Camera.Position, Camera.ViewMatrix.Forward()), true, PLACE_RANGE);

            primaryCooldown = 0;

            if (result.Intersects)
            {
                IndexPosition ipos = ShiftIPos(result.BlockIndex.Value, result.IntersectionCubeSide.Value);
                IndexPosition newChunkPos;
                Chunk.WrapBlockCoords(ipos.X, ipos.Y, ipos.Z, result.Chunk.IndexPosition, out ipos, out newChunkPos);

                Chunk chunkToMod;
                if (World.Terrain.Chunks.TryGetValue(newChunkPos, out chunkToMod))
                {
                    if (IsBlockPlacementSafe(ipos, newChunkPos))
                    {
                        buildAudioSource?.Play();

                        Block block = new Block(Block.CUSTOM.Data, BlockColor.R,
                                                BlockColor.G, BlockColor.B);

                        if (!GlobalNetwork.IsConnected)
                        {
                            OwnerPlayer.NumBlocks--;
                        }

                        if (!GlobalNetwork.IsConnected)
                        {
                            chunkToMod.SetBlock(block, ipos);
                        }
                        else
                        {
                            World.SetBlock(chunkToMod.IndexPosition, ipos, block, true);
                        }

                        primaryCooldown = Config.PrimaryFireDelay;
                    }
                }
            }

            base.OnPrimaryFire();
        }
Ejemplo n.º 8
0
        public override IndexPosition GetRayIntersectionIndex(TerrainRaycastResult rayIntersection)
        {
            IndexPosition pos = base.GetRayIntersectionIndex(rayIntersection);

            if (!TerrainEditor.IsSelecting)
            {
                pos += new IndexPosition(Maths.CubeSideToSurfaceNormal(rayIntersection.IntersectionCubeSide.Value));
            }
            else
            {
                pos += new IndexPosition(Maths.CubeSideToSurfaceNormal(lastNonSelectingNormal));
            }

            return(pos);
        }
Ejemplo n.º 9
0
 public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
 {
     if (Utils.SubsystemGameInfo.WorldSettings.GameMode != GameMode.Adventure)
     {
         var blockEntity = Utils.GetBlockEntity(raycastResult.CellFace.Point);
         if (blockEntity != null && componentMiner.ComponentPlayer != null)
         {
             ComponentLiquidPump componentDispenser = blockEntity.Entity.FindComponent <ComponentLiquidPump>(true);
             componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new LiquidPumpWidget(componentMiner.Inventory, componentDispenser);
             AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 10
0
        public override void FireBullet(Player player, Vector3 origin, Vector3 dir, Vector3 recoil,
                                        int blockDamage, float playerDamage, float maxDist = float.MaxValue)
        {
            Ray ray = new Ray(origin, dir + recoil);
            TerrainRaycastResult result = TerrainPhysics.Raycast(ray, true, maxDist);

            if (result.Intersects)
            {
                result.Chunk.DamageBlock(result.BlockIndex.Value, blockDamage);
                if (DashCMD.GetCVar <bool>("cl_impacts"))
                {
                    debugRenderer.AddBulletImpact(ray.Origin + ray.Direction * result.IntersectionDistance.Value, Color.Red);
                }
            }
        }
Ejemplo n.º 11
0
        public override void FireBullet(Player player, Vector3 origin, Vector3 dir, Vector3 recoil,
                                        int damage, float playerDamage, float maxDist = float.MaxValue)
        {
            // Signal server that we fired a bullet at this time
            OurPlayer.ClientSnapshot.BulletSnapshot.EnqueueBullet(new NetworkBullet(origin, Camera.Active.Yaw, Camera.Active.Pitch));

            // Simulate bullet locally if enabled
            if (DashCMD.GetCVar <bool>("cl_impacts"))
            {
                Ray ray = new Ray(origin, dir + recoil);
                TerrainRaycastResult result = TerrainPhysics.Raycast(ray, true, maxDist);

                ClientPlayer hitPlayer   = null;
                float?       hitPlayerAt = null;
                foreach (ClientPlayer otherPlayer in players.Values)
                {
                    if (otherPlayer != player)
                    {
                        if (DashCMD.GetCVar <bool>("cl_impacts"))
                        {
                            debugRenderer.AddPlayerRollback(otherPlayer.Transform.Position, Color.Green);
                        }

                        Ray newRay = new Ray(origin - otherPlayer.Transform.Position, dir);

                        float?dist;
                        if (newRay.Intersects(otherPlayer.GetOrientatedBoundingBox(), out dist))
                        {
                            if (!hitPlayerAt.HasValue || dist.Value < hitPlayerAt.Value)
                            {
                                hitPlayer   = otherPlayer;
                                hitPlayerAt = dist.Value;
                            }
                        }
                    }
                }

                if (result.Intersects && (!hitPlayerAt.HasValue || (hitPlayerAt.Value > result.IntersectionDistance.Value)))
                {
                    debugRenderer.AddBulletImpact(ray.Origin + ray.Direction * result.IntersectionDistance.Value, Color.Red);
                }
                else if (hitPlayerAt.HasValue)
                {
                    debugRenderer.AddBulletImpact(ray.Origin + ray.Direction * hitPlayerAt.Value, Color.Red);
                }
            }
        }
Ejemplo n.º 12
0
        public TerrainEditor(EditorScreen screen)
        {
            this.screen = screen;
            editor      = screen.WorldEditor;
            renderer    = screen.Window.Renderer;
            terrainPhys = new TerrainPhysicsExtension();
            entRenderer = renderer.GetRenderer3D <EntityRenderer>();
            colorPicker = screen.UI.ColorWindow.ColorPicker;

            blockCursorCube = new DebugCube(Color4.White, Block.CUBE_SIZE);
            SelectionBox    = new EditorSelectionBox();

            undoStack      = new Stack <TerrainOperationBatch>();
            redoStack      = new Stack <TerrainOperationBatch>();
            operationBatch = new TerrainOperationBatch();

            rayIntersection = new TerrainRaycastResult(new Ray(Vector3.Zero, Vector3.UnitZ));
        }
Ejemplo n.º 13
0
        public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
        {        //记录point
            ++ll; if (ll >= 2)
            {
                ll = 0; return(true);
            }
            componentPlayer = componentMiner.ComponentPlayer;
            ComponentBlockEntity componentBlockEntity = subsystemBlockEntities.GetBlockEntity(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z);

            if (componentBlockEntity == null)
            {
                toast("没有找到Blockentity"); return(false);
            }
            ComponentSingleChest singleChestData = componentBlockEntity.Entity.FindComponent <ComponentSingleChest>(true);

            singleChestData.Droptems(new Vector3(raycastResult.CellFace.X, raycastResult.CellFace.Y, raycastResult.CellFace.Z) + new Vector3(1f, 1f, 1f), 1);
            return(true);
        }
Ejemplo n.º 14
0
        public EditorWorldRaycastResult Raycast(Ray ray)
        {
            EditorObjectRaycastResult objectResult  = RaycastEditorObjects(ray);
            TerrainRaycastResult      terrainResult = RaycastTerrain(ray);

            if (objectResult.Intersects)
            {
                return(new EditorWorldRaycastResult(objectResult));
            }
            else if (terrainResult.Intersects)
            {
                return(new EditorWorldRaycastResult(terrainResult));
            }
            else
            {
                return(new EditorWorldRaycastResult(ray));
            }
        }
Ejemplo n.º 15
0
        protected override void OnSecondaryFire()
        {
            TerrainRaycastResult result = World.TerrainPhysics.Raycast(
                new Ray(Camera.Position, Camera.ViewMatrix.Forward()), true, PLACE_RANGE);

            if (result.Intersects)
            {
                IndexPosition ipos = ShiftIPos(result.BlockIndex.Value, result.IntersectionCubeSide.Value);
                IndexPosition newChunkPos;
                Chunk.WrapBlockCoords(ipos.X, ipos.Y, ipos.Z, result.Chunk.IndexPosition, out ipos, out newChunkPos);

                startGlobalPosition = Terrain.GetGlobalBlockCoords(newChunkPos, ipos);
                endGlobalPosition   = startGlobalPosition;
                holdingDown         = true;
            }

            base.OnSecondaryFire();
        }
Ejemplo n.º 16
0
        public override void Draw(EditorWorldRaycastResult worldIntersection)
        {
            if (worldIntersection.HitTerrain && !GUISystem.HandledMouseOver)
            {
                TerrainRaycastResult intersection = worldIntersection.TerrainResult;

                Vector3 blockCoords = TerrainEditor.IsSelecting
                   ? TerrainEditor.SelectionBox.Center()
                   : GetGlobalBlockCoords(intersection.Chunk.IndexPosition, intersection.BlockIndex.Value) * Block.CUBE_3D_SIZE;

                Vector3 scale = TerrainEditor.IsSelecting
                    ? TerrainEditor.SelectionBox.Size().ToVector3() + Vector3.UnitScale
                    : Vector3.UnitScale;

                cursorCube.Position = blockCoords;
                cursorCube.VoxelObject.MeshScale = scale + new Vector3(0.01f, 0.01f, 0.01f);
                cursorCube.RenderAsWireframe     = true;
                cursorCube.ColorOverlay          = Color.Black;

                entRenderer.Batch(cursorCube);
            }
        }
Ejemplo n.º 17
0
        protected override void Update(float deltaTime)
        {
            ModelRotation = new Vector3(GetTilt(), -10, 0);

            if (cooldown > 0)
            {
                cooldown -= deltaTime;
            }

            TerrainRaycastResult result = World.TerrainPhysics.Raycast(
                new Ray(Camera.Position, Camera.LookVector), true, MODIFY_RANGE);

            if (result.Intersects)
            {
                globalMousePosition = Terrain.GetGlobalBlockCoords(result.Chunk.IndexPosition, result.BlockIndex.Value);
                mouseOverBlock      = true;
            }
            else
            {
                mouseOverBlock = false;
            }

            base.Update(deltaTime);
        }
 public EditorWorldRaycastResult(Ray ray)
     : base(ray)
 {
     EditorObjectResult = new EditorObjectRaycastResult(ray);
     TerrainResult      = new TerrainRaycastResult(ray);
 }
        public void WE()
        {
            if (!(m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative))
            {
                WorldEditMenu.IsVisible = false;
            }
            else
            {
                WorldEditMenu.IsVisible = true;
            }

            WorldEditMenuContainerBottom.IsVisible = WorldEditMenu.IsChecked;
            WorldEditMenuContainerTop.IsVisible    = WorldEditMenu.IsChecked;


            if (WorldEditMenu.IsClicked)
            {
                if (WorldEditMenu.IsChecked)
                {
                    OldLookControlMode = (int)SettingsManager.LookControlMode;
                    SettingsManager.LookControlMode = LookControlMode.SplitTouch;
                }
                else
                {
                    SettingsManager.LookControlMode = (LookControlMode)OldLookControlMode;
                }
            }


            //Vector3 viewDirection = cam.ViewDirection;

            //m_componentPlayer.ComponentBody.Velocity = new Vector3(viewDirection.X * 100f, viewDirection.Y * 100f, viewDirection.Z * 100f);

            if (Keyboard.IsKeyDownOnce(Engine.Input.Key.F1) || F1.IsClicked)
            {
                Point1 = m_componentPlayer.ComponentMiner.PickTerrainForDigging(this.cam.ViewPosition, this.cam.ViewDirection);
                if (Point1.HasValue)
                {
                    SelectedBlock = m_subsystemTerrain.Terrain.GetCellValue(Point1.Value.CellFace.X, Point1.Value.CellFace.Y, Point1.Value.CellFace.Z);
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("Set position 1 on: " + (object)Point1.Value.CellFace.X + ", " + (object)Point1.Value.CellFace.Y + ", " + (object)Point1.Value.CellFace.Z + ",Block ID " + (object)SelectedBlock, false, false);
                }
            }
            if (Keyboard.IsKeyDown(Engine.Input.Key.F2) || F2.IsClicked)
            {
                Point2 = m_componentPlayer.ComponentMiner.PickTerrainForDigging(this.cam.ViewPosition, this.cam.ViewDirection);
                if (Point2.HasValue)
                {
                    ReplaceableBlock = m_subsystemTerrain.Terrain.GetCellValue(Point2.Value.CellFace.X, Point2.Value.CellFace.Y, Point2.Value.CellFace.Z);
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("Set position 2 on: " + (object)Point2.Value.CellFace.X + ", " + (object)Point2.Value.CellFace.Y + ", " + (object)Point2.Value.CellFace.Z + ",Block ID " + (object)ReplaceableBlock, false, false);
                }
            }
            if (Keyboard.IsKeyDown(Engine.Input.Key.F3) || F3.IsClicked)
            {
                Point3 = m_componentPlayer.ComponentMiner.PickTerrainForDigging(this.cam.ViewPosition, this.cam.ViewDirection);
                if (Point3.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("Set position 3 on: " + (object)Point1.Value.CellFace.X + ", " + (object)Point1.Value.CellFace.Y + ", " + (object)Point1.Value.CellFace.Z, false, false);
                    return;
                }
            }


            if (Keyboard.IsKeyDownOnce(Engine.Input.Key.F5) || F5.IsClicked)
            {
                if (!Point1.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 1", false, false);
                }
                else if (!Point2.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 2", false, false);
                }
                else if (!Point3.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 3", false, false);
                }
                else
                {
                    TerrainRaycastResult terrainRaycastResult = Point1.Value;
                    int x1 = terrainRaycastResult.CellFace.Point.X;
                    terrainRaycastResult = Point2.Value;
                    int x2   = terrainRaycastResult.CellFace.Point.X;
                    int num1 = Math.Min(x1, x2);
                    terrainRaycastResult = Point1.Value;
                    int x3 = terrainRaycastResult.CellFace.Point.X;
                    terrainRaycastResult = Point2.Value;
                    int x4   = terrainRaycastResult.CellFace.Point.X;
                    int num2 = Math.Max(x3, x4);
                    terrainRaycastResult = Point1.Value;
                    int y1 = terrainRaycastResult.CellFace.Point.Y;
                    terrainRaycastResult = Point2.Value;
                    int y2   = terrainRaycastResult.CellFace.Point.Y;
                    int num3 = Math.Min(y1, y2);
                    terrainRaycastResult = Point1.Value;
                    int y3 = terrainRaycastResult.CellFace.Point.Y;
                    terrainRaycastResult = Point2.Value;
                    int y4   = terrainRaycastResult.CellFace.Point.Y;
                    int num4 = Math.Max(y3, y4);
                    terrainRaycastResult = Point1.Value;
                    int z1 = terrainRaycastResult.CellFace.Point.Z;
                    terrainRaycastResult = Point2.Value;
                    int z2   = terrainRaycastResult.CellFace.Point.Z;
                    int num5 = Math.Min(z1, z2);
                    terrainRaycastResult = Point1.Value;
                    int z3 = terrainRaycastResult.CellFace.Point.Z;
                    terrainRaycastResult = Point2.Value;
                    int z4   = terrainRaycastResult.CellFace.Point.Z;
                    int num6 = Math.Max(z3, z4);
                    for (int index1 = 0; index1 <= num4 - num3; ++index1)
                    {
                        for (int index2 = 0; index2 <= num6 - num5; ++index2)
                        {
                            for (int index3 = 0; index3 <= num2 - num1; ++index3)
                            {
                                terrainRaycastResult = Point1.Value;
                                int x5 = terrainRaycastResult.CellFace.Point.X;
                                terrainRaycastResult = Point2.Value;
                                int x6 = terrainRaycastResult.CellFace.Point.X;
                                int x7;
                                int x8;
                                if (x5 > x6)
                                {
                                    terrainRaycastResult = Point1.Value;
                                    x7 = terrainRaycastResult.CellFace.Point.X - index3;
                                    terrainRaycastResult = Point3.Value;
                                    x8 = terrainRaycastResult.CellFace.Point.X - index3;
                                }
                                else
                                {
                                    terrainRaycastResult = Point1.Value;
                                    x7 = terrainRaycastResult.CellFace.Point.X + index3;
                                    terrainRaycastResult = Point3.Value;
                                    x8 = terrainRaycastResult.CellFace.Point.X + index3;
                                }
                                terrainRaycastResult = Point1.Value;
                                int y5 = terrainRaycastResult.CellFace.Point.Y;
                                terrainRaycastResult = Point2.Value;
                                int y6 = terrainRaycastResult.CellFace.Point.Y;
                                int y7;
                                int y8;
                                if (y5 > y6)
                                {
                                    terrainRaycastResult = Point1.Value;
                                    y7 = terrainRaycastResult.CellFace.Point.Y - index1;
                                    terrainRaycastResult = Point3.Value;
                                    y8 = terrainRaycastResult.CellFace.Point.Y - index1;
                                }
                                else
                                {
                                    terrainRaycastResult = Point1.Value;
                                    y7 = terrainRaycastResult.CellFace.Point.Y + index1;
                                    terrainRaycastResult = Point3.Value;
                                    y8 = terrainRaycastResult.CellFace.Point.Y + index1;
                                }
                                terrainRaycastResult = Point1.Value;
                                int z5 = terrainRaycastResult.CellFace.Point.Z;
                                terrainRaycastResult = Point2.Value;
                                int z6 = terrainRaycastResult.CellFace.Point.Z;
                                int z7;
                                int z8;
                                if (z5 > z6)
                                {
                                    terrainRaycastResult = Point1.Value;
                                    z7 = terrainRaycastResult.CellFace.Point.Z - index2;
                                    terrainRaycastResult = Point3.Value;
                                    z8 = terrainRaycastResult.CellFace.Point.Z - index2;
                                }
                                else
                                {
                                    terrainRaycastResult = Point1.Value;
                                    z7 = terrainRaycastResult.CellFace.Point.Z + index2;
                                    terrainRaycastResult = Point3.Value;
                                    z8 = terrainRaycastResult.CellFace.Point.Z + index2;
                                }
                                int cellValue = m_subsystemTerrain.Terrain.GetCellValue(x7, y7, z7);
                                if (cellValue != 15360)
                                {
                                    this.SetCell(x8, y8, z8, cellValue);
                                }
                            }
                        }
                    }
                }
            }
            else if (Keyboard.IsKeyDownOnce(Engine.Input.Key.F6) || F6.IsClicked)
            {
                if (!Point1.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 1", false, false);
                }
                else if (!Point2.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 2", false, false);
                }
                else
                {
                    TerrainRaycastResult terrainRaycastResult = Point1.Value;
                    int x1 = terrainRaycastResult.CellFace.Point.X;
                    terrainRaycastResult = Point2.Value;
                    int x2   = terrainRaycastResult.CellFace.Point.X;
                    int num1 = Math.Min(x1, x2);
                    terrainRaycastResult = Point1.Value;
                    int x3 = terrainRaycastResult.CellFace.Point.X;
                    terrainRaycastResult = Point2.Value;
                    int x4   = terrainRaycastResult.CellFace.Point.X;
                    int num2 = Math.Max(x3, x4);
                    terrainRaycastResult = Point1.Value;
                    int y1 = terrainRaycastResult.CellFace.Point.Y;
                    terrainRaycastResult = Point2.Value;
                    int y2   = terrainRaycastResult.CellFace.Point.Y;
                    int num3 = Math.Min(y1, y2);
                    terrainRaycastResult = Point1.Value;
                    int y3 = terrainRaycastResult.CellFace.Point.Y;
                    terrainRaycastResult = Point2.Value;
                    int y4   = terrainRaycastResult.CellFace.Point.Y;
                    int num4 = Math.Max(y3, y4);
                    terrainRaycastResult = Point1.Value;
                    int z1 = terrainRaycastResult.CellFace.Point.Z;
                    terrainRaycastResult = Point2.Value;
                    int z2   = terrainRaycastResult.CellFace.Point.Z;
                    int num5 = Math.Min(z1, z2);
                    terrainRaycastResult = Point1.Value;
                    int z3 = terrainRaycastResult.CellFace.Point.Z;
                    terrainRaycastResult = Point2.Value;
                    int z4   = terrainRaycastResult.CellFace.Point.Z;
                    int num6 = Math.Max(z3, z4);
                    for (int x5 = num1; x5 <= num2; ++x5)
                    {
                        for (int y5 = num3; y5 <= num4; ++y5)
                        {
                            for (int z5 = num5; z5 <= num6; ++z5)
                            {
                                this.SetCell(x5, y5, z5, SelectedBlock);
                            }
                        }
                    }
                }
            }
            else if (Keyboard.IsKeyDownOnce(Engine.Input.Key.F7) || F7.IsClicked)
            {
                if (!Point1.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 1", false, false);
                }
                else if (!Point2.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 2", false, false);
                }
                else
                {
                    TerrainRaycastResult terrainRaycastResult = Point1.Value;
                    int x1 = terrainRaycastResult.CellFace.Point.X;
                    terrainRaycastResult = Point2.Value;
                    int x2   = terrainRaycastResult.CellFace.Point.X;
                    int num1 = Math.Min(x1, x2);
                    terrainRaycastResult = Point1.Value;
                    int x3 = terrainRaycastResult.CellFace.Point.X;
                    terrainRaycastResult = Point2.Value;
                    int x4   = terrainRaycastResult.CellFace.Point.X;
                    int num2 = Math.Max(x3, x4);
                    terrainRaycastResult = Point1.Value;
                    int y1 = terrainRaycastResult.CellFace.Point.Y;
                    terrainRaycastResult = Point2.Value;
                    int y2   = terrainRaycastResult.CellFace.Point.Y;
                    int num3 = Math.Min(y1, y2);
                    terrainRaycastResult = Point1.Value;
                    int y3 = terrainRaycastResult.CellFace.Point.Y;
                    terrainRaycastResult = Point2.Value;
                    int y4   = terrainRaycastResult.CellFace.Point.Y;
                    int num4 = Math.Max(y3, y4);
                    terrainRaycastResult = Point1.Value;
                    int z1 = terrainRaycastResult.CellFace.Point.Z;
                    terrainRaycastResult = Point2.Value;
                    int z2   = terrainRaycastResult.CellFace.Point.Z;
                    int num5 = Math.Min(z1, z2);
                    terrainRaycastResult = Point1.Value;
                    int z3 = terrainRaycastResult.CellFace.Point.Z;
                    terrainRaycastResult = Point2.Value;
                    int z4   = terrainRaycastResult.CellFace.Point.Z;
                    int num6 = Math.Max(z3, z4);
                    for (int x5 = num1; x5 <= num2; ++x5)
                    {
                        for (int y5 = num3; y5 <= num4; ++y5)
                        {
                            for (int z5 = num5; z5 <= num6; ++z5)
                            {
                                if (m_subsystemTerrain.Terrain.GetCellValue(x5, y5, z5) == ReplaceableBlock)
                                {
                                    this.SetCell(x5, y5, z5, SelectedBlock);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (!Keyboard.IsKeyDownOnce(Engine.Input.Key.F8) && !F8.IsClicked)
                {
                    return;
                }
                if (!Point1.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 1", false, false);
                }
                else if (!Point2.HasValue)
                {
                    m_componentPlayer.ComponentGui.DisplaySmallMessage("You have not selected point 2", false, false);
                }
                else
                {
                    TerrainRaycastResult terrainRaycastResult = Point1.Value;
                    int x1 = terrainRaycastResult.CellFace.Point.X;
                    terrainRaycastResult = Point2.Value;
                    int x2   = terrainRaycastResult.CellFace.Point.X;
                    int num1 = Math.Min(x1, x2);
                    terrainRaycastResult = Point1.Value;
                    int x3 = terrainRaycastResult.CellFace.Point.X;
                    terrainRaycastResult = Point2.Value;
                    int x4   = terrainRaycastResult.CellFace.Point.X;
                    int num2 = Math.Max(x3, x4);
                    terrainRaycastResult = Point1.Value;
                    int y1 = terrainRaycastResult.CellFace.Point.Y;
                    terrainRaycastResult = Point2.Value;
                    int y2   = terrainRaycastResult.CellFace.Point.Y;
                    int num3 = Math.Min(y1, y2);
                    terrainRaycastResult = Point1.Value;
                    int y3 = terrainRaycastResult.CellFace.Point.Y;
                    terrainRaycastResult = Point2.Value;
                    int y4   = terrainRaycastResult.CellFace.Point.Y;
                    int num4 = Math.Max(y3, y4);
                    terrainRaycastResult = Point1.Value;
                    int z1 = terrainRaycastResult.CellFace.Point.Z;
                    terrainRaycastResult = Point2.Value;
                    int z2   = terrainRaycastResult.CellFace.Point.Z;
                    int num5 = Math.Min(z1, z2);
                    terrainRaycastResult = Point1.Value;
                    int z3 = terrainRaycastResult.CellFace.Point.Z;
                    terrainRaycastResult = Point2.Value;
                    int z4   = terrainRaycastResult.CellFace.Point.Z;
                    int num6 = Math.Max(z3, z4);
                    for (int x5 = num1; x5 <= num2; ++x5)
                    {
                        for (int y5 = num3; y5 <= num4; ++y5)
                        {
                            for (int z5 = num5; z5 <= num6; ++z5)
                            {
                                this.SetCell(x5, y5, z5, 0);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int value2 = value;

            return(GetItem(ref value2).GetPlacementValue(subsystemTerrain, componentMiner, value, raycastResult));
        }
Ejemplo n.º 21
0
 public override BlockPlacementData GetDigValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, int toolValue, TerrainRaycastResult raycastResult)
 {
     return(GetItem(ref value).GetDigValue(subsystemTerrain, componentMiner, value, toolValue, raycastResult));
 }
 public virtual IndexPosition GetRayIntersectionIndex(TerrainRaycastResult rayIntersection)
 {
     return(GetGlobalBlockCoords(rayIntersection.Chunk.IndexPosition, rayIntersection.BlockIndex.Value));
 }
Ejemplo n.º 23
0
        public void Update(float deltaTime, TerrainEditorTool selectedTool, TerrainRaycastResult rayIntersection)
        {
            terrainPhys.Terrain = terrain;

            if (terrain != null)
            {
                if (operationBatch.Count > 0)
                {
                    ApplyOperationBatch();
                    screen.UI.SetMidStatus("");
                }
                else if (undoBatch != null)
                {
                    redoStack.Push(undoBatch.GenerateUndo());
                    undoBatch.Apply();
                    undoBatch = null;
                    screen.UI.SetMidStatus("");
                }
                else if (redoBatch != null)
                {
                    undoStack.Push(redoBatch.GenerateUndo());
                    redoBatch.Apply();
                    redoBatch = null;
                    screen.UI.SetMidStatus("");
                }

                // Update selected tool
                if (selectedTool != null)
                {
                    // Process global intersection handling
                    if (rayIntersection.Intersects && !GUISystem.HandledMouseInput)
                    {
                        if (Input.GetMouseButton(MouseButton.Middle))
                        {
                            // Pick color
                            BlockColor = rayIntersection.Block.Value.GetColor();
                        }
                        else if (Input.GetMouseButtonDown(MouseButton.Left))
                        {
                            // Begin select
                            if (selectedTool.AllowUserSelecting())
                            {
                                SelectionBox.SetPrimary(selectedTool.GetRayIntersectionIndex(rayIntersection));
                                IsSelecting = true;
                            }
                        }
                        else if (Input.GetMouseButtonUp(MouseButton.Left))
                        {
                            IsSelecting = false;
                        }
                        else if (IsSelecting)
                        {
                            // Update selection box
                            bool ctrl = Input.IsControlHeld;
                            bool alt  = Input.IsAltHeld;

                            if (ctrl && alt)
                            {
                                SelectionBox.SetSecondary(selectedTool.GetRayIntersectionIndex(rayIntersection));
                            }
                            else if (ctrl)
                            {
                                IndexPosition sp    = selectedTool.GetRayIntersectionIndex(rayIntersection);
                                IndexPosition delta = new IndexPosition(
                                    Math.Abs(sp.X - SelectionBox.Primary.X),
                                    Math.Abs(sp.Y - SelectionBox.Primary.Y),
                                    Math.Abs(sp.Z - SelectionBox.Primary.Z));

                                IndexPosition fSp;

                                if (delta.X >= delta.Y && delta.X >= delta.Z)
                                {
                                    // X normal
                                    fSp = new IndexPosition(sp.X, SelectionBox.Primary.Y, SelectionBox.Primary.Z);
                                }
                                else if (delta.Y >= delta.X && delta.Y >= delta.Z)
                                {
                                    // Y normal
                                    fSp = new IndexPosition(SelectionBox.Primary.X, sp.Y, SelectionBox.Primary.Z);
                                }
                                else
                                {
                                    // Z normal
                                    fSp = new IndexPosition(SelectionBox.Primary.X, SelectionBox.Primary.Y, sp.Z);
                                }

                                SelectionBox.SetSecondary(fSp);
                            }
                            else
                            {
                                SelectionBox.SetSecondary(SelectionBox.Primary);
                            }
                        }
                    }
                }

                // Preform undo/redo
                if (Input.IsControlHeld)
                {
                    if (Input.GetKeyDown(Key.Z))
                    {
                        if (undoStack.Count > 0)
                        {
                            undoBatch = undoStack.Pop();
                        }
                    }
                    else if (Input.GetKeyDown(Key.Y))
                    {
                        if (redoStack.Count > 0)
                        {
                            redoBatch = redoStack.Pop();
                        }
                    }
                }

                // Show 'apply dialog' before application freezes from operation
                if (operationBatch.Count > 0 || undoBatch != null || redoBatch != null)
                {
                    screen.UI.SetMidStatus("Applying Operation...");
                }
            }
        }
Ejemplo n.º 24
0
        public static BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);
            int     realdata          = 0;//位置修正
            Vector3 forward           = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num  = Vector3.Dot(forward, Vector3.UnitZ);
            float   num2 = Vector3.Dot(forward, Vector3.UnitX);
            float   num3 = Vector3.Dot(forward, -Vector3.UnitZ);
            float   num4 = Vector3.Dot(forward, -Vector3.UnitX);

            if (num == MathUtils.Max(num, num2, num3, num4))
            {
                realdata = 2;
            }
            else if (num2 == MathUtils.Max(num, num2, num3, num4))
            {
                realdata = 3;
            }
            else if (num3 == MathUtils.Max(num, num2, num3, num4))
            {
                realdata = 0;
            }
            else if (num4 == MathUtils.Max(num, num2, num3, num4))
            {
                realdata = 1;
            }
            result.Value    = ILibrary.setDirection(value, realdata);//4*4表示方块位置,朝向
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Ejemplo n.º 25
0
 public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
 {
     return(new BlockPlacementData
     {
         Value = GetType(value) == 0 ? 0 : Terrain.ReplaceLight(value, 0),
         CellFace = raycastResult.CellFace
     });
 }
Ejemplo n.º 26
0
 public bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
 {
     return(componentMiner.Project.FindSubsystem <SubsystemSignBlockBehavior>(true).OnInteract(raycastResult, componentMiner));
 }
Ejemplo n.º 27
0
 public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
 {
     return(ILibrary.GetPlacementValue(subsystemTerrain, componentMiner, value, raycastResult));
 }
 public EditorWorldRaycastResult(TerrainRaycastResult result)
     : base(result)
 {
     TerrainResult      = result;
     EditorObjectResult = new EditorObjectRaycastResult(result.Ray);
 }
        public override bool OnInteract(TerrainRaycastResult raycastResult, ComponentMiner componentMiner)
        {
            ComponentEnergyMachine mcomponent;
            ComponentFluidStore    componentFluidStore;
            PanelWidget            panelWidget = new PanelWidget();
            int    value = raycastResult.Value;
            Point3 point = raycastResult.CellFace.Point;
            int    ID    = ILibrary.getItemId(value);

            if (Terrain.ExtractContents(value) == 1003)
            {
                switch (ID)
                {
                case 27:
                    mcomponent = subsystemBlockEntities.GetBlockEntity(point.X, point.Y, point.Z).Entity.FindComponent <ComponentCoalGenerator>(true);
                    componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new CoalGeneratorWidget((ComponentCoalGenerator)mcomponent);
                    break;

                case 30:
                    mcomponent = subsystemBlockEntities.GetBlockEntity(point.X, point.Y, point.Z).Entity.FindComponent <CptEgySolarGtor>(true);
                    componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new AspSolarWidget((CptEgySolarGtor)mcomponent);
                    break;

                case 40:
                    NewMutiBlockCheck.Result result = mutiBlockCheck.checkMutiBlocks(SubsystemTerrain.Terrain, point, dynamic_outsideaccept, dynamic_insideaccept, dynamic_sideaccept, dynamic_faceaccept);
                    if (result.finish)
                    {
                        componentFluidStore = subsystemBlockEntities.GetBlockEntity(result.savaPoint.X, result.savaPoint.Y, result.savaPoint.Z).Entity.FindComponent <ComponentMekDynamic>(true);
                        componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new MekDynamicWidget((ComponentMekDynamic)componentFluidStore);
                    }
                    break;

                case 41:
                    result = mutiBlockCheck.checkMutiBlocks(SubsystemTerrain.Terrain, point, dynamic_outsideaccept, dynamic_insideaccept, dynamic_sideaccept, dynamic_faceaccept);
                    if (result.finish)
                    {
                        componentFluidStore = subsystemBlockEntities.GetBlockEntity(result.savaPoint.X, result.savaPoint.Y, result.savaPoint.Z).Entity.FindComponent <ComponentMekDynamic>(true);
                        componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new MekDynamicWidget((ComponentMekDynamic)componentFluidStore);
                    }
                    break;

                case 47:
                    mcomponent = subsystemBlockEntities.GetBlockEntity(point.X, point.Y, point.Z).Entity.FindComponent <ComponentCrusher>();
                    componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new CrusherWidget((ComponentCrusher)mcomponent);
                    break;

                case 48: break;

                case 49: break;

                case 50: break;

                case 51: break;

                case 52: break;

                case 63:    //基础能量立方
                    mcomponent = subsystemBlockEntities.GetBlockEntity(point.X, point.Y, point.Z).Entity.FindComponent <ComponentEnergyMachine>(true);
                    componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new EnergyCubeWidget(mcomponent);
                    break;

                case 64:
                    if (Terrain.ExtractContents(componentMiner.ActiveBlockValue) == 1006 && Terrain.ExtractData(componentMiner.ActiveBlockValue) == 500)
                    {
                        return(true);
                    }
                    if (tranmitPoints.TryGetValue(point, out NewMutiBlockCheck.TranmitResult tranmitResult))
                    {
                        componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage("conn:" + tranmitResult.connectPoint.ToString(), false, false);
                    }
                    break;

                case 65:

                    break;

                case 72:         //充能冶炼炉
                    mcomponent = subsystemBlockEntities.GetBlockEntity(point.X, point.Y, point.Z).Entity.FindComponent <ComponentSmelt>(true);
                    componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new MekSmeltWidget((ComponentSmelt)mcomponent);
                    break;

                case 78:    //富集仓
                    mcomponent = subsystemBlockEntities.GetBlockEntity(point.X, point.Y, point.Z).Entity.FindComponent <ComponentEnrich>(true);
                    componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new EnrichWidget((ComponentEnrich)mcomponent);
                    break;

                case 80:    //合金炉
                    mcomponent = subsystemBlockEntities.GetBlockEntity(point.X, point.Y, point.Z).Entity.FindComponent <ComponentAlloy>(true);
                    componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new AlloyWidget((ComponentAlloy)mcomponent);
                    break;

                case 82:    //制造厂
                    mcomponent = subsystemBlockEntities.GetBlockEntity(point.X, point.Y, point.Z).Entity.FindComponent <ComponentManufactory>(true);
                    componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new ManufactoryWidget((ComponentManufactory)mcomponent);
                    break;

                default:
                    panelWidget.setText(subsystemItemElectric.scanSlot(SubsystemTerrain.Terrain, point));
                    component.ComponentGui.ModalPanelWidget = panelWidget;
                    break;
                }
            }
            else if (Terrain.ExtractContents(value) == 1007)
            {
                switch (ID)
                {
                case 39:
                    NewMutiBlockCheck.Result result = mutiBlockCheck.checkMutiBlocks(SubsystemTerrain.Terrain, point, dynamic_outsideaccept, dynamic_insideaccept, dynamic_sideaccept, dynamic_faceaccept);
                    if (result.finish)
                    {
                        componentFluidStore = subsystemBlockEntities.GetBlockEntity(result.savaPoint.X, result.savaPoint.Y, result.savaPoint.Z).Entity.FindComponent <ComponentMekDynamic>(true);
                        componentMiner.ComponentPlayer.ComponentGui.ModalPanelWidget = new MekDynamicWidget((ComponentMekDynamic)componentFluidStore);
                    }
                    break;
                }
            }
            return(false);
        }
Ejemplo n.º 30
0
        protected override void Update(float deltaTime)
        {
            if (GlobalNetwork.IsClient)
            {
                if (Input.GetControlDown("PickColor"))
                {
                    PickColor();
                }

                int ocx = ColorX, ocy = ColorY;
                if (Input.GetKeyDown(Key.Up) && ColorY > 0)
                {
                    ColorY--;
                }
                if (Input.GetKeyDown(Key.Down) && ColorY < (PaletteHeight - 1))
                {
                    ColorY++;
                }
                if (Input.GetKeyDown(Key.Left) && ColorX > 0)
                {
                    ColorX--;
                }
                if (Input.GetKeyDown(Key.Right) && ColorX < (PaletteWidth - 1))
                {
                    ColorX++;
                }

                if (ocx != ColorX || ocy != ColorY)
                {
                    BlockColor = Colors[ColorY, ColorX];
                }

                TerrainRaycastResult result = World.TerrainPhysics.Raycast(
                    new Ray(Camera.Position, Camera.ViewMatrix.Forward()), true, PLACE_RANGE);

                if (result.Intersects)
                {
                    IndexPosition ipos = ShiftIPos(result.BlockIndex.Value, result.IntersectionCubeSide.Value);
                    IndexPosition newChunkPos;
                    Chunk.WrapBlockCoords(ipos.X, ipos.Y, ipos.Z, result.Chunk.IndexPosition, out ipos, out newChunkPos);

                    globalMousePosition = Terrain.GetGlobalBlockCoords(newChunkPos, ipos);

                    mouseOverBlock = true;
                }
                else
                {
                    mouseOverBlock = false;
                }

                if (holdingDown)
                {
                    if (mouseOverBlock)
                    {
                        endGlobalPosition = globalMousePosition;
                    }

                    if (Input.GetControlUp("SecondaryFire"))
                    {
                        holdingDown     = false;
                        primaryCooldown = Config.PrimaryFireDelay;

                        if (mouseOverBlock)
                        {
                            buildAudioSource?.Play();

                            Vector3 startWorld = startGlobalPosition * Block.CUBE_3D_SIZE;
                            Vector3 endWorld   = endGlobalPosition * Block.CUBE_3D_SIZE;
                            Ray     ray        = new Ray(startWorld, endWorld - startWorld);
                            RayPlace(ray);
                        }
                    }
                }
            }

            base.Update(deltaTime);
        }