internal LastSelectionDetails(GameObject target) { target.TryGetComponent(out conditions); target.TryGetComponent(out identity); target.TryGetComponent(out modifiers); target.TryGetComponent(out rocketModule); target.TryGetComponent(out selectable); target.TryGetComponent(out world); if (rocketModule != null) { rocketInterface = rocketModule.CraftInterface; // Clustercraft can be pulled from the rocket-to-module interface gridEntity = rocketInterface.m_clustercraft; } else if (target.TryGetComponent(out gridEntity) && gridEntity is Clustercraft craft) { rocketInterface = craft.ModuleInterface; } else { rocketInterface = null; } fertility = target.GetSMI <FertilityMonitor.Instance>(); if (DlcManager.FeatureClusterSpaceEnabled()) { isRocket = target.TryGetComponent(out LaunchPad _) || target. TryGetComponent(out RocketProcessConditionDisplayTarget _); } else { isRocket = target.TryGetComponent(out LaunchableRocket _); } isAsteroid = gridEntity != null && gridEntity is AsteroidGridEntity; }
/// <summary> /// Find the asteroid field on the same tile as the selected rocket, if any. /// </summary> /// <param name="rocket">The rocket that is harvesting the tile.</param> /// <returns>The asteroid field occupying the same tile, or null if no asteroid fields /// occupy the same cluster map tile.</returns> private static HarvestablePOIClusterGridEntity FindFieldForRocket( ClusterGridEntity rocket) { HarvestablePOIClusterGridEntity asteroid = null; // List is preallocated, not new per call var shared = ClusterGrid.Instance.GetEntitiesOnCell(rocket.Location); int n = shared.Count; for (int i = 0; i < n; i++) { if (shared[i] is HarvestablePOIClusterGridEntity asteroidEntity) { asteroid = asteroidEntity; break; } } return(asteroid); }