예제 #1
0
 public void Add(WorldEditBlock worldEditBlock)
 {
     if (worldEditBlock.IsPlantBlock())
     {
         if (this.Plants.ContainsKey(worldEditBlock.Position))
         {
             return;
         }
         this.Add(this.Plants, worldEditBlock);
     }
     else if (worldEditBlock.IsWorldObjectBlock())
     {
         if (this.WorldObjects.ContainsKey(worldEditBlock.Position))
         {
             return;
         }
         this.Add(this.WorldObjects, worldEditBlock);
     }
     else
     {
         if (this.Blocks.ContainsKey(worldEditBlock.Position))
         {
             return;
         }
         this.Add(this.Blocks, worldEditBlock);
     }
 }
        public static WorldEditBlock CreateNew(Block pBlock, Vector3i pPosition, Vector3i?pSourcePosition)
        {
            WorldEditBlock web = new WorldEditBlock();

            web.Position = pPosition;
            web.Type     = pBlock.GetType();

            var constuctor = web.Type.GetConstructor(Type.EmptyTypes);

            if (constuctor == null)
            {
                if (pBlock is PlantBlock)
                {
                    web.Data = EcoSerializer.Serialize(PlantBlock.GetPlant(pPosition)).ToArray();
                }

                if (pBlock is WorldObjectBlock)
                {
                    WorldObjectBlock wob = (WorldObjectBlock)pBlock;

                    if (wob.WorldObjectHandle.Object.Position3i == pSourcePosition)
                    {
                        web.Data = EcoSerializer.Serialize(wob.WorldObjectHandle.Object).ToArray();
                    }
                }
            }

            return(web);
        }
예제 #3
0
 private void Add(Dictionary <Vector3i, WorldEditBlock> list, WorldEditBlock worldEditBlock)
 {
     if (!list.TryAdd(worldEditBlock.Position, worldEditBlock))
     {
         Log.WriteLine(Localizer.Do($"Unable add {worldEditBlock.Position} to {list}"));
     }
 }
        public bool SaveSelectionToClipboard(User pUser)
        {
            var vectors = GetSortedVectors();

            if (vectors == null)
            {
                return(false);
            }

            mUserClipboardPosition = pUser.Player.Position.Round;

            mClipboard.Clear();

            for (int x = vectors.Lower.X; x != vectors.Higher.X; x = (x + 1) % Shared.Voxel.World.VoxelSize.X)
            {
                for (int y = vectors.Lower.Y; y < vectors.Higher.Y; y++)
                {
                    for (int z = vectors.Lower.Z; z != vectors.Higher.Z; z = (z + 1) % Shared.Voxel.World.VoxelSize.Z)
                    {
                        var pos = new Vector3i(x, y, z);

                        //pos - mUserClipboardPosition: "Spitze minus Anfang"
                        mClipboard.Add(WorldEditBlock.CreateNew(Eco.World.World.GetBlock(pos), pos - mUserClipboardPosition, pos));
                    }
                }
            }
            return(true);
        }
예제 #5
0
        public void Rotate(float degrees)
        {
            AffineTransform transform = new AffineTransform();
            float           radians   = Mathf.DegToRad(degrees);

            transform = transform.RotateY(radians);

            List <WorldEditBlock> blocks = new List <WorldEditBlock>();

            blocks.AddRange(this.GetBlocks());
            blocks.AddRange(this.GetPlants());
            blocks.AddRange(this.GetWorldObjects());

            for (int i = 0; i < blocks.Count; i++)
            {
                WorldEditBlock block = blocks[i];
                block.RotateBlock(transform, degrees, radians);
                blocks[i] = block;
            }

            this.Clear();
            this.Parse(blocks);
        }
예제 #6
0
 public static void RestoreBlock(WorldEditBlock block, Vector3i position, UserSession session)
 {
     if (IsImpenetrable(position))
     {
         return;
     }
     ClearPosition(position);
     if (block.IsEmptyBlock())
     {
         RestoreEmptyBlock(position);
     }
     else if (block.IsPlantBlock())
     {
         RestorePlantBlock(block.BlockType, position, block.BlockData);
     }
     else if (block.IsWorldObjectBlock())
     {
         RestoreWorldObjectBlock(block.BlockType, position, block.BlockData, session);
     }
     else
     {
         RestoreBlock(block.BlockType, position);
     }
 }
 public static void SetBlock(WorldEditBlock pBlock, UserSession pSession)
 {
     SetBlock(pBlock.Type, pBlock.Position, pSession, null, null, pBlock.Data);
 }
 public void AddBlockChangedEntry(Block pBlock, Vector3i pPosition, Vector3i?pSourcePosition = null)
 {
     pSourcePosition = pSourcePosition ?? pPosition;
     mLastCommandBlocks.Push(WorldEditBlock.CreateNew(pBlock, pPosition, pSourcePosition));
 }
예제 #9
0
 public static void RestoreBlockOffset(WorldEditBlock block, Vector3i offsetPos, UserSession session)
 {
     RestoreBlock(block, ApplyOffset(block.Position, offsetPos), session);
 }