コード例 #1
0
 public void Write(IValueWriter w)
 {
     w.Write(_positionValueKey, Position);
     w.Write(_sizeValueKey, Size);
     w.Write(_isPlatformValueKey, IsPlatform);
     w.Write(_boundGrhIndexValueKey, BoundGrhIndex);
 }
コード例 #2
0
 /// <summary>
 ///   Writes a <see cref = "KeyValuePair{T,U}" />.
 /// </summary>
 /// <param name = "w">The <see cref = "IValueWriter" /> to write to.</param>
 /// <param name = "item">The value to write.</param>
 static void Write(IValueWriter w, KeyValuePair <string, HashInfo> item)
 {
     w.Write(_textureNameValueKey, item.Key);
     w.Write(_hashValueKey, item.Value.Hash);
     w.Write(_fileSizeValueKey, item.Value.FileSize);
     w.Write(_lastModifiedValueKey, item.Value.LastModifiedTime);
 }
コード例 #3
0
        /// <summary>
        /// Writes the NPCChatDialogItemBase's values to an IValueWriter.
        /// </summary>
        /// <param name="writer">IValueWriter to write the values to.</param>
        public void Write(IValueWriter writer)
        {
            AssertBranchHasTwoResponses();
            AssertNonBranchHasNoConditionals();
            AssertResponsesHaveValidValues();

            writer.Write("ID", ID);
            writer.Write("Title", Title ?? string.Empty);
            writer.Write("Text", Text ?? string.Empty);
            writer.Write("IsBranch", IsBranch);
            writer.WriteManyNodes("Responses", Responses, ((w, item) => item.Write(w)));

            if (IsBranch)
            {
                writer.WriteStartNode("Conditionals");
                {
                    var c = Conditionals;
                    var hasConditionals = (c != null) && (!c.IsEmpty());
                    writer.Write("HasConditionals", hasConditionals);
                    if (hasConditionals)
                    {
                        c.Write(writer);
                    }
                }
                writer.WriteEndNode("Conditionals");
            }
        }
コード例 #4
0
 /// <summary>
 /// When overridden in the derived class, writes a value to an <see cref="IValueWriter"/> with the specified name.
 /// </summary>
 /// <param name="name">Name of the value.</param>
 /// <param name="writer"><see cref="IValueWriter"/> to write to.</param>
 /// <param name="value">Value to write.</param>
 protected override void Write(string name, IValueWriter writer, T?value)
 {
     if (writer.SupportsNodes)
     {
         if (writer.SupportsNameLookup)
         {
             writer.WriteStartNode(name);
             {
                 writer.Write(_hasValueValueKey, value.HasValue);
                 _nonNullableSync.InternalWrite(_valueValueKey, writer, (value.HasValue ? value.Value : default(T)));
             }
             writer.WriteEndNode(name);
         }
         else
         {
             writer.Write("__" + name + "_HasValue__", value.HasValue);
             _nonNullableSync.InternalWrite(name, writer, (value.HasValue ? value.Value : default(T)));
         }
     }
     else
     {
         writer.Write(null, value.HasValue);
         if (value.HasValue)
         {
             _nonNullableSync.InternalWrite(name, writer, value.Value);
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// Writes a Color.
 /// </summary>
 /// <param name="writer">IValueWriter to write to.</param>
 /// <param name="name">Unique name of the <paramref name="value"/> that will be used to distinguish it
 /// from other values when reading.</param>
 /// <param name="value">Value to write.</param>
 public static void Write(this IValueWriter writer, string name, Color value)
 {
     if (writer.SupportsNameLookup)
     {
         // We are using name lookup, so we have to combine the values so we use only one name
         const string delimiter = ",";
         var          sb        = new StringBuilder(16);
         sb.Append(Parser.Invariant.ToString(value.R));
         sb.Append(delimiter);
         sb.Append(Parser.Invariant.ToString(value.G));
         sb.Append(delimiter);
         sb.Append(Parser.Invariant.ToString(value.B));
         sb.Append(delimiter);
         sb.Append(Parser.Invariant.ToString(value.A));
         writer.Write(name, sb.ToString());
     }
     else
     {
         // Not using name lookup, so just write them out
         // ReSharper disable RedundantCast
         writer.Write(null, (byte)value.R);
         writer.Write(null, (byte)value.G);
         writer.Write(null, (byte)value.B);
         writer.Write(null, (byte)value.A);
         // ReSharper restore RedundantCast
     }
 }
コード例 #6
0
ファイル: LineEmitter.cs プロジェクト: thepirateclub/netgore
 /// <summary>
 /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_angleKeyName, Angle);
     writer.Write(_emitBothWaysKeyName, EmitBothWays);
     writer.Write(_lengthKeyName, Length);
     writer.Write(_rectilinearKeyName, Rectilinear);
 }
コード例 #7
0
 /// <summary>
 /// Writes a <see cref="GuildMemberNameRank"/> to a <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the <paramref name="value"/> to.</param>
 /// <param name="name">Unique name of the <paramref name="value"/> that will be used to distinguish it
 /// from other values when reading.</param>
 /// <param name="value">The <see cref="GuildMemberNameRank"/> to write.</param>
 public static void Write(this IValueWriter writer, string name, GuildMemberNameRank value)
 {
     if (writer.SupportsNameLookup)
     {
         if (writer.SupportsNodes)
         {
             // Write out using a child node
             writer.WriteStartNode(name);
             writer.Write(_nameValueKey, value.Name);
             writer.Write(_rankValueKey, value.Rank);
             writer.WriteEndNode(name);
         }
         else
         {
             // Concat the values together so name lookup still works
             var s = value.Name + _concatDelimiter + value.Rank;
             writer.Write(name, s);
         }
     }
     else
     {
         // No need for name lookup, so just write out raw
         writer.Write(null, value.Name);
         writer.Write(null, value.Rank);
     }
 }
コード例 #8
0
 public void Write(IValueWriter w)
 {
     w.Write(_positionValueKey, Position);
     w.Write(_sizeValueKey, Size);
     w.Write(_isPlatformValueKey, IsPlatform);
     w.Write(_boundGrhIndexValueKey, BoundGrhIndex);
     w.WriteEnum(_directionBlockValueKey, DirectionalBlock);
 }
コード例 #9
0
 /// <summary>
 /// When overridden in the derived class, writes the values unique to this derived type to the
 /// <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_automaticSizeValueKey, AutomaticSize);
     writer.WriteStartNode(_textureNodeName);
     writer.Write(_textureNameValueKey, TextureName);
     writer.Write(_textureSourceValueKey, OriginalSourceRect);
     writer.WriteEndNode(_textureNodeName);
 }
