Пример #1
0
        /// <summary>
        /// If the exception can be handled in current scope, return true and
        /// set pc which is where the executive will jump to. Otherwise return
        /// false.
        /// </summary>
        /// <param name="pc">New pc value</param>
        /// <returns></returns>
        public bool CanHandleIt(ref int pc)
        {
            if (!IsStackUnwinding || TargetHandler == null || Context == null)
            {
                return(false);
            }

            // Note there is always an instance of ExceptionRegistration
            // associated with a scope -- either function defintion or a language
            // block -- and that instance of ExceptionRegistration associated
            // with current scope is called CurrentActiveRegistration which is
            // dynamically upated when switching scopes.
            if (TargetHandler.Registration == CurrentActiveRegistration)
            {
                CatchHandler catchHandler = TargetHandler.GetCatchHandler(Context.typeUID);
                if (catchHandler != null)
                {
                    pc = catchHandler.Entry;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
 // Use this for initialization
 void Start()
 {
     target = GameObject.Find("BattleControllers").GetComponent <TargetHandler>();
     flow   = GameObject.Find("BattleControllers").GetComponent <BattleFlowController>();
     ui     = GameObject.Find("BattleControllers").GetComponent <BattleUIController>();
     action = Action.Attack;
     gameObject.GetComponent <Button>().onClick.AddListener(SetAction);
 }
Пример #3
0
 public void ApplyToAllOf <TargetType>(TargetHandler <TargetType> handler)
     where TargetType : ObjectBase
 {
     foreach (var target in this)
     {
         if (target is TargetType)
         {
             handler(target as TargetType);
         }
     }
 }
Пример #4
0
 public void ApplyToAllOf <TargetType>(TargetHandler <TargetType> handler)
     where TargetType : ObjectBase
 {
     foreach (WorldObject worldObject in this)
     {
         if (worldObject is TargetType)
         {
             handler(worldObject as TargetType);
         }
     }
 }
Пример #5
0
    private void Awake()
    {
        team               = GetComponentInParent <Team>();
        targetHandler      = GetComponentInChildren <TargetHandler>();
        animatorController = GetComponentInChildren <CharacterAnimatorController>();
        audioController    = GetComponent <CharacterAudioController>();
        spineController    = GetComponent <SpineController>();
        stats              = GetComponent <CharacterStats>();

        OnReceiveDamageCharacter += CheckHealth;
        OnReceiveDamageZone      += (damage) => { CheckHealth(damage, null); };
    }
    // Use this for initialization
    void Start()
    {
        ui         = GameObject.Find("BattleControllers").GetComponent <BattleUIController>();
        target     = GameObject.Find("BattleControllers").GetComponent <TargetHandler>();
        party      = GameObject.Find("PlayerParty").GetComponent <PartyController>();
        controller = GameObject.Find("BattleControllers").GetComponent <BattleItemController>();
        gameObject.transform.SetParent(invPanel.transform, false);
        StartCoroutine("WaitAndUpdateText");
        Button theBtn = gameObject.GetComponent <Button>();

        theBtn.onClick.AddListener(SetAction);
        action = Action.Item;
    }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        protected virtual void OnTargetChanged
        (
            [CanBeNull] T previousTarget
        )
        {
            _CreateDelegates();
            TargetHandler handler = TargetChanged;

            if (!ReferenceEquals(handler, null))
            {
                handler(this, previousTarget);
            }
        }
Пример #8
0
    private void Start()
    {
        cam                   = fpsCam.GetComponent <Camera>();
        targetHandler         = targetCanvas.GetComponent <TargetHandler>();
        weaponSlotSlot        = weaponSlot.GetComponent <Slot>();
        enemyLayerMask        = 1 << 15;
        npcLayerMask          = 1 << 16;
        interactableLayerMask = 1 << 10;
        menuButtonImage       = menuButton.GetComponent <RawImage>();


        int defaultValue = EventSystem.current.pixelDragThreshold;

        EventSystem.current.pixelDragThreshold = Mathf.Max(defaultValue, (int)(defaultValue * Screen.dpi / 160f));
    }
Пример #9
0
    public void SetupFollower()
    {
        GameObject previousAllyObj = GetClosestUnmarked();

        if (previousAllyObj) //can find a closest neighbour
        {
            Transform     previousAlly       = previousAllyObj.transform;
            TargetHandler previousAllyTarget = previousAlly.GetComponent <TargetHandler>();


            previousAllyTarget.distToHead = Vector3.Distance(transform.position, previousAlly.position) + distToHead;


            lineFollower = previousAlly.transform;        //sets the follower to be previous player
            previousAllyTarget.lineFollowing = transform; //points previous player to follow you
            previousAllyTarget.SetupFollower();

            /*   if (lineFollowing)
             * {
             *     motor.forwardSpeedAdd1 = Vector3.Distance(transform.position, lineFollowing.position) / 15f;
             * }*/
        }
    }
 // Use this for initialization
 void Start()
 {
     target = GameObject.Find("BattleControllers").GetComponent <TargetHandler>();
     gameObject.GetComponent <Button>().onClick.AddListener(SendToTargetHandler);
 }
Пример #11
0
        private static Hexagon CreateHexagon(GeoData geoData, LayersLoaderTarget[] targets, HexagonLocationUV hexagonLocation, TargetHandler TargetValueStrategy)
        {
            Hexagon hexagon = new Hexagon {
                LocationUV = hexagonLocation, HexagonData = new HexagonData()
            };

            if (targets != null)
            {
                foreach (LayersLoaderTarget target in targets)
                {
                    hexagon.HexagonData[target.Destination] = TargetValueStrategy(geoData, target);
                }
            }

            return(hexagon);
        }
Пример #12
0
        /// <summary>
        /// This method is called when specified target handler has disposed.
        /// </summary>
        /// <param name="handler">TargetHandler what disposed.</param>
        private void TargetHandler_Disposed(TargetHandler handler)
        {
            lock(m_pLock){
                m_pTargetsHandlers.Remove(handler);

                // All targets are processed.
                if(m_pTargets.Count == 0 && m_pTargetsHandlers.Count == 0){
                    Dispose();
                }
            }
        }
Пример #13
0
        /// <summary>
        /// Processes received response.
        /// </summary>
        /// <param name="handler">Target handler what received response.</param>
        /// <param name="transaction">Client transaction what response it is.</param>
        /// <param name="response">Response received.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>handler</b>,<b>transaction</b> or <b>response</b> is null reference.</exception>
        private void ProcessResponse(TargetHandler handler,SIP_ClientTransaction transaction,SIP_Response response)
        {
            if(handler == null){
                throw new ArgumentNullException("handler");
            }
            if(transaction == null){
                throw new ArgumentNullException("transaction");
            }
            if(response == null){
                throw new ArgumentNullException("response");
            }

            /* RFC 3261 16.7 Response Processing.
                Steps 1 - 2 handled in TargetHandler.

                3.  Remove the topmost Via
                4.  Add the response to the response context
                5.  Check to see if this response should be forwarded immediately
                6.  When necessary, choose the best final response from the response context.
                    If no final response has been forwarded after every client
                    transaction associated with the response context has been terminated,
                    the proxy must choose and forward the "best" response from those it
                    has seen so far.

                The following processing MUST be performed on each response that is
                forwarded.  It is likely that more than one response to each request
                will be forwarded: at least each provisional and one final response.

                7.  Aggregate authorization header field values if necessary
                8.  Optionally rewrite Record-Route header field values
                9.  Forward the response
                10. Generate any necessary CANCEL requests
            */

            bool forwardResponse = false;

            lock(m_pLock){

                #region 3.  Remove the topmost Via

                /*
                    The proxy removes the topmost Via header field value from the
                    response.

                    If no Via header field values remain in the response, the
                    response was meant for this element and MUST NOT be forwarded.
                    The remainder of the processing described in this section is
                    not performed on this message, the UAC processing rules
                    described in Section 8.1.3 are followed instead (transport
                    layer processing has already occurred).

                    This will happen, for instance, when the element generates
                    CANCEL requests as described in Section 10.

                    NOTE: We MAY NOT do it for B2BUA, skip it for B2BUA
                */
                if(!m_IsB2BUA){
                    response.Via.RemoveTopMostValue();
                    if(response.Via.GetAllValues().Length == 0){
                        return;
                    }
                }

                #endregion

                #region 4.  Add the response to the response context

                /*
                    Final responses received are stored in the response context
                    until a final response is generated on the server transaction
                    associated with this context.  The response may be a candidate
                    for the best final response to be returned on that server
                    transaction.  Information from this response may be needed in
                    forming the best response, even if this response is not chosen.

                    If the proxy chooses to recurse on any contacts in a 3xx
                    response by adding them to the target set, it MUST remove them
                    from the response before adding the response to the response
                    context.  However, a proxy SHOULD NOT recurse to a non-SIPS URI
                    if the Request-URI of the original request was a SIPS URI.  If
                    the proxy recurses on all of the contacts in a 3xx response,
                    the proxy SHOULD NOT add the resulting contactless response to
                    the response context.

                    Removing the contact before adding the response to the response
                    context prevents the next element upstream from retrying a
                    location this proxy has already attempted.

                    3xx responses may contain a mixture of SIP, SIPS, and non-SIP
                    URIs.  A proxy may choose to recurse on the SIP and SIPS URIs
                    and place the remainder into the response context to be
                    returned, potentially in the final response.
                */

                if(response.StatusCodeType == SIP_StatusCodeType.Redirection && !m_NoRecurse && !handler.IsRecursed){
                    // Get SIP contacts and remove them from response.
                    SIP_t_ContactParam[] contacts = response.Contact.GetAllValues();
                    // Remove all contacts from response, we add non-SIP URIs back.
                    response.Contact.RemoveAll();
                    foreach(SIP_t_ContactParam contact in contacts){
                        // SIP URI add it to fork list.
                        if(contact.Address.IsSipOrSipsUri){
                            m_pTargets.Enqueue(new TargetHandler(this,null,(SIP_Uri)contact.Address.Uri,m_AddRecordRoute,true));
                        }
                        // Add specified URI back to response.
                        else{
                            response.Contact.Add(contact.ToStringValue());
                        }
                    }

                    // There are remaining non-SIP contacts, so we need to add the response to reponses collection.
                    if(response.Contact.GetAllValues().Length > 0){
                        m_pResponses.Add(response);
                    }

                    // Handle forking
                    if(m_pTargets.Count > 0){
                        if(m_ForkingMode == SIP_ForkingMode.Parallel){
                            while(m_pTargets.Count > 0){
                                TargetHandler h = m_pTargets.Dequeue();
                                m_pTargetsHandlers.Add(handler);
                                h.Start();
                            }
                        }
                        // Just fork next.
                        else{
                            TargetHandler h = m_pTargets.Dequeue();
                            m_pTargetsHandlers.Add(handler);
                            h.Start();
                        }

                        // Because we forked request to new target(s), we don't need to do steps 5 - 10.
                        return;
                    }
                }
                // Not 3xx response or recursing disabled.
                else{
                    m_pResponses.Add(response);
                }

                #endregion

                #region 5.  Check to see if this response should be forwarded immediately

                /*
                    Until a final response has been sent on the server transaction,
                    the following responses MUST be forwarded immediately:

                    -  Any provisional response other than 100 (Trying)

                    -  Any 2xx response

                    If a 6xx response is received, it is not immediately forwarded,
                    but the stateful proxy SHOULD cancel all client pending
                    transactions as described in Section 10, and it MUST NOT create
                    any new branches in this context.

                    After a final response has been sent on the server transaction,
                    the following responses MUST be forwarded immediately:

                    -  Any 2xx response to an INVITE request
                */

                if(!m_IsFinalResponseSent){
                    if(response.StatusCodeType == SIP_StatusCodeType.Provisional && response.StatusCode != 100){
                        forwardResponse = true;
                    }
                    else if(response.StatusCodeType == SIP_StatusCodeType.Success){
                        forwardResponse = true;
                    }
                    else if(response.StatusCodeType == SIP_StatusCodeType.GlobalFailure){
                        CancelAllTargets();
                    }
                }
                else{
                    if(response.StatusCodeType == SIP_StatusCodeType.Success && m_pServerTransaction.Request.RequestLine.Method == SIP_Methods.INVITE){
                        forwardResponse = true;
                    }
                }

                #endregion

                #region x.  Handle sequential forking

                /*
                    Sequential Search: In a sequential search, a proxy server attempts
                    each contact address in sequence, proceeding to the next one
                    only after the previous has generated a final response.  A 2xx
                    or 6xx class final response always terminates a sequential
                    search.
                */
                if(m_ForkingMode == SIP_ForkingMode.Sequential && response.StatusCodeType != SIP_StatusCodeType.Provisional){
                    if(response.StatusCodeType == SIP_StatusCodeType.Success){
                        // Do nothing, 2xx will be always forwarded and step 10. Cancels all targets.
                    }
                    else if(response.StatusCodeType == SIP_StatusCodeType.GlobalFailure){
                        // Do nothing, 6xx is already handled in setp 5.
                    }
                    else if(m_pTargets.Count > 0){
                        TargetHandler h = m_pTargets.Dequeue();
                        m_pTargetsHandlers.Add(handler);
                        h.Start();

                        // Skip all next steps, we will get new responses from new target.
                        return;
                    }
                }

                #endregion

                #region 6.  When necessary, choose the best final response from the response context

                /*
                    A stateful proxy MUST send a final response to a response
                    context's server transaction if no final responses have been
                    immediately forwarded by the above rules and all client
                    transactions in this response context have been terminated.

                    The stateful proxy MUST choose the "best" final response among
                    those received and stored in the response context.

                    If there are no final responses in the context, the proxy MUST
                    send a 408 (Request Timeout) response to the server
                    transaction.

                */

                if(!m_IsFinalResponseSent && !forwardResponse && m_pTargets.Count == 0){
                    bool mustChooseBestFinalResponse = true;
                    // Check if all transactions terminated.
                    foreach(TargetHandler h in m_pTargetsHandlers){
                        if(!h.IsCompleted){
                            mustChooseBestFinalResponse = false;
                            break;
                        }
                    }

                    if(mustChooseBestFinalResponse){
                        response = GetBestFinalResponse();
                        if(response == null){
                            response = this.Proxy.Stack.CreateResponse(SIP_ResponseCodes.x408_Request_Timeout,m_pServerTransaction.Request);
                        }

                        forwardResponse = true;
                    }
                }

                #endregion

                if(forwardResponse){

                    #region 7.  Aggregate authorization header field values if necessary

                    /*
                        If the selected response is a 401 (Unauthorized) or 407 (Proxy Authentication Required),
                        the proxy MUST collect any WWW-Authenticate and Proxy-Authenticate header field values
                        from all other 401 (Unauthorized) and 407 (Proxy Authentication Required) responses
                        received so far in this response context and add them to this response without
                        modification before forwarding. The resulting 401 (Unauthorized) or 407 (Proxy
                        Authentication Required) response could have several WWW-Authenticate AND
                        Proxy-Authenticate header field values.

                        This is necessary because any or all of the destinations the request was forwarded to
                        may have requested credentials.  The client needs to receive all of those challenges and
                        supply credentials for each of them when it retries the request.
                    */
                    if(response.StatusCode == 401 || response.StatusCode == 407){
                        foreach(SIP_Response resp in m_pResponses.ToArray()){
                            if(response != resp && (resp.StatusCode == 401 || resp.StatusCode == 407)){
                                // WWW-Authenticate
                                foreach(SIP_HeaderField hf in resp.WWWAuthenticate.HeaderFields){
                                    resp.WWWAuthenticate.Add(hf.Value);
                                }
                                // Proxy-Authenticate
                                foreach(SIP_HeaderField hf in resp.ProxyAuthenticate.HeaderFields){
                                    resp.ProxyAuthenticate.Add(hf.Value);
                                }
                            }
                        }
                    }

                    #endregion

                    #region 8.  Optionally rewrite Record-Route header field values

                    // This is optional so we currently won't do that.

                    #endregion

                    #region 9.  Forward the response

                    SendResponse(transaction,response);
                    if(response.StatusCodeType != SIP_StatusCodeType.Provisional){
                        m_IsFinalResponseSent = true;
                    }

                    #endregion

                    #region 10. Generate any necessary CANCEL requests

                    /*
                        If the forwarded response was a final response, the proxy MUST
                        generate a CANCEL request for all pending client transactions
                        associated with this response context.
                    */
                    if(response.StatusCodeType != SIP_StatusCodeType.Provisional){
                        CancelAllTargets();
                    }

                    #endregion
                }
            }
        }
 void Start()
 {
     _targetHandler = gameObject.GetComponent<TargetHandler>();
     GetNextTurret();
 }
Пример #15
0
 // Start is called before the first frame update
 void Start()
 {
     targets  = new List <CombatEntity>();
     instance = this;
 }
 public void AssignTargetHandler(TargetHandler targetHandler)
 {
     _targetHandler = targetHandler;
 }