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

50 lines
959 B
C#
Raw Normal View History

2021-11-11 02:40:02 +00:00
using QSB.MeteorSync.TransformSync;
using QSB.Utility;
using QSB.WorldSync;
using QuantumUNET;
using Object = UnityEngine.Object;
namespace QSB.MeteorSync.WorldObjects
{
public class QSBMeteor : WorldObject<MeteorController>
{
public MeteorTransformSync TransformSync;
private bool _initialized;
public override void Init(MeteorController attachedObject, int id)
{
ObjectId = id;
AttachedObject = attachedObject;
// remove WorldObject if prefab
if (AttachedObject.gameObject.scene.name == null)
{
QSBWorldSync.RemoveWorldObject(this);
return;
}
if (QSBCore.IsHost)
{
Object.Instantiate(QSBNetworkManager.Instance.MeteorPrefab).SpawnWithServerAuthority();
}
_initialized = true;
}
public override void OnRemoval()
{
if (!_initialized)
{
return;
}
if (QSBCore.IsHost)
{
QNetworkServer.Destroy(TransformSync.gameObject);
}
MeteorManager.AllReady = false;
}
}
}