Esempio n. 1
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);
        }
Esempio n. 2
0
        static KeyValuePair <GrhIndex, List <WallEntityBase> > ReadWalls(IValueReader r, CreateWallEntityFromReaderHandler createWall)
        {
            var grhIndex = r.ReadGrhIndex(_grhIndexValueKey);
            var walls    = r.ReadManyNodes(_wallsNodeName, x => createWall(x));

            return(new KeyValuePair <GrhIndex, List <WallEntityBase> >(grhIndex, walls.ToList()));
        }
Esempio n. 3
0
 public void Read(IValueReader reader)
 {
     GrhIndex    = reader.ReadGrhIndex(_grhIndexValueKey);
     _sourceName = reader.ReadString(_sourceValueKey);
     _destName   = reader.ReadString(_destValueKey);
     Offset      = reader.ReadVector2(_offsetValueKey);
     Origin      = reader.ReadVector2(_originValueKey);
 }
Esempio n. 4
0
 public void Read(IValueReader reader)
 {
     GrhIndex = reader.ReadGrhIndex(_grhIndexValueKey);
     _sourceName = reader.ReadString(_sourceValueKey);
     _destName = reader.ReadString(_destValueKey);
     Offset = reader.ReadVector2(_offsetValueKey);
     Origin = reader.ReadVector2(_originValueKey);
 }
Esempio n. 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>
        void IPersistable.ReadState(IValueReader reader)
        {
            PersistableHelper.Read(this, reader);

            // Manually handle the WaveNoise sprite
            var grhIndex = reader.ReadGrhIndex(_valueKeyWaveNoise);

            _waveNoise.SetGrh(grhIndex);
        }
Esempio n. 6
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 virtual void ReadState(IValueReader reader)
        {
            var grhIndex = reader.ReadGrhIndex(_grhIndexKeyName);

            if (!grhIndex.IsInvalid)
            {
                _grh.SetGrh(grhIndex);
            }

            PersistableHelper.Read(this, reader);
        }
Esempio n. 7
0
        void Read(IValueReader r)
        {
            var position = r.ReadVector2(_positionValueKey);
            var size     = r.ReadVector2(_sizeValueKey);

            IsPlatform    = r.ReadBool(_isPlatformValueKey);
            BoundGrhIndex = r.ReadGrhIndex(_boundGrhIndexValueKey);

            SetPositionRaw(position);
            SetSizeRaw(size);
        }
Esempio n. 8
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());
        }
Esempio n. 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;
            }
        }
Esempio n. 10
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;
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
 protected internal static void ReadHeader(IValueReader r, out GrhIndex grhIndex, out SpriteCategorization cat)
 {
     grhIndex = r.ReadGrhIndex(_indexValueKey);
     cat = r.ReadSpriteCategorization(_categorizationValueKey);
 }
Esempio n. 13
0
 protected internal static void ReadHeader(IValueReader r, out GrhIndex grhIndex, out SpriteCategorization cat)
 {
     grhIndex = r.ReadGrhIndex(_indexValueKey);
     cat      = r.ReadSpriteCategorization(_categorizationValueKey);
 }
Esempio n. 14
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 GrhIndex Read(string name, IValueReader reader)
 {
     return(reader.ReadGrhIndex(name));
 }
Esempio n. 15
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>
        void IPersistable.ReadState(IValueReader reader)
        {
            PersistableHelper.Read(this, reader);

            // Manually handle the WaveNoise sprite
            var grhIndex = reader.ReadGrhIndex(_valueKeyWaveNoise);
            _waveNoise.SetGrh(grhIndex);
        }
Esempio n. 16
0
        static KeyValuePair<GrhIndex, List<WallEntityBase>> ReadWalls(IValueReader r, CreateWallEntityFromReaderHandler createWall)
        {
            var grhIndex = r.ReadGrhIndex(_grhIndexValueKey);
            var walls = r.ReadManyNodes(_wallsNodeName, x => createWall(x));

            return new KeyValuePair<GrhIndex, List<WallEntityBase>>(grhIndex, walls.ToList());
        }
Esempio n. 17
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());
        }
Esempio n. 18
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 virtual void ReadState(IValueReader reader)
        {
            var grhIndex = reader.ReadGrhIndex(_grhIndexKeyName);

            if (!grhIndex.IsInvalid)
                _grh.SetGrh(grhIndex);

            PersistableHelper.Read(this, reader);
        }
Esempio n. 19
0
        void Read(IValueReader r)
        {
            var position = r.ReadVector2(_positionValueKey);
            var size = r.ReadVector2(_sizeValueKey);
            IsPlatform = r.ReadBool(_isPlatformValueKey);
            BoundGrhIndex = r.ReadGrhIndex(_boundGrhIndexValueKey);

            SetPositionRaw(position);
            SetSizeRaw(size);
        }