quantum-space-buddies/QSB/JellyfishSync/WorldObjects/QSBJellyfish.cs
2022-01-14 22:25:23 -08:00

56 lines
1.1 KiB
C#

using QSB.JellyfishSync.TransformSync;
using QSB.Utility;
using QSB.WorldSync;
using QuantumUNET;
using UnityEngine;
namespace QSB.JellyfishSync.WorldObjects
{
public class QSBJellyfish : WorldObject<JellyfishController>
{
public JellyfishTransformSync2 TransformSync;
private AlignWithTargetBody _alignWithTargetBody;
public override void Init()
{
_alignWithTargetBody = AttachedObject.GetRequiredComponent<AlignWithTargetBody>();
if (QSBCore.IsHost)
{
Object.Instantiate(QSBNetworkManager.singleton.JellyfishPrefab).SpawnWithServerAuthority();
}
StartDelayedReady();
QSBCore.UnityEvents.RunWhen(() => TransformSync, FinishDelayedReady);
}
public override void OnRemoval()
{
if (QSBCore.IsHost)
{
QNetworkServer.Destroy(TransformSync.gameObject);
}
}
public bool IsRising
{
get => AttachedObject._isRising;
set
{
if (AttachedObject._isRising == value)
{
return;
}
AttachedObject._isRising = value;
AttachedObject._attractiveFluidVolume.SetVolumeActivation(!value);
}
}
public bool Align
{
set => _alignWithTargetBody.enabled = value;
}
}
}