Files
2025-06-04 16:13:19 +09:30

45 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
public class AutoRemove : TrackedBehaviourBase
{
public float lifetime = -1;
protected override void Awake()
{
ExplosionValue value = CustomExplosionManager.LastInitializedComponent;
lifetime = value.CurrentExplosionParams._explosionData.Duration;
if(lifetime > 0)
syncOnConnect = value.Component.SyncOnConnect;
base.Awake();
if (lifetime > 0)
Destroy(gameObject, lifetime);
}
private void Update()
{
if(lifetime > 0)
lifetime -= Time.deltaTime;
}
protected override void OnDestroy()
{
base.OnDestroy();
CustomExplosionManager.removeInitializedParticle(gameObject);
}
protected override void OnClientConnected(PooledBinaryWriter _bw)
{
_bw.Write(lifetime);
}
protected override void OnConnectedToServer(PooledBinaryReader _br)
{
lifetime = _br.ReadSingle();
if (lifetime > 0)
Destroy(gameObject, lifetime);
}
}