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
This commit is contained in:
parent
c7ad912acf
commit
f0f24b2777
@ -1,4 +1,5 @@
|
|||||||
using NewHorizons.Builder.Props.TranslatorText;
|
using NewHorizons.Builder.Props.TranslatorText;
|
||||||
|
using NewHorizons.Components;
|
||||||
using NewHorizons.External.Modules.Props;
|
using NewHorizons.External.Modules.Props;
|
||||||
using NewHorizons.External.Modules.WarpPad;
|
using NewHorizons.External.Modules.WarpPad;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
@ -137,6 +138,9 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
transmitter.GetComponent<BoxShape>().enabled = true;
|
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);
|
transmitterObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
37
NewHorizons/Components/NomaiWarpTransmitterCooldown.cs
Normal file
37
NewHorizons/Components/NomaiWarpTransmitterCooldown.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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