Esempio n. 1
0
    void SetNewFaces()
    {
        foreach (Vector3 direction in _directions)
        {
            GameObject blockGameObject = GetGameObjInDir(direction);
            BlockFace  blockFaceOfNeighbouringBlock = BlockFaceMethods.BlockFaceFromNormal(-direction);

            if (blockGameObject == null)
            {
                continue;
            }

            BlockFaceBehaviour blockFaceBehaviour = blockGameObject.GetComponent <BlockFaceBehaviour>();
            BlockBehaviour     blockBehaviour     = blockGameObject.GetComponent <BlockBehaviour>();

            if (blockBehaviour.IsTranslating())
            {
                continue;
            }

            foreach (BlockPlugin plugin in blockBehaviour.GetPlugins())
            {
                MoveablePlugin moveable = plugin as MoveablePlugin;
                if (moveable == null)
                {
                    continue;
                }

                if (!moveable.IsDisplaced() ||
                    blockFaceOfNeighbouringBlock == moveable.GetDisplacedFace())
                {
                    BlockFace moveableFace = moveable.IsDisplaced()
                        ? moveable.GetDisplacedFace()
                        : blockFaceOfNeighbouringBlock;
                    blockFaceBehaviour.HighlightFace(blockFaceOfNeighbouringBlock);
                    _faceMap.Add(blockFaceBehaviour, moveableFace);;
                }

                break;
            }
        }
    }