コード例 #1
0
 internal LastSelectionDetails(GameObject target)
 {
     if (target.TryGetComponent(out ClusterGridEntity gridEntity) && gridEntity is
         HarvestablePOIClusterGridEntity asteroid)
     {
         asteroidField = asteroid;
         harvestable   = target.GetSMI <HarvestablePOIStates.Instance>();
         artifact      = target.GetSMI <ArtifactPOIStates.Instance>();
     }
コード例 #2
0
        /// <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);
        }