示例#1
0
 private void RunUpdate()
 {
     Useable.FunctionCallState functionCallState = this.callState;
     try
     {
         try
         {
             this.callState = Useable.FunctionCallState.OnUseUpdate;
             this.useUpdate.OnUseUpdate(this);
         }
         catch (Exception exception)
         {
             Debug.LogError(string.Concat("Inside OnUseUpdate\r\n", exception), this.implementation);
         }
     }
     finally
     {
         this.callState = functionCallState;
     }
 }
示例#2
0
    public bool Exit(Character attempt)
    {
        bool flag;

        Useable.EnsureServer();
        if ((int)this.callState != 0)
        {
            Debug.LogWarning(string.Concat("Some how Exit got called from a call stack originating with ", this.callState, " fix your script to not do this."), this);
            return(false);
        }
        if (!(attempt == this._user) || !attempt)
        {
            return(false);
        }
        try
        {
            if (this.implementation)
            {
                try
                {
                    this.callState = Useable.FunctionCallState.Exit;
                    this.use.OnUseExit(this, UseExitReason.Manual);
                }
                finally
                {
                    this.InvokeUseExitCallback();
                    this.callState = Useable.FunctionCallState.None;
                }
            }
            flag = true;
        }
        finally
        {
            this._user = null;
            this.UnlatchUse();
        }
        return(flag);
    }
示例#3
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);
    }
示例#4
0
    public bool Eject()
    {
        UseExitReason useExitReason;
        bool          flag;
        UseExitReason useExitReason1;

        Useable.EnsureServer();
        if ((int)this.callState == 0)
        {
            if (!this.inDestroy)
            {
                useExitReason1 = (!this.inKillCallback ? UseExitReason.Forced : UseExitReason.Killed);
            }
            else
            {
                useExitReason1 = UseExitReason.Destroy;
            }
            useExitReason = useExitReason1;
        }
        else
        {
            if ((int)this.callState != 4)
            {
                Debug.LogWarning(string.Concat("Some how Eject got called from a call stack originating with ", this.callState, " fix your script to not do this."), this);
                return(false);
            }
            useExitReason = UseExitReason.Manual;
        }
        if (!this._user)
        {
            return(false);
        }
        try
        {
            if (!this.implementation)
            {
                Debug.LogError(string.Concat("The IUseable has been destroyed with a user on it. IUseable should ALWAYS call UseableUtility.OnDestroy within the script's OnDestroy message first thing! ", base.gameObject), this);
            }
            else
            {
                try
                {
                    this.callState = Useable.FunctionCallState.Eject;
                    this.use.OnUseExit(this, useExitReason);
                }
                finally
                {
                    try
                    {
                        this.InvokeUseExitCallback();
                    }
                    finally
                    {
                        this.callState = Useable.FunctionCallState.None;
                    }
                }
            }
            flag = true;
        }
        finally
        {
            this.UnlatchUse();
            this._user = null;
        }
        return(flag);
    }