示例#1
0
        public static int MobileNotoriety(Mobile a, Mobile b)
        {
            if (_NotorietyParent == null)
            {
                _NotorietyParent = NotorietyHandlers.MobileNotoriety;
            }

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

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

                if (handled)
                {
                    if (result <= Bubble)
                    {
                        break;
                    }

                    return(result);
                }
            }

            return(_NotorietyParent(a, b));
        }
示例#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;
        }
示例#5
0
        public static int MobileNotoriety(Mobile a, IDamageable b)
        {
            if (b is Mobile)
            {
                return(MobileNotoriety(a, (Mobile)b));
            }

            if (_NotorietyParent == null)
            {
                _NotorietyParent = NotorietyHandlers.MobileNotoriety;
            }

            return(_NotorietyParent(a, b));
        }
示例#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;
        }
示例#7
0
 public NotorietyEntry(int priority, NotorietyHandler <T> handler)
 {
     Priority = priority;
     Handler  = handler;
 }
示例#8
0
 public static void UnregisterHarmfulHandler(NotorietyHandler <bool> handler)
 {
     _HarmfulHandlers.RemoveAll(e => e.Handler == handler);
 }
示例#9
0
 public static void RegisterHarmfulHandler(NotorietyHandler <bool> handler, int priority = 0)
 {
     UnregisterHarmfulHandler(handler);
     _HarmfulHandlers.Add(new NotorietyEntry <bool>(priority, handler));
 }
示例#10
0
 public static void UnregisterBeneficialHandler(NotorietyHandler <bool> handler)
 {
     _BeneficialHandlers.RemoveAll(e => e.Handler == handler);
 }
示例#11
0
 public static void UnregisterNameHandler(NotorietyHandler <int> handler)
 {
     _NameHandlers.RemoveAll(e => e.Handler == handler);
 }
示例#12
0
 public static void RegisterNameHandler(NotorietyHandler <int> handler, int priority = 0)
 {
     UnregisterNameHandler(handler);
     _NameHandlers.Add(new NotorietyEntry <int>(priority, handler));
 }
示例#13
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;
		}
示例#14
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;
		}
示例#15
0
 public static void Initialize()
 {
     NotoHandler = new NotorietyHandler(Handle_Notoriety);
 }
 public static void Initialize()
 {
     NotoHandler = new NotorietyHandler(Handle_Notoriety);
 }