Ejemplo n.º 1
0
        /// <summary>
        /// Tries to add a <see cref="NPCChatConditionalCollectionItemBase"/> to the <see cref="ConditionalCollection"/>.
        /// </summary>
        /// <param name="item">The item to add.</param>
        /// <returns>True if the <paramref name="item"/> was successfully added; otherwise false.</returns>
        public bool TryAddToConditionalCollection(NPCChatConditionalCollectionItemBase item)
        {
            if (ConditionalCollection == null)
            {
                return(false);
            }

            return(ConditionalCollection.TryAddItem(item));
        }
        /// <summary>
        /// Tries to add a NPCChatConditionalCollectionItemBase to the collection.
        /// </summary>
        /// <param name="item">The NPCChatConditionalCollectionItemBase to add.</param>
        /// <returns>True if the <paramref name="item"/> was successfully added; otherwise false.</returns>
        public bool TryAddItem(NPCChatConditionalCollectionItemBase item)
        {
            if (item == null)
            {
                return(false);
            }

            if (item is EditorNPCChatConditionalCollectionItem)
            {
                return(TryAddItem((EditorNPCChatConditionalCollectionItem)item));
            }

            var newItem = new EditorNPCChatConditionalCollectionItem(item);

            return(TryAddItem(newItem));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorNPCChatConditionalCollectionItem"/> class.
        /// </summary>
        /// <param name="source">The source <see cref="NPCChatConditionalCollectionBase"/> to copy the values from. If null,
        /// no values are copied.</param>
        public EditorNPCChatConditionalCollectionItem(NPCChatConditionalCollectionItemBase source)
        {
            if (source == null)
            {
                return;
            }

            var stream = new BitStream(256);

            using (var writer = BinaryValueWriter.Create(stream))
            {
                source.Write(writer);
            }

            stream.PositionBits = 0;

            IValueReader reader = BinaryValueReader.Create(stream);

            Read(reader);
        }