public bool CanRunEngines() { if (HasDriver() && fuelSystem.HasFuel() && !Waterlogged()) { return(!IsDead()); } return(false); }
public void EngineToggle(bool wantsOn) { if (!fuelSystem.HasFuel(true)) { return; } BasePlayer driver = GetDriver(); if (!wantsOn || Interface.CallHook("OnEngineStart", this, driver) == null) { SetFlag(Flags.Reserved1, wantsOn); if (wantsOn) { Interface.CallHook("OnEngineStarted", this, driver); } } }
public bool CanRunEngines() { if (HasAnyWorkingEngines() && HasDriver() && fuelSystem.HasFuel() && !waterlogged) { return(!IsDead()); } return(false); }
protected void FixedUpdate() { if (!isSpawned || base.isClient) { return; } if (!fuelSystem.HasFuel() || WaterLogged()) { SetFlag(Flags.On, false); } if (IsOn()) { fuelSystem.TryUseFuel(UnityEngine.Time.fixedDeltaTime, fuelPerSec); } SetFlag(Flags.Reserved6, fuelSystem.HasFuel()); bool flag = (IsFullyInflated && myRigidbody.velocity.y < 0f) || myRigidbody.velocity.y < 0.75f; GameObject[] array = killTriggers; foreach (GameObject gameObject in array) { if (gameObject.activeSelf != flag) { gameObject.SetActive(flag); } } float num = inflationLevel; if (IsOn() && !IsFullyInflated) { inflationLevel = Mathf.Clamp01(inflationLevel + UnityEngine.Time.fixedDeltaTime / 10f); } else if (grounded && inflationLevel > 0f && !IsOn() && (UnityEngine.Time.time > lastBlastTime + 30f || WaterLogged())) { inflationLevel = Mathf.Clamp01(inflationLevel - UnityEngine.Time.fixedDeltaTime / 10f); } if (num != inflationLevel) { if (IsFullyInflated) { bounds = raisedBounds; } else if (inflationLevel == 0f) { bounds = collapsedBounds; } SetFlag(Flags.Reserved1, inflationLevel > 0.3f); SetFlag(Flags.Reserved2, inflationLevel >= 1f); SendNetworkUpdate(); float inflationLevel2 = inflationLevel; } bool flag2 = !myRigidbody.IsSleeping() || inflationLevel > 0f; array = balloonColliders; foreach (GameObject gameObject2 in array) { if (gameObject2.activeSelf != flag2) { gameObject2.SetActive(flag2); } } if (IsOn()) { if (IsFullyInflated) { currentBuoyancy += UnityEngine.Time.fixedDeltaTime * 0.2f; lastBlastTime = UnityEngine.Time.time; } } else { currentBuoyancy -= UnityEngine.Time.fixedDeltaTime * 0.1f; } currentBuoyancy = Mathf.Clamp(currentBuoyancy, 0f, 0.8f + 0.2f * base.healthFraction); if (inflationLevel > 0f) { avgTerrainHeight = Mathf.Lerp(avgTerrainHeight, TerrainMeta.HeightMap.GetHeight(base.transform.position), UnityEngine.Time.deltaTime); float num2 = 1f - Mathf.InverseLerp(avgTerrainHeight + serviceCeiling - 20f, avgTerrainHeight + serviceCeiling, buoyancyPoint.position.y); myRigidbody.AddForceAtPosition(Vector3.up * (0f - UnityEngine.Physics.gravity.y) * myRigidbody.mass * 0.5f * inflationLevel, buoyancyPoint.position, ForceMode.Force); myRigidbody.AddForceAtPosition(Vector3.up * liftAmount * currentBuoyancy * num2, buoyancyPoint.position, ForceMode.Force); Vector3 windAtPos = GetWindAtPos(buoyancyPoint.position); float magnitude = windAtPos.magnitude; float num3 = 1f; float num4 = Mathf.Max(TerrainMeta.HeightMap.GetHeight(buoyancyPoint.position), TerrainMeta.WaterMap.GetHeight(buoyancyPoint.position)); float num5 = Mathf.InverseLerp(num4 + 20f, num4 + 60f, buoyancyPoint.position.y); float num6 = 1f; RaycastHit hitInfo; if (UnityEngine.Physics.SphereCast(new Ray(base.transform.position + Vector3.up * 2f, Vector3.down), 1.5f, out hitInfo, 5f, 1218511105)) { num6 = Mathf.Clamp01(hitInfo.distance / 5f); } num3 *= num5 * num2 * num6; num3 *= 0.2f + 0.8f * base.healthFraction; Vector3 vector = windAtPos.normalized * num3 * windForce; currentWindVec = Vector3.Lerp(currentWindVec, vector, UnityEngine.Time.fixedDeltaTime * 0.25f); myRigidbody.AddForceAtPosition(vector * 0.1f, buoyancyPoint.position, ForceMode.Force); myRigidbody.AddForce(vector * 0.9f, ForceMode.Force); } }