コード例 #10
0
 /// <summary>
 /// Writes the <see cref="IMessageProcessorStats"/> to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
 public void Write(IValueWriter writer)
 {
     writer.Write("ProcessorID", ProcessorID);
     writer.Write("Calls", Calls);
     writer.Write("TotalBits", TotalBits);
     writer.Write("Min", Min);
     writer.Write("Max", Max);
 }
コード例 #11
0
        /// <summary>
        /// Writes the <see cref="NPCChatDialogBase"/>'s values to an <see cref="IValueWriter"/>.
        /// </summary>
        /// <param name="writer"><see cref="IValueWriter"/> to write the values to.</param>
        public void Write(IValueWriter writer)
        {
            var items = GetDialogItems();

            writer.Write(_nodeValueKeyID, ID);
            writer.Write(_nodeValueKeyTitle, Title);
            writer.WriteManyNodes(_nodeValueKeyItems, items, ((w, item) => item.Write(w)));
        }
コード例 #12
0
 /// <summary>
 /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_closedKeyName, Closed);
     writer.Write(_scaleKeyName, Scale);
     writer.Write(_rotationKeyName, Rotation);
     writer.WriteEnum(_polygonOriginKeyName, PolygonOrigin);
     Points.Write(_pointsNodeName, writer);
 }
コード例 #13
0
ファイル: SkeletonBodyItemInfo.cs プロジェクト: wtfcolt/game
 public void Write(IValueWriter writer)
 {
     writer.Write(_grhIndexValueKey, GrhIndex);
     writer.Write(_sourceValueKey, SourceName);
     writer.Write(_destValueKey, DestName);
     writer.Write(_offsetValueKey, Offset);
     writer.Write(_originValueKey, Origin);
 }
コード例 #14
0
ファイル: SkeletonBodyItemInfo.cs プロジェクト: wtfcolt/game
 public void Write(IValueWriter writer)
 {
     writer.Write(_grhIndexValueKey, GrhIndex);
     writer.Write(_sourceValueKey, SourceName);
     writer.Write(_destValueKey, DestName);
     writer.Write(_offsetValueKey, Offset);
     writer.Write(_originValueKey, Origin);
 }
