forked from EVEIPH/EVE-IPH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShoppingList.vb
1680 lines (1348 loc) · 75.8 KB
/
ShoppingList.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Imports System.Data.SQLite
Public Class ShoppingList
Implements ICloneable
' Master Lists of materials to display. These are single lists that are updated when deleting quantity or full items
Private TotalItemList As List(Of ShoppingListItem) ' This is the total list of items, with orginal values - not updated
Private TotalBuyList As Materials ' Buy mats
Private TotalBuildList As BuiltItemList ' Build mats (components)
Private TotalInventionMats As Materials ' All Invention/RE materials used
Private TotalCopyMats As Materials ' All the copy materials needed to make copies to invent
' Use onhandlist of materials so we can keep track of user entries (of calculations they make based on mats on hand)
Public OnHandMatList As New Materials
Public OnHandComponentList As New Materials
' Price data
Private AdditionalCosts As Double ' For any additional costs added on the shopping list form
Private MaterialsBrokerFee As Double ' For the total broker fee for buying the materials in the list
Private TotalListUsage As Double ' Total of all usage values for the items in the list
Private TotalListMarketPrice As Double ' Total market price of everything in the list
Private TotalListCost As Double ' Total cost of everything in the list mats (with invention/copy costs) + usage + taxes + fees
Private TotalListBuildTime As Double ' Total time to build the items in the list in seconds
Private TotalListInventionCost As Double ' Total of all the invention materials in the list
Private TotalListCopyCost As Double ' Total of all the copy materials in the list
Protected ItemToFind As ShoppingListItem
Protected ProfitItemtoFind As String
Public Sub New()
Call Clear()
End Sub
Public Sub Clear()
TotalItemList = New List(Of ShoppingListItem)
TotalBuildList = New BuiltItemList
TotalBuyList = New Materials
TotalInventionMats = New Materials
TotalCopyMats = New Materials
AdditionalCosts = 0
MaterialsBrokerFee = 0
TotalListUsage = 0
TotalListMarketPrice = 0
TotalListCost = 0
ItemToFind = Nothing
' Reset onhand mats lists
OnHandMatList = New Materials
OnHandComponentList = New Materials
End Sub
#Region "Update Shopping List Functions"
' Removes or updates the item quantity and all mats associated with that item from the full list - i.e. Anshar
Public Sub UpdateShoppingItemQuantity(ByVal SentItem As ShoppingListItem, ByVal UpdateItemQuantity As Long)
Dim FoundItem As ShoppingListItem
Dim FoundBuildItem As BuiltItem
Dim TempBuiltItem As New BuiltItem
Dim UpdatedQuantity As Long
' First, see if there are any other items in the list, if this is the only one and the quantity is 0 then just clear all lists and leave
If UpdateItemQuantity <= 0 And TotalItemList.Count = 1 And TotalItemList(0).Name = SentItem.Name Then
Call Clear()
Exit Sub
End If
' Look for the item
ItemToFind = SentItem
FoundItem = TotalItemList.Find(AddressOf FindItem)
' Remove or update quantity for materials, built items, RE and invention mats
' Check the component list of the BP first, if we are building it, then update the number for built items, else we are buying it and update that
If FoundItem IsNot Nothing Then
' Look at built items first, then check materials only
If Not IsNothing(FoundItem.BPBuiltItems) Then
With FoundItem.BPBuiltItems
For i = 0 To .GetBuiltItemList.Count - 1
' Make sure the item exists (might have been deleted already in the main list) before updating
' Find the built item in the build list for this item
TempBuiltItem.ItemTypeID = .GetBuiltItemList(i).ItemTypeID
TempBuiltItem.BuildME = CInt(.GetBuiltItemList(i).BuildME)
TempBuiltItem.FacilityLocation = .GetBuiltItemList(i).FacilityLocation
Call TotalBuildList.SetItemToFind(TempBuiltItem)
FoundBuildItem = TotalBuildList.GetBuiltItemList.Find(AddressOf TotalBuildList.FindBuiltItem)
If FoundBuildItem IsNot Nothing Then
' Copy current built item info
With FoundBuildItem
TempBuiltItem = New BuiltItem
TempBuiltItem.BPTypeID = .BPTypeID
TempBuiltItem.ItemTypeID = .ItemTypeID
TempBuiltItem.ItemName = .ItemName
TempBuiltItem.ItemQuantity = .ItemQuantity
TempBuiltItem.ItemVolume = .ItemVolume
TempBuiltItem.FacilityMEModifier = .FacilityMEModifier
TempBuiltItem.FacilityLocation = .FacilityLocation
TempBuiltItem.FacilityType = .FacilityType
TempBuiltItem.IncludeActivityCost = .IncludeActivityCost
TempBuiltItem.IncludeActivityTime = .IncludeActivityTime
TempBuiltItem.IncludeActivityUsage = .IncludeActivityUsage
TempBuiltItem.BuildME = .BuildME
TempBuiltItem.BuildTE = .BuildTE
' If we are building a component, then we are buying all the mats for it so only use the buy list for mats to update
TempBuiltItem.BuildMaterials.InsertMaterialList(.BuildMaterials.GetMaterialList)
' use group name as facility location
Dim TempMat As New Material(.ItemTypeID, .ItemName, .FacilityLocation, .ItemQuantity, .ItemVolume, 0, CStr(.BuildME), CStr(.BuildTE), True)
UpdatedQuantity = GetUpdatedQuantity("Build", FoundItem, UpdateItemQuantity, TempMat)
End With
' Need to update to the quantity sent in the Build List
Call UpdateShoppingBuiltItemQuantity(TempBuiltItem, UpdatedQuantity)
End If
Next
End With
End If
' Now look at the materials
If Not IsNothing(FoundItem.BPMaterialList) Then
With FoundItem.BPMaterialList
For i = 0 To .GetMaterialList.Count - 1
' Look at buy items
If .GetMaterialList(i).GetBuildItem = False Then
' Make sure the item exists (might have been deleted already in the main list) before updating
If Not IsNothing(TotalBuyList.SearchListbyName(.GetMaterialList(i).GetMaterialName)) Then
UpdatedQuantity = GetUpdatedQuantity("Buy", FoundItem, UpdateItemQuantity, .GetMaterialList(i))
' Need to update to the quantity sent in the Buy list
Call UpdateShoppingBuyQuantity(.GetMaterialList(i).GetMaterialName, UpdatedQuantity)
End If
End If
' Update the quantity of the material in the total list too, but needs to be for each individual material
Dim x As Long = GetNewMatQuantity(FoundItem, IndustryActivities.Manufacturing, .GetMaterialList(i), UpdateItemQuantity)
Call .GetMaterialList(i).SetQuantity(x)
Next
End With
End If
' Update Buy List with invention mats
If Not IsNothing(FoundItem.InventionMaterials) Then
If Not IsNothing(FoundItem.InventionMaterials.GetMaterialList) Then
With FoundItem.InventionMaterials ' Update all base materials for this item first
Dim TempInventionMaterials As New Materials
For i = 0 To .GetMaterialList.Count - 1
' Make sure the material exists (might have been deleted already in the main list) before updating
If Not IsNothing(TotalBuyList.SearchListbyName(.GetMaterialList(i).GetMaterialName)) Then
' Need to update to the quantity sent in the Buy List
UpdatedQuantity = GetUpdatedQuantity("Invention", FoundItem, UpdateItemQuantity, .GetMaterialList(i))
Call UpdateShoppingBuyQuantity(.GetMaterialList(i).GetMaterialName, UpdatedQuantity)
' Update this material in the item's invention list for copy/paste function
If UpdatedQuantity > 0 Then
' Need to copy, remove, update, then add to update the volumes and prices of the material lists
Dim TempMat As Material
TempMat = CType(TotalInventionMats.SearchListbyName(.GetMaterialList(i).GetMaterialName).Clone, Material)
Call TempInventionMaterials.InsertMaterial(TempMat)
End If
End If
Next
' Reset the Invention Materials for this item
FoundItem.InventionMaterials = TempInventionMaterials
End With
End If
End If
' Update buy list with copy materials
If Not IsNothing(FoundItem.CopyMaterials) Then
If Not IsNothing(FoundItem.CopyMaterials.GetMaterialList) Then
With FoundItem.CopyMaterials ' Update all base materials for this item first
Dim TempCopyMaterials As New Materials
For i = 0 To .GetMaterialList.Count - 1
' Make sure the material exists (might have been deleted already in the main list) before updating
If Not IsNothing(TotalBuyList.SearchListbyName(.GetMaterialList(i).GetMaterialName)) Then
' Need to update to the quantity sent in the Buy List
UpdatedQuantity = GetUpdatedQuantity("Copying", FoundItem, UpdateItemQuantity, .GetMaterialList(i))
Call UpdateShoppingBuyQuantity(.GetMaterialList(i).GetMaterialName, UpdatedQuantity)
' Update this material in the item's invention list for copy/paste function
If UpdatedQuantity <= 0 Then
Call TotalCopyMats.RemoveMaterial(.GetMaterialList(i))
Else
' Need to copy, remove, update, then add to update the volumes and prices of the material lists
Dim TempMat As Material
TempMat = CType(TotalCopyMats.SearchListbyName(.GetMaterialList(i).GetMaterialName).Clone, Material)
Call TempCopyMaterials.InsertMaterial(TempMat)
End If
End If
Next
' Reset the Invention Materials for this item
FoundItem.CopyMaterials = TempCopyMaterials
End With
End If
End If
' Need to increment or decrement the new item quantity and volume, the rest of the mats and components will be updated above
If UpdateItemQuantity = 0 Then
Call TotalItemList.Remove(FoundItem)
Else
' This is simplistic but the easiest way to get an approximate value for a change in the shopping list - won't be exact!
FoundItem.BuildVolume = FoundItem.BuildVolume / FoundItem.Quantity * UpdateItemQuantity
'FoundItem.TotalMaterialCost = FoundItem.TotalMaterialCost / FoundItem.Quantity * UpdateItemQuantity
FoundItem.TotalUsage = FoundItem.TotalUsage / FoundItem.Quantity * UpdateItemQuantity
FoundItem.TotalItemMarketCost = FoundItem.TotalItemMarketCost / FoundItem.Quantity * UpdateItemQuantity
FoundItem.TotalBuildTime = FoundItem.TotalBuildTime / FoundItem.Quantity * UpdateItemQuantity
' Update the invention jobs if they update this later
If FoundItem.InventionJobs <> 0 Then
FoundItem.InventionJobs = CInt(Math.Ceiling(FoundItem.AvgInvRunsforSuccess * Math.Ceiling(UpdateItemQuantity / FoundItem.InventedRunsPerBP)))
' How many bps do we need to make?
FoundItem.NumBPs = CInt(Math.Ceiling(UpdateItemQuantity / FoundItem.InventedRunsPerBP))
End If
' Finally update the quantity
FoundItem.Quantity = UpdateItemQuantity
End If
End If
End Sub
' Removes or updates a built item quantity from the build list and its materials from the material list - i.e. remove particle accelerator and raw mats from item - Hammerhead II
Public Sub UpdateShoppingBuiltItemQuantity(ByVal SentItem As BuiltItem, ByVal UpdateItemQuantity As Long)
Dim FoundItem As BuiltItem
Dim UpdatedQuantity As Long ' This is the final mat quantity for updating the shopping buy/build list ammount
Dim RefMatQuantity As Long ' This is the reference for materials we send in the update quantity - will be the mat quantity for that built item
Dim UpdateItem As New BuiltItem
Dim UpdateItemMatList As New Materials
Dim InsertMat As Material
Dim ShoppingItem As New ShoppingListItem
Application.DoEvents()
' Task here: Update build list with correct quantity, and then the buy list with the correct material quantities
' First look up the item and the mats used to build it in the saved list
Call TotalBuildList.SetItemToFind(SentItem)
FoundItem = TotalBuildList.GetBuiltItemList.Find(AddressOf TotalBuildList.FindBuiltItem)
' Update the materials in the built list, take total number, divide mats by it and then multiply by quantity sent
If Not IsNothing(FoundItem) Then
With FoundItem.BuildMaterials
For i = 0 To .GetMaterialList.Count - 1
' Make sure the item exists (might have been deleted already in the main list) before updating
If Not IsNothing(TotalBuyList.SearchListbyName(.GetMaterialList(i).GetMaterialName)) Then
' Set the values we need for get updated quantity
ShoppingItem.Name = FoundItem.ItemName
ShoppingItem.TypeID = FoundItem.ItemTypeID
ShoppingItem.ManufacturingFacilityMEModifier = FoundItem.FacilityMEModifier
ShoppingItem.ManufacturingFacilityLocation = FoundItem.FacilityLocation
ShoppingItem.ManufacturingFacilityType = FoundItem.FacilityType
ShoppingItem.IncludeActivityCost = FoundItem.IncludeActivityCost
ShoppingItem.IncludeActivityTime = FoundItem.IncludeActivityTime
ShoppingItem.IncludeActivityUsage = FoundItem.IncludeActivityUsage
ShoppingItem.ItemME = FoundItem.BuildME
ShoppingItem.ItemTE = FoundItem.BuildTE
ShoppingItem.Quantity = FoundItem.ItemQuantity
' Blank these out for now if we use them later
ShoppingItem.InventionJobs = 0
ShoppingItem.InventedRunsPerBP = 0
ShoppingItem.AvgInvRunsforSuccess = 0
ShoppingItem.NumBPs = 1 ' Built items (components) are always one bp for now
' Get the new quantity for each material to build this item - which will be in the buy list
UpdatedQuantity = GetUpdatedQuantity("Buy", ShoppingItem, UpdateItemQuantity, .GetMaterialList(i), RefMatQuantity)
' Need to update to the quantity sent in the Buy List
Call UpdateShoppingBuyQuantity(.GetMaterialList(i).GetMaterialName, UpdatedQuantity)
' Save the updated materials for the build list, if they want to update later
With .GetMaterialList(i)
' Need to save the new value we want for this item, not the new quantity to update the other lists with
InsertMat = New Material(.GetMaterialTypeID, .GetMaterialName, .GetMaterialGroup, RefMatQuantity, .GetTotalVolume, 0, "", "")
End With
If UpdatedQuantity > 0 Then
UpdateItemMatList.InsertMaterial(InsertMat)
End If
End If
Next
End With
' Save the base data
UpdateItem.ItemTypeID = FoundItem.ItemTypeID
UpdateItem.BuildME = FoundItem.BuildME
UpdateItem.ItemName = FoundItem.ItemName
UpdateItem.ItemVolume = FoundItem.ItemVolume
UpdateItem.FacilityMEModifier = FoundItem.FacilityMEModifier
UpdateItem.FacilityLocation = FoundItem.FacilityLocation
UpdateItem.FacilityType = FoundItem.FacilityType
UpdateItem.IncludeActivityCost = FoundItem.IncludeActivityCost
UpdateItem.IncludeActivityTime = FoundItem.IncludeActivityTime
UpdateItem.IncludeActivityUsage = FoundItem.IncludeActivityUsage
' Update the new built list quantity
UpdateItem.ItemQuantity = UpdateItemQuantity
' Update the new built list material list, with updated quantities
UpdateItem.BuildMaterials = UpdateItemMatList
' Update the quantity of the build list item
Call TotalBuildList.RemoveBuiltItem(FoundItem) ' Remove the old one
If UpdateItemQuantity <> 0 Then
Call TotalBuildList.AddBuiltItem(UpdateItem) ' Add the updated one
End If
End If
End Sub
' Removes or updates the quantity of material in all lists of materials. i.e. Tritanium
Public Sub UpdateShoppingBuyQuantity(ByVal SentItemName As String, ByVal Quantity As Long)
If Not IsNothing(TotalBuyList) Then
If Not IsNothing(TotalBuyList.GetMaterialList) Then
If Quantity <= 0 Then
' We just delete the item (all quantity) from the total materials list
Call TotalBuyList.RemoveMaterial(TotalBuyList.SearchListbyName(SentItemName))
' Also remove from the total copy and invention lists
Call TotalInventionMats.RemoveMaterial(TotalInventionMats.SearchListbyName(SentItemName))
Call TotalCopyMats.RemoveMaterial(TotalCopyMats.SearchListbyName(SentItemName))
Else
Dim TempMaterial As Material
Dim FindMaterial As Material = TotalBuyList.SearchListbyName(SentItemName)
' Catch if item isn't in the list to what was sent
If Not IsNothing(FindMaterial) Then
TempMaterial = CType(FindMaterial.Clone, Material)
TotalBuyList.RemoveMaterial(TempMaterial)
' Set the new quantity
Call TempMaterial.SetQuantity(Quantity)
' Re-add so the prices are updated
TotalBuyList.InsertMaterial(TempMaterial)
End If
' Update Invention mats (if there)
FindMaterial = TotalInventionMats.SearchListbyName(SentItemName)
' Catch if item isn't in the list to what was sent
If Not IsNothing(FindMaterial) Then
TempMaterial = CType(FindMaterial.Clone, Material)
TotalInventionMats.RemoveMaterial(TempMaterial)
' Set the new quantity
Call TempMaterial.SetQuantity(Quantity)
' Re-add so the prices are updated
TotalInventionMats.InsertMaterial(TempMaterial)
End If
' Update Copy mats (if there)
FindMaterial = TotalCopyMats.SearchListbyName(SentItemName)
' Catch if item isn't in the list to what was sent
If Not IsNothing(FindMaterial) Then
TempMaterial = CType(FindMaterial.Clone, Material)
TotalCopyMats.RemoveMaterial(TempMaterial)
' Set the new quantity
Call TempMaterial.SetQuantity(Quantity)
' Re-add so the prices are updated
TotalCopyMats.InsertMaterial(TempMaterial)
End If
End If
End If
End If
End Sub
' Calculates the updated quantity for updating lists
' ProcessingType = Invention/RE/Build/Buy
' CurrentItem = the current item in the shopping list for reference of old values
' NewItemQuantity = new quantity of the current item we want to update
' UpdateItemMaterial = material of the item we are updating the quantity of based on the new item quantity
Private Function GetUpdatedQuantity(ByVal ProcessingType As String, _
ByVal CurrentItem As ShoppingListItem,
ByVal NewItemQuantity As Long, _
ByVal UpdateItemMaterial As Material, _
Optional ByRef RefMatQuantity As Long = 0) As Long
Dim UpdatedQuantity As Long = 0
Dim OnHandMats As Long
Dim ListMatQuantity As Long
Dim NumInventionJobs As Integer
Dim NewMatQuantity As Long = 0
' Set up the ME bonus and then calculate the new material quantity
Dim MEBonus As Double = 0
Dim SingleRunQuantity As Long = 0
Dim rsMatQuantity As SQLiteDataReader
Dim SQL As String
' Look up the cost for the material
If ProcessingType = "Invention" Or ProcessingType = "Copying" Then
SQL = "SELECT QUANTITY FROM ALL_BLUEPRINT_MATERIALS WHERE PRODUCT_ID = " & CurrentItem.BlueprintTypeID & " AND MATERIAL_ID = " & UpdateItemMaterial.GetMaterialTypeID
If ProcessingType = "Invention" Then
SQL = SQL & " AND ACTIVITY = 8"
Else
SQL = SQL & " AND ACTIVITY = 5"
End If
Else
SQL = "SELECT QUANTITY FROM ALL_BLUEPRINT_MATERIALS WHERE PRODUCT_ID = " & CurrentItem.TypeID & " AND MATERIAL_ID = " & UpdateItemMaterial.GetMaterialTypeID
SQL = SQL & " AND ACTIVITY = 1"
End If
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
rsMatQuantity = DBCommand.ExecuteReader
If rsMatQuantity.Read Then
SingleRunQuantity = rsMatQuantity.GetInt64(0)
Else
SingleRunQuantity = 1
End If
rsMatQuantity.Close()
' Calc out final mat quantity
If ProcessingType = "Invention" Or ProcessingType = "Copying" Then
ListMatQuantity = TotalBuyList.SearchListbyName(UpdateItemMaterial.GetMaterialName).GetQuantity
' For invention materials, find out how many mats we need by calcuating the new value from the item runs and invention jobs per item
If NewItemQuantity <= 0 Then
' Easy case, just remove the update material quantity (add the negative)
NewMatQuantity = ListMatQuantity + NewItemQuantity
Else
' Here, we need to figure out how many items per run to remove (3 inv mats per job, and remove 2 items, then remove 6 invention mats)
NumInventionJobs = CInt(Math.Ceiling(CurrentItem.AvgInvRunsforSuccess * Math.Ceiling(NewItemQuantity / CurrentItem.InventedRunsPerBP)))
' Update quantity based on invention calculations
NewMatQuantity = NumInventionJobs * SingleRunQuantity
RefMatQuantity = NewMatQuantity
End If
ElseIf ProcessingType = "Buy" Or ProcessingType = "Build" Then
MEBonus = (1 - (CurrentItem.ItemME / 100)) * CurrentItem.ManufacturingFacilityMEModifier
' Figure out how many bps we need now and apply the ME bonus for each bp and sum up
Dim NewNumBPs As Integer = 0
Dim NewRunsperBP As Integer = 0
If CurrentItem.InventionJobs <> 0 Then
If NewItemQuantity <> 0 Then
If CurrentItem.NumBPs = 1 Then
NewNumBPs = CInt(Math.Ceiling(NewItemQuantity / CurrentItem.InventedRunsPerBP))
Else
NewNumBPs = CInt(Math.Ceiling(NewItemQuantity / (CurrentItem.Quantity / CurrentItem.NumBPs)))
End If
NewRunsperBP = CInt(Math.Ceiling(NewItemQuantity / NewNumBPs))
End If
Else
' This isn't invented so just use the number of blueprints
NewNumBPs = CurrentItem.NumBPs
NewRunsperBP = CInt(Math.Ceiling(NewItemQuantity / NewNumBPs))
' Make sure we aren't building more bps than the quantity
If NewNumBPs > NewItemQuantity Then
NewNumBPs = CInt(NewItemQuantity)
End If
End If
' For each bp, apply the me bonus and add up
For i = 1 To NewNumBPs
' Set the quantity: required = max(runs,ceil(round(runs * baseQuantity * materialModifier,2))
NewMatQuantity += CLng(Math.Max(NewRunsperBP, Math.Ceiling(Math.Round(NewRunsperBP * SingleRunQuantity * MEBonus, 2))))
Next
' Set the mat quantity for reference
RefMatQuantity = NewMatQuantity
' Get the quantity from the correct list so we have the right total materials of all items using this material
If ProcessingType = "Buy" Then
ListMatQuantity = TotalBuyList.SearchListbyName(UpdateItemMaterial.GetMaterialName).GetQuantity
ElseIf ProcessingType = "Build" Then
Dim TempBuildItem As New BuiltItem
TempBuildItem.ItemTypeID = UpdateItemMaterial.GetMaterialTypeID
TempBuildItem.BuildME = CInt(UpdateItemMaterial.GetItemME)
TempBuildItem.FacilityLocation = UpdateItemMaterial.GetMaterialGroup
Call TotalBuildList.SetItemToFind(TempBuildItem)
ListMatQuantity = TotalBuildList.GetBuiltItemList.Find(AddressOf TotalBuildList.FindBuiltItem).ItemQuantity
End If
End If
' Update with onhand mats functionality
If UpdateItemMaterial.GetBuildItem Then ' Building
' If entered, use this as the quantity to update to reflect that the user already entered a updated value
OnHandMats = GetOnHandComponentQuantity(UpdateItemMaterial.GetMaterialName)
Else ' Buying
' If entered, use this as the quantity to update to reflect that the user already entered a updated value
OnHandMats = GetOnHandMaterialQuantity(UpdateItemMaterial.GetMaterialName)
End If
If OnHandMats <> 0 Then
UpdatedQuantity = NewMatQuantity - OnHandMats
Else
UpdatedQuantity = NewMatQuantity
End If
' Decrease the mats in the shopping list from what we had, then add what we now need
UpdatedQuantity = (ListMatQuantity - UpdateItemMaterial.GetQuantity) + UpdatedQuantity
' If the update caused it go below zero, reset
If UpdatedQuantity < 0 Then
UpdatedQuantity = 0
End If
Return UpdatedQuantity
End Function
Private Function GetNewMatQuantity(ByVal ItemData As ShoppingListItem, ByVal Activity As IndustryActivities, _
ByVal UpdateMaterial As Material, ByVal NewQuantity As Long) As Long
' Set up the ME bonus and then calculate the new material quantity
Dim MEBonus As Double = 0
Dim SingleRunQuantity As Long = 0
Dim rsMatQuantity As SQLiteDataReader
Dim SQL As String
If NewQuantity = 0 Then
Return 0
End If
' Look up the cost for the material
If Activity = IndustryActivities.Invention Or Activity = IndustryActivities.Copying Then
SQL = "SELECT QUANTITY FROM ALL_BLUEPRINT_MATERIALS WHERE PRODUCT_ID = " & ItemData.BlueprintTypeID & " AND MATERIAL_ID = " & UpdateMaterial.GetMaterialTypeID
SQL = SQL & " AND ACTIVITY = 8"
Else
SQL = "SELECT QUANTITY FROM ALL_BLUEPRINT_MATERIALS WHERE PRODUCT_ID = " & ItemData.TypeID & " AND MATERIAL_ID = " & UpdateMaterial.GetMaterialTypeID
SQL = SQL & " AND ACTIVITY = 1"
End If
DBCommand = New SQLiteCommand(SQL, EVEDB.DBREf)
rsMatQuantity = DBCommand.ExecuteReader
rsMatQuantity.Read()
SingleRunQuantity = rsMatQuantity.GetInt64(0)
MEBonus = (1 - (ItemData.ItemME / 100)) * ItemData.ManufacturingFacilityMEModifier
' Figure out how many bps we need now and apply the ME bonus for each bp and sum up
Dim NewNumBPs As Integer
Dim NewRunsperBP As Integer
If ItemData.InventionJobs <> 0 Then
If ItemData.NumBPs = 1 Then
NewNumBPs = CInt(Math.Ceiling(NewQuantity / ItemData.InventedRunsPerBP))
Else
NewNumBPs = CInt(Math.Ceiling(NewQuantity / (ItemData.Quantity / ItemData.NumBPs)))
End If
NewRunsperBP = CInt(Math.Ceiling(NewQuantity / NewNumBPs))
Else
' This isn't invented so just use the number of blueprints
NewNumBPs = ItemData.NumBPs
NewRunsperBP = CInt(Math.Ceiling(NewQuantity / NewNumBPs))
' Make sure we aren't building more bps than the quantity
If NewNumBPs > NewQuantity Then
NewNumBPs = CInt(NewQuantity)
End If
End If
Dim NewMatQuantity As Long = 0
' For each bp, apply the me bonus and add up
For i = 1 To NewNumBPs
' Set the quantity: required = max(runs,ceil(round(runs * baseQuantity * materialModifier,2))
NewMatQuantity += CLng(Math.Max(NewRunsperBP, Math.Ceiling(Math.Round(NewRunsperBP * SingleRunQuantity * MEBonus, 2))))
Next
Return NewMatQuantity
End Function
#End Region
' Inserts a full shopping list item into the list
Public Sub InsertShoppingItem(ByVal SentItem As ShoppingListItem, ByVal SentBuildList As BuiltItemList, ByVal SentBuyList As Materials)
Dim FoundItem As New ShoppingListItem
Dim TempMats As New Materials
Dim TempItems As New BuiltItemList
Dim SearchBuiltItems As New BuiltItemList
' Look for the item
ItemToFind = SentItem
FoundItem = TotalItemList.Find(AddressOf FindItem)
If FoundItem IsNot Nothing Then
' If it's already in the list, then remove it, and add the sent items to it, then re-add
TotalItemList.Remove(FoundItem)
' Add the new data to this item
With FoundItem
' Increment items
.Quantity = .Quantity + SentItem.Quantity
.BuildVolume = .BuildVolume + SentItem.BuildVolume
.TotalUsage = .TotalUsage + SentItem.TotalUsage
.TotalItemMarketCost = .TotalItemMarketCost + SentItem.TotalItemMarketCost
.TotalBuildTime = .TotalBuildTime + SentItem.TotalBuildTime
.NumBPs = .NumBPs + SentItem.NumBPs ' Need to add the set of numbps used to the current
.InventionJobs = .InventionJobs + SentItem.InventionJobs
' Increment BP Mat List
If Not IsNothing(SentItem.BPMaterialList) Then
TempMats = New Materials
TempMats = CType(.BPMaterialList.Clone, Materials)
If Not IsNothing(SentItem.BPMaterialList) Then
TempMats.InsertMaterialList(SentItem.BPMaterialList.GetMaterialList)
End If
.BPMaterialList = CType(TempMats.Clone, Materials)
Else
.BPMaterialList = New Materials
.BPMaterialList = CType(FoundItem.BPMaterialList.Clone, Materials)
End If
' Increment BP Build List
If Not IsNothing(SentItem.BPBuiltItems) Then
TempItems = New BuiltItemList
TempItems = CType(.BPBuiltItems.Clone, BuiltItemList)
If Not IsNothing(SentItem.BPBuiltItems) Then
For i = 0 To SentItem.BPBuiltItems.GetBuiltItemList.Count - 1
TempItems.AddBuiltItem(SentItem.BPBuiltItems.GetBuiltItemList(i))
Next
End If
.BPBuiltItems = CType(TempItems.Clone, BuiltItemList)
Else
.BPBuiltItems = New BuiltItemList
.BPBuiltItems = CType(FoundItem.BPBuiltItems.Clone, BuiltItemList)
End If
' Update invention mats
If Not IsNothing(SentItem.InventionMaterials) Then
.InventionMaterials.InsertMaterialList(SentItem.InventionMaterials.GetMaterialList)
End If
' Update copy mats
If Not IsNothing(SentItem.CopyMaterials) Then
.CopyMaterials.InsertMaterialList(SentItem.CopyMaterials.GetMaterialList)
End If
End With
' Now re-add, not a new item so number of items the same
TotalItemList.Add(FoundItem)
Else ' Just add it
TotalItemList.Add(SentItem)
End If
' Total Buy
If Not IsNothing(SentBuyList) Then
If Not IsNothing(SentBuyList.GetMaterialList) Then
TotalBuyList.InsertMaterialList(SentBuyList.GetMaterialList)
End If
End If
' Total Build - Need to rebuild every component as if we are only using one bp to get the numbers exact - TODO multi bps
If Not IsNothing(SentBuildList) Then
If Not IsNothing(SentBuildList.GetBuiltItemList) Then
' Loop through everything and find all the items to update
For i = 0 To SentBuildList.GetBuiltItemList.Count - 1
Dim TempBuiltItem As New BuiltItem
Dim FoundBuildItem As New BuiltItem
' Look up current built items
TempBuiltItem.ItemTypeID = SentBuildList.GetBuiltItemList(i).ItemTypeID
TempBuiltItem.ItemName = SentBuildList.GetBuiltItemList(i).ItemName
TempBuiltItem.BuildME = SentBuildList.GetBuiltItemList(i).BuildME
TempBuiltItem.FacilityLocation = SentBuildList.GetBuiltItemList(i).FacilityLocation
Call TotalBuildList.SetItemToFind(TempBuiltItem)
FoundBuildItem = TotalBuildList.GetBuiltItemList.Find(AddressOf TotalBuildList.FindBuiltItem)
' Rebuild with new quantity
If FoundBuildItem IsNot Nothing Then
' With this item, update the quantity and rebuild for new materials list
With SentBuildList.GetBuiltItemList(i)
' Get the component facility
Dim TempComponentFacility As New IndustryFacility
Dim TempSettings As FacilitySettings = GetFacilitySettings(.ItemName, .FacilityLocation, .FacilityType, 1, .IncludeActivityCost, .IncludeActivityTime, .IncludeActivityUsage)
' Set the component facility
Call TempComponentFacility.LoadFacility(TempSettings, True)
' Re-run with new quantity
Dim TempBP As New Blueprint(.BPTypeID, FoundBuildItem.ItemQuantity + .ItemQuantity, .BuildME, .BuildTE, 1, _
UserBPTabSettings.ProductionLines, SelectedCharacter, UserApplicationSettings, False, _
0, SelectedBPManufacturingTeam, TempComponentFacility, SelectedBPComponentManufacturingTeam, _
TempComponentFacility, TempComponentFacility, True)
Call TempBP.BuildItems(UserBPTabSettings.IncludeTaxes, UserBPTabSettings.IncludeFees, True, _
UserBPTabSettings.IgnoreMinerals, UserBPTabSettings.IgnoreT1Item)
Dim InsertBuildItem As New BuiltItem
InsertBuildItem.BuildMaterials = TempBP.GetRawMaterials
InsertBuildItem.BPTypeID = TempBP.GetTypeID
InsertBuildItem.ItemTypeID = TempBP.GetItemID
InsertBuildItem.ItemName = TempBP.GetItemName
InsertBuildItem.ItemQuantity = TempBP.GetUserRuns
InsertBuildItem.BuildME = TempBP.GetME
InsertBuildItem.BuildTE = TempBP.GetTE
InsertBuildItem.ItemVolume = TempBP.GetTotalItemVolume
InsertBuildItem.BuildMaterials = TempBP.GetRawMaterials
InsertBuildItem.FacilityMEModifier = TempBP.GetManufacturingFacility.MaterialMultiplier
InsertBuildItem.FacilityType = TempBP.GetManufacturingFacility.FacilityType
InsertBuildItem.IncludeActivityCost = TempBP.GetManufacturingFacility.IncludeActivityCost
InsertBuildItem.IncludeActivityTime = TempBP.GetManufacturingFacility.IncludeActivityTime
InsertBuildItem.IncludeActivityUsage = TempBP.GetManufacturingFacility.IncludeActivityUsage
' See if we need to add the system on to the end of the build location for POS
If InsertBuildItem.FacilityType = POSFacility Then
InsertBuildItem.FacilityLocation = TempBP.GetManufacturingFacility.FacilityName & " (" & TempBP.GetManufacturingFacility.SolarSystemName & ")"
Else
InsertBuildItem.FacilityLocation = TempBP.GetManufacturingFacility.FacilityName
End If
' Remove the old record
TotalBuildList.RemoveBuiltItem(FoundBuildItem)
' Now add the updated item
TotalBuildList.AddBuiltItem(InsertBuildItem)
End With
Else
' Just add the new item
TotalBuildList.AddBuiltItem(SentBuildList.GetBuiltItemList(i))
End If
Next
End If
End If
' Invention Materials
If Not IsNothing(SentItem.InventionMaterials) Then
TotalInventionMats.InsertMaterialList(SentItem.InventionMaterials.GetMaterialList)
End If
' Copy Materials
If Not IsNothing(SentItem.CopyMaterials) Then
TotalCopyMats.InsertMaterialList(SentItem.CopyMaterials.GetMaterialList)
End If
ItemToFind = Nothing
End Sub
' Will update all the prices in the shopping list
Public Sub UpdateListPrices()
Dim TempBuyList As New Materials ' Buy mats
Dim TempBuildList As New BuiltItemList ' Build mats (components)
Dim TempInventionMats As New Materials ' All Invention materials used
Dim TempCopyMats As New Materials ' All the copy materials used
Dim TempBPMatList As New Materials ' For the Total Item List
Dim TransferMaterial As Material
Dim TransferBuiltItem As BuiltItem
' Basically take the materials from the current lists and put them into new lists with 0 prices to get them updated
' Item List
For i = 0 To TotalItemList.Count - 1
For j = 0 To TotalItemList(i).BPMaterialList.GetMaterialList.Count - 1
With TotalItemList(i).BPMaterialList.GetMaterialList(j)
TransferMaterial = New Material(.GetMaterialTypeID, .GetMaterialName, .GetMaterialGroup, .GetQuantity, .GetVolume, 0, .GetItemME, .GetItemTE, .GetBuildItem, .GetItemType)
End With
' Add to the temp list
Call TempBPMatList.InsertMaterial(TransferMaterial)
Next
' Reset each BPMaterial list on each item
TotalItemList(i).BPMaterialList = TempBPMatList
Next
' Buy List
If Not IsNothing(TotalBuyList.GetMaterialList) Then
For i = 0 To TotalBuyList.GetMaterialList.Count - 1
With TotalBuyList.GetMaterialList(i)
TransferMaterial = New Material(.GetMaterialTypeID, .GetMaterialName, .GetMaterialGroup, .GetQuantity, .GetVolume, 0, .GetItemME, .GetItemTE, .GetBuildItem, .GetItemType)
End With
' Add the material with new price to list
Call TempBuyList.InsertMaterial(TransferMaterial)
Next
End If
' Reset List
TotalBuyList = TempBuyList
' Invention List
If Not IsNothing(TotalInventionMats.GetMaterialList) Then
For i = 0 To TotalInventionMats.GetMaterialList.Count - 1
With TotalInventionMats.GetMaterialList(i)
TransferMaterial = New Material(.GetMaterialTypeID, .GetMaterialName, .GetMaterialGroup, .GetQuantity, .GetVolume, 0, .GetItemME, .GetItemTE, .GetBuildItem, .GetItemType)
End With
' Add the material with new price to list
Call TempInventionMats.InsertMaterial(TransferMaterial)
Next
End If
' Reset List
TotalInventionMats = TempInventionMats
' Copy List
If Not IsNothing(TotalCopyMats.GetMaterialList) Then
For i = 0 To TotalCopyMats.GetMaterialList.Count - 1
With TotalCopyMats.GetMaterialList(i)
TransferMaterial = New Material(.GetMaterialTypeID, .GetMaterialName, .GetMaterialGroup, .GetQuantity, .GetVolume, 0, .GetItemME, .GetItemTE, .GetBuildItem, .GetItemType)
End With
' Add the material with new price to list
Call TempCopyMats.InsertMaterial(TransferMaterial)
Next
End If
' Reset List
TotalCopyMats = TempCopyMats
' Build Item List
If TotalBuildList.GetBuiltItemList.Count <> 0 Then
For i = 0 To TotalBuildList.GetBuiltItemList.Count - 1
' Copy the old data and reset the materials
TransferBuiltItem = New BuiltItem
TransferBuiltItem = CType(TotalBuildList.GetBuiltItemList(i).Clone, BuiltItem)
TransferBuiltItem.BuildMaterials = New Materials
' Get the new material prices
If Not IsNothing(TotalBuildList.GetBuiltItemList(i).BuildMaterials.GetMaterialList) Then
For j = 0 To TotalBuildList.GetBuiltItemList(i).BuildMaterials.GetMaterialList.Count - 1
With TotalBuildList.GetBuiltItemList(i).BuildMaterials.GetMaterialList(j)
TransferMaterial = New Material(.GetMaterialTypeID, .GetMaterialName, .GetMaterialGroup, .GetQuantity, .GetVolume, 0, .GetItemME, .GetItemTE, .GetBuildItem, .GetItemType)
End With
' Insert the mat to the item list
Call TransferBuiltItem.BuildMaterials.InsertMaterial(TransferMaterial)
Next
End If
' Add to the temp list
TempBuildList.AddBuiltItem(TransferBuiltItem)
Next
End If
' Reset the list
TotalBuildList = TempBuildList
End Sub
' Exports the shoppinglist data in CSV format if true, ignores the price volume if true, and sorts the raw mats by the order given
Public Function GetClipboardList(ByVal ExportFormat As String, ByVal IgnorePriceVolume As Boolean, ByVal MaterialNamesSortOrder() As String,
ByVal ItemNamesSortOrder() As String, ByVal BuildItemsSortOrder() As String, ByVal CopyEveListFormat As Boolean) As String
Dim i As Integer
Dim OutputText As String = ""
Dim TempListText As String
Dim FullBuildList As New Materials
Dim FullBuyList As New Materials
Dim FullItemList As New Materials
Dim TempMatList As New Materials
Dim InventionMatList As New Materials
Dim REMatList As New Materials
Dim IncludeInventionMats As Boolean = False
Dim IncludeREMats As Boolean = False
' Full output lists
FullBuildList = GetFullBuildMaterialList() ' GetFullBuildList uses BuildItem for built in pos, and Volume for the facility ME value
FullBuyList = CType(TotalBuyList.Clone, Materials)
FullItemList = GetFullItemList()
' If using the Eve List Format this will create an output that
' The EVE Client will handle for multi-buy functionality.
If CopyEveListFormat Then
For j = 0 To FullBuyList.GetMaterialList.Count - 1
OutputText += String.Format("{0} {1}{2}", FullBuyList.GetMaterialList(j).GetMaterialName(), FullBuyList.GetMaterialList(j).GetQuantity(), vbCrLf)
Next
Return OutputText
End If
' Add the Invention mats to buy
InventionMatList = GetFullInventionList()
If Not IsNothing(InventionMatList.GetMaterialList) Then
IncludeInventionMats = True
' Remove the invention materials from the buy list so we can separate them in the output
Call FullBuyList.RemoveMaterialList(InventionMatList.GetMaterialList)
' Update the total though as if the materials were in the full list for price purposes
FullBuyList.AddTotalValue(InventionMatList.GetTotalMaterialsCost)
FullBuyList.AddTotalVolume(InventionMatList.GetTotalVolume)
End If
' Sort the Item List by order sent (this is based on how they sorted in the grid)
' Item sort order Name, Quantity, ME, Num BPs, Build Type, Decryptor, and Relic
For i = 0 To ItemNamesSortOrder.Count - 1
' Parse the sort order fields
Dim ItemColumns As String() = ItemNamesSortOrder(i).Split(New [Char]() {"|"c})
' For each item, find it in the current buy list and replace
' Item sort order Name, Quantity, ME, Num BPs, Build Type, Decryptor/Relic, Location
For j = 0 To FullItemList.GetMaterialList.Count - 1
With FullItemList.GetMaterialList(j) ' GroupName stores the build type Decryptor/Relic in item type
' Split out the Build Type, Decryptor, NumBps, and Relic
Dim GroupNameItems As String() = .GetMaterialGroup.Split(New [Char]() {"|"c})
Dim ItemName As String = ""
Dim RelicName As String = ""
If ItemColumns(0).Contains("(") Then
ItemName = ItemColumns(0).Substring(0, InStr(ItemColumns(0), "(") - 2)
RelicName = ItemColumns(0).Substring(InStr(ItemColumns(0), "("), InStr(ItemColumns(0), ")") - InStr(ItemColumns(0), "(") - 1)
Else
ItemName = ItemColumns(0)
End If
If ItemName = .GetMaterialName And CLng(ItemColumns(1)) = .GetQuantity And ItemColumns(2) = .GetItemME _
And ItemColumns(4) = GroupNameItems(0) And ItemColumns(5) = GroupNameItems(1) _
And ItemColumns(3) = GroupNameItems(2) And RelicName = GroupNameItems(3) And ItemColumns(6) = GroupNameItems(4) Then
' Found it, so insert into temp list
TempMatList.InsertMaterial(FullItemList.GetMaterialList(j))
Exit For
End If
End With
Next
Next
FullItemList = CType(TempMatList.Clone, Materials)
TempMatList = New Materials
' Get the Shopping list for items
If Not IsNothing(FullItemList) Then
TempListText = FullItemList.GetClipboardList(ExportFormat, IgnorePriceVolume, True, True, UserApplicationSettings.IncludeInGameLinksinCopyText)
If TempListText <> "No items in List" Then
OutputText = "Shopping List for: " & vbCrLf
OutputText = OutputText & TempListText
' Spacer
OutputText = OutputText & vbCrLf
End If
End If
' Invention materials (If they exist)
If IncludeInventionMats Then
' Add Invention mats if there are any
TempListText = InventionMatList.GetClipboardList(ExportFormat, False, False, False, UserApplicationSettings.IncludeInGameLinksinCopyText)
If TempListText <> "No items in List" Then
OutputText = OutputText & "Estimated Invention Materials: " & vbCrLf
OutputText = OutputText & TempListText
' Spacer
OutputText = OutputText & vbCrLf & vbCrLf
End If
End If
' RE Materials (If they exist)
If IncludeREMats Then
' Add RE mats if there are any
TempListText = REMatList.GetClipboardList(ExportFormat, False, False, False, UserApplicationSettings.IncludeInGameLinksinCopyText)
If TempListText <> "No items in List" Then
OutputText = OutputText & "Estimated RE Materials: " & vbCrLf
OutputText = OutputText & TempListText
' Spacer
OutputText = OutputText & vbCrLf & vbCrLf
End If
End If
' Sort the Build List by order sent (this is based on how they sorted in the grid)
' Build item sort order - Name, Quantity, and ME
For i = 0 To BuildItemsSortOrder.Count - 1
' For each item, find it in the current buy list and replace
For j = 0 To FullBuildList.GetMaterialList.Count - 1
' Parse the sort order fields
Dim ItemColumns As String() = BuildItemsSortOrder(i).Split(New [Char]() {"|"c})
With FullBuildList.GetMaterialList(j) ' Mat group stores the build type and meta is in item type