using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using BITKit; using BITKit.Entities; using BITKit.Sensors; using UnityEngine; using UnityEngine.Animations; namespace BITFALL.Props { public class Prop_BouncingBetty : MonoBehaviour { [SerializeField] private float jumpForce; [SerializeField] private new Rigidbody rigidbody; private bool isTriggered; public async void OnDetected(Collider _collider) { if (isTriggered) return; rigidbody.isKinematic = false; rigidbody.useGravity = true; if(TryGetComponent(out var parentConstraint)) Destroy(parentConstraint); isTriggered = true; rigidbody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse); try { await Task.Delay(1000,destroyCancellationToken); GetComponentInChildren().Explosion(gameObject); } catch (OperationCanceledException) { } } } }