//public AlarmChangedEventArgs(ARPResource sender, ARPResource.AlarmType alarmType, Boolean TurnedOn, Boolean Acknowledged) public AlarmStateChangedEventArgs(System.Object actualEvent, KSPARPAPI arp) { Type type = actualEvent.GetType(); this.resource = new ARPResource(type.GetField("sender").GetValue(actualEvent)); this.oldValue = (ARPResource.AlarmStateEnum)type.GetField("oldValue").GetValue(actualEvent);; this.newValue = (ARPResource.AlarmStateEnum)type.GetField("newValue").GetValue(actualEvent);; this.MonitorState = (ARPResource.MonitorStateEnum)type.GetField("MonitorState").GetValue(actualEvent);; }
/// <summary> /// This method will set up the KSPARP object and wrap all the methods/functions /// </summary> /// <param name="Force">This option will force the Init function to rebind everything</param> /// <returns></returns> public static Boolean InitKSPARPWrapper() { //if (!_KSPARPWrapped ) //{ //reset the internal objects _KSPARPWrapped = false; actualARP = null; KSPARP = null; LogFormatted("Attempting to Grab KSPARP Types..."); //find the base type KSPARPType = AssemblyLoader.loadedAssemblies .Select(a => a.assembly.GetExportedTypes()) .SelectMany(t => t) .FirstOrDefault(t => t.FullName == "KSPAlternateResourcePanel.KSPAlternateResourcePanel"); if (KSPARPType == null) { return(false); } //now the resource Type KSPARPResourceType = AssemblyLoader.loadedAssemblies .Select(a => a.assembly.GetExportedTypes()) .SelectMany(t => t) .FirstOrDefault(t => t.FullName == "KSPAlternateResourcePanel.ARPResource"); if (KSPARPResourceType == null) { return(false); } //now grab the running instance LogFormatted("Got Assembly Types, grabbing Instance"); actualARP = KSPARPType.GetField("APIInstance", BindingFlags.Public | BindingFlags.Static).GetValue(null); if (actualARP == null) { LogFormatted("Failed grabbing Instance"); return(false); } //If we get this far we can set up the local object and its methods/functions LogFormatted("Got Instance, Creating Wrapper Objects"); KSPARP = new KSPARPAPI(actualARP); //} _KSPARPWrapped = true; return(true); }