コード例 #15
0
        /// <summary>
        /// Writes the SkeletonNode to an IValueWriter.
        /// </summary>
        /// <param name="writer">IValueWriter to write to.</param>
        public void Write(IValueWriter writer)
        {
            writer.Write(_nameValueKey, Name);
            writer.Write(_positionValueKey, Position);
            writer.Write(_isModifierValueKey, IsModifier);
            writer.Write(_hasParentValueKey, Parent != null);

            if (Parent != null)
            {
                writer.Write(_parentNameValueKey, Parent.Name);
            }
        }
コード例 #16
0
ファイル: DynamicEntity.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Writes the Position and Velocity to the specified IValueWriter. Use in conjuncture with
        /// DeserializePositionAndVelocity().
        /// </summary>
        /// <param name="writer">IValueWriter to write the values to.</param>
        /// <param name="currentTime">Current game time.</param>
        public void SerializePositionAndVelocity(IValueWriter writer, TickCount currentTime)
        {
            if (_syncPnVDupeCounter > 0)
            {
                --_syncPnVDupeCounter;
            }

            writer.Write(_positionValueKey, Position);
            writer.Write(_velocityValueKey, Velocity);

            _lastSentPosition = Position;
            _lastSentVelocity = Velocity;
            _syncPnVLastTime  = currentTime;
        }
コード例 #17
0
ファイル: AccountCharacterInfo.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Writes the state of the object to an <see cref="IValueWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
        public void WriteState(IValueWriter writer)
        {
            PersistableHelper.Write(this, writer);

            // Equipped bodies

            Debug.Assert(_equippedBodies.Count <= byte.MaxValue);

            writer.Write("EquippedBodiesCount", (byte)_equippedBodies.Count);

            for (var i = 0; i < _equippedBodies.Count; i++)
            {
                writer.Write("EquippedBody_" + i, _equippedBodies[i]);
            }
        }
コード例 #18
0
ファイル: BodyInfo.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Writes this <see cref="BodyInfo"/> to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
 public void Write(IValueWriter writer)
 {
     writer.Write(_idValueKey, ID);
     writer.Write(_bodyValueKey, Body);
     writer.Write(_fallValueKey, Fall);
     writer.Write(_jumpValueKey, Jump);
     writer.Write(_attackValueKey, Attack);
     writer.Write(_standValueKey, Stand);
     writer.Write(_walkValueKey, Walk);
     writer.Write(_sizeValueKey, Size);
     writer.Write(_paperdollValueKey, Paperdoll);
 }
コード例 #19
0
        /// <summary>
        /// Writes the state of the object to an <see cref="IValueWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
        void IPersistable.WriteState(IValueWriter writer)
        {
            PersistableHelper.Write(this, writer);

            // Manually handle the WaveNoise sprite
            writer.Write(_valueKeyWaveNoise, WaveNoise.GrhData.GrhIndex);
        }
コード例 #20
0
 /// <summary>
 /// Writes an <see cref="Stat{StatType}"/> to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <typeparam name="TStatType">The type of the stat.</typeparam>
 /// <param name="writer"><see cref="IValueWriter"/> to write to.</param>
 /// <param name="name">The unique name of the value to write.</param>
 /// <param name="stat">The <see cref="Stat{TStatType}"/> to write.</param>
 public static void Write <TStatType>(this IValueWriter writer, string name, Stat <TStatType> stat)
     where TStatType : struct, IComparable, IConvertible, IFormattable
 {
     if (writer.SupportsNodes)
     {
         writer.WriteStartNode(name);
         writer.WriteEnum("StatType", stat.StatType);
         writer.Write("Value", stat.Value);
         writer.WriteEndNode(name);
     }
     else
     {
         writer.WriteEnum(name + "_StatType", stat.StatType);
         writer.Write(name + "_Value", stat.Value);
     }
 }
コード例 #21
0
        /// <summary>
        /// When overridden in the derived class, writes the values unique to this derived type to the
        /// <paramref name="writer"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
        protected override void WriteCustomValues(IValueWriter writer)
        {
            var frameIndices = _frames.Select(x => x.GrhIndex).ToArray();

            writer.Write(_speedValueKey, (int)(1f / Speed));
            writer.WriteMany(_framesNodeName, frameIndices, writer.Write);
        }
