コード例 #1
0
ファイル: FreeBlock.cs プロジェクト: jamesrom/gbx-net
 public FreeBlock(CGameCtnBlock block)
 {
     Block = block;
 }
コード例 #2
0
 public FreeBlock(CGameCtnBlock block)
 {
     Block      = block;
     SnapPoints = Array.Empty <Vec3>();
 }
コード例 #3
0
        public override void Read(CGameCtnMacroBlockInfo n, GameBoxReader r)
        {
            n.Blocks = r.ReadArray(r1 =>
            {
                Int3?coord        = null;
                Direction?dir     = null;
                Vec3?position     = null;
                Vec3?pitchYawRoll = null;

                var ver        = r1.ReadInt32();
                var blockModel = r1.ReadIdent();
                int flags      = 0;

                if (ver >= 2)
                {
                    if (ver < 5)
                    {
                    }

                    flags = r1.ReadInt32();

                    if (ver >= 4)
                    {
                        if ((flags & (1 << 26)) != 0) // free block
                        {
                            position     = r1.ReadVec3();
                            pitchYawRoll = r1.ReadVec3();
                        }
                        else
                        {
                            coord = (Int3)r1.ReadByte3();
                            dir   = (Direction)r1.ReadByte();
                        }
                    }
                }

                if (ver >= 3)
                {
                    if (r1.ReadNodeRef() != null)
                    {
                        throw new NotImplementedException();
                    }
                }

                if (ver >= 4)
                {
                    if (r1.ReadNodeRef() != null)
                    {
                        throw new NotImplementedException();
                    }
                }

                var correctFlags = flags & 15;

                if ((flags & 0x20000) != 0) // Fixes inner pillars of some blocks
                {
                    correctFlags |= 0x400000;
                }

                if ((flags & 0x10000) != 0) // Fixes ghost blocks
                {
                    correctFlags |= 0x10000000;
                }

                var block = new CGameCtnBlock(blockModel, dir.GetValueOrDefault(), coord.GetValueOrDefault(), correctFlags);

                if ((flags & (1 << 26)) != 0)
                {
                    //block.IsFree = true;
                    //block.AbsolutePositionInMap = block.AbsolutePositionInMap.GetValueOrDefault() + position.GetValueOrDefault();
                    //block.PitchYawRoll += pitchYawRoll.GetValueOrDefault();
                }

                return(block);
            }).Where(x => x != null).ToArray();
        }