コード例 #1
0
ファイル: ParticleEmitter.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        public void ReadState(IValueReader reader)
        {
            // Read the primary values
            Name            = reader.ReadString(_nameKeyName);
            BlendMode       = reader.ReadEnum <BlendMode>(_blendModeKeyName);
            Budget          = reader.ReadInt(_budgetKeyName);
            EmitterLife     = reader.ReadInt(_emitterLifeKeyName);
            ParticleLife    = reader.ReadVariableInt(_particleLifeKeyName);
            Origin          = reader.ReadVector2(_originKeyName);
            ReleaseAmount   = reader.ReadVariableUShort(_releaseAmountKeyName);
            ReleaseColor    = reader.ReadVariableColor(_releaseColorKeyName);
            ReleaseRate     = reader.ReadVariableUShort(_releaseRateKeyName);
            ReleaseRotation = reader.ReadVariableFloat(_releaseRotationKeyName);
            ReleaseScale    = reader.ReadVariableFloat(_releaseScaleKeyName);
            ReleaseSpeed    = reader.ReadVariableFloat(_releaseSpeedKeyName);
            Sprite.SetGrh(reader.ReadGrhIndex(_grhIndexKeyName));

            // Read the custom values
            var customValuesReader = reader.ReadNode(_customValuesNodeName);

            ReadCustomValues(customValuesReader);

            // Read the modifier collection
            ParticleModifiers.Read(_particleModifiersNodeName, reader);
            EmitterModifiers.Read(_emitterModifiersNodeName, reader);
        }
コード例 #2
0
ファイル: AudioManager.cs プロジェクト: pashcovich/netgore
        /// <summary>
        /// Reads an audio value from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="r">The <see cref="IValueReader"/> to read from.</param>
        /// <returns>The read audio value.</returns>
        static KeyValuePair <string, int> ReadValue(IValueReader r)
        {
            var file  = r.ReadString("File");
            var index = r.ReadInt("Index");

            return(new KeyValuePair <string, int>(file, index));
        }
コード例 #3
0
ファイル: LineEmitter.cs プロジェクト: thepirateclub/netgore
 /// <summary>
 /// When overridden in the derived class, reads all custom state values from the <paramref name="reader"/>.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read the state values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     Angle        = reader.ReadFloat(_angleKeyName);
     EmitBothWays = reader.ReadBool(_emitBothWaysKeyName);
     Length       = reader.ReadInt(_lengthKeyName);
     Rectilinear  = reader.ReadBool(_rectilinearKeyName);
 }
コード例 #4
0
 /// <summary>
 /// Reads a Point.
 /// </summary>
 /// <param name="reader">IValueReader to read from.</param>
 /// <param name="name">Unique name of the value to read.</param>
 /// <returns>Value read from the reader.</returns>
 public static Point ReadSystemPoint(this IValueReader reader, string name)
 {
     if (reader.SupportsNameLookup)
     {
         var value = reader.ReadString(name);
         var split = value.Split(',');
         var x     = Parser.Invariant.ParseInt(split[0]);
         var y     = Parser.Invariant.ParseInt(split[1]);
         return(new Point(x, y));
     }
     else
     {
         var x = reader.ReadInt(null);
         var y = reader.ReadInt(null);
         return(new Point(x, y));
     }
 }
コード例 #5
0
ファイル: QuickBarForm.cs プロジェクト: wtfcolt/game
            /// <summary>
            /// Reads a <see cref="QuickBarSlotValues"/> from an <see cref="IValueReader"/>.
            /// </summary>
            /// <param name="r">The <see cref="IValueReader"/> to read the values from.</param>
            /// <returns>The <see cref="QuickBarSlotValues"/> read from the <paramref name="r"/>.</returns>
            public static QuickBarSlotValues Read(IValueReader r)
            {
                var slot  = r.ReadByte("Slot");
                var type  = r.ReadEnum <QuickBarItemType>("Type");
                var value = r.ReadInt("Value");

                return(new QuickBarSlotValues(slot, type, value));
            }