コード例 #22
0
        /// <summary>
        /// Writes a <see cref="DynamicEntity"/> to a stream.
        /// </summary>
        /// <param name="writer"><see cref="IValueWriter"/> to write the <see cref="DynamicEntity"/> to.</param>
        /// <param name="dEntity"><see cref="DynamicEntity"/> to write to the stream.</param>
        /// <param name="compact">Whether or not the <see cref="DynamicEntity"/> is to be stored in a way that is optimized
        /// for size. The compact format is not guaranteed to remain stable. Because of this, the compact format should
        /// never be used for persistent storage. It is recommended to only use the compact format in network IO.
        /// The <paramref name="compact"/> value must be the same when reading and writing. That is, you cannot write
        /// with <paramref name="compact"/> set to true, then read back with it set to false, or vise versa.</param>
        /// <exception cref="ArgumentNullException"><paramref name="writer"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="dEntity"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="dEntity"/> is not of a valid that <see cref="Type"/>
        /// that is supported by this factory.</exception>
        public void Write(IValueWriter writer, DynamicEntity dEntity, bool compact = false)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (dEntity == null)
            {
                throw new ArgumentNullException("dEntity");
            }

            var type     = dEntity.GetType();
            var typeName = _typeCollection[type];

            // FUTURE: Make use of the "compact" argument to write the typeName as an ID, not a string. Difficulty is finding a reliable way to share the IDs to use.

            if (typeName == null)
            {
                const string errmsg = "Failed to write. The specified DynamicEntity `{0}` is not of a supported type ({1}).";
                throw new ArgumentException(string.Format(errmsg, dEntity, dEntity.GetType()));
            }

            writer.Write(_typeStringKey, typeName);
            dEntity.WriteAll(writer);
        }
コード例 #23
0
 /// <summary>
 /// Writes a Size.
 /// </summary>
 /// <param name="writer">IValueWriter to write to.</param>
 /// <param name="name">Unique name of the <paramref name="value"/> that will be used to distinguish it
 /// from other values when reading.</param>
 /// <param name="value">Value to write.</param>
 public static void Write(this IValueWriter writer, string name, Size value)
 {
     if (writer.SupportsNameLookup)
     {
         // We are using name lookup, so we have to combine the values so we use only one name
         var x = Parser.Invariant.ToString(value.Width);
         var y = Parser.Invariant.ToString(value.Height);
         writer.Write(name, x + "," + y);
     }
     else
     {
         // Not using name lookup, so just write them out
         writer.Write(null, value.Width);
         writer.Write(null, value.Height);
     }
 }
コード例 #24
0
ファイル: MapGrhWalls.cs プロジェクト: thepirateclub/netgore
        static void WriteWalls(IValueWriter w, KeyValuePair <GrhIndex, List <WallEntityBase> > item)
        {
            var grhIndex = item.Key;
            var walls    = item.Value;

            w.Write(_grhIndexValueKey, grhIndex);
            w.WriteManyNodes(_wallsNodeName, walls, ((pwriter, pitem) => pitem.Write(pwriter)));
        }
コード例 #25
0
ファイル: DynamicEntity.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Writes all of the changed property values to the specified IValueWriter. Use in conjunction with Deserialize().
        /// </summary>
        /// <param name="writer">IValueWriter to write the changed property values to.</param>
        public void Serialize(IValueWriter writer)
        {
            // Highest possible PropertySync index that we will be writing
            uint highestPropertyIndex = _lastNetworkSyncIndex;

            // Find the indicies that need to be synchronized
            // Its important to note that we are iterating in ascending order and putting them in a queue, so they
            // will come out in ascending order, too
            var writeIndices = new Queue <int>(_lastNetworkSyncIndex + 1);

            for (var i = 0; i <= _lastNetworkSyncIndex; i++)
            {
                var propertySync = _propertySyncs[i];
                if (!propertySync.SkipNetworkSync && propertySync.HasValueChanged(this))
                {
                    writeIndices.Enqueue(i);
                }
            }

            // Write the count so the reader knows how many indicies there will be
            writer.Write("Count", (uint)writeIndices.Count, 0, highestPropertyIndex);

            // Write the properties - first their index (so we know what property it is), then the value
            // Since the indices are sorted, we know that each index cannot be greater than the previous index
            uint lastIndex = 0;

            while (writeIndices.Count > 0)
            {
                // Write the index of the property
                var propIndex = (uint)writeIndices.Dequeue();
                writer.Write(_propertyIndexValueKey, propIndex, lastIndex, highestPropertyIndex);

                // Write the actual property value
                var propertySync = _propertySyncs[propIndex];
                propertySync.WriteValue(this, writer);

                // Allow for additonal handling
                OnSerializeProperty(writer, propertySync);

                // Store this property index as the last written index
                lastIndex = propIndex;
            }

            // Synchronized!
            _isSynchronized = true;
        }
