示例#1
0
    private void InstallComponent()
    {
        if (InstallationManager.selectedPrefab != null)
        {
            if (ComponentIsAttached())
            {
                Destroy(MachineBuilder.componentGrid[nodePosition]);
                MachineBuilder.componentGrid.Remove(nodePosition);
            }

            // Only gears are permitted if the node is restricted
            if (restrictedInstallation && InstallationManager.selectedPrefab.transform.tag != "GearBit")
            {
                return;
            }

            attachedComponent      = Instantiate(InstallationManager.selectedPrefab, componentContainer.transform);
            attachedComponent.name = InstallationManager.selectedPrefab.ToString();

            // Y position is component type-specific
            attachedComponent.transform.position = new Vector3(
                transform.position.x, transform.position.y + InstallationManager.GetYDelta(), 0f);

            MachineBuilder.componentGrid.Add(nodePosition, attachedComponent);
            Debug.Log(MachineBuilder.LogComponentGrid());

            occupied = true;
        }
    }