Ejemplo n.º 1
0
        public string ToString(QuakeSideFormat format)
        {
            var sb = new StringBuilder();

            if ((Saveability & Saveability.Entity) == Saveability.Entity)
            {
                sb.AppendLine(OpenDelimiter);

                foreach (KeyValuePair <string, Option> keyVal in KeyVals)
                {
                    sb.Append("\"");
                    sb.Append(keyVal.Key);
                    sb.Append("\" \"");
                    sb.Append(keyVal.Value);
                    sb.Append("\"");
                    sb.Append(Environment.NewLine);
                }
            }

            if ((Saveability & Saveability.Solids) == Saveability.Solids)
            {
                foreach (Solid solid in Solids)
                {
                    sb.AppendLine(OpenDelimiter);

                    foreach (Side side in solid.Sides)
                    {
                        sb.AppendLine((side as QuakeSide).ToString(format));
                    }

                    sb.AppendLine(CloseDelimiter);
                }
            }

            if ((Saveability & Saveability.Children) == Saveability.Children)
            {
                foreach (Block child in Children)
                {
                    sb.AppendLine(child.ToString());
                }
            }

            if ((Saveability & Saveability.Entity) == Saveability.Entity)
            {
                sb.Append(CloseDelimiter);
            }

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        public string ToString(QuakeSideFormat format)
        {
            var sb = new StringBuilder();

            foreach (Vertex point in Plane.Points)
            {
                sb.Append("( ");

                for (int i = 0; i < 3; i++)
                {
                    float coord = point.Position[i];
                    sb.Append(coord + " ");
                }

                sb.Append(") ");
            }

            sb.Append(TextureName + " ");

            if (format == QuakeSideFormat.Valve220)
            {
                for (int i = 0; i < 2; i++)
                {
                    Vector3 vec = TextureBasis[i];

                    sb.Append("[ ");
                    sb.Append(vec.X + " " + vec.Y + " " + vec.Z + " " + TextureOffset[i]);
                    sb.Append(" ] ");
                }
            }
            else
            {
                sb.Append(TextureOffset.X + " ");
                sb.Append(TextureOffset.Y + " ");
            }

            sb.Append(TextureRotation + " ");
            sb.Append(TextureScale.X + " ");
            sb.Append(TextureScale.Y);

            return(sb.ToString());
        }
Ejemplo n.º 3
0
        public string ToString(QuakeSideFormat format)
        {
            var sb = new StringBuilder();

            // First build the final worldspawn.
            int       worldspawnIndex = MapObjects.FindIndex(o => o.Definition.ClassName == "worldspawn");
            MapObject worldspawn      = MapObjects[worldspawnIndex];

            foreach (MapObject mo in AllObjects)
            {
                // Only copy solids to worldspawn if that's all this entity
                // is set to save, otherwise let it get handled later.
                if (mo.Saveability == Saveability.Solids)
                {
                    worldspawn.Renderables.AddRange(mo.Renderables);
                }
            }

            sb.AppendLine(new QuakeBlock(worldspawn).ToString(format));

            for (int i = 0; i < MapObjects.Count; i++)
            {
                if (i == worldspawnIndex)
                {
                    continue;
                }

                MapObject mo = MapObjects[i];

                // Avoid saving a null character to the output.
                if (mo.Saveability == Saveability.None)
                {
                    continue;
                }

                sb.AppendLine(new QuakeBlock(mo).ToString(format));
            }

            return(sb.ToString());
        }