Ejemplo n.º 1
0
        // Serialize / deserialize
        new internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            base.ReadWrite(s);

            if (s.IsWriting)
            {
                s.wInt(flags.Count);

                foreach (KeyValuePair <string, bool> f in flags)
                {
                    s.wString(f.Key);
                    s.wBool(f.Value);
                }
            }
            else
            {
                int c; s.rInt(out c);

                flags = new Dictionary <string, bool>(c, StringComparer.Ordinal);
                for (int i = 0; i < c; i++)
                {
                    string t; s.rString(out t);
                    bool   b; s.rBool(out b);
                    flags.Add(t, b);
                }
            }

            s.rwInt(ref type);
            s.rwVector3D(ref pos);
            s.rwInt(ref angledoom);
            s.rwInt(ref pitch);            //mxd
            s.rwInt(ref roll);             //mxd
            s.rwDouble(ref scaleX);        //mxd
            s.rwDouble(ref scaleY);        //mxd
            s.rwInt(ref tag);
            s.rwInt(ref action);
            for (int i = 0; i < NUM_ARGS; i++)
            {
                s.rwInt(ref args[i]);
            }

            if (!s.IsWriting)
            {
                anglerad = Angle2D.DoomToReal(angledoom);
                UpdateCache();                 //mxd
            }
        }
Ejemplo n.º 2
0
        // Serialize / deserialize
        new internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            base.ReadWrite(s);

            s.rwVector2D(ref pos);
            s.rwDouble(ref zceiling);           //mxd
            s.rwDouble(ref zfloor);             //mxd

            if (s.IsWriting)
            {
                // Let all lines know they need an update
                foreach (Linedef l in linedefs)
                {
                    l.NeedUpdate();
                }
            }
        }
Ejemplo n.º 3
0
        // Serialize / deserialize (passive: this doesn't record)
        new internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
                updateneeded = true;
            }

            base.ReadWrite(s);

            //mxd
            if (s.IsWriting)
            {
                s.wInt(flags.Count);

                foreach (KeyValuePair <string, bool> f in flags)
                {
                    s.wString(f.Key);
                    s.wBool(f.Value);
                }
            }
            else
            {
                int c; s.rInt(out c);

                flags = new Dictionary <string, bool>(c, StringComparer.Ordinal);
                for (int i = 0; i < c; i++)
                {
                    string t; s.rString(out t);
                    bool   b; s.rBool(out b);
                    flags.Add(t, b);
                }
            }

            s.rwInt(ref fixedindex);
            s.rwInt(ref floorheight);
            s.rwInt(ref ceilheight);
            s.rwString(ref floortexname);
            s.rwString(ref ceiltexname);
            s.rwLong(ref longfloortexname);
            s.rwLong(ref longceiltexname);
            s.rwInt(ref effect);
            s.rwInt(ref brightness);

            //mxd. (Re)store tags
            if (s.IsWriting)
            {
                s.wInt(tags.Count);
                foreach (int tag in tags)
                {
                    s.wInt(tag);
                }
            }
            else
            {
                int c;
                s.rInt(out c);
                tags = new List <int>(c);
                for (int i = 0; i < c; i++)
                {
                    int t;
                    s.rInt(out t);
                    tags.Add(t);
                }
            }

            //mxd. Slopes
            s.rwDouble(ref flooroffset);
            s.rwVector3D(ref floorslope);
            s.rwDouble(ref ceiloffset);
            s.rwVector3D(ref ceilslope);
        }
Ejemplo n.º 4
0
        // Serialize / deserialize
        internal void ReadWrite(IReadWriteStream s)
        {
            s.rwInt(ref type);
            switch ((UniversalType)type)
            {
            case UniversalType.AngleRadians:
            case UniversalType.AngleDegreesFloat:
            case UniversalType.Float:
            {
                double v = 0.0f;
                //mxd. Seems to work faster this way
                //try { v = (float)value; } catch(NullReferenceException e) { }
                if (value != null)
                {
                    v = (double)value;
                }
                s.rwDouble(ref v);
                value = v;
                break;
            }

            case UniversalType.AngleDegrees:
            case UniversalType.AngleByte:                     //mxd
            case UniversalType.Color:
            case UniversalType.EnumBits:
            case UniversalType.EnumOption:
            case UniversalType.Integer:
            case UniversalType.LinedefTag:
            case UniversalType.LinedefType:
            case UniversalType.SectorEffect:
            case UniversalType.SectorTag:
            case UniversalType.ThingTag:
            case UniversalType.ThingType:
            {
                int v = 0;
                //mxd. Seems to work faster this way
                //try { v = (int)value; } catch(NullReferenceException e) { }
                if (value != null)
                {
                    v = (int)value;
                }
                s.rwInt(ref v);
                value = v;
                break;
            }

            case UniversalType.Boolean:
            {
                bool v = false;
                //mxd. Seems to work faster this way
                //try { v = (bool)value; } catch(NullReferenceException e) { }
                if (value != null)
                {
                    v = (bool)value;
                }
                s.rwBool(ref v);
                value = v;
                break;
            }

            case UniversalType.Flat:
            case UniversalType.String:
            case UniversalType.Texture:
            case UniversalType.EnumStrings:
            case UniversalType.ThingClass:
            {
                string v = (string)value;
                s.rwString(ref v);
                value = v;
                break;
            }

            default:
                General.Fail("Unknown field type to read/write!");
                break;
            }
        }