Exemplo n.º 1
0
        private static BlockDataWorld GetWorld(Message m, int width, int height)
        {
            var world = new BlockDataWorld(width, height);
            var datas = InitParse.Parse(m);

            foreach (var data in datas)
            {
                var block = data.Type;
                var l     = (Layer)data.Layer;

                switch (l)
                {
                case Layer.Background:
                    var bgWorldBlock = new BackgroundBlock((Background.Id)block);
                    var bg           = new BlockData <BackgroundBlock>(bgWorldBlock);
                    foreach (var pos in data.Locations)
                    {
                        world.Background[pos.X, pos.Y] = bg;
                    }
                    break;

                case Layer.Foreground:
                    var fgWorldBlock = WorldUtils.GetForegroundFromArgs((Foreground.Id)block, data.Args);
                    var fg           = new BlockData <ForegroundBlock>(fgWorldBlock);
                    foreach (var pos in data.Locations)
                    {
                        world.Foreground[pos.X, pos.Y] = fg;
                    }
                    break;
                }
            }

            return(world);
        }
Exemplo n.º 2
0
        internal ForegroundBlock?GetExpectedForeground(Point p)
        {
            PlaceSendMessage msg;

            if (!this._queuedItems.TryGetValue(new Point3D(Layer.Foreground, p.X, p.Y), out msg))
            {
                lock (this._sentBlocks)
                {
                    CheckHandle handle;
                    if (!this._sentLocations.TryGetValue(new Point3D(Layer.Foreground, p.X, p.Y), out handle))
                    {
                        return(null);
                    }
                    msg = handle.Message;
                }
            }
            return(WorldUtils.GetForegroundFromArgs((Foreground.Id)msg.Id, msg.Args));
        }