Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        Vector3    pos      = PlayerController.instance.transform.position;
        Vector3Int curBlock = PlayerController.GetCurrentBlock();

        int chunkX   = Mathf.FloorToInt(curBlock.x / 16f);
        int chunkY   = Mathf.FloorToInt(curBlock.y / 16f);
        int chunkZ   = Mathf.FloorToInt(curBlock.z / 16f);
        int xInChunk = curBlock.x - chunkX * 16;
        int yInChunk = curBlock.y - chunkY * 16;
        int zInChunk = curBlock.z - chunkZ * 16;

        Vector3Int posInt = pos.ToVector3Int();

        NBTHelper.GetLightsByte(posInt.x, posInt.y, posInt.z, out byte skyLight, out byte blockLight);
        byte maxLight = skyLight > blockLight ? skyLight : blockLight;

        UnityEngine.Profiling.Profiler.BeginSample("zstring");
        using (zstring.Block())
        {
            zstring text = zstring.Format(template, Application.version, GetFPS(), pos.x, pos.y, pos.z, curBlock.x, curBlock.y, curBlock.z);
            text += zstring.Format(template2, xInChunk, yInChunk, zInChunk, chunkX, chunkY, chunkZ, maxLight, skyLight, blockLight);
            if (WireFrameHelper.render)
            {
                text += zstring.Format(template3, WireFrameHelper.pos.x, WireFrameHelper.pos.y, WireFrameHelper.pos.z, WireFrameHelper.generator.name, WireFrameHelper.data);
            }
            label.text = text;

            label2.text = ChunkRefresher.GetChunkUpdatesCount() + (zstring)" chunk updates";
        }
        UnityEngine.Profiling.Profiler.EndSample();
    }
Ejemplo n.º 2
0
    public static void Create(byte type, byte data, Vector3 pos)
    {
        GameObject prefab = Resources.Load("Prefabs/BreakBlockEffect") as GameObject;
        GameObject go     = Instantiate(prefab);

        go.transform.localPosition = pos;
        Destroy(go, 1);

        int      chunkX = Mathf.FloorToInt(pos.x / 16f);
        int      chunkZ = Mathf.FloorToInt(pos.z / 16f);
        NBTChunk chunk  = NBTHelper.GetChunk(chunkX, chunkZ);

        BreakBlockEffect effect = go.AddComponent <BreakBlockEffect>();
        NBTBlock         block  = NBTGeneratorManager.GetMeshGenerator(type);

        Vector3Int posInt = pos.ToVector3Int();

        effect.texturePath = block.GetBreakEffectTexture(chunk, posInt, data);
        effect.tintColor   = block.GetFrontTintColorByData(chunk, posInt, data);
        NBTHelper.GetLightsByte(posInt.x, posInt.y, posInt.z, out byte skyLight, out byte blockLight);
        effect.skyLight   = skyLight / 15f;
        effect.blockLight = blockLight / 15f;
    }