diff --git a/Content.Server/Lathe/LatheSystem.cs b/Content.Server/Lathe/LatheSystem.cs index 508b580fa1..ad92ac3885 100644 --- a/Content.Server/Lathe/LatheSystem.cs +++ b/Content.Server/Lathe/LatheSystem.cs @@ -9,6 +9,7 @@ using Content.Server.Power.EntitySystems; using Content.Server.Stack; using Content.Server.UserInterface; using Content.Shared.Database; +using Content.Shared.Emag.Components; using Content.Shared.Lathe; using Content.Shared.Materials; using Content.Shared.Research.Components; @@ -31,7 +32,6 @@ namespace Content.Server.Lathe [Dependency] private readonly UserInterfaceSystem _uiSys = default!; [Dependency] private readonly MaterialStorageSystem _materialStorage = default!; [Dependency] private readonly StackSystem _stack = default!; - public override void Initialize() { base.Initialize(); @@ -48,8 +48,8 @@ namespace Content.Server.Lathe SubscribeLocalEvent((u, c, _) => UpdateUserInterfaceState(u, c)); SubscribeLocalEvent(OnMaterialAmountChanged); - SubscribeLocalEvent(OnGetRecipes); + SubscribeLocalEvent(GetEmagLatheRecipes); } public override void Update(float frameTime) @@ -202,6 +202,24 @@ namespace Content.Server.Lathe } } + private void GetEmagLatheRecipes(EntityUid uid, EmagLatheRecipesComponent component, LatheGetRecipesEvent args) + { + if (uid != args.Lathe || !TryComp(uid, out var technologyDatabase)) + return; + if (!HasComp(uid)) + return; + foreach (var recipe in component.EmagDynamicRecipes) + { + if (!technologyDatabase.UnlockedRecipes.Contains(recipe) || args.Recipes.Contains(recipe)) + continue; + args.Recipes.Add(recipe); + } + foreach (var recipe in component.EmagStaticRecipes) + { + args.Recipes.Add(recipe); + } + } + private void OnMaterialAmountChanged(EntityUid uid, LatheComponent component, ref MaterialAmountChangedEvent args) { UpdateUserInterfaceState(uid, component); @@ -272,7 +290,6 @@ namespace Content.Server.Lathe { return GetAvailableRecipes(uid, component).Contains(recipe.ID); } - #region UI Messages private void OnLatheQueueRecipeMessage(EntityUid uid, LatheComponent component, LatheQueueRecipeMessage args) diff --git a/Content.Shared/Lathe/EmagLatheComponent.cs b/Content.Shared/Lathe/EmagLatheComponent.cs new file mode 100644 index 0000000000..02a04b2024 --- /dev/null +++ b/Content.Shared/Lathe/EmagLatheComponent.cs @@ -0,0 +1,25 @@ +using Content.Shared.Research.Prototypes; +using Robust.Shared.GameStates; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; + +namespace Content.Shared.Lathe +{ + [RegisterComponent, NetworkedComponent] + [AutoGenerateComponentState] + public sealed partial class EmagLatheRecipesComponent : Component + { + /// + /// All of the dynamic recipes that the lathe is capable to get using EMAG + /// + [DataField("emagDynamicRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer))] + [AutoNetworkedField] + public List EmagDynamicRecipes = new(); + + /// + /// All of the static recipes that the lathe is capable to get using EMAG + /// + [DataField("emagStaticRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer))] + [AutoNetworkedField] + public List EmagStaticRecipes = new(); + } +} diff --git a/Content.Shared/Lathe/LatheComponent.cs b/Content.Shared/Lathe/LatheComponent.cs index 15c8b44c7f..b4095b7830 100644 --- a/Content.Shared/Lathe/LatheComponent.cs +++ b/Content.Shared/Lathe/LatheComponent.cs @@ -33,7 +33,6 @@ namespace Content.Shared.Lathe /// [DataField("producingSound")] public SoundSpecifier? ProducingSound; - #region Visualizer info [DataField("idleState", required: true)] public string IdleState = default!; diff --git a/Content.Shared/Lathe/SharedLatheSystem.cs b/Content.Shared/Lathe/SharedLatheSystem.cs index 4edae91ab4..e31925ec6d 100644 --- a/Content.Shared/Lathe/SharedLatheSystem.cs +++ b/Content.Shared/Lathe/SharedLatheSystem.cs @@ -1,4 +1,5 @@ -using Content.Shared.Materials; +using Content.Shared.Emag.Systems; +using Content.Shared.Materials; using Content.Shared.Research.Prototypes; using JetBrains.Annotations; using Robust.Shared.GameStates; @@ -22,6 +23,7 @@ public abstract class SharedLatheSystem : EntitySystem SubscribeLocalEvent(OnGetState); SubscribeLocalEvent(OnHandleState); + SubscribeLocalEvent(OnEmagged); } private void OnGetState(EntityUid uid, LatheComponent component, ref ComponentGetState args) @@ -59,6 +61,11 @@ public abstract class SharedLatheSystem : EntitySystem return true; } + private void OnEmagged(EntityUid uid, EmagLatheRecipesComponent component, ref GotEmaggedEvent args) + { + args.Handled = true; + } + public static int AdjustMaterial(int original, bool reduce, float multiplier) => reduce ? (int) MathF.Ceiling(original * multiplier) : original; diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 7967cd4815..441fbb6e30 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -125,6 +125,46 @@ - SubstationMachineCircuitboard - CellRechargerCircuitboard - WeaponCapacitorRechargerCircuitboard + - type: EmagLatheRecipes + emagStaticRecipes: + - CartridgePistol + - CartridgeMagnum + - ShellShotgun + - ShellShotgunFlare + - ShellTranquilizer + - CartridgeLightRifle + - CartridgeRifle + - MagazineBoxPistol + - MagazineBoxMagnum + - MagazineBoxRifle + - MagazineBoxLightRifle + emagDynamicRecipes: + - CartridgePistolRubber + - CartridgeMagnumRubber + - ShellShotgunBeanbag + - CartridgeRifleRubber + - CartridgeLightRifleRubber + - MagazineBoxPistolRubber + - MagazineBoxMagnumRubber + - MagazineBoxRifleRubber + - MagazineBoxLightRifleRubber + - CartridgePistolHighVelocity + - CartridgeMagnumHighVelocity + - CartridgeLightRifleHighVelocity + - CartridgeRifleHighVelocity + - MagazineBoxPistolHighVelocity + - MagazineBoxMagnumHighVelocity + - MagazineBoxLightRifleHighVelocity + - MagazineBoxRifleHighVelocity + - ShellShotgunIncendiary + - CartridgePistolIncendiary + - CartridgeMagnumIncendiary + - CartridgeLightRifleIncendiary + - CartridgeRifleIncendiary + - MagazineBoxPistolIncendiary + - MagazineBoxMagnumIncendiary + - MagazineBoxLightRifleIncendiary + - MagazineBoxRifleIncendiary - type: entity id: Protolathe @@ -228,6 +268,14 @@ - WelderExperimental - JawsOfLife - ClothingEyesGlassesChemical + - type: EmagLatheRecipes + emagDynamicRecipes: + - ExplosivePayload + - WeaponLaserCarbine + - WeaponAdvancedLaser + - WeaponLaserCannon + - WeaponXrayCannon + - WeaponTaser - type: entity id: CircuitImprinter