static bool Prefix(SGBarracksRosterList __instance, List <SGBarracksRosterSlot> inventory)
        {
            if (ModState.SimGameState == null)
            {
                return(true);                               // Only patch if we're in SimGame
            }
            // TODO: Apply a logical sort here
            Mod.Log.Info?.Write($"Sorting {inventory?.Count} pilot slots");

            List <SGBarracksRosterSlot> sortedSlots = new List <SGBarracksRosterSlot>(inventory);

            sortedSlots.Sort(SGBarracksRosterSlotComparisons.CompareByCrewTypeAndValue);

            int index = 0;

            foreach (SGBarracksRosterSlot slot in sortedSlots)
            {
                Mod.Log.Debug?.Write($" -- pilot: {slot.Pilot.Name} has index: {index}");
                slot.gameObject.transform.SetSiblingIndex(index);
                index++;
            }

            __instance.ForceRefreshImmediate();

            return(false);
        }
Exemple #2
0
            public static void Postfix(SGBarracksRosterList __instance, Dictionary <string, SGBarracksRosterSlot> ___currentRoster)
            {
                foreach (var pilot in ___currentRoster.Values)
                {
                    var timeoutIcon = pilot.GetComponentsInChildren <RectTransform>(true)
                                      .FirstOrDefault(x => x.name == "mw_TimeOutIcon");
                    if (timeoutIcon == null)
                    {
                        return;
                    }

                    if (!AdjustedIcons.Contains(timeoutIcon))
                    {
                        if (pilot.Pilot.pilotDef.PilotTags.Contains("pilot_fatigued"))
                        {
                            AdjustedIcons.Add(timeoutIcon);
                            // mw_TimeOutIcon (SVGImporter.SVGImage)
                            timeoutIcon.sizeDelta        /= SizeDeltaFactor;
                            timeoutIcon.anchoredPosition += AnchoredPositionOffset;
                        }
                    }
                    else
                    {
                        if (!pilot.Pilot.pilotDef.PilotTags.Contains("pilot_fatigued"))
                        {
                            AdjustedIcons.Remove(timeoutIcon);
                            timeoutIcon.sizeDelta        *= SizeDeltaFactor;
                            timeoutIcon.anchoredPosition -= AnchoredPositionOffset;
                        }
                    }
                }

                __instance.ForceRefreshImmediate();
            }