コード例 #1
0
ファイル: MapCw.Importer.cs プロジェクト: dhtdht020/GTTMCube
        void ParseBlockDefinition(NbtCompound compound)
        {
            byte id = (byte)compound["ID"].Value;

            BlockInfo.Name[id] = (string)compound["Name"].Value;
            BlockInfo.SetCollide(id, (byte)compound["CollideType"].Value);
            BlockInfo.SpeedMultiplier[id] = (float)compound["Speed"].Value;

            byte[] data = (byte[])compound["Textures"].Value;
            BlockInfo.SetTex(data[0], Side.Top, id);
            BlockInfo.SetTex(data[1], Side.Bottom, id);
            BlockInfo.SetTex(data[2], Side.Left, id);
            BlockInfo.SetTex(data[3], Side.Right, id);
            BlockInfo.SetTex(data[4], Side.Front, id);
            BlockInfo.SetTex(data[5], Side.Back, id);

            BlockInfo.BlocksLight[id] = (byte)compound["TransmitsLight"].Value == 0;
            byte sound = (byte)compound["WalkSound"].Value;

            BlockInfo.DigSounds[id]  = sound;
            BlockInfo.StepSounds[id] = sound;
            if (sound == SoundType.Glass)
            {
                BlockInfo.StepSounds[id] = SoundType.Stone;
            }
            BlockInfo.FullBright[id] = (byte)compound["FullBright"].Value != 0;

            byte blockDraw = (byte)compound["BlockDraw"].Value;

            if ((byte)compound["Shape"].Value == 0)
            {
                BlockInfo.SpriteOffset[id] = blockDraw;
                blockDraw = DrawType.Sprite;
            }
            BlockInfo.Draw[id] = blockDraw;

            data = (byte[])compound["Fog"].Value;
            BlockInfo.FogDensity[id] = (data[0] + 1) / 128f;
            // Fix for older ClassicalSharp versions which saved wrong fog density value
            if (data[0] == 0xFF)
            {
                BlockInfo.FogDensity[id] = 0;
            }
            BlockInfo.FogCol[id] = new PackedCol(data[1], data[2], data[3]);

            data = (byte[])compound["Coords"].Value;
            BlockInfo.MinBB[id] = new Vector3(data[0] / 16f, data[1] / 16f, data[2] / 16f);
            BlockInfo.MaxBB[id] = new Vector3(data[3] / 16f, data[4] / 16f, data[5] / 16f);

            BlockInfo.DefineCustom(game, id);
            BlockInfo.CanPlace[id]  = true;
            BlockInfo.CanDelete[id] = true;
            Events.RaiseBlockPermissionsChanged();
        }
コード例 #2
0
ファイル: BlockDefs.cs プロジェクト: dhtdht020/GTTMCube
        void HandleDefineBlockCommonEnd(NetReader reader, byte shape, BlockID block)
        {
            byte blockDraw = reader.ReadUInt8();

            if (shape == 0)
            {
                BlockInfo.SpriteOffset[block] = blockDraw;
                blockDraw = DrawType.Sprite;
            }
            BlockInfo.Draw[block] = blockDraw;

            byte fogDensity = reader.ReadUInt8();

            BlockInfo.FogDensity[block] = fogDensity == 0 ? 0 : (fogDensity + 1) / 128f;
            BlockInfo.FogCol[block]     = new PackedCol(reader.ReadUInt8(), reader.ReadUInt8(), reader.ReadUInt8());

            BlockInfo.DefineCustom(game, block);
        }