< Summary

Class:InputAction_Trigger
Assembly:InputController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/InputController/InputAction_Trigger.cs
Covered lines:5
Uncovered lines:6
Coverable lines:11
Total lines:48
Line coverage:45.4% (5 of 11)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetDCLAction()0%2100%
InputAction_Trigger()0%110100%
WasTriggeredThisFrame()0%110100%
RaiseOnTriggered()0%220100%
OnInspectorGUI()0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/InputController/InputAction_Trigger.cs

#LineLine coverage
 1using UnityEngine;
 2
 3/// <summary>
 4/// An instantaneous action which dispatches an event as soon as the input is read
 5/// </summary>
 6[CreateAssetMenu(fileName = "InputAction_Trigger", menuName = "InputActions/Trigger")]
 7public class InputAction_Trigger : ScriptableObject
 8{
 9    public delegate void Triggered(DCLAction_Trigger action);
 10    public event Triggered OnTriggered;
 11
 12    [SerializeField] internal DCLAction_Trigger dclAction;
 013    public DCLAction_Trigger GetDCLAction() => dclAction;
 14
 15    [SerializeField] internal BooleanVariable blockTrigger;
 016    public BooleanVariable isTriggerBlocked { get => blockTrigger; set => blockTrigger = value; }
 17
 6018    private int triggeredInFrame = -1;
 19
 320    public bool WasTriggeredThisFrame() { return triggeredInFrame == Time.frameCount; }
 21
 22    public void RaiseOnTriggered()
 23    {
 524        triggeredInFrame = Time.frameCount;
 525        OnTriggered?.Invoke(dclAction);
 326    }
 27
 28    #region Editor
 29
 30#if UNITY_EDITOR
 31
 32    [UnityEditor.CustomEditor(typeof(InputAction_Trigger), true)]
 33    internal class InputAction_TriggerEditor : UnityEditor.Editor
 34    {
 35        public override void OnInspectorGUI()
 36        {
 037            DrawDefaultInspector();
 038            if (Application.isPlaying && GUILayout.Button("Raise OnChange"))
 39            {
 040                ((InputAction_Trigger)target).RaiseOnTriggered();
 41            }
 042        }
 43    }
 44#endif
 45
 46    #endregion
 47
 48}