/// <summary> /// Enable or disable car /// </summary> internal void ToggleActive(bool enabled) { if (gameObject == null || gameObject.activeSelf == enabled || !IsActive) { return; } // Fix for when the player doesn't have keys for Hayosiko. // Van will NOT be toggled if (isHayosiko && MopFsmManager.PlayerHasHayosikoKey() == false) { ToggleUnityCar(enabled); return; } // If we're disabling a car, set the audio child parent to TemporaryAudioParent, and save the position and rotation. // We're doing that BEFORE we disable the object. if (!enabled) { for (int i = 0; i < preventToggleOnObjects.Count; i++) { preventToggleOnObjects[i].ObjectTransform.parent = temporaryParent; } Position = gameObject.transform.localPosition; Rotation = gameObject.transform.localRotation; } gameObject.SetActive(enabled); // Uppon enabling the object, set the localPosition and localRotation to the object's transform, and change audio source parents to Object // We're doing that AFTER we enable the object. if (enabled) { gameObject.transform.localPosition = Position; gameObject.transform.localRotation = Rotation; for (int i = 0; i < preventToggleOnObjects.Count; i++) { preventToggleOnObjects[i].ObjectTransform.parent = preventToggleOnObjects[i].OriginalParent; } if (isKekmet && MopFsmManager.IsTrailerAttached()) { if (Vector3.Distance(transform.Find("Trailer/Hook").position, WorldManager.instance.GetFlatbed().transform.Find("HookTarget").position) >= 0.4f) { GameFixes.Instance.KekmetTrailerDetach(); } else { GameFixes.Instance.KekmetTrailerAttach(); } } } }
void Update() { if (!MopSettings.DynamicDrawDistance) { return; } float toGoDrawDistance = MopFsmManager.GetDrawDistance(); if (player.position.y > 20) { toGoDrawDistance *= 2; } else if (WorldManager.instance.IsInSector()) { toGoDrawDistance /= 2; } mainCamera.farClipPlane = Mathf.Lerp(mainCamera.farClipPlane, toGoDrawDistance, Time.deltaTime * 2); }
/// <summary> /// Enable or disable car /// </summary> new void ToggleActive(bool enabled) { // Applying hood fix after first enabling. if (!AfterFirstEnable && enabled) { AfterFirstEnable = true; } // If the car is left in ParcFerme, the renderes may not re-enable, so just in case we force them to re-enable. if (IsSatsumaInParcFerme && !renderers[0].enabled) { ToggleAllRenderers(enabled); } if (!Rules.instance.SpecialRules.SatsumaIgnoreRenderers) { if (IsKeyInserted()) { if (lightSelection.Value > 0) { ToggleDashIllumination(true); } else { ToggleDashIllumination(false); } } else { ToggleDashIllumination(false); } } // Don't run the code, if the value is the same if (gameObject == null || disableableObjects[0].gameObject.activeSelf == enabled) { return; } if (!GameFixes.Instance.HoodFixDone && !GameFixes.Instance.RearBumperFixDone) { return; } if (!enabled) { lastGoodRotation = transform.rotation; lastGoodPosition = transform.position; } if (!GameFixes.Instance.HoodFixDone) { enabled = true; } if (preventDespawnDuringThisSession || MopFsmManager.IsRepairshopJobOrdered()) { enabled = true; preventDespawnDuringThisSession = true; } for (int i = 0; i < disableableObjects.Length; i++) { if (disableableObjects[i] == null) { continue; } bool isElementEnabled = Satsuma.instance.IsSatsumaInParcFerme ? true : enabled; disableableObjects[i].gameObject.SetActive(isElementEnabled); } ToggleAllRenderers(enabled); }
IEnumerator HoodFixCoroutine(Transform hoodPivot, Transform batteryPivot, Transform batteryTrigger) { yield return(new WaitForSeconds(2)); // Hood Transform hood = Resources.FindObjectsOfTypeAll <GameObject>().First(g => g.name == "hood(Clone)").transform; CustomPlayMakerFixedUpdate hoodFixedUpdate = hood.gameObject.AddComponent <CustomPlayMakerFixedUpdate>(); // Fiber Hood GameObject fiberHood = Resources.FindObjectsOfTypeAll <GameObject>() .First(obj => obj.name == "fiberglass hood(Clone)" && obj.GetComponent <PlayMakerFSM>() != null && obj.GetComponent <MeshCollider>() != null); //this is fine for now doesn't need to be disabled , i'll test it later /*int retries = 0; * if (MopFsmManager.IsStockHoodBolted() && hood.parent != hoodPivot) * { * hood.gameObject.SetActive(true); * * while (hood.parent != hoodPivot) * { * // Satsuma got disabled while trying to fix the hood. * // Attempt to fix it later. * if (!hoodPivot.gameObject.activeSelf) * { * yield break; * } * * MopFsmManager.ForceHoodAssemble(); * yield return null; * * // If 10 retries failed, quit the loop. * retries++; * if (retries == 10) * { * break; * } * } * }*/ /*hoodFixedUpdate.StartFixedUpdate(); breaks mp completely if someone tries to load a save with satsuma even though they are not supposed to * * if (fiberHood != null && MopFsmManager.IsFiberHoodBolted() && fiberHood.transform.parent != hoodPivot) * { * retries = 0; * while (fiberHood.transform.parent != hoodPivot) * { * // Satsuma got disabled while trying to fix the hood. * // Attempt to fix it later. * if (!hoodPivot.gameObject.activeSelf) * { * Satsuma.instance.AfterFirstEnable = false; * yield break; * } * * MopFsmManager.ForceHoodAssemble(); * yield return null; * * // If 10 retries failed, quit the loop. * retries++; * if (retries == 60) * { * break; * } * } * }*/ hood.gameObject.AddComponent <SatsumaBoltsAntiReload>(); fiberHood.gameObject.AddComponent <SatsumaBoltsAntiReload>(); // Adds delayed initialization for hood hinge. if (hood.gameObject.GetComponent <DelayedHingeManager>() == null) { hood.gameObject.AddComponent <DelayedHingeManager>(); } // Fix for hood not being able to be closed. if (hood.gameObject.GetComponent <SatsumaCustomHoodUse>() == null) { hood.gameObject.AddComponent <SatsumaCustomHoodUse>(); } // Fix for battery popping out. if (MopFsmManager.IsBatteryInstalled() && batteryPivot.parent == null) { batteryTrigger.gameObject.SetActive(true); batteryTrigger.gameObject.GetComponent <PlayMakerFSM>().SendEvent("ASSEMBLE"); } HoodFixDone = true; }