private void CheckAchievementsForCrew(ProtoCrewMember kerbal, bool hasToBeFirst) { if (kerbal == null) { return; } // we want to check crew member only if (!kerbal.IsCrew()) { return; } // ok, lets check this kerbal HallOfFameEntry entry = HallOfFame.Instance().GetEntry(kerbal); if (entry != null) { foreach (Ribbon ribbon in RibbonPool.Instance()) { Achievement achievement = ribbon.GetAchievement(); if (achievement.HasToBeFirst() == hasToBeFirst) { if (achievement.Check(entry)) { recorder.Record(ribbon, kerbal); } } } } else { Log.Warning("no entry for kerbal " + kerbal.name + " in hall of fame"); } }
private void CheckAchievementsForCrew(ProtoCrewMember kerbal) { // just for safety if (kerbal == null) { return; } // we want to check crew member only if (!kerbal.IsCrew()) { return; } // ok, lets check the kerbal Log.Detail("EventObserver:: checkArchivements for kerbal " + kerbal.name); Stopwatch sw = new Stopwatch(); sw.Start(); // // first check all first achievements CheckAchievementsForCrew(kerbal, true); // now check the rest CheckAchievementsForCrew(kerbal, false); // sw.Stop(); Log.Detail("EventObserver:: checkArchivements done in " + sw.ElapsedMilliseconds + " ms"); }
private void OnCrewBoardVessel(GameEvents.FromToAction <Part, Part> action) { Log.Detail("EventObserver:: crew board vessel " + action.from.GetType()); if (action.from == null || action.from.vessel == null) { return; } Part from = action.from; if (action.to == null || action.to.vessel == null) { return; } // boarding crew is still the active vessel Vessel eva = action.from.vessel; Vessel vessel = action.to.vessel; string nameOfKerbalOnEva = eva.vesselName; // find kerbal that return from eva in new crew ProtoCrewMember member = vessel.GetCrewMember(nameOfKerbalOnEva); if (member != null && member.IsCrew()) { Log.Detail(member.name + " returns from EVA to " + vessel.name); recorder.RecordBoarding(member); CheckAchievementsForCrew(member); } else { Log.Warning("boarding crew member " + nameOfKerbalOnEva + " not found in vesssel " + vessel.name); } }
/** * check kerbal type */ private bool CheckKerbalType(ProtoCrewMember kerbal) { if (!kerbal.IsCrew()) { Log.Warning("record for non crew member " + kerbal.name + " ignored"); return(false); } return(true); }
/** * check kerbal type */ private bool CheckKerbalType(ProtoCrewMember kerbal) { if (kerbal == null) { return(false); } if (!kerbal.IsCrew()) { if (Log.IsLogable(Log.LEVEL.DETAIL)) { Log.Detail("record for kerbal " + kerbal.name + " of type " + kerbal.type + " ignored"); } return(false); } return(true); }
private void CheckAchievementsForRosterStatus(ProtoCrewMember kerbal, ProtoCrewMember.RosterStatus oldState, ProtoCrewMember.RosterStatus newState, bool hasToBeFirst) { foreach (Ribbon ribbon in RibbonPool.Instance()) { Achievement achievement = ribbon.GetAchievement(); if (achievement.Check(kerbal, oldState, newState)) { // record crew member only if (kerbal.IsCrew()) { recorder.Record(ribbon, kerbal); } } } }
private void CheckAchievementsForContracts(ProtoCrewMember kerbal, Contract contract, bool hasToBeFirst) { if (kerbal == null) { return; } // we want to check crew member only if (!kerbal.IsCrew()) { return; } // ok, lets check the kerbal foreach (Ribbon ribbon in RibbonPool.Instance()) { Achievement achievement = ribbon.GetAchievement(); if (achievement.HasToBeFirst() == hasToBeFirst) { if (achievement.Check(contract)) { recorder.Record(ribbon, kerbal); } } } }
protected override void OnWindow(int id) { // persistent filter for displaying kerbals if (filter == null || filter.GetScene() != HighLogic.LoadedScene) { filter = FinalFrontier.Config.GetDisplayFilterForSzene(HighLogic.LoadedScene); } // // persistent sorter for displaying kerbals if (sorter == null || sorter.GetScene() != HighLogic.LoadedScene) { // sorter has changed sorter = FinalFrontier.Config.GetHallOfFameSorterForScene(HighLogic.LoadedScene); HallOfFame.Instance().SetSorter(sorter); } // color of info switch (sorter.GetMode()) { case HallOfFameSorter.SortMode.Stat: styleKerbalInfo.normal.textColor = HighLogic.Skin.label.normal.textColor; break; case HallOfFameSorter.SortMode.Skill: styleKerbalInfo.normal.textColor = Color.cyan; break; } // GUILayout.BeginHorizontal(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(490), GUILayout.Height(styleScrollviewHeight)); GUILayout.BeginVertical(); int index = 0; bool expandDetected = false; bool autoexpandEnabled = FinalFrontier.Config.IsAutoExpandEnabled(); lock (HallOfFame.Instance()) { foreach (HallOfFameEntry entry in HallOfFame.Instance()) { // autoexpand this entry on mouse hover? bool expandedEntry = autoexpandEnabled && (expandedRibbonAreaIndex == index) && (entry.GetRibbons().Count > Constants.MAX_RIBBONS_PER_AREA); // ProtoCrewMember kerbal = entry.GetKerbal(); string info = GetInfo(entry); string missionTimeInDays = Utils.GameTimeInDaysAsstring(entry.TotalMissionTime) + (GameUtils.IsKerbinTimeEnabled() ? " kerbin" : ""); if (kerbal != null && filter.Accept(entry) && kerbal.IsCrew()) { string buttonTooltip = kerbal.name + ": " + entry.MissionsFlown + " missions, " + missionTimeInDays + " days mission time"; GUILayout.BeginHorizontal(styleKerbalAreaExpanded); //expandedEntry ? styleKerbalAreaExpanded : styleKerbalArea); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); // butto to open decoration board if (GUILayout.Button(new GUIContent(entry.GetName(), buttonTooltip), styleKerbalButton)) { Log.Detail("opening decoration board for kerbal " + entry.GetName()); display.SetEntry(entry); display.SetVisible(true); } DrawStatus(kerbal); GUILayout.EndHorizontal(); GUILayout.Label(info, styleKerbalInfo); GUILayout.EndVertical(); DrawRibbons(entry, expandedEntry ? Constants.MAX_RIBBONS_PER_EXPANDED_AREA : Constants.MAX_RIBBONS_PER_AREA); GUILayout.EndHorizontal(); // if (Event.current.type == EventType.Repaint) { if (MouseOver(0.0f, scrollPosition.y)) { expandedRibbonAreaIndex = index; expandDetected = true; } } } index++; } // foreach entry } // lock (HAllOfFame) GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.BeginVertical(); if (GUILayout.Button("Close", FFStyles.STYLE_BUTTON)) { SetVisible(false); ribbonBrowser.SetVisible(false); display.SetVisible(false); } GUILayout.Label("", FFStyles.STYLE_STRETCHEDLABEL); if (GUILayout.Button("Ribbons", FFStyles.STYLE_BUTTON)) { if (!ribbonBrowser.IsVisible()) { OpenRibbonBrowser(); } else { ribbonBrowser.SetVisible(false); } } GUILayout.Label("", FFStyles.STYLE_STRETCHEDLABEL); GUILayout.Label("Filter:", FFStyles.STYLE_STRETCHEDLABEL); if (GUILayout.Toggle(filter.showDead, "dead", FFStyles.STYLE_TOGGLE)) { filter.showDead = true; } else { filter.showDead = false; } if (GUILayout.Toggle(filter.showAssigned, "active", FFStyles.STYLE_TOGGLE)) { filter.showAssigned = true; } else { filter.showAssigned = false; } if (GUILayout.Toggle(filter.showAvailable, "available", FFStyles.STYLE_TOGGLE)) { filter.showAvailable = true; } else { filter.showAvailable = false; } if (GUILayout.Toggle(filter.showUndecorated, "undecorated", FFStyles.STYLE_TOGGLE)) { filter.showUndecorated = true; } else { filter.showUndecorated = false; } if (HighLogic.LoadedScene == GameScenes.FLIGHT) { if (GUILayout.Toggle(filter.showFlightOnly, "flight only", FFStyles.STYLE_TOGGLE)) { filter.showFlightOnly = true; } else { filter.showFlightOnly = false; } } GUILayout.Label("", FFStyles.STYLE_STRETCHEDLABEL); // fixed space // sorter GUILayout.FlexibleSpace(); GUILayout.Label("Sort by:", FFStyles.STYLE_STRETCHEDLABEL); DrawSorterButtons(); GUILayout.Label("", FFStyles.STYLE_STRETCHEDLABEL); // fixed space GUILayout.FlexibleSpace(); if (GUILayout.Button("Config", FFStyles.STYLE_BUTTON)) { if (!configWindow.IsVisible()) { MoveWindowAside(configWindow); } configWindow.SetVisible(!configWindow.IsVisible()); } if (GUILayout.Button("About", FFStyles.STYLE_BUTTON)) { about.SetVisible(!about.IsVisible()); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint && !expandDetected) { expandedRibbonAreaIndex = -1; } DragWindow(); }