quantum-space-buddies/QSB/MeteorSync/WorldObjects/QSBFragment.cs

44 lines
1.4 KiB
C#
Raw Normal View History

2021-11-18 04:31:32 +00:00
using OWML.Common;
using QSB.Utility;
using QSB.WorldSync;
2021-11-15 10:39:06 +00:00
using UnityEngine;
2021-11-14 00:57:06 +00:00
namespace QSB.MeteorSync.WorldObjects
{
public class QSBFragment : WorldObject<FragmentIntegrity>
{
public override void Init(FragmentIntegrity attachedObject, int id)
{
ObjectId = id;
AttachedObject = attachedObject;
DetachableFragment = AttachedObject.GetComponent<DetachableFragment>();
2021-11-15 10:39:06 +00:00
if (QSBCore.IsHost)
{
LeashLength = Random.Range(MeteorManager.WhiteHoleVolume._debrisDistMin, MeteorManager.WhiteHoleVolume._debrisDistMax);
2021-11-19 06:23:39 +00:00
// QSBCore.UnityEvents.FireOnNextUpdate(() =>
// {
// AttachedObject._integrity = 0;
// AttachedObject.CallOnTakeDamage();
// });
2021-11-15 10:39:06 +00:00
}
2021-11-14 00:57:06 +00:00
}
2021-11-14 04:41:46 +00:00
2021-11-15 08:29:36 +00:00
public DetachableFragment DetachableFragment;
2021-11-19 06:23:39 +00:00
public bool IsDetached => DetachableFragment != null && DetachableFragment._isDetached;
public bool IsThruWhiteHole => IsDetached && DetachableFragment._sector != null &&
DetachableFragment._sector._parentSector == MeteorManager.WhiteHoleVolume._whiteHoleSector;
2021-11-18 04:31:32 +00:00
public OWRigidbody RefBody => IsThruWhiteHole ? MeteorManager.WhiteHoleVolume._whiteHoleBody : Locator._brittleHollow._owRigidbody;
2021-11-19 06:23:39 +00:00
public OWRigidbody Body => IsDetached ? AttachedObject.transform.parent.parent.GetAttachedOWRigidbody() : null;
2021-11-15 08:29:36 +00:00
2021-11-15 10:39:06 +00:00
/// what the leash length will be when we eventually detach and fall thru white hole
public float LeashLength;
2021-11-15 08:29:36 +00:00
2021-11-14 04:41:46 +00:00
public void AddDamage(float damage)
{
AttachedObject.AddDamage(damage);
}
2021-11-14 00:57:06 +00:00
}
}