Example #1
0
        protected void SetIdle(CallReason callreason)
        {
            ContinueEvent -= SetIdle;
            var stateModifier = new ActionStateModifier(ActionCode.Idle);

            World.Instance.ApplyModifier(ActionSource, stateModifier);
        }
Example #2
0
        private void ResetSpeed(CallReason continueReason)
        {
            var speedModifier = new FloatModifier(ModifyMode.Divide, AttributeCode.Speed, 1.5f);

            World.Instance.ApplyModifier(ActionSource, speedModifier);
            ContinueEvent -= ResetSpeed;
        }
        private void DoDamage(CallReason continueReason)
        {
            var healthModifier = new IntModifier(ModifyMode.Addition, AttributeCode.Health, -5);
            var sourcePos      = World.Instance.GetEntity(ActionSource).Position;

            log.InfoFormat("Bow Attack LookDir is {0}", LookDirection);

            var LookDirP = new Vector(LookDirection.Z, -LookDirection.X);
            var P1       = sourcePos + LookDirP * 0.5f * ATTACKWIDTH;
            var P2       = sourcePos - LookDirP * 0.5f * ATTACKWIDTH;
            var P3       = P2 + LookDirection * ATTACKDISTANCE;

            var dmgArea = new RectangleAreaTarget(P1, P2, P3)
            {
                AreaTargetOption = AreaTargetOption.IgnoreSource,
                SourceName       = ActionSource
            };

            World.Instance.ApplyModifier(dmgArea, healthModifier);

            // SetIdle
            AddCondition(new TimedContinueCondition(new System.TimeSpan(0, 0, 0, 0, 500)));
            ContinueEvent -= DoDamage;
            ContinueEvent += SetIdle;
            StartConditions();
        }
Example #4
0
 protected void SetActionCooldown(CallReason callreason)
 {
     if (callreason != CallReason.ConditionFullfilled)
     {
         return;
     }
     World.Instance.SetSkillCooldown(ActionSource, (ActionCode)Code);
 }
 protected void RaiseContinueEvent(CallReason reason)
 {
     if (m_Disposed)
     {
         return;
     }
     ContinueEvent(reason);
 }
Example #6
0
        private void Tick(CallReason callReason)
        {
            DoDamage();

            if (callReason == CallReason.LastTick)
            {
                m_DamageTicker.ContinueEvent -= Tick;
                Entity.Die();
            }
        }
Example #7
0
        private void DoHealing(CallReason continueReason)
        {
            if (continueReason == CallReason.Interupted)
            {
                return;
            }

            var healthModifier = new IntModifier(ModifyMode.Addition, AttributeCode.Health, 30);

            World.Instance.ApplyModifier(Target, healthModifier);
        }
Example #8
0
 private void FinishedAutoAttack(CallReason cr)
 {
     if (cr == CallReason.Interupted)
     {
         return;
     }
     if (PerformContinueAAs)
     {
         m_ContinueAutoAttack = true;
     }
 }
Example #9
0
        private void CreateFireStormEntity(CallReason continueReason)
        {
            if (continueReason == CallReason.Interupted)
            {
                return;
            }

            ContinueEvent -= CreateFireStormEntity;
            m_LastCreatedID++;
            SetIdle(continueReason);
            EntityFactory.Instance.CreateSkillEntity(ActionSource, m_LastCreatedID.ToString(), ActionCode.FireStorm, Target);
        }
Example #10
0
        private void OnConditionFullfilled(CallReason continueReason)
        {
            if (continueReason == CallReason.Interupted)
            {
                log.InfoFormat("{0} was interupted.", ActionSource);
            }
            foreach (ActionContinueCondition condition in m_ContinueConidtions)
            {
                condition.Dispose();
            }
            m_ContinueConidtions.Clear();

            ContinueEvent(continueReason);
        }
Example #11
0
        private void OnFinishedCasting(CallReason callReason)
        {
            switch (callReason)
            {
            case CallReason.ConditionFullfilled:
                FinishedCastingEvent(callReason);
                ContinueEvent -= OnFinishedCasting;
                break;

            case CallReason.Interupted:
                SetIdle(callReason);
                break;
            }
        }
Example #12
0
        private void DoDamage(CallReason continueReason)
        {
            var healthModifier = new IntModifier(ModifyMode.Addition, AttributeCode.Health, -7);
            var sourcePos      = World.Instance.GetEntity(ActionSource).Position;

            var dmgArea = new CircleAreaTarget(sourcePos, RADIUS)
            {
                AreaTargetOption = AreaTargetOption.IgnoreSource,
                SourceName       = ActionSource
            };

            World.Instance.ApplyModifier(dmgArea, healthModifier);

            var interupted = World.Instance.GetEntitesInArea(dmgArea);

            m_InteruptionHandler.OnInterupt(interupted);
        }
