class Helper extends Object; private delegate int ByPrice(class A, class B) { return A.default.BuyPrice > B.default.BuyPrice ? -1 : 0; } public static simulated function ModifyTrader( KFGameReplicationInfo KFGRI, Array > RemoveItems, Array > AddItems, bool ReplaceMode) { local KFGFxObject_TraderItems TraderItems; local STraderItem Item; local class WeapDef; local Array > WeapDefs; local int Index; local int MaxItemID; if (KFGRI == None) return; TraderItems = KFGFxObject_TraderItems(DynamicLoadObject(KFGRI.TraderItemsPath, class'KFGFxObject_TraderItems')); if (!ReplaceMode) { foreach TraderItems.SaleItems(Item) { if (Item.WeaponDef != None && RemoveItems.Find(Item.WeaponDef) == INDEX_NONE) { WeapDefs.AddItem(Item.WeaponDef); } } } for (Index = 0; Index < AddItems.Length; Index++) WeapDefs.AddItem(AddItems[Index]); WeapDefs.Sort(ByPrice); TraderItems.SaleItems.Length = 0; MaxItemID = 0; foreach WeapDefs(WeapDef) { Item.WeaponDef = WeapDef; Item.ItemID = ++MaxItemID; TraderItems.SaleItems.AddItem(Item); } TraderItems.SetItemsInfo(TraderItems.SaleItems); KFGRI.TraderItems = TraderItems; } public static simulated function PreloadContent(Array > WeapDefs) { local class WeapDef; foreach WeapDefs(WeapDef) { PreloadWeapon(WeapDef); } } public static simulated function PreloadWeapon(class WeapDef) { local class KFW; KFW = class (DynamicLoadObject(WeapDef.default.WeaponClassPath, class'Class')); if (KFW != None) { // This doesn't seem to have any effect right now // But I still leave it for the future // in the hope that someday we can preload weapon models using this function class'KFWeapon'.static.TriggerAsyncContentLoad(KFW); } } defaultproperties { }