示例#1
0
 private UseResponse Enter(Character attempt, UseEnterRequest request)
 {
     if (!this.canUse)
     {
         return(UseResponse.Fail_NotIUseable);
     }
     EnsureServer();
     if (((int)this.callState) != 0)
     {
         Debug.LogWarning("Some how Enter got called from a call stack originating with " + this.callState + " fix your script to not do this.", this);
         return(UseResponse.Fail_InvalidOperation);
     }
     if (hasException)
     {
         ClearException(false);
     }
     if (attempt == null)
     {
         return(UseResponse.Fail_NullOrMissingUser);
     }
     if (attempt.signaledDeath)
     {
         return(UseResponse.Fail_UserDead);
     }
     if (this._user == null)
     {
         if (this.implementation != null)
         {
             try
             {
                 UseResponse response;
                 this.callState = FunctionCallState.Enter;
                 if (this.canCheck)
                 {
                     try
                     {
                         response = (UseResponse)this.useCheck.CanUse(attempt, request);
                     }
                     catch (Exception exception)
                     {
                         lastException = exception;
                         return(UseResponse.Fail_CheckException);
                     }
                     if (((int)response) != 1)
                     {
                         if (response.Succeeded())
                         {
                             Debug.LogError("A IUseableChecked return a invalid value that should have cause success [" + response + "], but it was not UseCheck.Success! fix your script.", this.implementation);
                             return(UseResponse.Fail_Checked_BadResult);
                         }
                         if (this.wantDeclines)
                         {
                             try
                             {
                                 this.useDecline.OnUseDeclined(attempt, response, request);
                             }
                             catch (Exception exception2)
                             {
                                 Debug.LogError(string.Concat(new object[] { "Caught exception in OnUseDeclined \r\n (response was ", response, ")", exception2 }), this.implementation);
                             }
                         }
                         return(response);
                     }
                 }
                 else
                 {
                     response = UseResponse.Pass_Unchecked;
                 }
                 try
                 {
                     this._user = attempt;
                     this.use.OnUseEnter(this);
                 }
                 catch (Exception exception3)
                 {
                     this._user = null;
                     Debug.LogError("Exception thrown during Useable.Enter. Object not set as used!\r\n" + exception3, attempt);
                     lastException = exception3;
                     return(UseResponse.Fail_EnterException);
                 }
                 if (response.Succeeded())
                 {
                     this.LatchUse();
                 }
                 return(response);
             }
             finally
             {
                 this.callState = FunctionCallState.None;
             }
         }
         return(UseResponse.Fail_Destroyed);
     }
     if (this._user == attempt)
     {
         if (this.wantDeclines && (this.implementation != null))
         {
             try
             {
                 this.useDecline.OnUseDeclined(attempt, UseResponse.Fail_Redundant, request);
             }
             catch (Exception exception4)
             {
                 Debug.LogError("Caught exception in OnUseDeclined \r\n (response was Fail_Redundant)" + exception4, this.implementation);
             }
         }
         return(UseResponse.Fail_Redundant);
     }
     if (this.wantDeclines && (this.implementation != null))
     {
         try
         {
             this.useDecline.OnUseDeclined(attempt, UseResponse.Fail_Vacancy, request);
         }
         catch (Exception exception5)
         {
             Debug.LogError("Caught exception in OnUseDeclined \r\n (response was Fail_Vacancy)" + exception5, this.implementation);
         }
     }
     return(UseResponse.Fail_Vacancy);
 }
