Mister_Nebula 460a974ee2 cleanup
2021-08-09 11:49:58 +01:00

47 lines
1.4 KiB
C#

using OWML.Utils;
using QSB.Events;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.Tools.ProbeLauncherTool.WorldObjects
{
internal class QSBProbeLauncher : WorldObject<ProbeLauncher>
{
private float _probeRetrievalLength;
private GameObject _preLaunchProbeProxy;
private ProbeLauncherEffects _effects;
private SingularityWarpEffect _probeRetrievalEffect;
public override void Init(ProbeLauncher launcher, int id)
{
ObjectId = id;
AttachedObject = launcher;
_probeRetrievalLength = AttachedObject.GetValue<float>("_probeRetrievalLength");
_preLaunchProbeProxy = AttachedObject.GetValue<GameObject>("_preLaunchProbeProxy");
_effects = AttachedObject.GetValue<ProbeLauncherEffects>("_effects");
_probeRetrievalEffect = AttachedObject.GetValue<SingularityWarpEffect>("_probeRetrievalEffect");
AttachedObject.OnLaunchProbe += (SurveyorProbe probe) => QSBEventManager.FireEvent(EventNames.QSBLaunchProbe, this);
}
public void RetrieveProbe(bool playEffects)
{
_preLaunchProbeProxy.SetActive(true);
if (playEffects)
{
_effects.PlayRetrievalClip();
_probeRetrievalEffect.WarpObjectIn(_probeRetrievalLength);
}
}
public void LaunchProbe()
{
_preLaunchProbeProxy.SetActive(false);
// TODO : make this do underwater stuff correctly
_effects.PlayLaunchClip(false);
_effects.PlayLaunchParticles(false);
}
}
}