using UnityEngine; /// /// Force test the SettlementInteractionManager detection logic /// public class SettlementInteractionTest : MonoBehaviour { [ContextMenu("Force Test Settlement Detection")] public void ForceTestSettlementDetection() { Debug.Log("=== FORCING SETTLEMENT INTERACTION MANAGER TEST ==="); var settlementManager = FindFirstObjectByType(); if (settlementManager == null) { Debug.LogError("āŒ SettlementInteractionManager not found"); return; } Debug.Log("āœ… SettlementInteractionManager found"); Debug.Log($" GameObject: {settlementManager.gameObject.name}"); Debug.Log($" Enabled: {settlementManager.enabled}"); Debug.Log($" GameObject Active: {settlementManager.gameObject.activeInHierarchy}"); // Get private fields using reflection to see current state var teamMarkerField = typeof(SettlementInteractionManager).GetField("teamMarker", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var mapDataField = typeof(SettlementInteractionManager).GetField("mapData", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var currentNearbySettlementField = typeof(SettlementInteractionManager).GetField("currentNearbySettlement", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (teamMarkerField != null) { var teamMarker = teamMarkerField.GetValue(settlementManager) as Transform; Debug.Log($" TeamMarker reference: {(teamMarker != null ? teamMarker.name : "NULL")}"); } if (mapDataField != null) { var mapData = mapDataField.GetValue(settlementManager); Debug.Log($" MapData reference: {(mapData != null ? "EXISTS" : "NULL")}"); } if (currentNearbySettlementField != null) { var currentSettlement = currentNearbySettlementField.GetValue(settlementManager); Debug.Log($" Current nearby settlement: {(currentSettlement != null ? "EXISTS" : "NULL")}"); } // Force call the CheckForSettlementInteraction method using reflection Debug.Log("\nšŸ” FORCING CheckForSettlementInteraction()..."); var checkMethod = typeof(SettlementInteractionManager).GetMethod("CheckForSettlementInteraction", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (checkMethod != null) { try { checkMethod.Invoke(settlementManager, null); Debug.Log("āœ… CheckForSettlementInteraction() called successfully"); } catch (System.Exception e) { Debug.LogError($"āŒ Error calling CheckForSettlementInteraction(): {e.Message}"); } } else { Debug.LogError("āŒ CheckForSettlementInteraction method not found"); } // Check state after forced call if (currentNearbySettlementField != null) { var currentSettlement = currentNearbySettlementField.GetValue(settlementManager); Debug.Log($" Current nearby settlement AFTER: {(currentSettlement != null ? "EXISTS" : "NULL")}"); } } }