Exemplo n.º 1
0
        public override void Update(DwarfGame game, DwarfTime time)
        {
            if (Player.IsCameraRotationModeActive())
            {
                Player.VoxSelector.Enabled = false;
                Player.World.SetMouse(null);
                Player.BodySelector.Enabled = false;
                return;
            }

            Player.VoxSelector.Enabled  = true;
            Player.BodySelector.Enabled = false;

            if (Player.World.IsMouseOverGui)
            {
                Player.World.SetMouse(Player.World.MousePointer);
            }
            else
            {
                Player.World.SetMouse(new Gui.MousePointer("mouse", 1, 4));
            }

            KeyboardState state    = Keyboard.GetState();
            bool          leftKey  = state.IsKeyDown(ControlSettings.Mappings.RotateObjectLeft);
            bool          rightKey = state.IsKeyDown(ControlSettings.Mappings.RotateObjectRight);

            if (LeftPressed && !leftKey)
            {
                Pattern = Pattern.Rotate(Rail.Orientation.East);
            }
            if (RightPressed && !rightKey)
            {
                Pattern = Pattern.Rotate(Rail.Orientation.West);
            }
            LeftPressed  = leftKey;
            RightPressed = rightKey;

            var voxelUnderMouse = Player.VoxSelector.VoxelUnderMouse;

            UpdatePreviewBodies(voxelUnderMouse);

            var tint = Color.White;

            if (CanPlace(voxelUnderMouse))
            {
                tint = Color.Green;
            }
            else
            {
                tint = Color.Red;
            }
            foreach (var body in PreviewBodies)
            {
                body.SetTintRecursive(tint);
            }
        }
Exemplo n.º 2
0
 public override void OnEnd()
 {
     foreach (var body in PreviewBodies)
     {
         body.Delete();
     }
     PreviewBodies.Clear();
     Pattern           = null;
     SelectedResources = null;
 }