41 lines
1.2 KiB
C#
Raw Normal View History

2021-11-14 00:57:45 -08:00
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(FragmentIntegrity attachedObject, int id)
{
ObjectId = id;
AttachedObject = attachedObject;
2021-11-15 00:29:36 -08:00
DetachableFragment = AttachedObject.GetRequiredComponent<DetachableFragment>();
2021-11-15 02:39:06 -08:00
if (QSBCore.IsHost)
{
LeashLength = Random.Range(MeteorManager.WhiteHoleVolume._debrisDistMin, MeteorManager.WhiteHoleVolume._debrisDistMax);
}
2021-11-13 16:57:06 -08:00
}
2021-11-13 20:41:46 -08:00
public override void OnRemoval()
{
MeteorManager.Ready = false;
}
2021-11-15 00:29:36 -08:00
public DetachableFragment DetachableFragment;
public bool IsThruWhiteHole => DetachableFragment._sector._parentSector == MeteorManager.WhiteHoleVolume._whiteHoleSector;
public OWRigidbody RefBody => IsThruWhiteHole ? MeteorManager.WhiteHoleVolume._whiteHoleBody :
2021-11-15 02:39:06 -08:00
Locator._brittleHollow._owRigidbody;
public OWRigidbody Body => IsThruWhiteHole ? 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)
{
AttachedObject.AddDamage(damage);
}
2021-11-13 16:57:06 -08:00
}
}