using System; using System.Collections; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using BITKit; using Cysharp.Threading.Tasks.Triggers; using UnityEngine; namespace BITFALL.Props { public class Prop_C4 : MonoBehaviour,IDescription { [SerializeField] private int countdown = 45; [SerializeField] private new Light light; [SerializeReference,SubclassSelector] private ITicker ticker; private float _initialLightIntensity; private readonly IntervalUpdate explosionCountdown=new(); private void OnEnable() { ticker.Add(OnUpdate); } private void OnDisable() { ticker.Remove(OnUpdate); } private void Start() { _initialLightIntensity = light.intensity; explosionCountdown.Interval = countdown; explosionCountdown.Reset(); } private void OnUpdate(float delta) { light.intensity =Mathf.Lerp( _initialLightIntensity,0, (float)explosionCountdown.Remaining % 1); if (explosionCountdown.AllowUpdate) { GetComponentInChildren().Explosion(gameObject); } } public string Name=>"C4已安装"; //public string Name=>"C4: 预计剩余时间: "+explosionCountdown.Remaining.ToString("F2")+"s"; } }