fCraft.World.GetLifes C# (CSharp) Method

GetLifes() public method

public GetLifes ( ) : IEnumerable
return IEnumerable
        public IEnumerable<Life2DZone> GetLifes()
        {
            lock ( SyncRoot ) {
                return null == Map ? null : Map.LifeZones.Values.ToList();
            }
        }

Usage Example

Example #1
0
        private static void OnList(Player p, Command cmd)
        {
            World w = p.World;

            if (null == w)
            {
                p.Message("&WYou are in limbo state. Prepare for eternal torment.");
                return;
            }
            string param = cmd.Next();
            Func <Life2DZone, bool> f = l => true;

            if (!string.IsNullOrWhiteSpace(param))
            {
                switch (param)
                {
                case "started":
                    f = l => !l.Stopped;
                    break;

                case "stopped":
                    f = l => l.Stopped;
                    break;

                default:
                    p.Message("&WUnrecognised parameter " + param + ". Ignored.\n");
                    break;
                }
            }
            int i = 0;

            foreach (Life2DZone life in w.GetLifes().Where(life => f(life)))
            {
                if (i++ > 0)
                {
                    p.Message(", ");
                }
                p.Message((life.Stopped ? "&8" : "&2") + life.Name);
            }
        }