< 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:7
Uncovered lines:4
Coverable lines:11
Total lines:41
Line coverage:63.6% (7 of 11)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
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;
 65846113    public DCLAction_Trigger DCLAction => dclAction;
 14
 15    [SerializeField] internal BooleanVariable blockTrigger;
 89790116    public BooleanVariable isTriggerBlocked { get => blockTrigger; set => blockTrigger = value; }
 17
 8518    private int triggeredInFrame = -1;
 19
 20    public bool WasTriggeredThisFrame() =>
 321        triggeredInFrame == Time.frameCount;
 22
 23    public void RaiseOnTriggered()
 24    {
 525        triggeredInFrame = Time.frameCount;
 526        OnTriggered?.Invoke(dclAction);
 327    }
 28
 29#if UNITY_EDITOR
 30    [UnityEditor.CustomEditor(typeof(InputAction_Trigger), true)]
 31    internal class InputAction_TriggerEditor : UnityEditor.Editor
 32    {
 33        public override void OnInspectorGUI()
 34        {
 035            DrawDefaultInspector();
 036            if (Application.isPlaying && GUILayout.Button("Raise OnChange"))
 037                ((InputAction_Trigger)target).RaiseOnTriggered();
 038        }
 39    }
 40#endif
 41}