コード例 #6
0
ファイル: AnimatedGrhData.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Initializes a new instance of the <see cref="AnimatedGrhData"/> class.
        /// </summary>
        /// <param name="r">The <see cref="IValueReader"/>.</param>
        /// <param name="grhIndex">The <see cref="GrhIndex"/>.</param>
        /// <param name="cat">The <see cref="SpriteCategorization"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="cat"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="grhIndex"/> is equal to GrhIndex.Invalid.</exception>
        AnimatedGrhData(IValueReader r, GrhIndex grhIndex, SpriteCategorization cat) : base(grhIndex, cat)
        {
            var speed = r.ReadInt(_speedValueKey);
            var frames = r.ReadMany(_framesNodeName, (xreader, xname) => xreader.ReadGrhIndex(xname));

            _speed = 1f / speed;
            _frames = CreateFrames(frames);
            _size = GetMaxSize(_frames);
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AnimatedGrhData"/> class.
        /// </summary>
        /// <param name="r">The <see cref="IValueReader"/>.</param>
        /// <param name="grhIndex">The <see cref="GrhIndex"/>.</param>
        /// <param name="cat">The <see cref="SpriteCategorization"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="cat"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="grhIndex"/> is equal to GrhIndex.Invalid.</exception>
        AnimatedGrhData(IValueReader r, GrhIndex grhIndex, SpriteCategorization cat) : base(grhIndex, cat)
        {
            var speed  = r.ReadInt(_speedValueKey);
            var frames = r.ReadMany(_framesNodeName, (xreader, xname) => xreader.ReadGrhIndex(xname));

            _speed  = 1f / speed;
            _frames = CreateFrames(frames);
            _size   = GetMaxSize(_frames);
        }
コード例 #8
0
        /// <summary>
        ///   Reads a <see cref = "KeyValuePair{T,U}" /> from an <see cref = "IValueReader" />.
        /// </summary>
        /// <param name = "r">The <see cref = "IValueReader" /> to read from.</param>
        /// <returns>The read <see cref = "KeyValuePair{T,U}" />.</returns>
        static KeyValuePair <string, HashInfo> Read(IValueReader r)
        {
            var key          = r.ReadString(_textureNameValueKey);
            var hash         = r.ReadString(_hashValueKey);
            var fileSize     = r.ReadInt(_fileSizeValueKey);
            var lastModified = r.ReadLong(_lastModifiedValueKey);

            var hashInfo = new HashInfo(hash, fileSize, lastModified);

            return(new KeyValuePair <string, HashInfo>(key, hashInfo));
        }
コード例 #9
0
        /// <summary>
        /// Reads a <see cref="Rectangle"/> from an IValueReader.
        /// </summary>
        /// <param name="reader">The IValueReader to read from.</param>
        /// <param name="name">Unique name of the value to read.</param>
        /// <returns>Value read from the <paramref name="reader"/>.</returns>
        public static Rectangle ReadRectangle(this IValueReader reader, string name)
        {
            int x, y, w, h;

            if (reader.SupportsNameLookup)
            {
                var value = reader.ReadString(name);
                var split = value.Split(',');
                x = Parser.Invariant.ParseInt(split[0]);
                y = Parser.Invariant.ParseInt(split[1]);
                w = Parser.Invariant.ParseInt(split[2]);
                h = Parser.Invariant.ParseInt(split[3]);
            }
            else
            {
                x = reader.ReadInt(null);
                y = reader.ReadInt(null);
                w = reader.ReadInt(null);
                h = reader.ReadInt(null);
            }

            return(new Rectangle(x, y, w, h));
        }
コード例 #10
0
        /// <summary>
        ///   Reads a <see cref = "KeyValuePair{T,U}" /> from an <see cref = "IValueReader" />.
        /// </summary>
        /// <param name = "r">The <see cref = "IValueReader" /> to read from.</param>
        /// <returns>The read <see cref = "KeyValuePair{T,U}" />.</returns>
        static KeyValuePair<string, HashInfo> Read(IValueReader r)
        {
            var key = r.ReadString(_textureNameValueKey);
            var hash = r.ReadString(_hashValueKey);
            var fileSize = r.ReadInt(_fileSizeValueKey);
            var lastModified = r.ReadLong(_lastModifiedValueKey);

            var hashInfo = new HashInfo(hash, fileSize, lastModified);
            return new KeyValuePair<string, HashInfo>(key, hashInfo);
        }
コード例 #11
0
 /// <summary>
 /// When overridden in the derived class, reads a value with the specified name from an IValueReader.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="reader">IValueReader to read from.</param>
 /// <returns>Value read from the IValueReader.</returns>
 protected override int Read(string name, IValueReader reader)
 {
     return(reader.ReadInt(name));
 }
コード例 #12
0
 static void TestXmlValueReader(IValueReader reader)
 {
     Assert.AreEqual(10, reader.ReadInt("MyInt"));
     Assert.AreEqual(25.55f, reader.ReadFloat("MyFloat"));
     Assert.AreEqual("Hello!", reader.ReadString("MyString"));
 }
コード例 #13
0
ファイル: EmitterModifierTests.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// When overridden in the derived class, reads the <see cref="EmitterModifier"/>'s custom values
 /// from the <see cref="reader"/>.
 /// </summary>
 /// <param name="reader"><see cref="IValueReader"/> to read the custom values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     SerializedValue = reader.ReadInt("SerializedValue");
 }
