public static double getIntervalRecord(ProgressNode n, ref string descr) { Type t = n.GetType(); if (t == typeof(RecordsAltitude)) { descr = progressParser.altitudeTitle; return(((RecordsAltitude)n).record); } else if (t == typeof(RecordsDepth)) { descr = progressParser.depthTitle; return(((RecordsDepth)n).record); } else if (t == typeof(RecordsDistance)) { descr = progressParser.distanceTitle; return(((RecordsDistance)n).record); } else if (t == typeof(RecordsSpeed)) { descr = progressParser.speedTitle; return(((RecordsSpeed)n).record); } descr = ""; return(0); }
public progressStandard(CelestialBody b, ProgressType t, ProgressNode n, string s = "", string g = "", string r = "", bool rewards = true) { if (b != null) body = b; pType = t; hasRewards = rewards; id = n.Id; descriptor = s; note = g; noteReference = r; if (t == ProgressType.POINTOFINTEREST) bodyName = ((PointOfInterest)n).body; try { time = (double)n.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } if (n.IsComplete) calculateRewards(b); }
public static CrewRef crewFromNode(ProgressNode n) { Type t = n.GetType(); try { //if (t == typeof(FlagPlant)) // return (CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); if (t == typeof(Spacewalk)) { return((CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n)); } else if (t == typeof(SurfaceEVA)) { return((CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n)); } else if (t == typeof(CrewRecovery)) { return((CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node [" + t.Name + "] Crew Reference\n" + e); } return(null); }
public static VesselRef vesselFromNode(ProgressNode n) { Type t = n.GetType(); try { if (t == typeof(BaseConstruction)) { return((VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n)); } else if (t == typeof(CelestialBodyFlight)) { return(((CelestialBodyFlight)n).firstVessel); } else if (t == typeof(CelestialBodyLanding)) { return((VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n)); } else if (t == typeof(CelestialBodyOrbit)) { return(((CelestialBodyOrbit)n).firstVessel); } else if (t == typeof(CelestialBodySuborbit)) { return(((CelestialBodySuborbit)n).firstVessel); } else if (t == typeof(CelestialBodyReturn)) { return(((CelestialBodyReturn)n).firstVessel); } else if (t == typeof(CelestialBodyScience)) { return((VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n)); } else if (t == typeof(StationConstruction)) { return((VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n)); } else if (t == typeof(ReachSpace)) { return(((ReachSpace)n).firstVessel); } else if (t == typeof(PointOfInterest)) { return((VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[5].GetValue(n)); } else if (t == typeof(TowerBuzz)) { return((VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[3].GetValue(n)); } } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node [" + t.Name + "] Vessel Reference\n" + e); } return(null); }
public static bool isPOI(ProgressNode n) { if (n.GetType() == typeof(PointOfInterest)) { return(true); } return(false); }
private void OnProgressComplete(ProgressNode node) { // Reflection hack time. There is a member that is (sometimes) private that stores the celestial body. // Other times it's public, but this will catch that too. FieldInfo cbField = node.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance). Where(fi => fi.FieldType == typeof(CelestialBody)).FirstOrDefault(); if (cbField != null) { lastBody = (CelestialBody)cbField.GetValue(node); } else { lastBody = null; } }
public progressStandard(CelestialBody b, ProgressType t, ProgressNode n, string s = "", string g = "", string r = "", bool rewards = true) { if (b != null) { body = b; } pType = t; hasRewards = rewards; id = n.Id; descriptor = s; note = g; noteReference = r; if (t == ProgressType.POINTOFINTEREST) { string bodyN = ((PointOfInterest)n).body; for (int i = FlightGlobals.Bodies.Count - 1; i >= 0; i--) { CelestialBody bod = FlightGlobals.Bodies[i]; if (bod.bodyName != bodyN) { continue; } bodyName = bod.displayName.LocalizeBodyName(); break; } } try { time = (double)n.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } if (n.IsComplete) { calculateRewards(b); } }
public static void LogAchievement(Achievement achievement, ProgressNode node) { Debug.Log("FF: ribbon achievement (progress node)"); LogAchievement(achievement); if (node != null) { Debug.Log(" - Type: " + node.GetType()); Debug.Log(" - IsComplete: " + node.IsComplete); Debug.Log(" - IsReached: " + node.IsReached); Debug.Log(" - IsCompleteManned: " + node.IsCompleteManned); Debug.Log(" - IsCompleteUnmanned: " + node.IsCompleteUnmanned); } else { Debug.Log(" - node is <null>"); } Debug.Log("+ - end -"); }
public static bool isIntervalType(ProgressNode n) { Type t = n.GetType(); if (t == typeof(RecordsAltitude)) { return(true); } else if (t == typeof(RecordsDepth)) { return(true); } else if (t == typeof(RecordsDistance)) { return(true); } else if (t == typeof(RecordsSpeed)) { return(true); } return(false); }
private CelestialBody getBodyFromType(ProgressNode n) { Type t = n.GetType(); try { if (t == typeof(BaseConstruction)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyEscape)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyFlight)) return ((CelestialBodyFlight)n).body; else if (t == typeof(CelestialBodyFlyby)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyLanding)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyOrbit)) return ((CelestialBodyOrbit)n).body; else if (t == typeof(CelestialBodySuborbit)) return ((CelestialBodySuborbit)n).body; else if (t == typeof(CelestialBodyReturn)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyScience)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodySplashdown)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(CelestialBodyTransfer)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(Docking)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(FlagPlant)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(Rendezvous)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(Spacewalk)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(StationConstruction)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(SurfaceEVA)) return (CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node Celestial Body Reference\n" + e); } return null; }
private void onComplete(ProgressNode node) { if (node == null) return; if (!node.IsComplete) return; if (!isIntervalType(node)) { if (isPOI(node)) { progressStandard s = progressParser.getPOINode(node.Id); if (s == null) { Debug.Log("[Progress Tracking Parser] POI Progress Node Not Found"); } else { s.calculateRewards(null); s.NoteReference = progressParser.vesselNameFromNode(node); try { s.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } } else { progressStandard s = progressParser.getStandardNode(node.Id); if (s != null) { s.calculateRewards(null); string note = progressParser.crewNameFromNode(node); if (string.IsNullOrEmpty(note)) note = progressParser.vesselNameFromNode(node); s.NoteReference = note; try { s.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } else { CelestialBody body = getBodyFromType(node); if (body == null) { Debug.Log("[Progress Tracking Parser] Body From Progress Node Null..."); } else { progressBodyCollection b = progressParser.getProgressBody(body); if (b != null) { progressStandard sb = b.getNode(node.Id); if (sb == null) { Debug.Log("[Progress Tracking Parser] Body Sub Progress Node Not Found"); } else { sb.calculateRewards(body); string note = progressParser.crewNameFromNode(node); if (string.IsNullOrEmpty(note)) note = progressParser.vesselNameFromNode(node); sb.NoteReference = note; try { sb.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } } } } } } else { progressInterval i = progressParser.getIntervalNode(node.Id); if (i == null) { Debug.Log("[Progress Tracking Parser] Interval Progress Node Not Found"); } else { if (node.IsReached) { i.calculateRewards(i.Interval); i.Interval += 1; } } } progressParser.updateCompletionRecord(); }
private double getIntervalRecord(ProgressNode n) { Type t = n.GetType(); if (t == typeof(RecordsAltitude)) return ((RecordsAltitude)n).record; else if (t == typeof(RecordsDepth)) return ((RecordsDepth)n).record; else if (t == typeof(RecordsDistance)) return ((RecordsDistance)n).record; else if (t == typeof(RecordsSpeed)) return ((RecordsSpeed)n).record; return 0; }
public static CrewRef crewFromNode(ProgressNode n) { Type t = n.GetType(); try { //if (t == typeof(FlagPlant)) // return (CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); if (t == typeof(Spacewalk)) return (CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(SurfaceEVA)) return (CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(CrewRecovery)) return (CrewRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node Crew Reference\n" + e); } return null; }
public static VesselRef vesselFromNode(ProgressNode n) { Type t = n.GetType(); try { if (t == typeof(BaseConstruction)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(CelestialBodyFlight)) return ((CelestialBodyFlight)n).firstVessel; else if (t == typeof(CelestialBodyLanding)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(CelestialBodyOrbit)) return ((CelestialBodyOrbit)n).firstVessel; else if (t == typeof(CelestialBodySuborbit)) return ((CelestialBodySuborbit)n).firstVessel; else if (t == typeof(CelestialBodyReturn)) return ((CelestialBodyReturn)n).firstVessel; else if (t == typeof(CelestialBodyScience)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(StationConstruction)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[1].GetValue(n); else if (t == typeof(ReachSpace)) return ((ReachSpace)n).firstVessel; else if (t == typeof(PointOfInterest)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n); else if (t == typeof(TowerBuzz)) return (VesselRef)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[3].GetValue(n); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node [" + t.Name + "] Vessel Reference\n" + e); } return null; }
public static CelestialBody getBodyFromType(ProgressNode n) { Type t = n.GetType(); try { if (t == typeof(BaseConstruction)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyEscape)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyFlight)) { return(((CelestialBodyFlight)n).body); } else if (t == typeof(CelestialBodyFlyby)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyLanding)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyOrbit)) { return(((CelestialBodyOrbit)n).body); } else if (t == typeof(CelestialBodySuborbit)) { return(((CelestialBodySuborbit)n).body); } else if (t == typeof(CelestialBodyReturn)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyScience)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodySplashdown)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(CelestialBodyTransfer)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(Docking)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(FlagPlant)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(Rendezvous)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(Spacewalk)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(StationConstruction)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } else if (t == typeof(SurfaceEVA)) { return((CelestialBody)t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(n)); } } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Finding Progress Node [" + t.Name + "] Celestial Body Reference\n" + e); } return(null); }
private bool isIntervalType(ProgressNode n) { Type t = n.GetType(); if (t == typeof(RecordsAltitude)) return true; else if (t == typeof(RecordsDepth)) return true; else if (t == typeof(RecordsDistance)) return true; else if (t == typeof(RecordsSpeed)) return true; return false; }
private void onComplete(ProgressNode node) { if (node == null) { return; } if (!node.IsComplete) { return; } if (!progressParser.isIntervalType(node)) { if (progressParser.isPOI(node)) { progressStandard s = progressParser.getPOINode(node.Id); if (s == null) { Debug.Log("[Progress Tracking Parser] POI Progress Node Not Found"); } else { s.calculateRewards(null); s.NoteReference = progressParser.vesselNameFromNode(node); try { s.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } } else { progressStandard s = progressParser.getStandardNode(node.Id); if (s != null) { s.calculateRewards(null); string note = progressParser.crewNameFromNode(node); if (string.IsNullOrEmpty(note)) { note = progressParser.vesselNameFromNode(node); } s.NoteReference = note; try { s.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } else { CelestialBody body = progressParser.getBodyFromType(node); if (body == null) { Debug.Log("[Progress Tracking Parser] Body From Progress Node Null..."); } else { progressBodyCollection b = progressParser.getProgressBody(body); if (b != null) { progressStandard sb = b.getNode(node.Id); if (sb == null) { Debug.Log("[Progress Tracking Parser] Body Sub Progress Node Not Found"); } else { sb.calculateRewards(body); string note = progressParser.crewNameFromNode(node); if (string.IsNullOrEmpty(note)) { note = progressParser.vesselNameFromNode(node); } sb.NoteReference = note; try { sb.Time = (double)node.GetType().GetField("AchieveDate", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(node); } catch (Exception e) { Debug.LogWarning("[Progress Tracking Parser] Error In Detecting Progress Node Achievement Date\n" + e); } } } } } } } else { progressInterval i = progressParser.getIntervalNode(node.Id); if (i == null) { Debug.Log("[Progress Tracking Parser] Interval Progress Node Not Found"); } else { if (node.IsReached) { i.calculateRewards(i.Interval); i.Interval += 1; } } } progressParser.updateCompletionRecord(); }
private bool isPOI(ProgressNode n) { if (n.GetType() == typeof(PointOfInterest)) return true; return false; }