Upload from upload_mods.ps1
This commit is contained in:
44
Scripts/MonoBehaviours/AutoRemove.cs
Normal file
44
Scripts/MonoBehaviours/AutoRemove.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user