コード例 #1
0
        /// <summary>
        /// Get the surrounding locations based on a strength radius
        /// </summary>
        /// <param name="strength">number of places to go out</param>
        /// <returns>list of valid surrounding locations</returns>
        public IEnumerable <ILocation> GetSurroundings(int strength)
        {
            var radiusLocations = new List <ILocation>();

            //If we don't have any paths out what can we even do
            if (Pathways.Count() == 0)
            {
                return(radiusLocations);
            }

            var currentRadius   = 0;
            var currentPathsSet = Pathways.EntitiesContained();

            while (currentRadius <= strength && currentPathsSet.Count() > 0)
            {
                var currentLocsSet = currentPathsSet.Select(path => path.ToLocation);

                if (currentLocsSet.Count() == 0)
                {
                    break;
                }

                radiusLocations.AddRange(currentLocsSet);
                currentPathsSet = currentLocsSet.SelectMany(ro => ro.Pathways.EntitiesContained());

                currentRadius++;
            }

            return(radiusLocations);
        }
コード例 #2
0
        /// <summary>
        /// Get all of the entities matching a type inside this in a named container
        /// </summary>
        /// <typeparam name="T">the type</typeparam>
        /// <returns>the contained entities</returns>
        /// <param name="containerName">the name of the container</param>
        public IEnumerable <T> GetContents <T>(string containerName)
        {
            var implimentedTypes = DataUtility.GetAllImplimentingedTypes(typeof(T));

            var contents = new List <T>();

            if (implimentedTypes.Contains(typeof(IMobile)))
            {
                contents.AddRange(MobilesInside.EntitiesContained(containerName).Select(ent => (T)ent));
            }

            if (implimentedTypes.Contains(typeof(IInanimate)))
            {
                contents.AddRange(Contents.EntitiesContained(containerName).Select(ent => (T)ent));
            }

            if (implimentedTypes.Contains(typeof(IPathway)))
            {
                contents.AddRange(Pathways.EntitiesContained(containerName).Select(ent => (T)ent));
            }

            return(contents);
        }