public void Update() { if (RPOS.ObservedPlayer == null) { return; } CraftingInventory component = RPOS.ObservedPlayer.GetComponent <CraftingInventory>(); if (component == null) { return; } bool flag = component.isCrafting; if (flag) { component.CraftThink(); } if (!flag && this.wasCrafting) { this.UpdateIngredients(); } else if (!this.wasCrafting && flag) { this.craftSound.Play(); } if (this.craftButton.gameObject.activeSelf) { this.craftButton.GetComponentInChildren <UILabel>().text = (!component.isCrafting ? "Craft" : "Cancel"); } if (this.craftProgressBar && this.craftProgressBar.gameObject && this.craftProgressBar.gameObject.activeSelf) { UISlider uISlider = this.craftProgressBar; float? nullable = component.craftingCompletePercent; uISlider.sliderValue = (!nullable.HasValue ? 0f : nullable.Value); float?nullable1 = component.craftingSecondsRemaining; float single = (!nullable1.HasValue ? 0f : nullable1.Value); if (single != this._lastTimeStringValue) { this._lastTimeStringString = single.ToString("0.0"); this._lastTimeStringValue = single; } this.progressLabel.text = this._lastTimeStringString; Color color = Color.white; float single1 = component.craftingSpeedPerSec; if (single1 > 1f) { color = Color.green; } else if (single1 < 1f) { color = Color.yellow; } else if (single1 < 0.5f) { color = Color.red; } this.progressLabel.color = color; } if (this.selectedItem != null) { this.UpdateWorkbenchRequirements(); } if (this.progressLabel) { this.progressLabel.enabled = flag; } this.wasCrafting = component.isCrafting; }
public void Update() { if (RPOS.ObservedPlayer != null) { CraftingInventory component = RPOS.ObservedPlayer.GetComponent <CraftingInventory>(); if (component != null) { bool isCrafting = component.isCrafting; if (isCrafting) { component.CraftThink(); } if (!isCrafting && this.wasCrafting) { this.UpdateIngredients(); } else if (!this.wasCrafting && isCrafting) { this.craftSound.Play(); } if (this.craftButton.gameObject.activeSelf) { this.craftButton.GetComponentInChildren <UILabel>().text = !component.isCrafting ? "Craft" : "Cancel"; } if (((this.craftProgressBar != null) && (this.craftProgressBar.gameObject != null)) && this.craftProgressBar.gameObject.activeSelf) { float?craftingCompletePercent = component.craftingCompletePercent; this.craftProgressBar.sliderValue = !craftingCompletePercent.HasValue ? 0f : craftingCompletePercent.Value; float?craftingSecondsRemaining = component.craftingSecondsRemaining; float num = !craftingSecondsRemaining.HasValue ? 0f : craftingSecondsRemaining.Value; if (num != this._lastTimeStringValue) { this._lastTimeStringString = num.ToString("0.0"); this._lastTimeStringValue = num; } this.progressLabel.text = this._lastTimeStringString; Color white = Color.white; float craftingSpeedPerSec = component.craftingSpeedPerSec; if (craftingSpeedPerSec > 1f) { white = Color.green; } else if (craftingSpeedPerSec < 1f) { white = Color.yellow; } else if (craftingSpeedPerSec < 0.5f) { white = Color.red; } this.progressLabel.color = white; } if (this.selectedItem != null) { this.UpdateWorkbenchRequirements(); } if (this.progressLabel != null) { this.progressLabel.enabled = isCrafting; } this.wasCrafting = component.isCrafting; } } }