public static void SetMany <T>(this IEnumerable <IEnumerable <T> > blocks, ForegroundBlock block) where T : IBlockSettable <ForegroundBlock, BackgroundBlock>
 {
     foreach (var item in blocks)
     {
         item.Set(block);
     }
 }
示例#2
0
 public static void Set(this IEnumerable <BlocksItem> blocks, ForegroundBlock block)
 {
     foreach (var item in blocks)
     {
         item.Set(block);
     }
 }
示例#3
0
        private void RaiseForeground(int x, int y, ForegroundBlock newBlock, Player player)
        {
            var oldData = this.World.Foreground[x, y];
            var newData = new BlockData <ForegroundBlock>(player, newBlock);

            this.World.Foreground[x, y] = newData;

            new ForegroundPlaceEvent(x, y, oldData, newData)
            .RaiseIn(this.BotBits);
        }
示例#4
0
 public void Set(ForegroundBlock block)
 {
     this._blocks.Place(this._x, this._y, block);
 }
示例#5
0
        internal static BlockDataWorld GetWorld(Message m, int width, int height, uint offset = InitOffset)
        {
            var  world   = new BlockDataWorld(width, height);
            uint pointer = GetStart(m, offset);

            string strValue2;

            while ((strValue2 = m[pointer] as string) == null || strValue2 != "we")
            {
                var    block      = m.GetInteger(pointer++);
                var    l          = (Layer)m.GetInteger(pointer++);
                byte[] byteArrayX = m.GetByteArray(pointer++);
                byte[] byteArrayY = m.GetByteArray(pointer++);

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

                case Layer.Foreground:
                    ForegroundBlock foregroundBlock;
                    BlockArgsType   blockArgsType = WorldUtils.GetBlockArgsType(WorldUtils.GetForegroundType(id: (Foreground.Id)block));

                    switch (blockArgsType)
                    {
                    case BlockArgsType.None:
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block);
                        break;

                    case BlockArgsType.Number:
                        uint i = m.GetUInt(pointer++);
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block, i);
                        break;

                    case BlockArgsType.String:
                        string str = m.GetString(pointer++);
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block, str);
                        break;

                    case BlockArgsType.Portal:
                        var  portalRotation = (Morph.Id)m.GetUInt(pointer++);
                        uint portalId       = m.GetUInt(pointer++);
                        uint portalTarget   = m.GetUInt(pointer++);
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block, portalId, portalTarget, portalRotation);
                        break;

                    case BlockArgsType.Label:
                        string text      = m.GetString(pointer++);
                        string textcolor = m.GetString(pointer++);
                        foregroundBlock = new ForegroundBlock((Foreground.Id)block, text, textcolor);
                        break;

                    default:
                        throw new NotSupportedException("Invalid block.");
                    }

                    var fg = new BlockData <ForegroundBlock>(foregroundBlock);
                    foreach (Point pos in GetPos(byteArrayX, byteArrayY))
                    {
                        world.Foreground[pos.X, pos.Y] = fg;
                    }
                    break;
                }
            }

            return(world);
        }
示例#6
0
 public void Place(int x, int y, ForegroundBlock block)
 {
     new PlaceSendMessage(Layer.Foreground, x, y, (int)block.Id, block.GetArgs())
     .SendIn(this.BotBits);
 }