< Summary

Class:HoseController
Assembly:Test
File(s):E:/Unity/Unity Project/vr-firefighter-simulator/Assets/Test/HoseController.cs
Covered lines:49
Uncovered lines:0
Coverable lines:49
Total lines:86
Line coverage:100% (49 of 49)
Covered branches:0
Total branches:0
Covered methods:9
Total methods:9
Method coverage:100% (9 of 9)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
HoseController()0%000100%
Awake()0%000100%
Update()0%000100%
IsValidChange()0%000100%
HandleHoseAudio()0%000100%
StartHoseAudio()0%000100%
EndHoseAudio()0%000100%
HandleHoseWaterWithDelay()0%000100%
HandleHoseWater()0%000100%

File(s)

E:/Unity/Unity Project/vr-firefighter-simulator/Assets/Test/HoseController.cs

#LineLine coverage
 1using System.Collections;
 2using UnityEngine;
 3
 4public class HoseController : MonoBehaviour
 5{
 6    public HoseHandleMovement hoseHandle;
 7    public ParticleSystem hoseWaterPs;
 8    public AudioSource audioSource;
 9    public AudioClip hoseAudioStart;
 10    public AudioClip hoseAudioDuring;
 11    public float waterDelayTime;
 12    public float changeStateInterval;
 13
 214    private float lastChangeState = 10f;
 15    private bool hoseIsOn;
 16
 17    // Start is called before the first frame update
 18    void Awake()
 119    {
 120        this.hoseHandle = GameObject.FindGameObjectWithTag("HoseHandle").GetComponent<HoseHandleMovement>();
 121        this.audioSource = this.GetComponent<AudioSource>();
 122        this.hoseIsOn = false;
 123        this.HandleHoseWater();
 124    }
 25
 26    // Update is called once per frame
 27    void Update()
 2212528    {
 2212529        if (this.IsValidChange() && !this.hoseHandle.getIsTurning() && ActionMapper.GetDevicesTrigger())
 49330        {
 49331            this.hoseIsOn = !this.hoseIsOn;
 49332            this.hoseHandle.ActivateHandleMovement(this.hoseIsOn);
 49333            this.HandleHoseAudio();
 49334            StartCoroutine(this.HandleHoseWaterWithDelay(this.waterDelayTime));
 49335            this.lastChangeState = 0f;
 49336        }
 2212537        this.lastChangeState += Time.deltaTime;
 2212538    }
 39
 40    bool IsValidChange()
 2212541    {
 2212542        return this.lastChangeState >= this.changeStateInterval;
 2212543    }
 44
 45    void HandleHoseAudio()
 49346    {
 74047        if (this.hoseIsOn) {
 24748            StartCoroutine(this.StartHoseAudio());
 49349        } else {
 24650            this.EndHoseAudio();
 24651        }
 49352    }
 53
 54    IEnumerator StartHoseAudio()
 24755    {
 24756        this.audioSource.clip = this.hoseAudioStart;
 24757        this.audioSource.Play();
 24758        yield return new WaitForSeconds(this.audioSource.clip.length);
 24659        this.audioSource.clip = this.hoseAudioDuring;
 24660        this.audioSource.Play();
 24661    }
 62
 63    void EndHoseAudio()
 24664    {
 24665        StartCoroutine(AudioUtils.FadeOut(this.audioSource, 0.7f));
 24666    }
 67
 68    IEnumerator HandleHoseWaterWithDelay(float delayTime)
 49369    {
 70        //Wait for the specified delay time before continuing.
 49371        yield return new WaitForSeconds(delayTime);
 72
 73        // Turn water on or off
 49374        this.HandleHoseWater();
 49375    }
 76
 77    void HandleHoseWater()
 49478    {
 74179        if (this.hoseIsOn) {
 24780            this.hoseWaterPs.Play();
 49481        } else {
 24782            this.hoseWaterPs.Stop();
 24783        }
 49484    }
 85
 86}