private void Unload() { CostLabelUI.DestroyAll(); _scrapItem?.Remove(); _pluginInstance = null; _pluginConfig = null; }
private object OnNpcConversationRespond(VehicleVendor vendor, BasePlayer player, ConversationData conversationData, ResponseNode responseNode) { CostLabelUI.Destroy(player); foreach (var intercepter in _responseIntercepters) { var forceNextSpeechNode = intercepter.Intercept(vendor, player, conversationData, responseNode); if (forceNextSpeechNode != string.Empty) { ConversationUtils.ForceSpeechNode(vendor, player, forceNextSpeechNode); return(false); } } return(null); }
public override string Intercept(NPCTalking npcTalking, BasePlayer player, ConversationData conversationData, ResponseNode responseNode) { int vanillaPrice; if (!ConversationUtils.PrecedesPaymentOption(conversationData, responseNode, _matchResponseAction, out vanillaPrice)) { return(string.Empty); } var priceConfig = _getVehicleConfig().GetPriceForPlayer(player.IPlayer, _freePermission); if (priceConfig == null || priceConfig.MatchesVanillaPrice(vanillaPrice)) { return(string.Empty); } var neededScrap = PlayerInventoryUtils.GetPlayerNeededScrap(player, vanillaPrice); var canAffordVanillaPrice = neededScrap <= 0; var canAffordCustomPrice = priceConfig.CanPlayerAfford(player); CostLabelUI.Create(player, priceConfig); if (canAffordCustomPrice == canAffordVanillaPrice) { return(string.Empty); } if (!canAffordCustomPrice) { // Reduce scrap that will be removed to just below the amount they need for vanilla. neededScrap--; } // Add or remove scrap so the vanilla logic for showing the payment option will match the custom payment logic. PlayerInventoryUtils.UpdateWithFakeScrap(player, neededScrap); // This delay needs to be long enough for the text to print out, which could vary by language. player.Invoke(() => PlayerInventoryUtils.Refresh(player), 3f); return(string.Empty); }
private void OnNpcConversationEnded(VehicleVendor vendor, BasePlayer player) { CostLabelUI.Destroy(player); }