예제 #1
0
    public static void SetActiveTurretController(TurretController turretController, bool inheritControlStates)
    {
        if (s_instance == null)
        {
            return;
        }

        if (s_instance.m_activeTurretController != null)
        {
            if (inheritControlStates && turretController != null)
            {
                turretController.SetCanControl(s_instance.m_activeTurretController.CanControl);
                turretController.SetCanFire(s_instance.m_activeTurretController.CanFire);
            }

            foreach (TurretController tc in s_instance.m_activeTurretController.GetComponents <TurretController>())
            {
                tc.SetActive(false);
            }
        }

        s_instance.m_activeTurretController = turretController;

        if (turretController != null)
        {
            Debug.Log(DebugUtilities.AddTimestampPrefix("Active TurretController is now " + turretController.GetType()));
            foreach (TurretController tc in turretController.gameObject.GetComponents <TurretController>())
            {
                tc.SetActive(tc == turretController);
            }
        }
        else
        {
            Debug.Log(DebugUtilities.AddTimestampPrefix("Active TurretController was cleared"));
        }
    }