public override ModularPlacableObject Duplicate()
        {
            ModularPiece DuplicatedPiece = (ModularPiece)base.Duplicate();

            DuplicatedPiece.Initialize(ParentSet);              // initialize modular set
            DuplicatedPiece.InitializeID(ID);
            DuplicatedPiece.InitializeTextureData(this.CurrentTextureKeys);
            DuplicatedPiece.InitializeColors(this.Colors);
            this.ParentSet.AddModularPiece(DuplicatedPiece);             // add duplicated piece to modular sets
            DuplicatedPiece.RegisterUndoable();
            return(DuplicatedPiece);
        }
        public ModularPiece InitStoreItem(ModularPieceData Piece, Vector3 Scale, Vector3 RotationOffset = default(Vector3), Vector3 InitRotation = default(Vector3), Vector3 InitPosition = default(Vector3))
        {
            if (Piece != null)
            {
                GameObject obj = Piece.Prefab;                 // pick base object

                // instantiate item
                ModularPiece piece = GameObject.Instantiate(obj, InitPosition, Quaternion.identity).GetComponent <ModularPiece> ();
                piece.gameObject.name = Piece.Name;
                piece.InitializeID(Piece.Key);
                piece.InitializeTextureData();
                piece.InitializeColors();
                piece.transform.localScale    = Scale;
                piece.transform.localPosition = InitPosition;
                piece.NoneOffsettedRotation   = Quaternion.Euler(InitRotation);     // set rotation with rotation property
                piece.RotationOffset          = Quaternion.Euler(RotationOffset);   // set rotation offset
                piece.Initialize(GameManager.I.Modular.ScopedSet);                  // initialize piece data
                return(piece);
            }
            return(null);
        }
        public void AddModularPiece(ModularPiece piece, ModularPlacableData Trans)
        {
            piece.Initialize(this);               // initialize piece cause isnt placed by system
            piece.transform.SetParent(transform); // reparent piece
            _Pieces.Add(piece);                   // add piece to set

            piece.LocalPosition = Trans.LocalPosition;
            piece.transform.localEulerAngles = Trans.LocalEulerAngles;
            piece.transform.localScale       = Trans.LocalScale;

            AddModularPieceRenderer(piece);             // add to render set

            UpdatePieceRestrictions(piece);             // add modular piece restriction

            if (Editing)
            {
                piece.InitializeEditable();
            }
            else
            {
                piece.InitializePlaced(Management.GameManager.I.Modular.ModularPieceLayer);
                piece.OnPlaced();
            }             // if is in editing mode, initialize as editable piece
        }