using Cysharp.Threading.Tasks; using QSB.Messaging; using QSB.MeteorSync.Messages; using QSB.WorldSync; using System.Threading; using UnityEngine; namespace QSB.MeteorSync.WorldObjects; public class QSBFragment : WorldObject { public override async UniTask Init(CancellationToken ct) { if (QSBCore.IsHost) { LeashLength = Random.Range(MeteorManager.WhiteHoleVolume._debrisDistMin, MeteorManager.WhiteHoleVolume._debrisDistMax); // SetIntegrity(0); } } public override void SendInitialState(uint to) { this.SendMessage(new FragmentInitialStateMessage(AttachedObject._origIntegrity, (float)LeashLength) { To = to }); this.SendMessage(new FragmentIntegrityMessage(AttachedObject._integrity) { To = to }); } public void SetIntegrity(float integrity) { if (OWMath.ApproxEquals(AttachedObject._integrity, integrity)) { return; } AttachedObject._integrity = integrity; AttachedObject.CallOnTakeDamage(); } /// /// what the leash length will be when we eventually detach and fall thru white hole. /// /// generated by the server and sent to clients in the initial state message. /// public float? LeashLength; }