Ejemplo n.º 1
0
    private void InitModelPools(meshUtils.SerializedModelRegister[] modeldata)
    {
        // load models
        Config_Map   mapConfig   = _mapConfig;
        Setup_Render renderSetup = _renderSetup;

        meshUtils.Init(mapConfig.Models.Count);

        var meshinit = FindObjectOfType <Meshpooling.MeshInit>();        //Todo: Create ModelResource

        var uihandler = FindObjectOfType <UIHandler>();

        uihandler.InitModelButtons(mapConfig);

        //TODO: Create Buttons per model

        List <Config_Model> singlepool = new List <Config_Model>();
        List <Config_Model> multipool  = new List <Config_Model>();
        int type = 0;

        foreach (Config_Model model in mapConfig.Models)
        {
            model.MeshType = type;

            if (model.PoolSingle)
            {
                singlepool.Add(model);
            }
            else
            {
                multipool.Add(model);
            }

            type++;
        }



        meshinit.Init(renderSetup.Compute_MeshPool, multipool);
        meshinit.RunMeshes();

        List <List <Vector4> > models;

        if (modeldata != null)
        {
            models = meshUtils.DeserializeModelRegister(modeldata);
        }
        else
        {
            MapGeneration.GenerateModels(mapConfig, out models);
        }



        List <Vector3[]> poslist = new();

        for (int i = 0; i < models.Count; i++)
        {
            Vector4[] positions = models[i].ToArray();

            Vector3[] posdata = new Vector3[positions.Length];
            for (int j = 0; j < positions.Length; j++)
            {
                posdata[j] = new Vector3(positions[j].x, positions[j].y, positions[j].z);
            }

            poslist.Add(posdata);
        }

        GenerateSinglePools(singlepool);

        meshUtils.SpawnFromPool(poslist);
        meshUtils.RegisterAllToHexagons();
    }