示例#2
0
    private UseResponse Enter(Character attempt, UseEnterRequest request)
    {
        UseResponse useResponse;
        UseResponse useResponse1;

        if (!this.canUse)
        {
            return(UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_Checked_BadConfiguration | UseResponse.Fail_CheckException | UseResponse.Fail_UserDead | UseResponse.Fail_NotIUseable);
        }
        Useable.EnsureServer();
        if ((int)this.callState != 0)
        {
            Debug.LogWarning(string.Concat("Some how Enter got called from a call stack originating with ", this.callState, " fix your script to not do this."), this);
            return(UseResponse.Pass_Checked | UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_Checked_UserIncompatible | UseResponse.Fail_Checked_BadConfiguration | UseResponse.Fail_Checked_BadResult | UseResponse.Fail_CheckException | UseResponse.Fail_EnterException | UseResponse.Fail_UserDead | UseResponse.Fail_Destroyed | UseResponse.Fail_NotIUseable | UseResponse.Fail_InvalidOperation);
        }
        if (Useable.hasException)
        {
            Useable.ClearException(false);
        }
        if (!attempt)
        {
            return(UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_CheckException | UseResponse.Fail_UserDead | UseResponse.Fail_NullOrMissingUser);
        }
        if (attempt.signaledDeath)
        {
            return(UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_CheckException | UseResponse.Fail_UserDead);
        }
        if (this._user)
        {
            if (this._user == attempt)
            {
                if (this.wantDeclines && this.implementation)
                {
                    try
                    {
                        this.useDecline.OnUseDeclined(attempt, UseResponse.Pass_Checked | UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_Checked_UserIncompatible | UseResponse.Fail_Checked_BadConfiguration | UseResponse.Fail_Checked_BadResult | UseResponse.Fail_CheckException | UseResponse.Fail_EnterException | UseResponse.Fail_Vacancy | UseResponse.Fail_Redundant, request);
                    }
                    catch (Exception exception)
                    {
                        Debug.LogError(string.Concat("Caught exception in OnUseDeclined \r\n (response was Fail_Redundant)", exception), this.implementation);
                    }
                }
                return(UseResponse.Pass_Checked | UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_Checked_UserIncompatible | UseResponse.Fail_Checked_BadConfiguration | UseResponse.Fail_Checked_BadResult | UseResponse.Fail_CheckException | UseResponse.Fail_EnterException | UseResponse.Fail_Vacancy | UseResponse.Fail_Redundant);
            }
            if (this.wantDeclines && this.implementation)
            {
                try
                {
                    this.useDecline.OnUseDeclined(attempt, UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_Checked_BadConfiguration | UseResponse.Fail_CheckException | UseResponse.Fail_Vacancy, request);
                }
                catch (Exception exception1)
                {
                    Debug.LogError(string.Concat("Caught exception in OnUseDeclined \r\n (response was Fail_Vacancy)", exception1), this.implementation);
                }
            }
            return(UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_Checked_BadConfiguration | UseResponse.Fail_CheckException | UseResponse.Fail_Vacancy);
        }
        if (!this.implementation)
        {
            return(UseResponse.Pass_Checked | UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_Checked_UserIncompatible | UseResponse.Fail_CheckException | UseResponse.Fail_EnterException | UseResponse.Fail_UserDead | UseResponse.Fail_Destroyed);
        }
        try
        {
            this.callState = Useable.FunctionCallState.Enter;
            if (!this.canCheck)
            {
                useResponse = UseResponse.Pass_Unchecked;
            }
            else
            {
                try
                {
                    useResponse = (UseResponse)this.useCheck.CanUse(attempt, request);
                }
                catch (Exception exception2)
                {
                    Useable.lastException = exception2;
                    useResponse1          = UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_CheckException;
                    return(useResponse1);
                }
                if ((int)useResponse != 1)
                {
                    if (!useResponse.Succeeded())
                    {
                        if (this.wantDeclines)
                        {
                            try
                            {
                                this.useDecline.OnUseDeclined(attempt, useResponse, request);
                            }
                            catch (Exception exception4)
                            {
                                Exception exception3 = exception4;
                                Debug.LogError(string.Concat(new object[] { "Caught exception in OnUseDeclined \r\n (response was ", useResponse, ")", exception3 }), this.implementation);
                            }
                        }
                        useResponse1 = useResponse;
                        return(useResponse1);
                    }
                    else
                    {
                        Debug.LogError(string.Concat("A IUseableChecked return a invalid value that should have cause success [", useResponse, "], but it was not UseCheck.Success! fix your script."), this.implementation);
                        useResponse1 = UseResponse.Pass_Checked | UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_Checked_UserIncompatible | UseResponse.Fail_Checked_BadConfiguration | UseResponse.Fail_Checked_BadResult;
                        return(useResponse1);
                    }
                }
            }
            try
            {
                this._user = attempt;
                this.use.OnUseEnter(this);
            }
            catch (Exception exception6)
            {
                Exception exception5 = exception6;
                this._user = null;
                Debug.LogError(string.Concat("Exception thrown during Useable.Enter. Object not set as used!\r\n", exception5), attempt);
                Useable.lastException = exception5;
                useResponse1          = UseResponse.Pass_Checked | UseResponse.Fail_Checked_OutOfOrder | UseResponse.Fail_Checked_UserIncompatible | UseResponse.Fail_CheckException | UseResponse.Fail_EnterException;
                return(useResponse1);
            }
            if (useResponse.Succeeded())
            {
                this.LatchUse();
            }
            useResponse1 = useResponse;
        }
        finally
        {
            this.callState = Useable.FunctionCallState.None;
        }
        return(useResponse1);
    }