< Summary

Class:HoseController
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/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)

D:/--UnityProject/VR/_____ISSTA 26/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()
 1178928    {
 1178929        if (this.IsValidChange() && !this.hoseHandle.getIsTurning() && ActionMapper.GetDevicesTrigger())
 38330        {
 38331            this.hoseIsOn = !this.hoseIsOn;
 38332            this.hoseHandle.ActivateHandleMovement(this.hoseIsOn);
 38333            this.HandleHoseAudio();
 38334            StartCoroutine(this.HandleHoseWaterWithDelay(this.waterDelayTime));
 38335            this.lastChangeState = 0f;
 38336        }
 1178937        this.lastChangeState += Time.deltaTime;
 1178938    }
 39
 40    bool IsValidChange()
 1178941    {
 1178942        return this.lastChangeState >= this.changeStateInterval;
 1178943    }
 44
 45    void HandleHoseAudio()
 38346    {
 57547        if (this.hoseIsOn) {
 19248            StartCoroutine(this.StartHoseAudio());
 38349        } else {
 19150            this.EndHoseAudio();
 19151        }
 38352    }
 53
 54    IEnumerator StartHoseAudio()
 19255    {
 19256        this.audioSource.clip = this.hoseAudioStart;
 19257        this.audioSource.Play();
 19258        yield return new WaitForSeconds(this.audioSource.clip.length);
 19159        this.audioSource.clip = this.hoseAudioDuring;
 19160        this.audioSource.Play();
 19161    }
 62
 63    void EndHoseAudio()
 19164    {
 19165        StartCoroutine(AudioUtils.FadeOut(this.audioSource, 0.7f));
 19166    }
 67
 68    IEnumerator HandleHoseWaterWithDelay(float delayTime)
 38369    {
 70        //Wait for the specified delay time before continuing.
 38371        yield return new WaitForSeconds(delayTime);
 72
 73        // Turn water on or off
 38374        this.HandleHoseWater();
 38375    }
 76
 77    void HandleHoseWater()
 38478    {
 57679        if (this.hoseIsOn) {
 19280            this.hoseWaterPs.Play();
 38481        } else {
 19282            this.hoseWaterPs.Stop();
 19283        }
 38484    }
 85
 86}