quantum-space-buddies/QSB/MeteorSync/WorldObjects/QSBMeteor.cs
2021-11-10 21:13:49 -08:00

57 lines
1004 B
C#

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;
}
public void Impact()
{
// todo
}
}
}