2022-01-29 04:49:07 +00:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using Mirror;
|
2022-01-21 23:13:16 +00:00
|
|
|
|
using QSB.JellyfishSync.Messages;
|
2022-01-15 06:54:18 +00:00
|
|
|
|
using QSB.JellyfishSync.TransformSync;
|
2022-01-21 23:13:16 +00:00
|
|
|
|
using QSB.Messaging;
|
2022-03-14 08:53:12 +00:00
|
|
|
|
using QSB.Utility.LinkedWorldObject;
|
2021-12-01 09:10:38 +00:00
|
|
|
|
using QSB.WorldSync;
|
2022-01-29 04:49:07 +00:00
|
|
|
|
using System.Threading;
|
2021-12-01 09:10:38 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.JellyfishSync.WorldObjects;
|
|
|
|
|
|
2022-03-14 08:53:12 +00:00
|
|
|
|
public class QSBJellyfish : WorldObject<JellyfishController>, ILinkedWorldObject<JellyfishTransformSync>
|
2021-12-01 09:10:38 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override bool ShouldDisplayDebug() => false;
|
2022-01-22 01:56:20 +00:00
|
|
|
|
|
2022-03-14 08:53:12 +00:00
|
|
|
|
public JellyfishTransformSync NetworkBehaviour { get; private set; }
|
|
|
|
|
public void LinkTo(NetworkBehaviour networkBehaviour) => NetworkBehaviour = (JellyfishTransformSync)networkBehaviour;
|
2021-12-01 09:10:38 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override async UniTask Init(CancellationToken ct)
|
|
|
|
|
{
|
|
|
|
|
if (QSBCore.IsHost)
|
2021-12-01 09:10:38 +00:00
|
|
|
|
{
|
2022-03-14 08:53:12 +00:00
|
|
|
|
this.SpawnLinked(QSBNetworkManager.singleton.JellyfishPrefab);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await this.WaitForLink(ct);
|
2022-02-27 12:40:44 +00:00
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnRemoval()
|
|
|
|
|
{
|
|
|
|
|
if (QSBCore.IsHost)
|
2021-12-01 09:10:38 +00:00
|
|
|
|
{
|
2022-03-14 08:53:12 +00:00
|
|
|
|
NetworkServer.Destroy(NetworkBehaviour.gameObject);
|
2021-12-01 09:10:38 +00:00
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
}
|
2021-12-01 10:23:12 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void SendInitialState(uint to) =>
|
|
|
|
|
this.SendMessage(new JellyfishRisingMessage(AttachedObject._isRising) { To = to });
|
2022-01-21 23:13:16 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public void SetIsRising(bool value)
|
|
|
|
|
{
|
|
|
|
|
if (AttachedObject._isRising == value)
|
2021-12-01 10:23:12 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
return;
|
2022-02-27 12:40:44 +00:00
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
|
|
|
|
|
AttachedObject._isRising = value;
|
|
|
|
|
AttachedObject._attractiveFluidVolume.SetVolumeActivation(!value);
|
2021-12-01 09:10:38 +00:00
|
|
|
|
}
|
2022-03-14 08:53:12 +00:00
|
|
|
|
}
|