2021-12-17 19:16:22 -08:00
|
|
|
|
using QSB.JellyfishSync.TransformSync;
|
2021-12-21 11:45:40 -08:00
|
|
|
|
using QSB.Utility;
|
2021-12-01 01:10:38 -08:00
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using QuantumUNET;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.JellyfishSync.WorldObjects
|
|
|
|
|
{
|
|
|
|
|
public class QSBJellyfish : WorldObject<JellyfishController>
|
|
|
|
|
{
|
|
|
|
|
public JellyfishTransformSync TransformSync;
|
2021-12-01 03:55:56 -08:00
|
|
|
|
private AlignWithTargetBody _alignWithTargetBody;
|
2021-12-01 01:10:38 -08:00
|
|
|
|
|
2021-12-11 14:38:54 -08:00
|
|
|
|
public override void Init()
|
2021-12-01 01:10:38 -08:00
|
|
|
|
{
|
2021-12-01 03:55:56 -08:00
|
|
|
|
_alignWithTargetBody = AttachedObject.GetRequiredComponent<AlignWithTargetBody>();
|
2021-12-01 01:10:38 -08:00
|
|
|
|
|
|
|
|
|
if (QSBCore.IsHost)
|
|
|
|
|
{
|
2021-12-21 11:45:40 -08:00
|
|
|
|
Object.Instantiate(QSBNetworkManager.Instance.JellyfishPrefab).SpawnWithServerAuthority();
|
2021-12-01 01:10:38 -08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-02 00:42:24 -08:00
|
|
|
|
StartDelayedReady();
|
2021-12-17 19:16:22 -08:00
|
|
|
|
QSBCore.UnityEvents.RunWhen(() => TransformSync, FinishDelayedReady);
|
2021-12-01 01:10:38 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnRemoval()
|
|
|
|
|
{
|
|
|
|
|
if (QSBCore.IsHost)
|
|
|
|
|
{
|
|
|
|
|
QNetworkServer.Destroy(TransformSync.gameObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-01 02:23:12 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsRising
|
|
|
|
|
{
|
|
|
|
|
get => AttachedObject._isRising;
|
|
|
|
|
set
|
|
|
|
|
{
|
2021-12-01 23:09:34 -08:00
|
|
|
|
if (AttachedObject._isRising == value)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 02:23:12 -08:00
|
|
|
|
AttachedObject._isRising = value;
|
|
|
|
|
AttachedObject._attractiveFluidVolume.SetVolumeActivation(!value);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-01 03:55:56 -08:00
|
|
|
|
|
|
|
|
|
public bool Align
|
|
|
|
|
{
|
|
|
|
|
set => _alignWithTargetBody.enabled = value;
|
|
|
|
|
}
|
2021-12-01 01:10:38 -08:00
|
|
|
|
}
|
|
|
|
|
}
|