2021-11-13 16:57:06 -08:00
|
|
|
|
using QSB.MeteorSync.TransformSync;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using QuantumUNET;
|
|
|
|
|
using UnityEngine;
|
2021-11-10 18:40:02 -08:00
|
|
|
|
|
|
|
|
|
namespace QSB.MeteorSync.WorldObjects
|
|
|
|
|
{
|
|
|
|
|
public class QSBMeteor : WorldObject<MeteorController>
|
|
|
|
|
{
|
2021-11-13 16:57:06 -08:00
|
|
|
|
public MeteorTransformSync TransformSync;
|
|
|
|
|
|
2021-11-10 18:40:02 -08:00
|
|
|
|
public override void Init(MeteorController attachedObject, int id)
|
|
|
|
|
{
|
|
|
|
|
ObjectId = id;
|
|
|
|
|
AttachedObject = attachedObject;
|
2021-11-13 16:57:06 -08:00
|
|
|
|
|
|
|
|
|
if (QSBCore.IsHost)
|
|
|
|
|
{
|
|
|
|
|
Object.Instantiate(QSBNetworkManager.Instance.MeteorPrefab).SpawnWithServerAuthority();
|
|
|
|
|
}
|
2021-11-10 18:40:02 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnRemoval()
|
|
|
|
|
{
|
2021-11-13 16:57:06 -08:00
|
|
|
|
if (QSBCore.IsHost)
|
|
|
|
|
{
|
|
|
|
|
QNetworkServer.Destroy(TransformSync.gameObject);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-13 21:15:01 -08:00
|
|
|
|
MeteorManager.Ready = false;
|
2021-11-10 18:40:02 -08:00
|
|
|
|
}
|
2021-11-13 23:29:06 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static bool IsSpecialImpact(GameObject go) =>
|
|
|
|
|
go == Locator.GetPlayerBody().gameObject || go == Locator.GetProbe().gameObject;
|
|
|
|
|
|
|
|
|
|
public void SpecialImpact()
|
|
|
|
|
{
|
|
|
|
|
AttachedObject._intactRenderer.enabled = false;
|
|
|
|
|
AttachedObject._impactLight.enabled = true;
|
|
|
|
|
AttachedObject._impactLight.intensity = AttachedObject._impactLightCurve.Evaluate(0f);
|
|
|
|
|
foreach (var particleSystem in AttachedObject._impactParticles)
|
|
|
|
|
{
|
|
|
|
|
particleSystem.Play();
|
|
|
|
|
}
|
|
|
|
|
AttachedObject._impactSource.PlayOneShot(AudioType.BH_MeteorImpact);
|
|
|
|
|
foreach (var owCollider in AttachedObject._owColliders)
|
|
|
|
|
{
|
|
|
|
|
owCollider.SetActivation(false);
|
|
|
|
|
}
|
|
|
|
|
AttachedObject._owRigidbody.MakeKinematic();
|
|
|
|
|
FragmentSurfaceProxy.UntrackMeteor(AttachedObject);
|
|
|
|
|
FragmentCollisionProxy.UntrackMeteor(AttachedObject);
|
|
|
|
|
AttachedObject._ignoringCollisions = false;
|
|
|
|
|
AttachedObject._hasImpacted = true;
|
|
|
|
|
AttachedObject._impactTime = Time.time;
|
|
|
|
|
}
|
2021-11-10 18:40:02 -08:00
|
|
|
|
}
|
|
|
|
|
}
|