using UnityEngine; using System.Collections.Generic; public class House : MonoBehaviour { [SerializeField] private int maxResidents = 4; private List residents = new List(); public bool HasSpace => residents.Count < maxResidents; public int ResidentCount => residents.Count; void Start() { Debug.Log("House created"); } public bool AddResident(Villager villager) { if (HasSpace && !residents.Contains(villager)) { residents.Add(villager); Debug.Log($"Villager {villager.villagerName} moved into house. Residents: {residents.Count}/{maxResidents}"); return true; } return false; } public void RemoveResident(Villager villager) { if (residents.Contains(villager)) { residents.Remove(villager); Debug.Log($"Villager {villager.villagerName} left house. Residents: {residents.Count}/{maxResidents}"); } } public string GetBuildingInfo() { return $"House\nResidents: {residents.Count}/{maxResidents}"; } void OnDrawGizmos() { // Show house occupancy Gizmos.color = HasSpace ? Color.green : Color.red; Gizmos.DrawWireCube(transform.position + Vector3.up * 1.5f, Vector3.one * 0.3f); } }