예제 #1
0
        private static readonly ChassisLocations[] Locations = MechDefSlots.Locations;       // order of locations to fill up first
        #endregion

        internal void RefreshData(MechLabPanel mechLab)
        {
            var fillerImageCache = MechLabLocationWidgetSetDataPatch.FillerImageCache;

            if (fillerImageCache.Count < Locations.Length)
            {
                return;
            }

            var slots = new MechDefSlots(mechLab.activeMechDef);

            using (var reservedSlots = slots.GetReservedSlots().GetEnumerator())
            {
                foreach (var location in Locations)
                {
                    var fillerImages = fillerImageCache[location];
                    var widget       = mechLab.GetLocationWidget((ArmorLocation)location); // by chance armorlocation = chassislocation for main locations
                    var adapter      = new MechLabLocationWidgetAdapter(widget);
                    var used         = adapter.usedSlots;
                    for (var i = 0; i < adapter.maxSlots; i++)
                    {
                        var fillerImage = fillerImages[i];
                        if (i >= used && reservedSlots.MoveNext())
                        {
                            var reservedSlot = reservedSlots.Current;
                            if (reservedSlot == null)
                            {
                                throw new NullReferenceException();
                            }
                            fillerImage.gameObject.SetActive(true);
                            var uicolor = reservedSlot.ReservedSlotColor;
                            var color   = LazySingletonBehavior <UIManager> .Instance.UIColorRefs.GetUIColor(uicolor);

                            fillerImage.color = slots.IsOverloaded ? DynamicSlotsSpaceMissingColor : color;
                        }
                        else
                        {
                            fillerImage.gameObject.SetActive(false);
                        }
                    }
                }
            }
        }
        private static readonly ChassisLocations[] Locations = MechDefSlots.Locations;       // order of locations to fill up first
        #endregion

        internal void RefreshData(MechLabPanel mechLab)
        {
            if (MechLabLocationWidget_SetData_Patch.Fillers.Count < Locations.Length)
            {
                return;
            }

            var slots = new MechDefSlots(mechLab.activeMechDef);

            using (var reservedSlots = slots.GetReservedSlots().GetEnumerator())
            {
                foreach (var location in Locations)
                {
                    var fillers = MechLabLocationWidget_SetData_Patch.Fillers[location];
                    var widget  = mechLab.GetLocationWidget((ArmorLocation)location); // by chance armorlocation = chassislocation for main locations
                    var adapter = new MechLabLocationWidgetAdapter(widget);
                    var used    = adapter.usedSlots;
                    for (var i = 0; i < adapter.maxSlots; i++)
                    {
                        var filler = fillers[i];
                        if (i >= used && reservedSlots.MoveNext())
                        {
                            var reservedSlot = reservedSlots.Current;
                            if (reservedSlot == null)
                            {
                                throw new NullReferenceException();
                            }
                            filler.Show(reservedSlot);
                        }
                        else
                        {
                            filler.Hide();
                        }
                    }
                }
            }
        }