Пример #1
0
        public Block GetBlock(Vector3i absolutePosition)
        {
            Optional <Region> currentRegion = GetRegionFromAbsolute(absolutePosition);

            Debug.Assert(currentRegion.Valid);

            Vector3i currentBlockRelativePosition = Transformation.AbsoluteToRelative(absolutePosition,
                                                                                      currentRegion.Data.RegionOrigin);

            return(currentRegion.Data.GetBlock(currentBlockRelativePosition));
        }
Пример #2
0
        public void ChangeFacing(Vector3i absolutePosition, BlockFaceField facing, bool activate)
        {
            Optional <Region> currentRegion = GetRegionFromAbsolute(absolutePosition);

            Debug.Assert(currentRegion.Valid);

            Vector3i relativePosition = Transformation.AbsoluteToRelative(absolutePosition,
                                                                          currentRegion.Data.RegionOrigin);

            if (activate)
            {
                currentRegion.Data.AddFace(relativePosition, facing);
            }
            else
            {
                currentRegion.Data.RemoveFace(relativePosition, facing);
            }
        }
Пример #3
0
        public void ChangeBlock(Vector3i absolutePosition, BlockType type)
        {
            Optional <Region> currentRegion = GetRegionFromAbsolute(absolutePosition);

            Debug.Assert(currentRegion.Valid);

            Vector3i currentBlockRelativePosition = Transformation.AbsoluteToRelative(absolutePosition,
                                                                                      currentRegion.Data.RegionOrigin);

            Block oldBlock = currentRegion.Data.GetBlock(currentBlockRelativePosition);

            currentRegion.Data.AddBlock(currentBlockRelativePosition, type);
            Block newBlock = currentRegion.Data.GetBlock(currentBlockRelativePosition);

            BlockChangedData blockChangedData = new BlockChangedData(oldBlock, newBlock);

            GlobalSystems.EventManager.SendEvent(new BlockChangedEvent(new GameTools.Optional <object>(this),
                                                                       0,
                                                                       blockChangedData));
        }