protected void OnAdditionChange() { base.GetComponentInParent <WallChunkArchitect>().Addition = (WallChunkArchitect.Additions)base.state.Addition; WallDoor.Actions activeDoorStatusAction = this.GetActiveDoorStatusAction(); if (activeDoorStatusAction != this._currentAction) { base.enabled = true; if (this._currentAction == WallDoor.Actions.Idle) { this._alpha = 0f; } else { this._alpha = 1f - this._alpha; } this._currentAction = activeDoorStatusAction; if (this._targetRb) { this._targetRb.isKinematic = (this._currentAction == WallDoor.Actions.Closing); if (this._targetRb.isKinematic) { this._targetRb.transform.localRotation = Quaternion.identity; } } this.PlaySfx(activeDoorStatusAction); } }
protected virtual void Update() { if (this._currentAction == WallDoor.Actions.Idle) { if (this.CanToggle() && TheForest.Utils.Input.GetButtonDown("Take")) { if (!BoltNetwork.isRunning) { WallDoor.Actions currentAction = this.ToggleDoorStatusAction(true); this._currentAction = currentAction; this._targetRb.isKinematic = (this._currentAction == WallDoor.Actions.Closing); if (this._targetRb.isKinematic) { this._targetRb.transform.localRotation = Quaternion.identity; } this._alpha = 0f; } else { WallDoor.Actions currentAction = this.ToggleDoorStatusAction(true); } } this.RefreshIcons(); } else { this._alpha += Time.deltaTime * 3f; if (this._alpha < 1f) { if (this._currentAction == WallDoor.Actions.Openning) { this._target.localRotation = Quaternion.Slerp(WallDoor.ClosedRotation, WallDoor.OpenedRotation, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); } else { this._alpha += Time.deltaTime * 3f; this._target.localPosition = Vector3.Slerp(WallDoor.OpenedPosition, WallDoor.ClosedPosition, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); } } else if (this._alpha < 2f) { if (this._currentAction == WallDoor.Actions.Openning) { this._alpha += Time.deltaTime * 3f; this._target.localPosition = Vector3.Slerp(WallDoor.ClosedPosition, WallDoor.OpenedPosition, MathEx.Easing.EaseInOutQuad(this._alpha - 1f, 0f, 1f, 1f)); } else { this._target.localRotation = Quaternion.Slerp(WallDoor.OpenedRotation, WallDoor.ClosedRotation, MathEx.Easing.EaseInOutQuad(this._alpha - 1f, 0f, 1f, 1f)); } } else { this.FinalizeDoorStatus(); this.RefreshIcons(); base.enabled = (Grabber.FocusedItemGO == base.gameObject); } } }
protected virtual void PlaySfx(WallDoor.Actions action) { if (LocalPlayer.Sfx) { if (action == WallDoor.Actions.Closing) { LocalPlayer.Sfx.PlayStructureBreak(base.gameObject, 0.008f); } else { LocalPlayer.Sfx.PlayBreakWood(base.gameObject); } } }
protected override void PlaySfx(WallDoor.Actions action) { if (LocalPlayer.Sfx) { if (action == WallDoor.Actions.Closing) { LocalPlayer.Sfx.PlayStructureBreak(base.gameObject, 0.4f); } else { LocalPlayer.Sfx.PlayStructureBreak(base.gameObject, 0.4f); } } }
protected override void Update() { if (this._currentAction == WallDoor.Actions.Idle) { if (this.CanToggle() && TheForest.Utils.Input.GetButtonDown("Take")) { if (!BoltNetwork.isRunning) { WallDoor.Actions currentAction = base.ToggleDoorStatusAction(true); this._currentAction = currentAction; this._alpha = 0f; } else { WallDoor.Actions currentAction = base.ToggleDoorStatusAction(true); } } base.RefreshIcons(); } else { this._alpha += Time.deltaTime; if (this._alpha < 1f) { if (this._currentAction == WallDoor.Actions.Openning) { if (this._gate.Addition == WallChunkArchitect.Additions.Door1) { this._target1.localRotation = Quaternion.Slerp(WallDefensiveGate.ClosedRotation1, WallDefensiveGate.OpenedRotation, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); if (this._target2) { this._target2.localRotation = Quaternion.Slerp(WallDefensiveGate.ClosedRotation2, WallDefensiveGate.OpenedRotation, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); } } else { this._target1.localRotation = Quaternion.Slerp(WallDefensiveGate.ClosedRotation2, WallDefensiveGate.OpenedRotation, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); if (this._target2) { this._target2.localRotation = Quaternion.Slerp(WallDefensiveGate.ClosedRotation1, WallDefensiveGate.OpenedRotation, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); } } } else if (this._gate.Addition == WallChunkArchitect.Additions.LockedDoor1) { this._target1.localRotation = Quaternion.Slerp(WallDefensiveGate.OpenedRotation, WallDefensiveGate.ClosedRotation1, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); if (this._target2) { this._target2.localRotation = Quaternion.Slerp(WallDefensiveGate.OpenedRotation, WallDefensiveGate.ClosedRotation2, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); } } else { this._target1.localRotation = Quaternion.Slerp(WallDefensiveGate.OpenedRotation, WallDefensiveGate.ClosedRotation2, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); if (this._target2) { this._target2.localRotation = Quaternion.Slerp(WallDefensiveGate.OpenedRotation, WallDefensiveGate.ClosedRotation1, MathEx.Easing.EaseInOutQuad(this._alpha, 0f, 1f, 1f)); } } } else { this.FinalizeDoorStatus(); base.RefreshIcons(); base.enabled = (Grabber.FocusedItemGO == base.gameObject); } } }