| using System; |
| using System; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| public class TimedDestruction : MonoBehaviour |
| public class TimedDestruction : MonoBehaviour |
| { |
| { |
| private void Awake() |
| private void Awake() |
| { |
| { |
| this.m_nview = base.GetComponent<ZNetView>(); |
| this.m_nview = base.GetComponent<ZNetView>(); |
| if (this.m_triggerOnAwake) |
| if (this.m_triggerOnAwake) |
| { |
| { |
| this.Trigger(); |
| this.Trigger(); |
| } |
| } |
| } |
| } |
| |
| |
| public void Trigger() |
| public void Trigger() |
| { |
| { |
| base.InvokeRepeating("DestroyNow", this.m_timeout, 1f); |
| base.InvokeRepeating("DestroyNow", this.m_timeout, 1f); |
| } |
| } |
| |
| |
| public void Trigger(float timeout) |
| public void Trigger(float timeout) |
| { |
| { |
| base.InvokeRepeating("DestroyNow", timeout, 1f); |
| base.InvokeRepeating("DestroyNow", timeout, 1f); |
| } |
| } |
| |
| |
| private void DestroyNow() |
| private void DestroyNow() |
| { |
| { |
| . | if (!this.m_nview) |
| if (this.m_nview) |
| { |
| { |
| . | UnityEngine.Object.Destroy(base.gameObject); |
| if (!this.m_nview.IsValid()) |
| return; |
| { |
| |
| return; |
| |
| } |
| |
| if (!this.m_nview.HasOwner() && this.m_forceTakeOwnershipAndDestroy) |
| |
| { |
| |
| this.m_nview.ClaimOwnership(); |
| |
| } |
| |
| if (this.m_nview.IsOwner()) |
| |
| { |
| |
| ZNetScene.instance.Destroy(base.gameObject); |
| |
| return; |
| |
| } |
| } |
| } |
| . | if (!this.m_nview.IsValid() || !this.m_nview.IsOwner()) |
| else |
| { |
| { |
| . | return; |
| UnityEngine.Object.Destroy(base.gameObject); |
| } |
| } |
| . | ZNetScene.instance.Destroy(base.gameObject); |
| |
| } |
| } |
| |
| |
| public float m_timeout = 1f; |
| public float m_timeout = 1f; |
| |
| |
| public bool m_triggerOnAwake; |
| public bool m_triggerOnAwake; |
| . | |
| |
| |
| [global::Tooltip("If there are objects that you always want to destroy, even if there is no owner, check this. For instance, fires in the ashlands may be created by cinder rain outside of ownership-zones, so they must be deleted even if no owner exists.")] |
| |
| public bool m_forceTakeOwnershipAndDestroy; |
| |
| |
| private ZNetView m_nview; |
| private ZNetView m_nview; |
| } |
| } |
| |
| |