< Summary

Class:WaterCollision
Assembly:Test
File(s):D:/--UnityProject/VR/_____ISSTA 26/vr-firefighter-simulator/Assets/Test/WaterCollision.cs
Covered lines:21
Uncovered lines:3
Coverable lines:24
Total lines:47
Line coverage:87.5% (21 of 24)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:3
Method coverage:100% (3 of 3)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%000100%
OnParticleCollision(...)0%00076.92%
HandleSplash(...)0%000100%

File(s)

D:/--UnityProject/VR/_____ISSTA 26/vr-firefighter-simulator/Assets/Test/WaterCollision.cs

#LineLine coverage
 1using UnityEngine;
 2using System.Collections.Generic;
 3
 4public class WaterCollision : MonoBehaviour
 5{
 6    public ParticleSystem splashPrefab;
 7    private ParticleSystem splash;
 8    private ParticleSystem pSystem;
 9    private List<ParticleCollisionEvent> collisionEvents;
 10    private ParticleCollisionEvent collisionEvent;
 11
 12    void Awake()
 113    {
 14        // Create instance of splash
 115        this.splash = GameObject.Instantiate(this.splashPrefab);
 116        this.splash.Stop();
 17        // Get particle system and initialize list for later
 118        this.pSystem = this.GetComponent<ParticleSystem>();
 119        this.collisionEvents = new List<ParticleCollisionEvent>();
 120    }
 21
 22    void OnParticleCollision(GameObject other)
 317823    {
 24        // Get collision events
 317825        int numCollisionEvents = this.pSystem.GetCollisionEvents(other, this.collisionEvents);
 26        // Get component for water interaction
 317827        IWaterInteractable go = other.gameObject.GetComponent<IWaterInteractable>();
 28        // If the component allows for interaction and there are collisions, send the event
 317829        if (numCollisionEvents > 0)
 317830        {
 317831            this.collisionEvent = this.collisionEvents[0];
 32            // Only send water hit if there's a gameobject
 317833            if (go != null)
 034            {
 035                go.WaterHit(collisionEvent.normal);
 036            }
 317837            this.HandleSplash(collisionEvent.intersection, collisionEvent.normal);
 317838        }
 317839    }
 40
 41    void HandleSplash(Vector3 position, Vector3 normal)
 317842    {
 317843        this.splash.gameObject.transform.position = position;
 317844        this.splash.gameObject.transform.up = normal;
 317845        this.splash.Play();
 317846    }
 47}