Hallucination system
This commit is contained in:
+39
-1
@@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UI;
|
||||
using Unheimlich.Core;
|
||||
using Unheimlich.Features.DetectiveBoard;
|
||||
using Unheimlich.Features.Player;
|
||||
using Unheimlich.World.CameraSystem;
|
||||
@@ -14,7 +15,7 @@ namespace Unheimlich.Features.DetectiveBoard.UI
|
||||
/// Manages hover, selection, dragging, and click forwarding for Post-It nodes.
|
||||
/// Interactions are only active when the board is in inspection mode.
|
||||
/// </summary>
|
||||
public class DetectiveBoardInteraction : MonoBehaviour
|
||||
public class DetectiveBoardInteraction : Singleton<DetectiveBoardInteraction>
|
||||
{
|
||||
[Header("Settings")]
|
||||
[SerializeField] private LayerMask _boardLayer;
|
||||
@@ -33,6 +34,8 @@ namespace Unheimlich.Features.DetectiveBoard.UI
|
||||
private Plane _canvasPlane;
|
||||
private Vector3 _dragOffset;
|
||||
|
||||
protected override void OnAwake() { }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_boardCanvas = GetComponent<Canvas>();
|
||||
@@ -349,6 +352,41 @@ namespace Unheimlich.Features.DetectiveBoard.UI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Positions a freshly-created board node under the current mouse cursor
|
||||
/// and immediately enters drag mode on it, so the player can place it freely.
|
||||
/// Called by ClueHandUI after AddClueNode.
|
||||
/// </summary>
|
||||
public void SpawnNodeUnderMouseAndDrag(PostItNode node)
|
||||
{
|
||||
if (node == null || _camera == null)
|
||||
return;
|
||||
|
||||
UpdateCanvasPlane();
|
||||
|
||||
Vector2 mousePos = Mouse.current != null
|
||||
? Mouse.current.position.ReadValue()
|
||||
: new Vector2(Screen.width * 0.5f, Screen.height * 0.5f);
|
||||
|
||||
Ray ray = _camera.ScreenPointToRay(new Vector3(mousePos.x, mousePos.y, 0f));
|
||||
|
||||
if (_canvasPlane.Raycast(ray, out float enter))
|
||||
{
|
||||
Vector3 worldHitPoint = ray.GetPoint(enter);
|
||||
Vector3 localPos = _boardCanvas.transform.InverseTransformPoint(worldHitPoint);
|
||||
node.SetPosition(new Vector2(localPos.x, localPos.y));
|
||||
}
|
||||
|
||||
// Begin drag with zero offset so the node centre tracks the mouse exactly
|
||||
if (_selectedNode != null)
|
||||
_selectedNode.SetSelected(false);
|
||||
|
||||
_selectedNode = node;
|
||||
_selectedNode.SetSelected(true);
|
||||
_isDragging = true;
|
||||
_dragOffset = Vector3.zero;
|
||||
}
|
||||
|
||||
private PostItNode RaycastForNode()
|
||||
{
|
||||
if (_camera == null || Mouse.current == null)
|
||||
|
||||
Reference in New Issue
Block a user