コード例 #1
0
    public static void DestroyBoardBeingPlaced()
    {
        ReferenceObject.transform.parent = null; // without this line the referenceobject is left on the board and you are unable to delete it without move board
        if (BoardBeingPlaced == null)
        {
            return;
        }

        // so that we don't end up with empty clusters when deleting boards.
        // this code is from stuffdeleter.cs. TODO: merge in a nice way
        CircuitInput[]  inputs  = BoardBeingPlaced.GetComponentsInChildren <CircuitInput>();
        CircuitOutput[] outputs = BoardBeingPlaced.GetComponentsInChildren <CircuitOutput>();
        foreach (CircuitInput input in inputs)
        {
            StuffDeleter.DestroyInput(input);
        }
        foreach (CircuitOutput output in outputs)
        {
            StuffDeleter.DestroyOutput(output);
        }

        BoardBeingPlaced.transform.parent = null; // this is done so that when StuffPlacer sets the BoxCollidersOfThingBeingPlaced it doesn't get the box collider from the old board. Maybe a better way would be DestroyImmediate but the documentation is really insistant that you don't use that so IDK. Man... the extent to which stuff in this codebase is interdependant on other stuff in unintuitive ways really bothers me. I'll need to refactor the refactor at this rate...

        Object.Destroy(BoardBeingPlaced);
        StuffPlacer.ResetReferences();
    }