コード例 #26
0
ファイル: ShopBase.cs プロジェクト: thepirateclub/netgore
 /// <summary>
 /// Writes the information describing the shop items to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
 public void WriteShopItems(IValueWriter writer)
 {
     writer.Write("Items", (byte)_shopItems.Length);
     for (var i = 0; i < _shopItems.Length; i++)
     {
         WriteShopItem(writer, "Item" + i, _shopItems[i]);
     }
 }
コード例 #27
0
 /// <summary>
 /// Writes a <see cref="ParticleEmitter"/> to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
 /// <param name="emitter">The <see cref="ParticleEmitter"/> to write.</param>
 public static void Write(IValueWriter writer, ParticleEmitter emitter)
 {
     writer.Write(_emitterTypeKeyName, Instance.GetTypeName(emitter.GetType()));
     writer.WriteStartNode(_emitterNodeName);
     {
         emitter.WriteState(writer);
     }
     writer.WriteEndNode(_emitterNodeName);
 }
コード例 #28
0
ファイル: Map.cs プロジェクト: thepirateclub/netgore
 void SaveLighting(IValueWriter w)
 {
     w.WriteStartNode(_lightingNodeName);
     {
         w.Write("Ambient", AmbientLight);
         w.WriteManyNodes(_lightsNodeName, _lights.ToArray(), (wr, l) => l.WriteState(wr));
     }
     w.WriteEndNode(_lightingNodeName);
 }
コード例 #29
0
ファイル: EnumHelper.cs プロジェクト: thepirateclub/netgore
        public static void WriteValue(IValueWriter writer, string name, T value)
        {
            var signedV = ToInt(value) - _minValue;

            Debug.Assert(signedV >= uint.MinValue);
            var v = (uint)signedV;

            writer.Write(name, v, _bitsRequired);
        }
コード例 #30
0
 /// <summary>
 /// Writes this <see cref="BodyInfo"/> to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
 public void Write(IValueWriter writer)
 {
     writer.Write(_idValueKey, ID);
     writer.Write(_bodyValueKey, Body);
     writer.Write(_fallValueKey, Fall);
     writer.Write(_jumpValueKey, Jump);
     writer.Write(_punchValueKey, Punch);
     writer.Write(_standValueKey, Stand);
     writer.Write(_walkValueKey, Walk);
     writer.Write(_sizeValueKey, Size);
 }
コード例 #31
0
        /// <summary>
        /// Writes the NPCChatDialogItemBase's values to an IValueWriter.
        /// </summary>
        /// <param name="writer">IValueWriter to write the values to.</param>
        public void Write(IValueWriter writer)
        {
            writer.Write("Value", Value);
            writer.Write("Page", Page);
            writer.Write("Text", Text ?? string.Empty);
            writer.WriteMany("Actions", Actions.Select(x => x.Name), writer.Write);

            writer.WriteStartNode("Conditionals");
            {
                var c = Conditionals;
                var hasConditionals = (c != null) && (c.Count() > 0);
                writer.Write("HasConditionals", hasConditionals);
                if (hasConditionals)
                {
                    c.Write(writer);
                }
            }
            writer.WriteEndNode("Conditionals");
        }
コード例 #32
0
ファイル: SkeletonNode.cs プロジェクト: mateuscezar/netgore
        /// <summary>
        /// Writes the SkeletonNode to an IValueWriter.
        /// </summary>
        /// <param name="writer">IValueWriter to write to.</param>
        public void Write(IValueWriter writer)
        {
            writer.Write(_nameValueKey, Name);
            writer.Write(_positionValueKey, Position);
            writer.Write(_isModifierValueKey, IsModifier);
            writer.Write(_hasParentValueKey, Parent != null);

            if (Parent != null)
                writer.Write(_parentNameValueKey, Parent.Name);
        }
コード例 #33
0
 /// <summary>
 /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_emitPeriodKeyName, EmitPeriod);
     writer.Write(_restPeriodKeyName, RestPeriod);
 }
コード例 #34
0
ファイル: MapGrh.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Writes the state of the object to an <see cref="IValueWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
        public virtual void WriteState(IValueWriter writer)
        {
            writer.Write(_grhIndexKeyName, Grh.GrhData != null ? Grh.GrhData.GrhIndex : GrhIndex.Invalid);

            PersistableHelper.Write(this, writer);
        }
コード例 #35
0
ファイル: PolygonEmitter.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_closedKeyName, Closed);
     writer.Write(_scaleKeyName, Scale);
     writer.Write(_rotationKeyName, Rotation);
     writer.WriteEnum(_polygonOriginKeyName, PolygonOrigin);
     Points.Write(_pointsNodeName, writer);
 }
