< Summary

Class:LaunchProjectile
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Room/Assets/_Course Library/Scripts/Test/LaunchProjectile.cs
Covered lines:12
Uncovered lines:2
Coverable lines:14
Total lines:63
Line coverage:85.7% (12 of 14)
Covered branches:0
Total branches:0
Covered methods:3
Total methods:4
Method coverage:75% (3 of 4)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LaunchProjectile()0%000100%
Fire()0%000100%
ApplyForce(...)0%000100%
OnReleased()0%0000%

File(s)

E:/Unity/Unity Project/VR-Room/Assets/_Course Library/Scripts/Test/LaunchProjectile.cs

#LineLine coverage
 1using BNG;
 2using System.Diagnostics.CodeAnalysis;
 3using UnityEngine;
 4using HenryLab;
 5
 6/// <summary>
 7/// Apply forward force to instantiated prefab
 8/// </summary>
 9public class LaunchProjectile : MonoBehaviour, ITriggerableEntity, IGrabbableEntity
 10{
 11    [ExcludeFromCodeCoverage] public float TriggeringTime => 1.5f;
 12    [ExcludeFromCodeCoverage] public string Name => Str.Gun;
 13    [ExcludeFromCodeCoverage] public Transform Destination => null;
 14
 15    [ExcludeFromCodeCoverage]
 16    public Grabbable Grabbable
 17    {
 18        get
 19        {
 20            var g = GetComponent<Grabbable>();
 21            if(g) return g;
 22            return gameObject.AddComponent<Grabbable>();
 23        }
 24    }
 25
 26    [ExcludeFromCodeCoverage] public void Triggerring() { }
 27
 28    [ExcludeFromCodeCoverage]
 29    public void Triggerred()
 30    {
 31        Fire();
 32    }
 33
 34    [ExcludeFromCodeCoverage] public void OnGrabbed() { }
 35
 36    [Tooltip("The projectile that's created")]
 237    public GameObject projectilePrefab = null;
 38
 39    [Tooltip("The point that the project is created")]
 240    public Transform startPoint = null;
 41
 42    [Tooltip("The speed at which the projectile is launched")]
 243    public float launchSpeed = 1.0f;
 44
 45    public void Fire()
 646    {
 647        GameObject newObject = Instantiate(projectilePrefab, startPoint.position, startPoint.rotation);
 48
 649        if(newObject.TryGetComponent(out Rigidbody rigidBody))
 650            ApplyForce(rigidBody);
 651    }
 52
 53    private void ApplyForce(Rigidbody rigidBody)
 654    {
 655        Vector3 force = startPoint.forward * launchSpeed;
 656        rigidBody.AddForce(force);
 657    }
 58
 59    public void OnReleased()
 060    {
 061        throw new System.NotImplementedException();
 62    }
 63}