Beispiel #1
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Gets a neighboring site.
        /// </summary>
        /// <param name="location">
        /// The location of the neighboring site relative to the site.
        /// </param>
        /// <param name="neighbor">
        /// The object which will be assigned the requested site.  If this
        /// parameter is null and the location is valid, then a new instance
        /// will be created and assigned to the parameter.
        /// </param>
        /// <returns>
        /// true if the location is on the landscape, and the information
        /// about the requested site was assigned to the neighbor parameter.
        /// false if the location is not valid (in which case, the neighbor
        /// parameter is unchanged).
        /// </returns>
        public bool GetNeighbor(RelativeLocation location,
                                ref MutableSite neighbor)
        {
            Location?neighborLocation = ComputeNeighborLocation(this.Location, location);

            if (neighborLocation.HasValue)
            {
                return(landscape.GetSite(neighborLocation.Value, ref neighbor));
            }
            return(false);
        }
		//---------------------------------------------------------------------

		internal SiteEnumerator(ILandscape landscape)
		{
			this.landscape = landscape;
			atEnd = (landscape.Count == 0);
			moveNextNotCalled = true;
			if (! atEnd) {
				activeSiteEtor = landscape.ActiveSites.GetEnumerator() as ActiveSiteEnumerator;
				if (landscape.InactiveSiteCount > 0) {
					inactiveSite = new MutableSite(landscape,
					                               landscape.FirstInactiveSite,
					                               false, /* isActive? */
					                               landscape.InactiveSiteDataIndex);
				}
			}
		}
Beispiel #3
0
        //---------------------------------------------------------------------

        public bool GetSite(Location location,
                            ref MutableSite site)
        {
            if (IsValid(location))
            {
                uint index    = activeSiteMap[location];
                bool isActive = (index != ActiveSiteMap.InactiveSiteDataIndex);
                if (site == null)
                {
                    site = new MutableSite(this, location, isActive, index);
                }
                else
                {
                    site.SetAll(this, location, isActive, index);
                }
                return(true);
            }
            return(false);
        }
Beispiel #4
0
		//---------------------------------------------------------------------

		/// <summary>
		/// Gets a neighboring site.
		/// </summary>
		/// <param name="location">
		/// The location of the neighboring site relative to the site.
		/// </param>
		/// <param name="neighbor">
		/// The object which will be assigned the requested site.  If this
		/// parameter is null and the location is valid, then a new instance
		/// will be created and assigned to the parameter.
		/// </param>
		/// <returns>
		/// true if the location is on the landscape, and the information
		/// about the requested site was assigned to the neighbor parameter.
		/// false if the location is not valid (in which case, the neighbor
		/// parameter is unchanged).
		/// </returns>
		public bool GetNeighbor(RelativeLocation location,
		                        ref MutableSite  neighbor)
		{
			Location? neighborLocation = ComputeNeighborLocation(this.Location, location);
			if (neighborLocation.HasValue)
				return landscape.GetSite(neighborLocation.Value, ref neighbor);
			return false;
		}