Beispiel #1
0
        private void CreateHandler(SpellEffect effect, int h, SpellEffectHandler[] handlers, ref SpellTargetCollection targets, ref SpellFailedReason failReason)
        {
            var handler = effect.SpellEffectHandlerCreator(this, effect);

            handlers[h]           = handler;
            handler.InitialTarget = (Unit)SelectedTarget;

            if (targets == null)
            {
                targets = CreateSpellTargetCollection();
            }
            // make sure, we have the right Caster-Type

            /*handler.CheckCasterType(ref failReason);
             * if (failReason != SpellFailedReason.Ok)
             * {
             *      return;
             * }
             *
             * // find targets and amount SpellTargetCollection if effects have same ImplicitTargetTypes
             * if (InitialTargets != null)
             * {
             *      // do we have given targets?
             *      if (targets == null)
             *      {
             *              targets = CreateSpellTargetCollection();
             *      }
             * }
             * else if (handler.HasOwnTargets)
             * {
             *      // see if targets are shared between effects
             *      targets = null;
             *
             *      for (var j = 0; j < h; j++)
             *      {
             *              var handler2 = handlers[j];
             *              if (handler.Effect.SharesTargetsWith(handler2.Effect))
             *              {
             *                      // same targets -> share target collection
             *                      targets = handler2.m_targets;
             *                      break;
             *              }
             *      }
             *
             *      if (targets == null)
             *      {
             *              targets = CreateSpellTargetCollection();
             *      }
             * }*/

            if (targets != null)
            {
                handler.m_targets = targets;
                targets.m_handlers.Add(handler);
            }
        }
Beispiel #2
0
        private void CreateHandler(SpellEffect effect, int h, SpellEffectHandler[] handlers, ref SpellTargetCollection targets, ref SpellFailedReason failReason)
        {
            var handler = effect.SpellEffectHandlerCreator(this, effect);

            handlers[h] = handler;

            // make sure, we have the right Caster-Type
            handler.CheckCasterType(ref failReason);
            if (failReason != SpellFailedReason.Ok)
            {
                return;
            }

            // find targets and amount SpellTargetCollection if effects have same ImplicitTargetTypes
            if (InitialTargets != null)
            {
                // do we have given targets?
                if (targets == null)
                {
                    targets = CreateSpellTargetCollection();
                }
            }
            else if (handler.HasOwnTargets)
            {
                // see if targets are shared between effects
                targets = null;

                for (var j = 0; j < h; j++)
                {
                    var handler2 = handlers[j];
                    if (handler.Effect.SharesTargetsWith(handler2.Effect, IsAICast))
                    {
                        // same targets -> share target collection
                        targets = handler2.m_targets;
                        break;
                    }
                }

                if (targets == null)
                {
                    targets = CreateSpellTargetCollection();
                }
            }

            if (targets != null)
            {
                handler.m_targets = targets;
                targets.m_handlers.Add(handler);
            }
        }
Beispiel #3
0
        private void CreateHandler(SpellEffect effect, int h, SpellEffectHandler[] handlers, ref SpellTargetCollection targets, ref SpellFailedReason failReason)
        {
            var handler = effect.SpellEffectHandlerCreator(this, effect);
            handlers[h] = handler;

            // make sure, we have the right Caster-Type
            handler.CheckCasterType(ref failReason);
            if (failReason != SpellFailedReason.Ok)
            {
                return;
            }

            // find targets and amount SpellTargetCollection if effects have same ImplicitTargetTypes
            if (InitialTargets != null)
            {
                // do we have given targets?
                if (targets == null)
                {
                    targets = CreateSpellTargetCollection();
                }
            }
            else if (handler.HasOwnTargets)
            {
                // see if targets are shared between effects
                targets = null;

                for (var j = 0; j < h; j++)
                {
                    var handler2 = handlers[j];
                    if (handler.Effect.SharesTargetsWith(handler2.Effect, IsAICast))
                    {
                        // same targets -> share target collection
                        targets = handler2.m_targets;
                        break;
                    }
                }

                if (targets == null)
                {
                    targets = CreateSpellTargetCollection();
                }
            }

            if (targets != null)
            {
                handler.m_targets = targets;
                targets.m_handlers.Add(handler);
            }
        }
Beispiel #4
0
		private void CreateHandler(SpellEffect effect, int h, SpellEffectHandler[] handlers, ref SpellTargetCollection targets, ref SpellFailedReason failReason)
		{
			var handler = effect.SpellEffectHandlerCreator(this, effect);
			handlers[h] = handler;

			// make sure, we have the right Caster-Type
			handler.CheckCasterType(ref failReason);
			if (failReason != SpellFailedReason.Ok)
			{
				return;
			}

			// find targets and amount SpellTargetCollection if effects have same ImplicitTargetTypes
			if (m_initialTargets != null)
			{
				// do we have given targets?
				//targets = SpellTargetCollection.SpellTargetCollectionPool.Obtain();
				if (targets == null)
				{
					targets = new SpellTargetCollection();
				}
			}
			else if (handler.HasOwnTargets)
			{
				targets = null;

				// check if we have same target-types, else collect targets specifically for this Effect
				for (var j = 0; j < h; j++)
				{
					var handler2 = handlers[j];
					if (handler.Effect.TargetsEqual(handler2.Effect))
					{
						targets = handler2.m_targets;
						break;
					}
				}

				if (targets == null)
				{
					//targets = SpellTargetCollection.SpellTargetCollectionPool.Obtain();
					targets = new SpellTargetCollection();
				}
			}

			if (targets != null)
			{
				handler.m_targets = targets;
				targets.m_handlers.Add(handler);
			}
		}