コード例 #14
0
 /// <summary>
 /// Reads a 32-bit signed integer.
 /// </summary>
 /// <param name="name">Unique name of the value to read.</param>
 /// <returns>Value read from the reader.</returns>
 public int ReadInt(string name)
 {
     return(_reader.ReadInt(name));
 }
コード例 #15
0
 /// <summary>
 /// When overridden in the derived class, reads the <see cref="EmitterModifier"/>'s custom values
 /// from the <see cref="reader"/>.
 /// </summary>
 /// <param name="reader"><see cref="IValueReader"/> to read the custom values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     EmitPeriod = reader.ReadInt(_emitPeriodKeyName);
     RestPeriod = reader.ReadInt(_restPeriodKeyName);
 }
コード例 #16
0
ファイル: AudioManager.cs プロジェクト: mateuscezar/netgore
        /// <summary>
        /// Reads an audio value from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="r">The <see cref="IValueReader"/> to read from.</param>
        /// <returns>The read audio value.</returns>
        static KeyValuePair<string, int> ReadValue(IValueReader r)
        {
            var file = r.ReadString("File");
            var index = r.ReadInt("Index");

            return new KeyValuePair<string, int>(file, index);
        }
コード例 #17
0
 static void TestXmlValueReader(IValueReader reader)
 {
     Assert.AreEqual(10, reader.ReadInt("MyInt"));
     Assert.AreEqual(25.55f, reader.ReadFloat("MyFloat"));
     Assert.AreEqual("Hello!", reader.ReadString("MyString"));
 }
コード例 #18
0
ファイル: QuickBarForm.cs プロジェクト: mateuscezar/netgore
            /// <summary>
            /// Reads a <see cref="QuickBarSlotValues"/> from an <see cref="IValueReader"/>.
            /// </summary>
            /// <param name="r">The <see cref="IValueReader"/> to read the values from.</param>
            /// <returns>The <see cref="QuickBarSlotValues"/> read from the <paramref name="r"/>.</returns>
            public static QuickBarSlotValues Read(IValueReader r)
            {
                var slot = r.ReadByte("Slot");
                var type = r.ReadEnum<QuickBarItemType>("Type");
                var value = r.ReadInt("Value");

                return new QuickBarSlotValues(slot, type, value);
            }
コード例 #19
0
ファイル: LineEmitter.cs プロジェクト: mateuscezar/netgore
 /// <summary>
 /// When overridden in the derived class, reads all custom state values from the <paramref name="reader"/>.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read the state values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     Angle = reader.ReadFloat(_angleKeyName);
     EmitBothWays = reader.ReadBool(_emitBothWaysKeyName);
     Length = reader.ReadInt(_lengthKeyName);
     Rectilinear = reader.ReadBool(_rectilinearKeyName);
 }
コード例 #20
0
        /// <summary>
        /// Reads an MapSpawnValuesID from an IValueReader.
        /// </summary>
        /// <param name="reader">IValueReader to read from.</param>
        /// <param name="name">Unique name of the value to read.</param>
        /// <returns>The MapSpawnValuesID read from the IValueReader.</returns>
        public static MapSpawnValuesID Read(IValueReader reader, string name)
        {
            var value = reader.ReadInt(name);

            return(new MapSpawnValuesID(value));
        }
コード例 #21
0
ファイル: ItemID.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Reads an ItemID from an IValueReader.
        /// </summary>
        /// <param name="reader">IValueReader to read from.</param>
        /// <param name="name">Unique name of the value to read.</param>
        /// <returns>The ItemID read from the IValueReader.</returns>
        public static ItemID Read(IValueReader reader, string name)
        {
            var value = reader.ReadInt(name);

            return(new ItemID(value));
        }
コード例 #22
0
 /// <summary>
 /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
 /// same order as they were written.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
 public void ReadState(IValueReader reader)
 {
     A = reader.ReadString("A");
     B = reader.ReadInt("B");
 }
