49 lines
1.4 KiB
C#
Raw Normal View History

2021-11-17 20:31:32 -08:00
using OWML.Common;
using QSB.Utility;
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;
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-13 16:57:06 -08:00
}
2021-11-13 20:41:46 -08:00
2021-11-15 00:29:36 -08:00
public DetachableFragment DetachableFragment;
public bool IsThruWhiteHole => DetachableFragment != null && 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;
public OWRigidbody Body
{
get
{
if (DetachableFragment != null && DetachableFragment._isDetached)
2021-11-17 20:31:32 -08:00
{
return AttachedObject.transform.parent.parent.GetAttachedOWRigidbody();
}
DebugLog.ToConsole($"{LogName} - trying to get rigidbody when not detached", MessageType.Error);
2021-11-17 20:31:32 -08:00
return 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
}
}