mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Adds a 5 second cooldown to warp transmitters after using return pad (#618)
<!-- Some improvement that requires no action on the part of add-on creators i.e., improved star graphics --> ## Improvements - Added a 5 second delay to warp transmitters after you come back through the return pad. Means 360 degree alignment target actually works when returning through it instead of sending you straight back. (resolves #563)
This commit is contained in:
commit
fcfe685c22
@ -1,4 +1,5 @@
|
||||
using NewHorizons.Builder.Props.TranslatorText;
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.External.Modules.Props;
|
||||
using NewHorizons.External.Modules.WarpPad;
|
||||
using NewHorizons.Utility;
|
||||
@ -137,6 +138,9 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
transmitter.GetComponent<BoxShape>().enabled = true;
|
||||
|
||||
// Prevents the transmitter from sending you straight back if you use the return function of the receiver #563
|
||||
transmitterObject.AddComponent<NomaiWarpTransmitterCooldown>();
|
||||
|
||||
transmitterObject.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
45
NewHorizons/Components/NomaiWarpTransmitterCooldown.cs
Normal file
45
NewHorizons/Components/NomaiWarpTransmitterCooldown.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Components
|
||||
{
|
||||
public class NomaiWarpTransmitterCooldown : MonoBehaviour
|
||||
{
|
||||
private NomaiWarpTransmitter _transmitter;
|
||||
private NomaiWarpReceiver _receiver;
|
||||
|
||||
private float _reenabledTime = 0f;
|
||||
private bool _cooldownActive;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_transmitter = GetComponent<NomaiWarpTransmitter>();
|
||||
_transmitter.OnReceiveWarpedBody += _transmitter_OnReceiveWarpedBody;
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (_transmitter != null)
|
||||
{
|
||||
_transmitter.OnReceiveWarpedBody -= _transmitter_OnReceiveWarpedBody;
|
||||
}
|
||||
}
|
||||
|
||||
private void _transmitter_OnReceiveWarpedBody(OWRigidbody warpedBody, NomaiWarpPlatform startPlatform, NomaiWarpPlatform targetPlatform)
|
||||
{
|
||||
_cooldownActive = true;
|
||||
|
||||
_reenabledTime = Time.time + 5f;
|
||||
_receiver = _transmitter._targetReceiver;
|
||||
_transmitter._targetReceiver = null;
|
||||
}
|
||||
|
||||
public void FixedUpdate()
|
||||
{
|
||||
if (_cooldownActive && Time.time > _reenabledTime)
|
||||
{
|
||||
_cooldownActive = false;
|
||||
_transmitter._targetReceiver = _receiver;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user