public bool Exit(Character attempt) { EnsureServer(); if (((int)this.callState) != 0) { Debug.LogWarning("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 != null)) { try { if (this.implementation != null) { try { this.callState = FunctionCallState.Exit; this.use.OnUseExit(this, UseExitReason.Manual); } finally { this.InvokeUseExitCallback(); this.callState = FunctionCallState.None; } } return(true); } finally { this._user = null; this.UnlatchUse(); } } return(false); }
public bool Eject() { UseExitReason manual; EnsureServer(); if (((int)this.callState) != 0) { if (((int)this.callState) != 4) { Debug.LogWarning("Some how Eject got called from a call stack originating with " + this.callState + " fix your script to not do this.", this); return(false); } manual = UseExitReason.Manual; } else { manual = !this.inDestroy ? (!this.inKillCallback ? UseExitReason.Forced : UseExitReason.Killed) : UseExitReason.Destroy; } if (this._user != null) { try { if (this.implementation != null) { try { this.callState = FunctionCallState.Eject; this.use.OnUseExit(this, manual); } finally { try { this.InvokeUseExitCallback(); } finally { this.callState = FunctionCallState.None; } } } else { Debug.LogError("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); } return(true); } finally { this.UnlatchUse(); this._user = null; } } return(false); }
private void RunUpdate() { FunctionCallState callState = this.callState; try { this.callState = FunctionCallState.OnUseUpdate; this.useUpdate.OnUseUpdate(this); } catch (Exception exception) { Debug.LogError("Inside OnUseUpdate\r\n" + exception, this.implementation); } finally { this.callState = callState; } }
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); }