Ejemplo n.º 1
0
    public bool LoadedMount = false; // set in LoadSaveObject

    private void Start()
    {
        if (!LoadedMount)// only do this for new mounts. This is uncomfortably hacky
        {
            GameObject TheBoardPart = Instantiate(References.Prefabs.CircuitBoard, transform);
            TheBoardPart.transform.localPosition    = new Vector3(-0.15f, 0.65f, -0.15f);
            TheBoardPart.transform.localEulerAngles = new Vector3(0, 90, 90);
            TheBoardPart.AddComponent <ObjectInfo>().ComponentType = ComponentType.CircuitBoard;
            TheBoardPart.tag = "PlaceOnlyCircuitBoard";

            Destroy(TheBoardPart.GetComponent <MegaMeshComponent>());

            CircuitBoard board = TheBoardPart.GetComponent <CircuitBoard>();
            board.CreateCuboid();
            board.SetBoardColor(Color.white);

            // necessary for the board to appear in the selection menu
            MegaMeshManager.RemoveComponentImmediatelyOf(TheBoardPart);
            if (gameObject.layer == 5)
            {
                TheBoardPart.layer = 5;
            }

            if (StuffPlacer.GetThingBeingPlaced == gameObject)
            {
                StuffPlacer.NewThingBeingPlaced(gameObject);
            }                                                                                                  // holy shit this is a terrible line of code. God damn.
        }
        else
        {
            transform.GetChild(1).tag = "PlaceOnlyCircuitBoard"; // this tag is applied to prevent actions like board moving and painting
        }

        Destroy(this);
    }
    private static void LoadCircuitBoard(GameObject LoadedObject, SavedCircuitBoard save)
    {
        CircuitBoard board = LoadedObject.GetComponent <CircuitBoard>();

        board.x = save.x;
        board.z = save.z;
        board.SetBoardColor(save.color);

        board.CreateCuboid();
    }
Ejemplo n.º 3
0
    private static void LoadCircuitBoard(GameObject LoadedObject, SavedObject save)
    {
        object[]     data  = save.CustomDataArray;
        CircuitBoard board = LoadedObject.GetComponent <CircuitBoard>();

        board.x = (int)data[0];
        board.z = (int)data[1];
        board.SetBoardColor((Color)data[2]);

        board.CreateCuboid();
    }
    public static void CreateNewBoard(int x, int z)
    {
        GameObject NewBoard = Object.Instantiate(References.Prefabs.CircuitBoard, BoardPlacer.ReferenceObject.transform);

        // set the board's dimensions
        CircuitBoard board = NewBoard.GetComponent <CircuitBoard>();

        board.x = x;
        board.z = z;
        board.CreateCuboid();

        BoardPlacer.NewBoardBeingPlaced(NewBoard);
    }
Ejemplo n.º 5
0
        public GameObject Board(int width, int height,
                                Vector3 position, Quaternion rotation, Transform parent = null)
        {
            GameObject   board   = UnityEngine.Object.Instantiate(boardPlacer.BoardPrefab, position, rotation, parent);
            CircuitBoard circuit = board.GetComponent <CircuitBoard>();

            circuit.x = width;
            circuit.z = height;
            circuit.CreateCuboid();
            StuffPlacer.DestroyIntersectingConnections(board);
            DestroyInvalidWiresOnBoard(board);
            MegaMesh.AddMeshesFrom(board);
            MegaBoardMeshManager.AddBoardsFrom(board);
            SetChildCircuitsMegaMeshStatus(board, true);
            return(board);
        }