Example #1
0
        /// <summary>
        /// Handles when a <see cref="GrhData"/> is added to the <see cref="GrhData"/>s DArray.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="NetGore.Collections.DArrayEventArgs{T}"/> instance containing the event data.</param>
        static void AddHandler(DArray <GrhData> sender, DArrayEventArgs <GrhData> e)
        {
            Debug.Assert(e.Index != GrhIndex.Invalid);

            var gd = e.Item;

            if (gd == null)
            {
                Debug.Fail("gd is null.");
                return;
            }

            // Set the categorization event so we can keep up with any changes to the categorization.
            gd.CategorizationChanged -= ChangeCategorizationHandler;
            gd.CategorizationChanged += ChangeCategorizationHandler;

            AddToDictionary(gd);

            if (Added != null)
            {
                Added.Raise(gd, EventArgs.Empty);
            }

            if (!_isLoading)
            {
                if (AddedNew != null)
                {
                    AddedNew.Raise(gd, EventArgs.Empty);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Handles when a GrhData is removed from the DArray
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="NetGore.Collections.DArrayEventArgs{T}"/> instance containing the event data.</param>
        static void RemoveHandler(object sender, DArrayEventArgs <GrhData> e)
        {
            Debug.Assert(e.Index != GrhIndex.Invalid);

            RemoveFromDictionary(e.Item);

            if (Removed != null)
            {
                Removed.Raise(e.Item, EventArgs.Empty);
            }
        }