예제 #1
0
        protected BasicObject[] UnpackObstacleList(GroupDefinition.ObstacleTypes objType)
        {
            List <BasicObject> items = new List <BasicObject>();

            UInt32 objects = ReadUInt32();

            for (int i = 0; i < objects; i++)
            {
                BasicObject obj = UnpackObjectByType(objType);
                if (obj != null)
                {
                    items.Add(obj);
                }
            }

            return(items.ToArray());
        }
예제 #2
0
        protected BasicObject UnpackObjectByType(GroupDefinition.ObstacleTypes objType)
        {
            switch (objType)
            {
            case GroupDefinition.ObstacleTypes.wallType:
                return(UnpackWall());

            case GroupDefinition.ObstacleTypes.boxType:
                return(UnpackBox());

            case GroupDefinition.ObstacleTypes.pyrType:
                return(UnpackPyramid());

            case GroupDefinition.ObstacleTypes.baseType:
                return(UnpackBase());

            case GroupDefinition.ObstacleTypes.teleType:
                return(UnpackTeleporter());

            case GroupDefinition.ObstacleTypes.meshType:
                return(UnpackMesh());

            case GroupDefinition.ObstacleTypes.arcType:
                return(UnpackArc());

            case GroupDefinition.ObstacleTypes.coneType:
                return(UnpackCone());

            case GroupDefinition.ObstacleTypes.sphereType:
                return(UnpackSphere());

            case GroupDefinition.ObstacleTypes.tetraType:
                return(UnpackTetra());

            default:
                return(null);
            }
        }
예제 #3
0
        protected List <BasicObject> UnpackObstacles()
        {
            List <BasicObject> items = new List <BasicObject>();

            items.Add(ParseWorldObject());

            // parse the fixed size world
            for (GroupDefinition.ObstacleTypes objType = GroupDefinition.ObstacleTypes.wallType; objType < GroupDefinition.ObstacleTypes.ObstacleTypeCount; objType++)
            {
                items.AddRange(UnpackObstacleList(objType));
            }

            UInt32 count = ReadUInt32();

            for (int i = 0; i < count; i++)
            {
                GroupDefinition group = new GroupDefinition();
                items.Add(group);
                group.Name = ReadULongPascalString();

                for (GroupDefinition.ObstacleTypes objType = GroupDefinition.ObstacleTypes.wallType; objType < GroupDefinition.ObstacleTypes.ObstacleTypeCount; objType++)
                {
                    group.Obstacles.AddRange(UnpackObstacleList(objType));
                }
            }
            count = ReadUInt32();

            for (int j = 0; j < count; j++)
            {
                GroupInstance instance = new GroupInstance();
                items.Add(instance);
                instance.GroupDef = ReadULongPascalString();
                instance.Name     = ReadULongPascalString(); // this has some material mapping shit int in, TODO, extract it

                instance.Transform = UnpackMeshTransform();

                byte bits = ReadByte();

                instance.ModifyTeam          = ((bits & (1 << 0)) == 0) ? false : true;
                instance.ModifyColor         = ((bits & (1 << 1)) == 0) ? false : true;
                instance.ModifyPhysicsDriver = ((bits & (1 << 2)) == 0) ? false : true;
                instance.ModifyMaterial      = ((bits & (1 << 3)) == 0) ? false : true;
                instance.DriveThrough        = ((bits & (1 << 4)) == 0) ? false : true;
                instance.ShootThrough        = ((bits & (1 << 5)) == 0) ? false : true;
                instance.Ricochet            = ((bits & (1 << 6)) == 0) ? false : true;

                if (instance.ModifyTeam)
                {
                    instance.Team = (TeamColors)ReadUInt16();
                }
                if (instance.ModifyColor)
                {
                    instance.Tint = ReadColor4F();
                }
                if (instance.ModifyPhysicsDriver)
                {
                    instance.Phydrv = ReadInt32();
                }
                if (instance.ModifyMaterial)
                {
                    instance.MaterialID = ReadInt32();
                }
            }


            return(items);
        }