diff --git a/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/ArmChair_Taakka_Furniture.prefab b/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/ArmChair_Taakka_Furniture.prefab index 1a2910bad2..cde00c4ec1 100644 --- a/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/ArmChair_Taakka_Furniture.prefab +++ b/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/ArmChair_Taakka_Furniture.prefab @@ -157,6 +157,8 @@ MonoBehaviour: _trayFurnitureObject: {fileID: 6752174233831251881, guid: 1b28187fcb500d44994fdaf7a4ce0946, type: 3} cullCheckAmount: 0.1 + _hasInteractionSlot: 1 + Pattern: 1 --- !u!210 &5631410605880800485 SortingGroup: m_ObjectHideFlags: 0 diff --git a/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/CoffeeTable_Taakka_Furniture.prefab b/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/CoffeeTable_Taakka_Furniture.prefab index c2c3655680..bfdf957b73 100644 --- a/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/CoffeeTable_Taakka_Furniture.prefab +++ b/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/CoffeeTable_Taakka_Furniture.prefab @@ -157,6 +157,8 @@ MonoBehaviour: _trayFurnitureObject: {fileID: 6752174233831251881, guid: 51a482fa8b9398d41af78f689c11ef7c, type: 3} cullCheckAmount: 0.1 + _hasInteractionSlot: 1 + Pattern: 1 --- !u!210 &4009186818869656794 SortingGroup: m_ObjectHideFlags: 0 diff --git a/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/Floorlamp_Taakka_Furniture.prefab b/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/Floorlamp_Taakka_Furniture.prefab index 32166be919..0545aabb35 100644 --- a/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/Floorlamp_Taakka_Furniture.prefab +++ b/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/Floorlamp_Taakka_Furniture.prefab @@ -157,6 +157,8 @@ MonoBehaviour: _trayFurnitureObject: {fileID: 6752174233831251881, guid: 9a69f4ef2d7504345bd286ab4ffdb68c, type: 3} cullCheckAmount: 0.1 + _hasInteractionSlot: 1 + Pattern: 0 --- !u!210 &4891055075118862418 SortingGroup: m_ObjectHideFlags: 0 diff --git a/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/Sofa_Taakka_Furniture.prefab b/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/Sofa_Taakka_Furniture.prefab index ae2544ba08..a2f994cf1e 100644 --- a/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/Sofa_Taakka_Furniture.prefab +++ b/Assets/MenuUi/Prefabs/Windows/SoulHome/Furniture Assets/Taakka/Sofa_Taakka_Furniture.prefab @@ -157,6 +157,8 @@ MonoBehaviour: _trayFurnitureObject: {fileID: 6752174233831251881, guid: 4e82351aae20cc84899b237b1cb3093a, type: 3} cullCheckAmount: 0.1 + _hasInteractionSlot: 1 + Pattern: 0 --- !u!210 &6881114897110281887 SortingGroup: m_ObjectHideFlags: 0 diff --git a/Assets/MenuUi/Scripts/SoulHome/FurnitureHandling.cs b/Assets/MenuUi/Scripts/SoulHome/FurnitureHandling.cs index 9bbc7bbd0b..54a2bc56cd 100644 --- a/Assets/MenuUi/Scripts/SoulHome/FurnitureHandling.cs +++ b/Assets/MenuUi/Scripts/SoulHome/FurnitureHandling.cs @@ -1,12 +1,16 @@ using System.Collections; using System.Collections.Generic; using Altzone.Scripts.Model.Poco.Game; +using UnityEditor.Graphs; using UnityEngine; +using UnityEngine.InputSystem.XR; using UnityEngine.Rendering; using Debug = Prg.Debug; namespace MenuUI.Scripts.SoulHome { + + public class FurnitureHandling : MonoBehaviour { public enum Direction @@ -16,6 +20,11 @@ public enum Direction Right, Back } + public enum InteractionPattern + { + Surround, // All surrounding slots + FrontRow, // All slots along the "front" width + } [SerializeField] private string _name; @@ -39,6 +48,7 @@ public enum Direction [SerializeField] private SortingGroup _sortingGroup; + private Furniture _furniture; [SerializeField] private GameObject _trayFurnitureObject; @@ -50,6 +60,95 @@ public enum Direction private FurnitureSlot _slot; private FurnitureSlot _tempSlot; + [SerializeField] + private bool _hasInteractionSlot = false; + private Vector2Int _interactionOffset = new Vector2Int(0, 1); + public bool HasInteractionSlot => _hasInteractionSlot; + + //[SerializeField] public InteractionPattern Pattern = InteractionPattern.FrontRow; + public List AssignedInteractionSlots { get; private set; } = new List(); + + [HideInInspector] + public List customInteractionOffsets = new List(); + + [Header("Dimensions (Edit Mode Configurations)")] + [SerializeField] private int _width = 1; + [SerializeField] private int _height = 1; + + public int Width => _width; + public int Height => _height; + + public void ClearInteractionSlots() + { + foreach (var slot in AssignedInteractionSlots) + { + slot.IsReserved = false; + slot.InteractionOwner = null; + slot.ClearValidity(); + } + AssignedInteractionSlots.Clear(); + } + + public void AddInteractionSlot(FurnitureSlot slot) + { + if (!AssignedInteractionSlots.Contains(slot)) + { + slot.IsReserved = true; + AssignedInteractionSlots.Add(slot); + } + } + + //Get closest interaction slot for npc to path to + public FurnitureSlot GetClosestInteractionSlot(Vector3 npcPosition) + { + if (AssignedInteractionSlots == null || AssignedInteractionSlots.Count == 0) + return null; + + FurnitureSlot closest = null; + float minDistance = float.MaxValue; + + foreach (var slot in AssignedInteractionSlots) + { + float dist = Vector3.Distance(npcPosition, slot.transform.position); + if (dist < minDistance) + { + minDistance = dist; + closest = slot; + } + } + return closest; + } + + public void StartInteract(SoulHomeAvatarController controller) + { + StartCoroutine(InteractRoutine(controller)); + } + + private IEnumerator InteractRoutine(SoulHomeAvatarController controller) + { + GameObject original = controller.gameObject; + original.SetActive(false); + + GameObject dummy = Instantiate(original); + dummy.SetActive(true); + + dummy.transform.SetParent(this.transform, true); + dummy.transform.localPosition = Vector3.zero; + + Animator dummyAnim = dummy.GetComponentInChildren(); + //dummyAnim.Play(""); + + //yield return new WaitForEndOfFrame(); // Wait for animator to update + //float animLength = dummyAnim.GetCurrentAnimatorStateInfo(0).length; + //yield return new WaitForSeconds(animLength); + + //Temporary + yield return new WaitForSeconds(10); + + Destroy(dummy); + original.SetActive(true); + } + public Furniture Furniture { get => _furniture; set => _furniture = value; } public Vector2 Position { get => _position; set => _position = value; } public FurnitureSlot Slot { get => _slot; @@ -126,6 +225,10 @@ void Start() public Vector3Int GetFurnitureSize() { + if (Furniture == null) + { + return new Vector3Int(_width, _height, 0); + } if (Furniture.IsRotated) return Furniture.GetFurnitureSizeRotated(); return Furniture.GetFurnitureNormalSize(); } diff --git a/Assets/MenuUi/Scripts/SoulHome/FurnitureInteractionCustomEditor.cs b/Assets/MenuUi/Scripts/SoulHome/FurnitureInteractionCustomEditor.cs new file mode 100644 index 0000000000..14bd7a61f0 --- /dev/null +++ b/Assets/MenuUi/Scripts/SoulHome/FurnitureInteractionCustomEditor.cs @@ -0,0 +1,83 @@ +using MenuUI.Scripts.SoulHome; +using UnityEditor; +using UnityEngine; + +[CustomEditor(typeof(FurnitureHandling))] +public class FurnitureInteractionCustomEditor : Editor +{ + private SerializedProperty widthProp; + private SerializedProperty heightProp; + + private void OnEnable() + { + widthProp = serializedObject.FindProperty("_width"); + heightProp = serializedObject.FindProperty("_height"); + } + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + serializedObject.Update(); + + FurnitureHandling script = (FurnitureHandling)target; + + if (widthProp.intValue < 1) widthProp.intValue = 1; + if (heightProp.intValue < 1) heightProp.intValue = 1; + + GUILayout.Space(15); + EditorGUILayout.HelpBox("GREEN = Furniture Body (Size)\nYELLOW = Interaction Slots", MessageType.Info); + GUILayout.Label("Custom Interaction Pattern (Front View)", EditorStyles.boldLabel); + + int width = widthProp.intValue; + int height = heightProp.intValue; + + if (width <= 0 || height <= 0) + { + EditorGUILayout.HelpBox($"Size is 0 or negative.", MessageType.Warning); + return; + } + + for (int y = 1; y >= -height; y--) + { + EditorGUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + + for (int x = -1; x <= width; x++) + { + Vector2Int pos = new Vector2Int(x, y); + + bool isInteraction = script.customInteractionOffsets.Contains(pos); + bool isFurnitureBody = (x >= 0 && x < width && y <= 0 && y > -height); + + if (isFurnitureBody) GUI.backgroundColor = Color.green; + else if (isInteraction) GUI.backgroundColor = Color.yellow; + else GUI.backgroundColor = Color.white; + + string buttonText = isFurnitureBody ? "F" : (isInteraction ? "I" : ""); + + if (GUILayout.Button(buttonText, GUILayout.Width(30), GUILayout.Height(30))) + { + if (!isFurnitureBody) + { + Undo.RecordObject(script, "Modify Custom Interaction Slot"); + if (isInteraction) script.customInteractionOffsets.Remove(pos); + else script.customInteractionOffsets.Add(pos); + + EditorUtility.SetDirty(script); + } + } + GUI.backgroundColor = Color.white; + } + GUILayout.FlexibleSpace(); + EditorGUILayout.EndHorizontal(); + } + + if (GUILayout.Button("Clear Pattern")) + { + Undo.RecordObject(script, "Clear Interaction Pattern"); + script.customInteractionOffsets.Clear(); + EditorUtility.SetDirty(script); + } + + serializedObject.ApplyModifiedProperties(); + } +} diff --git a/Assets/MenuUi/Scripts/SoulHome/FurnitureInteractionCustomEditor.cs.meta b/Assets/MenuUi/Scripts/SoulHome/FurnitureInteractionCustomEditor.cs.meta new file mode 100644 index 0000000000..e159e6bb34 --- /dev/null +++ b/Assets/MenuUi/Scripts/SoulHome/FurnitureInteractionCustomEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0425e049265e0f24291294d300431efc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/MenuUi/Scripts/SoulHome/FurnitureSlot.cs b/Assets/MenuUi/Scripts/SoulHome/FurnitureSlot.cs index 9174dc7f37..6e85c77009 100644 --- a/Assets/MenuUi/Scripts/SoulHome/FurnitureSlot.cs +++ b/Assets/MenuUi/Scripts/SoulHome/FurnitureSlot.cs @@ -27,6 +27,11 @@ public class FurnitureSlot : MonoBehaviour [SerializeField] private SpriteRenderer _slotValidityIndicator; + public bool IsReserved { get; set; } + + public FurnitureHandling InteractionOwner; + public FurnitureHandling SlotOwner; + public Furniture Furniture { get => furniture; set { @@ -82,9 +87,14 @@ public void InitializeSlot(int row, int column, int id, FurnitureGrid furnitureG _slotValidityIndicator.sortingOrder = id*1000 + 901; } - public void SetValidity(bool validity) + public void SetValidity(bool validity, bool isInteractSlot = false) { - if (validity) + if (isInteractSlot) + { + + _slotValidityIndicator.color = new Color(1, 1, 0, 0.3f); //Yellow + } + else if (validity) { _slotValidityIndicator.color = new Color(0,1,0, 0.3f); } diff --git a/Assets/MenuUi/Scripts/SoulHome/RoomData.cs b/Assets/MenuUi/Scripts/SoulHome/RoomData.cs index 883e2fd44f..1a31f336aa 100644 --- a/Assets/MenuUi/Scripts/SoulHome/RoomData.cs +++ b/Assets/MenuUi/Scripts/SoulHome/RoomData.cs @@ -1193,5 +1193,15 @@ public void ResetPosition(GameObject furniture, bool temp) } furniture.GetComponent().SetScale(); } + + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + public void AddToValidityList(FurnitureSlot slot) + { + if (slot != null && !_currentSlotValidity.Contains(slot)) + { + _currentSlotValidity.Add(slot); + } + } + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } } diff --git a/Assets/MenuUi/Scripts/SoulHome/SoulHomeAvatarController.cs b/Assets/MenuUi/Scripts/SoulHome/SoulHomeAvatarController.cs index a4a4807470..f3ddef6712 100644 --- a/Assets/MenuUi/Scripts/SoulHome/SoulHomeAvatarController.cs +++ b/Assets/MenuUi/Scripts/SoulHome/SoulHomeAvatarController.cs @@ -25,6 +25,7 @@ public class SoulHomeAvatarController : MonoBehaviour, ISoulHomeObjectClick [SerializeField] private float _roomChangeCooldown = 20f; // Percentage chance of avatar changing rooms when moving [SerializeField] private float _roomChangeChance = 50f; + [SerializeField] private float _furnitureInteractChance = 50f; [SerializeField] private SortingGroup _sortingGroup; [SerializeField] @@ -46,6 +47,8 @@ public class SoulHomeAvatarController : MonoBehaviour, ISoulHomeObjectClick private AvatarStatus _status; + private FurnitureHandling _targetFurniture; + private Transform _points; private RoomData _roomData; private List _travelPoints = new(); @@ -82,7 +85,7 @@ void Start() { //_animator.keepAnimatorStateOnDisable = true; _animator.writeDefaultValuesOnDisable = true; - + if (transform.parent.CompareTag("Room")) { @@ -176,10 +179,21 @@ private IEnumerator HandleIdle() while (elapsed < idleTime) { elapsed += Time.deltaTime; - yield return null; } + //Random chance to move towards furniture + if (Random.Range(0, 100) < _furnitureInteractChance) + { + FurnitureHandling[] items = _roomData.GetComponentsInChildren(); + if (items.Length > 0) + { + int randomIndex = Random.Range(0, items.Length); + MoveToFurniture(items[randomIndex].gameObject); + yield break; + } + } + SelectStatus(); } @@ -267,7 +281,8 @@ private IEnumerator MoveRoutine(bool changeRoom) } else { - SelectStatus(); + OnArrival(); // always ends in SelectStatus() + //SelectStatus(); } } @@ -683,6 +698,8 @@ private IEnumerator InteractAnimation() SelectStatus(); } + + private List ValidateAnimations(List animationToValidate) { List validatedAnimation = new(); @@ -734,6 +751,45 @@ public void HandleClick() StartCoroutine(InteractAnimation()); } + public void MoveToFurniture(GameObject furnitureObj) + { + _targetFurniture = furnitureObj.GetComponent(); + if (_targetFurniture == null) return; + + FurnitureSlot targetSlot = _targetFurniture.GetClosestInteractionSlot(transform.position); + if (targetSlot != null) + { + if (_statusCoroutine != null) StopCoroutine(_statusCoroutine); + _travelPoints.Clear(); + _status = AvatarStatus.Wander; + + Vector2Int targetGridPos = new Vector2Int(targetSlot.column, targetSlot.row); + HandleWander(targetGridPos); + } + else + { + _targetFurniture = null; + SelectStatus(); + } + } + + private void OnArrival() + { + if (_targetFurniture != null) + { + _targetFurniture.StartInteract(this); + Debug.Log($"NPC arrived at: {_targetFurniture.gameObject.name}"); + _targetFurniture = null; + + //Temporary until real furniture interaction is added + StartCoroutine(InteractAnimation()); + } + else + { + SelectStatus(); + } + } + #if UNITY_EDITOR private void OnDrawGizmos() diff --git a/Assets/MenuUi/Scripts/SoulHome/TowerController.cs b/Assets/MenuUi/Scripts/SoulHome/TowerController.cs index 58e0782c03..c0b5ecd1f0 100644 --- a/Assets/MenuUi/Scripts/SoulHome/TowerController.cs +++ b/Assets/MenuUi/Scripts/SoulHome/TowerController.cs @@ -9,6 +9,8 @@ using UnityEngine.InputSystem; using Altzone.Scripts.Model.Poco.Game; using Altzone.Scripts.Audio; +using static MenuUI.Scripts.SoulHome.FurnitureHandling; +using UnityEditor.Graphs; namespace MenuUI.Scripts.SoulHome { @@ -226,7 +228,7 @@ void Update() //Debug.Log("Touch: X: " + (prevp.x - lp.x)); if (touch.phase is UnityEngine.InputSystem.TouchPhase.Ended or UnityEngine.InputSystem.TouchPhase.Canceled) { - startScrollSlide = new Vector2(Mathf.Abs(prevp.x - lp.x) / scrollSpeed, 0); + startScrollSlide = new Vector2(Mathf.Abs(prevp.x - lp.x) / scrollSpeed, 0); currentScrollSlide = startScrollSlide; currentScrollSlideDirection = new Vector2(prevp.x - lp.x, 0); currentScrollSlideDirection.Normalize(); @@ -383,7 +385,7 @@ public bool FindRayPoint(Vector2 relPoint, ClickState click) } //_furnitureList.Add(furnitureObject); } - } + } if (hit2.collider.gameObject.CompareTag("Room")) { @@ -543,7 +545,7 @@ private void ClampCameraDistance(float change) public void ZoomIn(GameObject room) { _camera.transform.position = new(room.transform.position.x, room.transform.position.y + room.GetComponent().size.y / 2,_camera.transform.position.z); - + outDelay = Time.time; Vector3 bl = _camera.ViewportToWorldPoint(new Vector3(0, 0, Mathf.Abs(_camera.transform.position.z))); @@ -644,10 +646,105 @@ public void PlaceFurniture(Vector2 hitPoint, bool hover) int prevRoomId = (_selectedFurniture.transform.parent != null && _selectedFurniture.transform.parent.GetComponent() != null) ? _selectedFurniture.transform.parent.GetComponent().roomId : -1; foreach (RaycastHit2D hit2 in hitArray) { + if (hit2.collider.gameObject.CompareTag("Room")) { check = hit2.collider.GetComponent().HandleFurniturePosition(hitArray, _selectedFurniture, hover, hitPoint, hitRoom); + + //Displayment of interact slots during placement + if ((hover || check) && _selectedFurniture != null) + { + FurnitureHandling handling = _selectedFurniture.GetComponent(); + FurnitureSlot hoveredSlot = GetHoveredSlot(hitArray); + + if (hoveredSlot != null && handling.HasInteractionSlot) + { + RoomData room = hit2.collider.GetComponent(); + + int W = handling.Furniture.GetFurnitureNormalSize().x; + int H = handling.Furniture.GetFurnitureNormalSize().y; + + foreach (Vector2Int offset in handling.customInteractionOffsets) + { + Vector2Int rotatedOffset = offset; + switch (handling.TempSpriteDirection) + { + case Direction.Front: + rotatedOffset = offset; + rotatedOffset.x = offset.x; + rotatedOffset.y = -offset.y - H + 1; + break; + + case Direction.Right: + rotatedOffset = new Vector2Int(offset.y + H - 1, -offset.x); + break; + + case Direction.Left: + rotatedOffset = new Vector2Int(-offset.y, offset.x - (W - 1)); + break; + } + + int targetCol = hoveredSlot.column + rotatedOffset.x; + int targetRow = hoveredSlot.row + rotatedOffset.y; + + HighlightSlot(room, targetCol, targetRow); + } + } + } + + //Save interaction slots on placement + if (!hover && check && _selectedFurniture != null) + { + FurnitureHandling handling = _selectedFurniture.GetComponent(); + + if (handling.HasInteractionSlot) + { + handling.ClearInteractionSlots(); + FurnitureSlot hoveredSlot = GetHoveredSlot(hitArray); + + if (hoveredSlot != null) + { + RoomData room = hit2.collider.GetComponent(); + + int W = handling.Furniture.GetFurnitureNormalSize().x; + int H = handling.Furniture.GetFurnitureNormalSize().y; + + foreach (Vector2Int offset in handling.customInteractionOffsets) + { + Vector2Int rotatedOffset = offset; + + switch (handling.TempSpriteDirection) + { + case Direction.Front: + rotatedOffset = offset; + rotatedOffset.x = offset.x; + rotatedOffset.y = -offset.y - H + 1; + break; + + case Direction.Right: + rotatedOffset = new Vector2Int(offset.y + H - 1, -offset.x); + break; + + case Direction.Back: + rotatedOffset = new Vector2Int(-offset.x + W - 1, -offset.y - (H - 1)); + break; + + case Direction.Left: + rotatedOffset = new Vector2Int(-offset.y, offset.x - (W - 1)); + break; + } + + int targetCol = hoveredSlot.column + rotatedOffset.x; + int targetRow = hoveredSlot.row + rotatedOffset.y; + + HighlightSlot(room, targetCol, targetRow); + SaveSlot(room, targetCol, targetRow, handling); + } + } + } + } } + } if (hover) { @@ -777,7 +874,7 @@ public void ResetChanges() int roomId = furniture.GetComponent().TempSlot.roomId; _rooms.transform.GetChild(roomId).GetChild(0).GetComponent().FreeFurnitureSlots(furniture.GetComponent(), furniture.GetComponent().TempSlot); } - + furniture.GetComponent().ResetSlot(); furniture.GetComponent().ResetDirection(); } @@ -976,5 +1073,72 @@ public float GetCameraXDistance() //Debug.Log(widthToEdge + ":" + cameraAngle + ":" + Mathf.Tan(cameraAngle * (Mathf.PI / 180)) + ":" + distanceMaxX); return distanceMaxX; } + + private FurnitureSlot GetHoveredSlot(RaycastHit2D[] hits) + { + foreach (RaycastHit2D hit in hits) + { + if (hit.collider.CompareTag("FloorFurnitureSlot") || hit.collider.CompareTag("WallFurnitureSlot")) + { + return hit.collider.GetComponent(); + } + } + return null; + } + + //Helper method for saving interctable slots + private void SaveSlot(RoomData room, int col, int row, FurnitureHandling handling) + { + if (col >= 0 && col < room.SlotColumns && row >= 0 && row < room.SlotRows) + { + FurnitureSlot slot = room.Grid[col, row].FurnitureSlot; + handling.AddInteractionSlot(slot); + slot.InteractionOwner = handling; + } + } + + //Helper method for highlighting interctable slots + private void HighlightSlot(RoomData room, int col, int row) + { + if (col >= 0 && col < room.SlotColumns && row >= 0 && row < room.SlotRows) + { + FurnitureSlot interactSlot = room.Grid[col, row].FurnitureSlot; + FurnitureHandling current = _selectedFurniture.GetComponent(); + + bool overlapsFurniture = interactSlot.SlotOwner != null && interactSlot.SlotOwner != current; + bool overlapsInteract = interactSlot.InteractionOwner != null && interactSlot.InteractionOwner != current; + + bool isValid = !overlapsFurniture && !overlapsInteract; + + + if (isValid) + { + interactSlot.SetValidity(isValid, true); + } + else if(!isValid) + { + interactSlot.SetValidity(false, false); + } + room.AddToValidityList(interactSlot); + } + } + + private Vector2Int RotateOffset(Vector2Int offset, bool isVertical, bool facingLeftOrBack) + { + + //Front (Default) + if (!isVertical && !facingLeftOrBack) return new Vector2Int(offset.x, offset.y); + + //Right + if (isVertical && !facingLeftOrBack) return new Vector2Int(offset.y, -offset.x); + + //Back + if (!isVertical && facingLeftOrBack) return new Vector2Int(-offset.x, -offset.y); + + //Left + if (isVertical && facingLeftOrBack) return new Vector2Int(-offset.y, offset.x); + + return offset; + } } }