WIRED Effect: Move Furni Towards Nearest User
This wired works like so:
Calculate Direction:
The method calculates the direction in which the furniture item should move to approach the closest user. It determines the relative positions of the furniture item and the user to decide the direction. If the user is in the same row or column as the furniture item, the method calculates whether the user is to the north, south, east, or west of the furniture item. If the user is not in the same row or column, the method calculates the direction based on which axis the user is farther away from the furniture item.
Determine Valid Move:
After calculating the direction, the method checks if the movement is valid. It ensures that the new tile the furniture item intends to move to is not blocked by other items or marked as invalid in the room layout. It also checks if the new tile is within the boundaries of the room. Additionally, the method considers whether the furniture item fits into the new tile, taking into account its size and rotation. If the move satisfies all these conditions, it is considered valid.
This wired effect would move furniture closer to a user when a user is within a specified range of tiles from the furniture item. In this case, the specified range is set to 3 tiles.
So, whenever a user is within 3 tiles horizontally or vertically from the furniture item, the wired effect would activate, and the furniture item would move towards that user. If the user is closer than 3 tiles, the furniture item will move as close as possible, possibly ending up in the same tile as the user due to the collision handling mentioned earlier.
If there are multiple users within the specified range, the furniture item would move towards the closest user among them. This creates an interactive behavior where furniture items in the virtual environment can respond dynamically to the presence of users, potentially leading to engaging gameplay or room interactions.