Exemple #1
0
        public static bool AllowBeneficial(Mobile a, Mobile b)
        {
            if (_BeneficialParent == null)
            {
                _BeneficialParent = NotorietyHandlers.Mobile_AllowBeneficial;
            }

            if (a == null || a.Deleted || b == null || b.Deleted)
            {
                return(_BeneficialParent(a, b));
            }

            foreach (var handler in _BeneficialHandlers.Where(e => e.Handler != null)
                     .OrderByDescending(e => e.Priority)
                     .Select(e => e.Handler))
            {
                bool handled;
                var  result = handler(a, b, out handled);

                if (handled)
                {
                    return(result);
                }
            }

            return(_BeneficialParent(a, b));
        }
Exemple #2
0
        public static void CSDispose()
        {
            Notoriety.Handler             = _NotorietyParent ?? NotorietyHandlers.MobileNotoriety;
            Mobile.AllowBeneficialHandler = _BeneficialParent ?? NotorietyHandlers.Mobile_AllowBeneficial;
            Mobile.AllowHarmfulHandler    = _HarmfulParent ?? NotorietyHandlers.Mobile_AllowHarmful;

            _NotorietyParent  = null;
            _BeneficialParent = null;
            _HarmfulParent    = null;
        }
        protected NotorietyHandlerChain()
        {
            // Store the original handlers in some read only private variables
            // so we can call them later if need be.
            _notorietyHandlerSuccessor       = Notoriety.Handler;
            _allowBeneficialHandlerSuccessor = Mobile.AllowBeneficialHandler;
            _allowHarmfulHandlerSuccessor    = Mobile.AllowHarmfulHandler;

            // Set the current handlers to our new chain handlers.
            Notoriety.Handler             = HandleNotoriety;
            Mobile.AllowBeneficialHandler = AllowBeneficial;
            Mobile.AllowHarmfulHandler    = AllowHarmful;
        }
        protected NotorietyHandlerChain()
        {
            // Store the original handlers in some read only private variables
            // so we can call them later if need be.
            _notorietyHandlerSuccessor = Notoriety.Handler;
            _allowBeneficialHandlerSuccessor = Mobile.AllowBeneficialHandler;
            _allowHarmfulHandlerSuccessor = Mobile.AllowHarmfulHandler;

            // Set the current handlers to our new chain handlers.
            Notoriety.Handler = HandleNotoriety;
            Mobile.AllowBeneficialHandler = AllowBeneficial;
            Mobile.AllowHarmfulHandler = AllowHarmful;
        }
Exemple #5
0
        private static void CSInvoke()
        {
            if (_NotorietyParent == null && Notoriety.Handler != MobileNotoriety)
            {
                _NotorietyParent = Notoriety.Handler ?? NotorietyHandlers.MobileNotoriety;
            }

            if (_BeneficialParent == null && Mobile.AllowBeneficialHandler != AllowBeneficial)
            {
                _BeneficialParent = Mobile.AllowBeneficialHandler ?? NotorietyHandlers.Mobile_AllowBeneficial;
            }

            if (_HarmfulParent == null && Mobile.AllowHarmfulHandler != AllowHarmful)
            {
                _HarmfulParent = Mobile.AllowHarmfulHandler ?? NotorietyHandlers.Mobile_AllowHarmful;
            }

            Notoriety.Handler             = MobileNotoriety;
            Mobile.AllowBeneficialHandler = AllowBeneficial;
            Mobile.AllowHarmfulHandler    = AllowHarmful;
        }
Exemple #6
0
		public static void Disable()
		{
			Notoriety.Handler = _NotorietyParent ?? NotorietyHandlers.MobileNotoriety;
			Mobile.AllowBeneficialHandler = _BeneficialParent ?? NotorietyHandlers.Mobile_AllowBeneficial;
			Mobile.AllowHarmfulHandler = _HarmfulParent ?? NotorietyHandlers.Mobile_AllowHarmful;

			_NotorietyParent = null;
			_BeneficialParent = null;
			_HarmfulParent = null;
		}
Exemple #7
0
		public static void Enable()
		{
			if (_NotorietyParent == null && Notoriety.Handler != MobileNotoriety)
			{
				_NotorietyParent = Notoriety.Handler ?? NotorietyHandlers.MobileNotoriety;
			}

			if (_BeneficialParent == null && Mobile.AllowBeneficialHandler != AllowBeneficial)
			{
				_BeneficialParent = Mobile.AllowBeneficialHandler ?? NotorietyHandlers.Mobile_AllowBeneficial;
			}

			if (_HarmfulParent == null && Mobile.AllowHarmfulHandler != AllowHarmful)
			{
				_HarmfulParent = Mobile.AllowHarmfulHandler ?? NotorietyHandlers.Mobile_AllowHarmful;
			}

			Notoriety.Handler = MobileNotoriety;
			Mobile.AllowBeneficialHandler = AllowBeneficial;
			Mobile.AllowHarmfulHandler = AllowHarmful;
		}