47 lines
1.5 KiB
C#
Raw Normal View History

2022-01-21 15:13:16 -08:00
using QSB.Messaging;
using QSB.MeteorSync.Messages;
using QSB.WorldSync;
2021-11-15 02:39:06 -08:00
using UnityEngine;
2021-11-13 16:57:06 -08:00
namespace QSB.MeteorSync.WorldObjects
{
public class QSBFragment : WorldObject<FragmentIntegrity>
{
public override void Init()
2021-11-13 16:57:06 -08:00
{
DetachableFragment = AttachedObject.GetComponent<DetachableFragment>();
2021-11-15 02:39:06 -08:00
if (QSBCore.IsHost)
{
LeashLength = Random.Range(MeteorManager.WhiteHoleVolume._debrisDistMin, MeteorManager.WhiteHoleVolume._debrisDistMax);
2021-11-18 22:23:39 -08:00
// QSBCore.UnityEvents.FireOnNextUpdate(() =>
// {
// AttachedObject._integrity = 0;
// AttachedObject.CallOnTakeDamage();
// });
2021-11-15 02:39:06 -08:00
}
2021-11-13 16:57:06 -08:00
}
2021-11-13 20:41:46 -08:00
2022-01-21 15:13:16 -08:00
public override void SendResyncInfo(uint to)
{
if (QSBCore.IsHost)
{
this.SendMessage(new FragmentResyncMessage(this) { To = to });
}
}
2021-11-15 00:29:36 -08:00
public DetachableFragment DetachableFragment;
2021-11-18 22:23:39 -08:00
public bool IsDetached => DetachableFragment != null && DetachableFragment._isDetached;
public bool IsThruWhiteHole => IsDetached && DetachableFragment._sector != null &&
DetachableFragment._sector._parentSector == MeteorManager.WhiteHoleVolume._whiteHoleSector;
2021-11-17 20:31:32 -08:00
public OWRigidbody RefBody => IsThruWhiteHole ? MeteorManager.WhiteHoleVolume._whiteHoleBody : Locator._brittleHollow._owRigidbody;
2021-11-18 22:23:39 -08:00
public OWRigidbody Body => IsDetached ? AttachedObject.transform.parent.parent.GetAttachedOWRigidbody() : null;
2021-11-15 00:29:36 -08:00
2021-11-15 02:39:06 -08:00
/// what the leash length will be when we eventually detach and fall thru white hole
public float LeashLength;
2021-11-15 00:29:36 -08:00
2021-11-13 20:41:46 -08:00
public void AddDamage(float damage)
2021-11-20 19:49:50 +00:00
=> AttachedObject.AddDamage(damage);
2021-11-13 16:57:06 -08:00
}
}