using System; using System.Collections; using System.Collections.Generic; using NGS.AdvancedCullingSystem.Dynamic; using UnityEngine; using UnityEngine.Animations; namespace BITKit { public class Prop_Fixed : MonoBehaviour { [SerializeField] private new Rigidbody rigidbody; [SerializeField] private LayerMask allowLayer; private Collider _collider; private void Start() { if (!rigidbody.isKinematic) return; DestorySelf(); } private void Update() { if (!rigidbody.IsSleeping() || !_collider) return; if (_collider.gameObject.isStatic) { DestorySelf(); return; } enabled = false; transform.SetParentConstraint(_collider.transform); rigidbody.isKinematic = true; } private void OnCollisionStay(Collision other) { if (allowLayer.value is not 0 && allowLayer.Includes(other.gameObject.layer) is false) return; _collider = other.collider; } private void DestorySelf() { foreach (var x in GetComponentsInChildren()) { Destroy(this); if(rigidbody)Destroy(rigidbody); var dc = x.gameObject.AddComponent(); dc.ControllerID = 1; } } } }