示例#1
0
 /// <summary>
 /// Get all the dead creatures in the context.
 ///
 /// A creature is dead when the energy is equal to or lower then 0.
 /// </summary>
 /// <returns>List of all the dead creatures in the context</returns>
 public ReadOnlyCollection <Creature> GetDeadCreatures()
 => SimObjects.OfType <Creature>().Where(c => c.IsAlive == false).ToList().AsReadOnly();
示例#2
0
        /// <summary>
        /// get all simobjects of a certain SimObject type
        /// </summary>
        /// <typeparam name="TSimObject">A type of SimObject</typeparam>
        /// <returns></returns>
        public ReadOnlyCollection <TSimObject> GetSimObjects <TSimObject>() where TSimObject : SimObject
        {
            var so = SimObjects.OfType <TSimObject>().ToList();

            return(new ReadOnlyCollection <TSimObject>(so));
        }