Example #1
0
        /// <summary>
        /// Updates the modifiers.
        /// </summary>
        /// <param name="i_EventData">The event data.</param>
        protected void UpdateModifiers(ref NumericalPropertyChangeEventStruct <TNumerical, TContext, TModifierReader> i_EventData)
        {
            int size = m_Modifiers.Count;

            for (int i = 0; i < size; ++i)
            {
                m_Modifiers[i].Update(ref i_EventData);
            }
            m_FinalModifier = i_EventData.NewModifier;

            //Log.DebugLog("Numerical property final modifier updated from {0} to {1}.", i_EventData.OldModifier, i_EventData.NewModifier);
        }
        protected void FireChangeEvent(ref NumericalPropertyChangeEventStruct <TNumerical, TContext, TModifierReader> i_EventData)
        {
            //Log.DebugLog("Numerical property change event fired.");

            if (ChangeSubscription != null)
            {
                ChangeSubscription(ref i_EventData);
            }
            if (SimpleChangeSubscription != null)
            {
                SimpleChangeSubscription(this);
            }
        }
Example #3
0
        /// <summary>
        /// Overriden instance update logic for firing the post-update events.
        /// </summary>
        /// <param name="i_ChangeTypeMask">A mask of change type flags describing this update event.</param>
        /// <param name="i_Context">The change context.</param>
        protected override void UpdateInternal(ENumericalPropertyChangeType i_ChangeTypeMask, TContext i_Context)
        {
            if ((m_Modifiers.Count > 0) || (ChangeSubscription != null) || (SimpleChangeSubscription != null))
            {
                if (!m_Updating)
                {
                    m_Updating = true;
                }
                else
                {
                    i_ChangeTypeMask |= ENumericalPropertyChangeType.NestedUpdate;
                }

                NumericalPropertyChangeEventStruct <TNumerical, TContext, TModifierReader> eventData =
                    new NumericalPropertyChangeEventStruct <TNumerical, TContext, TModifierReader>(
                        this,
                        i_ChangeTypeMask,
                        i_Context
                        );

                UpdateModifiers(ref eventData);
                UpdateModifiedValue();

                if ((i_ChangeTypeMask & ENumericalPropertyChangeType.NestedUpdate) == ENumericalPropertyChangeType.None)
                {
                    m_Updating = false;
                }
                if (ChangeSubscription != null)
                {
                    ChangeSubscription(ref eventData);
                }
                if (SimpleChangeSubscription != null)
                {
                    SimpleChangeSubscription(this);
                }
            }
            else
            {
                UpdateModifiedValue();
            }
        }
Example #4
0
        /// <summary>
        /// Instance update logic that can be overriden and customised.
        /// </summary>
        /// <param name="i_ChangeTypeMask">A mask of change type flags describing this update event.</param>
        /// <param name="i_Context">The change context.</param>
        protected virtual void UpdateInternal(ENumericalPropertyChangeType i_ChangeTypeMask, TContext i_Context)
        {
            if (m_Modifiers.Count > 0)
            {
                //tracking of nested update types
                if (!m_Updating)
                {
                    m_Updating = true;
                }
                else
                {
                    i_ChangeTypeMask |= ENumericalPropertyChangeType.NestedUpdate;
                }

                NumericalPropertyChangeEventStruct <TNumerical, TContext, TModifierReader> eventData =
                    new NumericalPropertyChangeEventStruct <TNumerical, TContext, TModifierReader>(
                        this,
                        i_ChangeTypeMask,
                        i_Context
                        );

                UpdateModifiers(ref eventData);
                UpdateModifiedValue();

                //leaving the scope of nested updating
                if ((i_ChangeTypeMask & ENumericalPropertyChangeType.NestedUpdate) == ENumericalPropertyChangeType.None)
                {
                    m_Updating = false;
                }
            }
            else
            {
                UpdateModifiedValue();
            }
        }
        /// <summary>
        /// Instance update logic that can be overriden and customised.
        /// </summary>
        /// <param name="i_ChangeTypeMask">A mask of change type flags describing this update event.</param>
        /// <param name="i_Context">The change context.</param>
        protected override void UpdateInternal(ENumericalPropertyChangeType i_ChangeTypeMask, TContext i_Context)
        {
            if ((m_Modifiers.Count > 0))
            {
                if (!m_Updating)
                {
                    m_Updating = true;
                }
                else
                {
                    i_ChangeTypeMask |= ENumericalPropertyChangeType.NestedUpdate;
                }

                m_DataZero.Set(GetMax());
                m_DataZero.Substract(m_Value);
                TNumerical oldDepletion = m_DataZero.Get();
                m_DataZero.ToZero();

                NumericalPropertyChangeEventStruct <TNumerical, TContext, TModifierReader> eventData =
                    new NumericalPropertyChangeEventStruct <TNumerical, TContext, TModifierReader>(
                        this,
                        i_ChangeTypeMask,
                        oldDepletion,
                        i_Context
                        );

                UpdateModifiers(ref eventData);
                m_Depletion = eventData.NewDepletion;
                UpdateExhaustableModifiedValue();

                if ((i_ChangeTypeMask & ENumericalPropertyChangeType.NestedUpdate) == ENumericalPropertyChangeType.None)
                {
                    m_Updating = false;
                }
            }
            else
            {
                UpdateExhaustableModifiedValue();
            }
        }