Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using Oxide.Core;
- using UnityEngine;
- namespace Oxide.Plugins
- {
- [Info("NoBPFrags", "Gattaca", "1.2.1")]
- [Description("Removal of Blueprint Fragments from Workbenches.")]
- public class NoBPFrags : RustPlugin
- {
- private readonly List<string> _ingredientsToRemove = new List<string>
- {
- "basicblueprintfragment",
- "advancedblueprintfragment"
- };
- private readonly List<string> _targetItems = new List<string>
- {
- "workbench2",
- "workbench3"
- };
- #region Oxide Hooks
- private void OnServerInitialized()
- {
- // Delay
- timer.Once(5f, () =>
- {
- ModifyWorkbenchBlueprints();
- });
- }
- private void Unload()
- {
- Puts("NoBPFrags unloaded.");
- }
- #endregion
- #region Core Logic
- private void ModifyWorkbenchBlueprints()
- {
- foreach (var targetItemName in _targetItems)
- {
- var definition = ItemManager.FindItemDefinition(targetItemName);
- // checks
- if (definition == null) continue;
- if (definition.Blueprint == null) continue;
- if (definition.Blueprint.ingredients == null) continue;
- var ingredientsToRemove = new List<ItemAmount>();
- // Find the frags
- foreach (var ingredient in definition.Blueprint.ingredients)
- {
- if (ingredient == null) continue;
- if (ingredient.itemDef != null && _ingredientsToRemove.Contains(ingredient.itemDef.shortname))
- {
- ingredientsToRemove.Add(ingredient);
- }
- }
- // Destroy them
- if (ingredientsToRemove.Count > 0)
- {
- foreach (var item in ingredientsToRemove)
- {
- definition.Blueprint.ingredients.Remove(item);
- Puts($"[NoBPFrags] Removed '{item.itemDef.shortname}' from '{targetItemName}'.");
- }
- }
- }
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment