KerbalAlarmClock icon indicating copy to clipboard operation
KerbalAlarmClock copied to clipboard

KACWrapper: Exception for getRemaining in the VAB

Open yalov opened this issue 7 years ago • 0 comments

I believe this cast to double in the KACWrapper

public Double Remaining { get { return (Double)RemainingField.GetValue(actualAlarm); } }

throw

[EXC 01:04:08.717] InvalidCastException: Cannot cast from source type to destination type.
	SKA_KACWrapper.KACWrapper+KACAPI+KACAlarm.get_Remaining ()
	SKA.SKA.IsAlarmFinished (System.String id)
	SKA.SKA+<>c.<.ctor>b__13_0 ()
	UnityEngine.Events.InvokableCall.Invoke ()
	UnityEngine.Events.UnityEvent.Invoke ()
	UnityEngine.UI.Button.Press ()
	UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData)
	UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData)
	UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor)
	UnityEngine.EventSystems.EventSystem:Update()

in the VAB.

my code:

private static bool IsAlarmFinished(string id)
{
    if (KACWrapper.APIReady)
    {
        foreach (var alarm in KACWrapper.KAC.Alarms)
        {
            if (alarm.ID == id)
            {
                Log("L1");
                if (alarm.Remaining < 0.0)
                {
                    Log("L2a");
                    return true;
                }
                else
                {
                    Log("L2b");
                    return false;
                }
                //...

L1 is showed up, but either L2 aren't

yalov avatar Jan 19 '19 23:01 yalov