Example #13
0
        private void DoDamage(CallReason continueReason)
        {
            if (continueReason == CallReason.Interupted)
            {
                SetIdle(continueReason);
                return;
            }

            var healthModifier = new IntModifier(ModifyMode.Addition, AttributeCode.Health, -5);
            var sourcePos      = World.Instance.GetEntity(ActionSource).Position;

            var dmgArea = new Cone2DAreaTarget(sourcePos, LookDirection, ATTACKANGLE, ATTACKDISTANCE)
            {
                AreaTargetOption = AreaTargetOption.IgnoreSource,
                SourceName       = ActionSource
            };

            World.Instance.ApplyModifier(dmgArea, healthModifier);
            AddCondition(new TimedContinueCondition(new System.TimeSpan(0, 0, 0, 0, 500)));

            ContinueEvent -= DoDamage;
            ContinueEvent += SetIdle;
            StartConditions();
        }
Example #14
0
        private void DoDamage(CallReason continueReason)
        {
            var healthModifier = new IntModifier(ModifyMode.Addition, AttributeCode.Health, -5);
            var sourcePos      = World.Instance.GetEntity(ActionSource).Position;

            log.InfoFormat("DS LookDir is {0}", LookDirection);

            var LookDirP = new Vector(LookDirection.Z, -LookDirection.X);
            var P1       = sourcePos + LookDirP * 0.5f * ATTACKWIDTH;
            var P2       = sourcePos - LookDirP * 0.5f * ATTACKWIDTH;
            var P3       = P2 + LookDirection * ATTACKDISTANCE;

            var dmgArea = new RectangleAreaTarget(P1, P2, P3)
            {
                AreaTargetOption = AreaTargetOption.IgnoreSource,
                SourceName       = ActionSource
            };

            World.Instance.ApplyModifier(dmgArea, healthModifier);

            var interupted = World.Instance.GetEntitesInArea(dmgArea);

            m_InteruptionHandler.OnInterupt(interupted);
        }
Example #15
0
        // This method has one of 5 possible outcomes:
        //
        // 1. We got a response from the service (null, not null or an exception) and the caching settings dictate that we should cache it:
        //    We cache it with the default RefreshTime. This extends the ExpirationTime as well.
        //
        // 2. The caching settings dictate that the response shouldn't be cached, and should be ignored, and currentValue != null :
        //    We return the currentValue and set its next refresh time to be now + FailedRefreshDelay so we don't "attack" the target service
        //
        // 3. The caching settings dictate that the response should not be cached, and should be ignored, and currentValue == null :
        //    We return the response anyway, since we don't have a previously-good value
        //
        // 4. The caching settings dictate that the response shouldn't be cached, nor ignored and removed from cache:
        //    We return the response and remove the previously-cached response from the cache
        //
        // 5. The caching settings dictate that the response shouldn't be cached, nor ignored and remain in cache:
        //    We return the response
        private async Task <object> TryFetchNewValue(string cacheKey, Func <Task <object> > serviceMethod,
                                                     IMethodCachingSettings settings, string[] metricsKeys, CallReason callReason, AsyncCacheItem currentValue = null)
        {
            // We use the RecentRevokesCache to keep track of recent revoke messages that arrived, to detect if the response we're about
            // to receive was revoked while in transit. It will track revoke messages as long as the task is not completed.
            var requestSendTime = DateTime.UtcNow;
            var tcs             = new TaskCompletionSource <bool>();

            RecentRevokesCache.RegisterOutgoingRequest(tcs.Task, requestSendTime);

            // We capture the response from the service here, including if it was an exception
            var(response, responseKind) = await CallService(serviceMethod, metricsKeys);

            string outcome = null;

            // Outcome #1: Cache the response
            if (settings.ResponseKindsToCache.HasFlag(responseKind))
            {
                outcome = "cached";
                CacheResponse(cacheKey, requestSendTime, response, settings);
            }
            else if (settings.ResponseKindsToIgnore.HasFlag(responseKind))
            {
                // Outcome #2: Leave old response cached and return it, and set its refresh time to the (short) FailedRefreshDelay
                if (currentValue != null)
                {
                    outcome = "ignored_cachedValueExist";
                    currentValue.NextRefreshTime = DateTime.UtcNow + settings.FailedRefreshDelay.Value;
                    response = currentValue.Value;
                }

                // Outcome #3: We don't have currentValue, so we cant ignore response and we return it
                else
                {
                    outcome = "ignored_cachedValueDoesNotExist";
                }
            }

            else //Dont cache and dont ignore (i.e. return it)
            {
                outcome = "notCachedNotIgnored";

                // Outcome #4: Do not cache response and return it; remove previously-cached value (if exist)
                if (settings.NotIgnoredResponseBehavior == NotIgnoredResponseBehavior.RemoveCachedResponse)
                {
                    if (MemoryCache.Remove(cacheKey) != null)
                    {
                        outcome = "notCachedNotIgnored_cachedValueRemoved";
                    }
                }

                // Outcome #5: Do not cache response and return it; leave old response cached
                // If old response is not null, set its refresh time to the (short) FailedRefreshDelay
                else if (currentValue != null)
                {
                    currentValue.NextRefreshTime = DateTime.UtcNow + settings.FailedRefreshDelay.Value;
                }
            }

            Log.Debug(x => x("Service call", unencryptedTags: new { cacheKey, callReason, responseKind, outcome }));

            tcs.SetResult(true);    // RecentRevokesCache can stop tracking revoke keys
            return(await response); // Might throw stored exception
        }
Example #16
0
 private void SelfDestroy(CallReason r)
 {
     m_SelfDestroy = true;
 }