Emaggable protolathe (#18456)

This commit is contained in:
ubis1
2023-08-07 17:21:04 +03:00
committed by GitHub
parent 1c476731ed
commit e203423665
5 changed files with 101 additions and 5 deletions

View File

@@ -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<LatheComponent, BeforeActivatableUIOpenEvent>((u, c, _) => UpdateUserInterfaceState(u, c));
SubscribeLocalEvent<LatheComponent, MaterialAmountChangedEvent>(OnMaterialAmountChanged);
SubscribeLocalEvent<TechnologyDatabaseComponent, LatheGetRecipesEvent>(OnGetRecipes);
SubscribeLocalEvent<EmagLatheRecipesComponent, LatheGetRecipesEvent>(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<TechnologyDatabaseComponent>(uid, out var technologyDatabase))
return;
if (!HasComp<EmaggedComponent>(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)

View File

@@ -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
{
/// <summary>
/// All of the dynamic recipes that the lathe is capable to get using EMAG
/// </summary>
[DataField("emagDynamicRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))]
[AutoNetworkedField]
public List<string> EmagDynamicRecipes = new();
/// <summary>
/// All of the static recipes that the lathe is capable to get using EMAG
/// </summary>
[DataField("emagStaticRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer<LatheRecipePrototype>))]
[AutoNetworkedField]
public List<string> EmagStaticRecipes = new();
}
}

View File

@@ -33,7 +33,6 @@ namespace Content.Shared.Lathe
/// </summary>
[DataField("producingSound")]
public SoundSpecifier? ProducingSound;
#region Visualizer info
[DataField("idleState", required: true)]
public string IdleState = default!;

View File

@@ -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<LatheComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<LatheComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<EmagLatheRecipesComponent, GotEmaggedEvent>(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;

View File

@@ -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