internal void RefreshData(MechLabPanel mechLab) { var builder = new MechDefBuilder(mechLab.activeMechDef); var fslList = new List <DynamicSlotBuilder>(); foreach (var location in MechDefBuilder.Locations) { // armorlocation = chassislocation for main locations var widget = mechLab.GetLocationWidget((ArmorLocation)location); ClearFillers(widget); var adapter = new MechLabLocationWidgetAdapter(widget); fslList.Add(new DynamicSlotBuilder(builder, location, adapter)); } //for (var reservedSlots = builder.Reserved; reservedSlots > 0; reservedSlots--) foreach (var reservedSlot in builder.GetReservedSlots()) { var fsl = fslList.Max(); if (fsl.currentFreeSlots <= 0) { // no more free slots to use up! break; } ShowFiller(fsl.adapter.instance, reservedSlot, fsl.currentFreeSlotIndex, fsl.currentFreeSlotFixed); fsl.currentFreeSlots--; } }
internal void RefreshData(MechLabPanel mechLab) { if (MechLabLocationWidget_SetData_Patch.Fillers.Count < MechDefBuilder.Locations.Length) { return; } var slots = new MechDefBuilder(mechLab.activeMechDef); using (var reservedSlots = slots.GetReservedSlots().GetEnumerator()) { foreach (var location in MechDefBuilder.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; var start = location == ChassisLocations.CenterTorso ? Control.settings.MechLabGeneralSlots : 0; for (var i = start; i < adapter.maxSlots; i++) { var fillerIndex = location == ChassisLocations.CenterTorso ? i - Control.settings.MechLabGeneralSlots : i; var filler = fillers[fillerIndex]; if (i >= used && reservedSlots.MoveNext()) { var reservedSlot = reservedSlots.Current; if (reservedSlot == null) { throw new NullReferenceException(); } filler.Show(reservedSlot); } else { filler.Hide(); } } } } }