Example #1
0
 /// <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)
 {
     Closed        = reader.ReadBool(_closedKeyName);
     Scale         = reader.ReadFloat(_scaleKeyName);
     Rotation      = reader.ReadFloat(_rotationKeyName);
     PolygonOrigin = reader.ReadEnum <PolygonOrigin>(_polygonOriginKeyName);
     Points.Read(_pointsNodeName, reader);
 }
Example #2
0
 /// <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);
 }
Example #3
0
 /// <summary>
 /// Reads a <see cref="Vector2"/>.
 /// </summary>
 /// <param name="reader"><see cref="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 Vector2 ReadVector2(this IValueReader reader, string name)
 {
     if (reader.SupportsNameLookup)
     {
         var value = reader.ReadString(name);
         var split = value.Split(',');
         var x     = Parser.Invariant.ParseFloat(split[0]);
         var y     = Parser.Invariant.ParseFloat(split[1]);
         return(new Vector2(x, y));
     }
     else
     {
         var x = reader.ReadFloat(null);
         var y = reader.ReadFloat(null);
         return(new Vector2(x, y));
     }
 }
Example #4
0
        /// <summary>
        /// Reads the <see cref="BackgroundImage"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        protected virtual void Read(IValueReader reader)
        {
            Name      = reader.ReadString(_valueKeyName);
            Alignment = reader.ReadEnum <Alignment>(_valueKeyAlignment);
            Color     = reader.ReadColor(_valueKeyColor);
            Depth     = reader.ReadFloat(_valueKeyDepth);
            Offset    = reader.ReadVector2(_valueKeyOffset);
            var grhIndex = reader.ReadGrhIndex(_valueKeyGrhIndex);

            _sprite = new Grh(grhIndex, AnimType.Loop, Map.GetTime());
        }
Example #5
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)
        {
            PositionProvider = null;
            Tag = null;

            Position  = reader.ReadVector2(_positionValueKey);
            Size      = reader.ReadVector2(_sizeValueKey);
            Color     = reader.ReadColor(_colorValueKey);
            Rotation  = reader.ReadFloat(_rotationValueKey);
            IsEnabled = reader.ReadBool(_isEnabledValueKey);

            var grhIndex = reader.ReadGrhIndex(_spriteValueKey);

            if (grhIndex.IsInvalid)
            {
                Sprite = new Grh(grhIndex, AnimType.Loop, 0);
            }
            else
            {
                Sprite = null;
            }
        }
Example #6
0
 /// <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)
 {
     Closed = reader.ReadBool(_closedKeyName);
     Scale = reader.ReadFloat(_scaleKeyName);
     Rotation = reader.ReadFloat(_rotationKeyName);
     PolygonOrigin = reader.ReadEnum<PolygonOrigin>(_polygonOriginKeyName);
     Points.Read(_pointsNodeName, reader);
 }
Example #7
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 float Read(string name, IValueReader reader)
 {
     return(reader.ReadFloat(name));
 }
Example #8
0
 /// <summary>
 /// Reads the <see cref="SkeletonFrame"/> from an <see cref="IValueReader"/>.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
 /// <param name="contentPath">The <see cref="ContentPaths"/> to use to load additional assets.</param>
 public void Read(IValueReader reader, ContentPaths contentPath)
 {
     _delay    = reader.ReadFloat(_delayValueKey);
     _fileName = reader.ReadString(_fileNameValueKey);
     _skeleton = new Skeleton(_fileName, contentPath);
 }
Example #9
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)
        {
            PositionProvider = null;
            Tag = null;

            Position = reader.ReadVector2(_positionValueKey);
            Size = reader.ReadVector2(_sizeValueKey);
            Color = reader.ReadColor(_colorValueKey);
            Rotation = reader.ReadFloat(_rotationValueKey);
            IsEnabled = reader.ReadBool(_isEnabledValueKey);

            var grhIndex = reader.ReadGrhIndex(_spriteValueKey);
            if (!grhIndex.IsInvalid)
                Sprite = new Grh(grhIndex, AnimType.Loop, 0);
            else
                Sprite = null;
        }
 /// <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)
 {
     Position = reader.ReadVector2(_positionKeyName);
     Radius   = reader.ReadFloat(_radiusKeyName);
     Strength = reader.ReadFloat(_strengthKeyName);
 }
 /// <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.ReadFloat(valueName);
 }
 /// <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)
 {
     Position = reader.ReadVector2(_positionKeyName);
     Radius = reader.ReadFloat(_radiusKeyName);
     Strength = reader.ReadFloat(_strengthKeyName);
 }
 /// <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)
 {
     InitialScale = reader.ReadFloat(_initialScaleKeyName);
     UltimateScale = reader.ReadFloat(_ultimateScaleKeyName);
 }
Example #14
0
 /// <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)
 {
     ConeAngle = reader.ReadFloat(_coneAngleKeyName);
     Direction = reader.ReadFloat(_directionKeyName);
 }
Example #15
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"));
 }
 /// <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)
 {
     InitialScale  = reader.ReadFloat(_initialScaleKeyName);
     UltimateScale = reader.ReadFloat(_ultimateScaleKeyName);
 }
 /// <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)
 {
     Rate = reader.ReadFloat(_rateKeyName);
 }
Example #18
0
 /// <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);
 }
Example #19
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"));
 }
Example #20
0
 /// <summary>
 /// Reads a 32-bit floating-point number.
 /// </summary>
 /// <param name="name">Unique name of the value to read.</param>
 /// <returns>Value read from the reader.</returns>
 public float ReadFloat(string name)
 {
     return(_reader.ReadFloat(name));
 }
 /// <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.ReadFloat(valueName);
 }
Example #22
0
 /// <summary>
 /// Reads the <see cref="SkeletonFrame"/> from an <see cref="IValueReader"/>.
 /// </summary>
 /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
 /// <param name="contentPath">The <see cref="ContentPaths"/> to use to load additional assets.</param>
 public void Read(IValueReader reader, ContentPaths contentPath)
 {
     _delay = reader.ReadFloat(_delayValueKey);
     _fileName = reader.ReadString(_fileNameValueKey);
     _skeleton = new Skeleton(_fileName, contentPath);
 }
Example #23
0
 /// <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)
 {
     Rate = reader.ReadFloat(_rateKeyName);
 }
Example #24
0
 /// <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)
 {
     ConeAngle = reader.ReadFloat(_coneAngleKeyName);
     Direction = reader.ReadFloat(_directionKeyName);
 }
Example #25
0
        /// <summary>
        /// Reads the <see cref="BackgroundImage"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read from.</param>
        protected virtual void Read(IValueReader reader)
        {
            Name = reader.ReadString(_valueKeyName);
            Alignment = reader.ReadEnum<Alignment>(_valueKeyAlignment);
            Color = reader.ReadColor(_valueKeyColor);
            Depth = reader.ReadFloat(_valueKeyDepth);
            Offset = reader.ReadVector2(_valueKeyOffset);
            var grhIndex = reader.ReadGrhIndex(_valueKeyGrhIndex);

            _sprite = new Grh(grhIndex, AnimType.Loop, Map.GetTime());
        }
Example #26
0
 protected float ReadFloat(TelemetryId id)
 {
     return(valueReader.ReadFloat(id));
 }