コード例 #36
0
        /// <summary>
        /// Writes the <see cref="ParticleModifier"/> to the <paramref name="writer"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
        public void Write(IValueWriter writer)
        {
            var typeName = _typeFactory.GetTypeName(GetType());

            writer.Write(_typeKeyName, typeName);

            writer.WriteStartNode(_customValuesNodeName);
            {
                WriteState(writer);
            }
            writer.WriteEndNode(_customValuesNodeName);
        }
コード例 #37
0
        /// <summary>
        /// Writes the state of the object to an <see cref="IValueWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
        public void WriteState(IValueWriter writer)
        {
            // Write the primary values
            writer.Write(_nameKeyName, Name);
            writer.Write(_blendModeKeyName, BlendMode);
            writer.Write(_budgetKeyName, Budget);
            writer.Write(_emitterLifeKeyName, EmitterLife);
            writer.Write(_particleLifeKeyName, ParticleLife);
            writer.Write(_originKeyName, Origin);
            writer.Write(_releaseAmountKeyName, ReleaseAmount);
            writer.Write(_releaseColorKeyName, ReleaseColor);
            writer.Write(_releaseRateKeyName, ReleaseRate);
            writer.Write(_releaseRotationKeyName, ReleaseRotation);
            writer.Write(_releaseScaleKeyName, ReleaseScale);
            writer.Write(_releaseSpeedKeyName, ReleaseSpeed);
            writer.Write(_grhIndexKeyName, Sprite.GrhData != null ? Sprite.GrhData.GrhIndex : GrhIndex.Invalid);

            // Write the custom values
            writer.WriteStartNode(_customValuesNodeName);
            {
                WriteCustomValues(writer);
            }
            writer.WriteEndNode(_customValuesNodeName);

            // Write the modifier collection
            ParticleModifiers.Write(_particleModifiersNodeName, writer);
            EmitterModifiers.Write(_emitterModifiersNodeName, writer);
        }
コード例 #38
0
ファイル: ParticleColorModifier.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
        protected override void WriteCustomValues(IValueWriter writer)
        {
            writer.Write(_modifyRedKeyName, ModifyRed);
            writer.Write(_modifyGreenKeyName, ModifyGreen);
            writer.Write(_modifyBlueKeyName, ModifyBlue);
            writer.Write(_modifyAlphaKeyName, ModifyAlpha);

            writer.Write(_releaseColorKeyName, ReleaseColor);
            writer.Write(_ultimateColorKeyName, UltimateColor);
        }
コード例 #39
0
ファイル: ParticleModifierTests.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write("SerializedValue", SerializedValue);
 }
コード例 #40
0
ファイル: AccountCharacterInfo.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Writes the state of the object to an <see cref="IValueWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
        public void WriteState(IValueWriter writer)
        {
            PersistableHelper.Write(this, writer);

            // Equipped bodies

            Debug.Assert(_equippedBodies.Count <= byte.MaxValue);

            writer.Write("EquippedBodiesCount", (byte)_equippedBodies.Count);

            for (var i = 0; i < _equippedBodies.Count; i++)
            {
                writer.Write("EquippedBody_" + i, _equippedBodies[i]);
            }
        }
コード例 #41
0
 /// <summary>
 /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_initialScaleKeyName, InitialScale);
     writer.Write(_ultimateScaleKeyName, UltimateScale);
 }
コード例 #42
0
ファイル: NPCChatResponseBase.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// Writes the NPCChatDialogItemBase's values to an IValueWriter.
        /// </summary>
        /// <param name="writer">IValueWriter to write the values to.</param>
        public void Write(IValueWriter writer)
        {
            writer.Write("Value", Value);
            writer.Write("Page", Page);
            writer.Write("Text", Text ?? string.Empty);
            writer.WriteMany("Actions", Actions.Select(x => x.Name), writer.Write);

            writer.WriteStartNode("Conditionals");
            {
                var c = Conditionals;
                var hasConditionals = (c != null) && (!c.IsEmpty());
                writer.Write("HasConditionals", hasConditionals);
                if (hasConditionals)
                    c.Write(writer);
            }
            writer.WriteEndNode("Conditionals");
        }
コード例 #43
0
ファイル: AudioManager.cs プロジェクト: mateuscezar/netgore
 /// <summary>
 /// Writes the audio values to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="w">The <see cref="IValueWriter"/> to write to.</param>
 /// <param name="value">The value to write.</param>
 static void WriteValue(IValueWriter w, KeyValuePair<string, int> value)
 {
     w.Write("File", value.Key);
     w.Write("Index", value.Value);
 }