コード例 #23
0
        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        public void ReadState(IValueReader reader)
        {
            // Read the primary values
            Name = reader.ReadString(_nameKeyName);
            BlendMode = reader.ReadEnum<BlendMode>(_blendModeKeyName);
            Budget = reader.ReadInt(_budgetKeyName);
            EmitterLife = reader.ReadInt(_emitterLifeKeyName);
            ParticleLife = reader.ReadVariableInt(_particleLifeKeyName);
            Origin = reader.ReadVector2(_originKeyName);
            ReleaseAmount = reader.ReadVariableUShort(_releaseAmountKeyName);
            ReleaseColor = reader.ReadVariableColor(_releaseColorKeyName);
            ReleaseRate = reader.ReadVariableUShort(_releaseRateKeyName);
            ReleaseRotation = reader.ReadVariableFloat(_releaseRotationKeyName);
            ReleaseScale = reader.ReadVariableFloat(_releaseScaleKeyName);
            ReleaseSpeed = reader.ReadVariableFloat(_releaseSpeedKeyName);
            Sprite.SetGrh(reader.ReadGrhIndex(_grhIndexKeyName));

            // Read the custom values
            var customValuesReader = reader.ReadNode(_customValuesNodeName);
            ReadCustomValues(customValuesReader);

            // Read the modifier collection
            ParticleModifiers.Read(_particleModifiersNodeName, reader);
            EmitterModifiers.Read(_emitterModifiersNodeName, reader);
        }
コード例 #24
0
 /// <summary>
 /// When overridden in the derived class, reads the underlying value from the <paramref name="reader"/>.
 /// </summary>
 /// <param name="reader">The IValueReader to read from.</param>
 /// <param name="valueName">The name to of the value in the <paramref name="reader"/>.</param>
 protected override void ReadValue(IValueReader reader, string valueName)
 {
     _value = reader.ReadInt(valueName);
 }
コード例 #25
0
ファイル: CharacterID.cs プロジェクト: thepirateclub/netgore
        /// <summary>
        /// Reads an CharacterID from an IValueReader.
        /// </summary>
        /// <param name="reader">IValueReader to read from.</param>
        /// <param name="name">Unique name of the value to read.</param>
        /// <returns>The CharacterID read from the IValueReader.</returns>
        public static CharacterID Read(IValueReader reader, string name)
        {
            var value = reader.ReadInt(name);

            return(new CharacterID(value));
        }
コード例 #26
0
 /// <summary>
 /// When overridden in the derived class, reads the <see cref="EmitterModifier"/>'s custom values
 /// from the <see cref="reader"/>.
 /// </summary>
 /// <param name="reader"><see cref="IValueReader"/> to read the custom values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     EmitPeriod = reader.ReadInt(_emitPeriodKeyName);
     RestPeriod = reader.ReadInt(_restPeriodKeyName);
 }
コード例 #27
0
 /// <summary>
 /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
 /// same order as they were written.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
 public void ReadState(IValueReader reader)
 {
     A = reader.ReadString("A");
     B = reader.ReadInt("B");
 }
コード例 #28
0
ファイル: ParticleModifierTests.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Reads the <see cref="ParticleModifier"/>'s custom values from the <see cref="reader"/>.
 /// </summary>
 /// <param name="reader"><see cref="IValueReader"/> to read the custom values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     SerializedValue = reader.ReadInt("SerializedValue");
 }
コード例 #29
0
 /// <summary>
 /// When overridden in the derived class, reads the underlying value from the <paramref name="reader"/>.
 /// </summary>
 /// <param name="reader">The IValueReader to read from.</param>
 /// <param name="valueName">The name to of the value in the <paramref name="reader"/>.</param>
 protected override void ReadValue(IValueReader reader, string valueName)
 {
     _value = reader.ReadInt(valueName);
 }
コード例 #30
0
ファイル: RectEmitter.cs プロジェクト: thepirateclub/netgore
 /// <summary>
 /// When overridden in the derived class, reads all custom state values from the <paramref name="reader"/>.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read the state values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     Height    = reader.ReadInt(_heightKeyName);
     Width     = reader.ReadInt(_widthKeyName);
     Perimeter = reader.ReadBool(_perimeterKeyName);
 }
コード例 #31
0
ファイル: RectEmitter.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// When overridden in the derived class, reads all custom state values from the <paramref name="reader"/>.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read the state values from.</param>
 protected override void ReadCustomValues(IValueReader reader)
 {
     Height = reader.ReadInt(_heightKeyName);
     Width = reader.ReadInt(_widthKeyName);
     Perimeter = reader.ReadBool(_perimeterKeyName);
 }
コード例 #32
0
 protected int ReadInt(TelemetryId id)
 {
     return(valueReader.ReadInt(id));
 }