| | | 1 | | using BNG; |
| | | 2 | | using System.Diagnostics.CodeAnalysis; |
| | | 3 | | using UnityEngine; |
| | | 4 | | using VRExplorer; |
| | | 5 | | |
| | | 6 | | public class LightCandle : MonoBehaviour, IGrabbableEntity |
| | | 7 | | { |
| | | 8 | | [ExcludeFromCodeCoverage] |
| | | 9 | | public Grabbable Grabbable |
| | | 10 | | { |
| | | 11 | | get |
| | | 12 | | { |
| | | 13 | | var g = GetComponent<Grabbable>(); |
| | | 14 | | if(g) return g; |
| | | 15 | | return gameObject.AddComponent<Grabbable>(); |
| | | 16 | | } |
| | | 17 | | } |
| | | 18 | | [ExcludeFromCodeCoverage] public string Name => Str.Grabbable; |
| | | 19 | | |
| | | 20 | | [ExcludeFromCodeCoverage] |
| | | 21 | | public void OnGrabbed() |
| | | 22 | | { |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | public ParticleSystem flames; |
| | | 26 | | private Rigidbody rigidbody; |
| | 5 | 27 | | public float velocityThreshold = 0.5f; |
| | | 28 | | void Start() |
| | 4 | 29 | | { |
| | 4 | 30 | | rigidbody = GetComponent<Rigidbody>(); |
| | 4 | 31 | | } |
| | | 32 | | void Update() |
| | 6767 | 33 | | { |
| | 6767 | 34 | | if(rigidbody.velocity.magnitude >= velocityThreshold) |
| | 174 | 35 | | { |
| | 174 | 36 | | flames.Stop(); |
| | 174 | 37 | | } |
| | 6767 | 38 | | } |
| | | 39 | | void OnCollisionEnter(Collision collision) |
| | 11 | 40 | | { |
| | 11 | 41 | | if(collision.gameObject.CompareTag("Player")) |
| | 2 | 42 | | { |
| | 2 | 43 | | flames.Play(); |
| | 2 | 44 | | } |
| | 11 | 45 | | } |
| | | 46 | | } |