コード例 #44
0
ファイル: RectEmitter.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_heightKeyName, Height);
     writer.Write(_widthKeyName, Width);
     writer.Write(_perimeterKeyName, Perimeter);
 }
コード例 #45
0
ファイル: PersistableForm.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Writes the state of the object to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
 public virtual void WriteState(IValueWriter writer)
 {
     writer.Write(_locationValueKey, Location);
     writer.Write(_sizeValueKey, Size);
     PersistableHelper.Write(this, writer);
 }
コード例 #46
0
 /// <summary>
 /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_rateKeyName, Rate);
 }
コード例 #47
0
ファイル: PersistableCheckBox.cs プロジェクト: wtfcolt/game
 /// <summary>
 /// Writes the state of the object to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
 public virtual void WriteState(IValueWriter writer)
 {
     writer.Write(_checkedValueKey, Checked);
     PersistableHelper.Write(this, writer);
 }
コード例 #48
0
 /// <summary>
 /// Writes the <see cref="IMessageProcessorStats"/> to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
 public void Write(IValueWriter writer)
 {
     writer.Write("ProcessorID", ProcessorID);
     writer.Write("Calls", Calls);
     writer.Write("TotalBits", TotalBits);
     writer.Write("Min", Min);
     writer.Write("Max", Max);
 }
コード例 #49
0
ファイル: Map.cs プロジェクト: mateuscezar/netgore
 void SaveLighting(IValueWriter w)
 {
     w.WriteStartNode(_lightingNodeName);
     {
         w.Write("Ambient", AmbientLight);
         w.WriteManyNodes(_lightsNodeName, _lights.ToArray(), (wr, l) => l.WriteState(wr));
     }
     w.WriteEndNode(_lightingNodeName);
 }
コード例 #50
0
ファイル: MapGrhWalls.cs プロジェクト: Vizzini/netgore
        static void WriteWalls(IValueWriter w, KeyValuePair<GrhIndex, List<WallEntityBase>> item)
        {
            var grhIndex = item.Key;
            var walls = item.Value;

            w.Write(_grhIndexValueKey, grhIndex);
            w.WriteManyNodes(_wallsNodeName, walls, ((pwriter, pitem) => pitem.Write(pwriter)));
        }
コード例 #51
0
 /// <summary>
 /// When overridden in the derived class, writes all custom state values to the <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the state values to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_positionKeyName, Position);
     writer.Write(_radiusKeyName, Radius);
     writer.Write(_strengthKeyName, Strength);
 }
コード例 #52
0
        /// <summary>
        /// Writes the state of the object to an <see cref="IValueWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
        void IPersistable.WriteState(IValueWriter writer)
        {
            PersistableHelper.Write(this, writer);

            // Manually handle the WaveNoise sprite
            writer.Write(_valueKeyWaveNoise, WaveNoise.GrhData.GrhIndex);
        }
コード例 #53
0
ファイル: QuickBarForm.cs プロジェクト: mateuscezar/netgore
 /// <summary>
 /// Writes the <see cref="QuickBarSlotValues"/> to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="w">The <see cref="IValueWriter"/> to write the values to.</param>
 public void Write(IValueWriter w)
 {
     w.Write("Slot", Slot);
     w.WriteEnum("Type", Type);
     w.Write("Value", Value);
 }
コード例 #54
0
ファイル: StationaryGrhData.cs プロジェクト: Furt/netgore
 /// <summary>
 /// When overridden in the derived class, writes the values unique to this derived type to the
 /// <paramref name="writer"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
 protected override void WriteCustomValues(IValueWriter writer)
 {
     writer.Write(_automaticSizeValueKey, AutomaticSize);
     writer.WriteStartNode(_textureNodeName);
     writer.Write(_textureNameValueKey, TextureName);
     writer.Write(_textureSourceValueKey, OriginalSourceRect);
     writer.WriteEndNode(_textureNodeName);
 }
コード例 #55
0
ファイル: ColumnSchema.cs プロジェクト: mateuscezar/netgore
 static void WriteKVP(IValueWriter writer, KeyValuePair<string, string> value)
 {
     writer.Write(_keyValueName, value.Key);
     writer.Write(_valueValueName, value.Value ?? string.Empty);
 }
