예제 #1
0
    /* LoadShelter()
     * Chargement de la configuration d'abri lors du chargement de montage
     **/
    private IEnumerator LoadShelter(ArrayList CustomConf = null,ArrayList PosConf = null)
    {
        while(_isBuilding)
            yield return null;

        foreach(DynShelterModule m in _modules)
        {
            m.RemoveModule();
        }
        _modules.Clear();
        _modManager.ClearManager();
        _currentModule = null;
        _selectedIndex = 0;

        yield return null;

        _isBuilding = true;
        //Attend que le objdata soit configuré
        while(gameObject.GetComponent<ObjData>().GetObjectModel() == null)
        {
            yield return new WaitForEndOfFrame();
        }

        //Création de l'abri par default
        ArrayList stConf = CustomConf;

        if(stConf.Count > 0)
        {
            Color32 c = new Color32(255,255,255,255);
        //			SaveTransform();
            for(int i=0;i<stConf.Count-2;i=i+8)
            {
                ModuleType typ = ModuleType.bloc;
                switch ((string)stConf[i]) //TYP >0
                {
                case "facade":
                    typ = ModuleType.facade;
                    break;
                case "bloc":
                    typ = ModuleType.bloc;
                    break;
                case "extremite":
                    typ = ModuleType.extremite;
                    break;
                }

                int t = (int) stConf[i+1]; //TAILLE >1

                string styl = (string) stConf[i+2]; //STYLE >2

                _nextInsertion = true;
                _decalZ = 0.0f;
                yield return StartCoroutine(AddModule(t,styl,typ,_currentColor));

                c = (Color32)stConf[i+3]; //color > 3
                _currentModule.SetColor(c);

                _currentModule.SetNextLocks((bool)stConf[i+4]);//NLock> 4
                _currentModule.SetPrevLocks((bool)stConf[i+5]);//PLock> 5
                _currentModule.SetAnchor((bool)stConf[i+6]); //Anchor > 6

                yield return new WaitForEndOfFrame();

                _modManager.UpdateLocalMods(_currentModule.GetGameObj(),true);
                _modManager.ApplyLoadConf((string[])stConf[i+7]); //ModConf>7
            }
            ChangeModuleColor(c);
            _isBuilding = false;
        }

        _selectedIndex = 0;
        UpdateCurrentModule();

        for(int i=0;i<_modules.Count;i++)
        {
            ((DynShelterModule)_modules[i]).SetPos(false,(float)PosConf[i]);
        }

        UpdateBoxCollider();

        enabled = false;
        ShowArrows(false);
        CenterDeployAndFeetLimit();
        yield return null;
    }