Ejemplo n.º 1
0
        public static bool AllowHarmful(Mobile a, Mobile b)
        {
            if (_HarmfulParent == null)
            {
                _HarmfulParent = NotorietyHandlers.Mobile_AllowHarmful;
            }

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

            foreach (var handler in _HarmfulHandlers.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(_HarmfulParent(a, b));
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 5
0
        public static bool AllowHarmful(Mobile a, IDamageable b)
        {
            if (b is Mobile)
            {
                return(AllowHarmful(a, (Mobile)b));
            }

            if (_HarmfulParent == null)
            {
                _HarmfulParent = NotorietyHandlers.Mobile_AllowHarmful;
            }

            return(_HarmfulParent(a, b));
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
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;
		}
Ejemplo n.º 8
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;
		}