コード例 #56
0
        /// <summary>
        /// Writes the NPCChatDialogItemBase's values to an IValueWriter.
        /// </summary>
        /// <param name="writer">IValueWriter to write the values to.</param>
        public void Write(IValueWriter writer)
        {
            AssertBranchHasTwoResponses();
            AssertNonBranchHasNoConditionals();
            AssertResponsesHaveValidValues();

            writer.Write("ID", ID);
            writer.Write("Title", Title ?? string.Empty);
            writer.Write("Text", Text ?? string.Empty);
            writer.Write("IsBranch", IsBranch);
            writer.WriteManyNodes("Responses", Responses, ((w, item) => item.Write(w)));

            if (IsBranch)
            {
                writer.WriteStartNode("Conditionals");
                {
                    var c = Conditionals;
                    var hasConditionals = (c != null) && (c.Count() > 0);
                    writer.Write("HasConditionals", hasConditionals);
                    if (hasConditionals)
                        c.Write(writer);
                }
                writer.WriteEndNode("Conditionals");
            }
        }
コード例 #57
0
        /// <summary>
        /// Writes the <see cref="NPCChatDialogBase"/>'s values to an <see cref="IValueWriter"/>.
        /// </summary>
        /// <param name="writer"><see cref="IValueWriter"/> to write the values to.</param>
        public void Write(IValueWriter writer)
        {
            var items = GetDialogItems();

            writer.Write(_nodeValueKeyID, ID);
            writer.Write(_nodeValueKeyTitle, Title);
            writer.WriteManyNodes(_nodeValueKeyItems, items, ((w, item) => item.Write(w)));
        }
コード例 #58
0
ファイル: Light.cs プロジェクト: mateuscezar/netgore
 /// <summary>
 /// Writes the state of the object to an <see cref="IValueWriter"/>.
 /// </summary>
 /// <param name="writer">The <see cref="IValueWriter"/> to write the values to.</param>
 public void WriteState(IValueWriter writer)
 {
     writer.Write(_positionValueKey, Position);
     writer.Write(_sizeValueKey, Size);
     writer.Write(_colorValueKey, Color);
     writer.Write(_rotationValueKey, Rotation);
     writer.Write(_isEnabledValueKey, IsEnabled);
     writer.Write(_spriteValueKey, Sprite != null ? Sprite.GrhData.GrhIndex : GrhIndex.Invalid);
 }
コード例 #59
0
        private void WriteEntity(NetworkEntity entity, ISerializationContext context, IValueWriter writer)
        {
            writer.WriteString (entity.EntityName);
            writer.WriteUInt16 ((UInt16)entity.NetworkID);
            writer.WriteUInt16 ((UInt16)entity.Fields.Count);

            foreach (var kvp in entity.Fields)
            {
                object fieldValue = kvp.Value.Value;

                writer.WriteString (kvp.Key);

                // Write the field type
                ushort typeID;
                context.TypeMap.GetTypeId (fieldValue.GetType (), out typeID);
                writer.WriteUInt16 (typeID);

                if (fieldValue is Vector2)
                    writer.Write (context, (Vector2)fieldValue, Vector2Serializer.Instance);
                else if (fieldValue is Vector3)
                    writer.Write (context, (Vector3)fieldValue, Vector3Serializer.Instance);
                else
                    writer.Write (context, fieldValue, kvp.Value.Type);
            }
        }
コード例 #60
0
        /// <summary>
        /// Writes a <see cref="IRefractionEffect"/> to an <see cref="IValueWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IValueWriter"/> to write to.</param>
        /// <param name="re">The <see cref="IRefractionEffect"/> to write.</param>
        /// <exception cref="ArgumentException"><paramref name="re"/> is not in the <see cref="ValidTypes"/>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="re"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="writer"/> is null.</exception>
        public static void Write(IValueWriter writer, IRefractionEffect re)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            if (re == null)
                throw new ArgumentNullException("re");

            var asPersistable = re as IPersistable;

            string typeName = null;
            if (asPersistable != null)
                typeName = Instance[re.GetType()];

            if (typeName == null)
            {
                const string errmsg = "Type `{0}` is not a valid persistable IRefractionEffect type.";
                if (log.IsErrorEnabled)
                    log.ErrorFormat(errmsg, re.GetType());
                throw new ArgumentException(string.Format(errmsg, re.GetType()), "re");
            }

            writer.Write(_refractionEffectTypeKeyName, typeName);
            writer.WriteStartNode(_refractionEffectNodeName);
            {
                asPersistable.WriteState(writer);
            }
            writer.WriteEndNode(_refractionEffectNodeName);
        }