Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the shadow factory #2299

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Content.Server.Silicons.Laws;
using Content.Shared.Emag.Components;
using Content.Shared.Emag.Systems;
using Content.Shared.Silicons.Laws;
using Content.Shared.Silicons.Laws.Components;
using Robust.Shared.Prototypes;

namespace Content.Server.Silicons.Borgs;

/// <summary>
/// Handles lawset patching when switching type.
/// If a borg is made emagged it needs its emag laws carried over.
/// </summary>
public sealed partial class BorgSwitchableTypeSystem
{
[Dependency] private readonly SiliconLawSystem _law = default!;

private void ConfigureLawset(EntityUid uid, ProtoId<SiliconLawsetPrototype> id)
{
var laws = _law.GetLawset(id);
_law.SetLaws(laws.Laws, uid);

// re-add law 0 and final law based on new lawset
if (CompOrNull<EmagSiliconLawComponent>(uid)?.OwnerName != null)
{
// raising the event manually to bypass re-emagging checks
var ev = new GotEmaggedEvent(uid); // user wont be used since OwnerName isnt null, safe to pass itself
RaiseLocalEvent(uid, ref ev);
}

// ion storms don't get mirrored because thats basically impossible to track
}
}
7 changes: 6 additions & 1 deletion Content.Server/Silicons/Borgs/BorgSwitchableTypeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Content.Server.Silicons.Borgs;
/// <summary>
/// Server-side logic for borg type switching. Handles more heavyweight and server-specific switching logic.
/// </summary>
public sealed class BorgSwitchableTypeSystem : SharedBorgSwitchableTypeSystem
public sealed partial class BorgSwitchableTypeSystem : SharedBorgSwitchableTypeSystem // DeltaV: Made partial
{
[Dependency] private readonly BorgSystem _borgSystem = default!;
[Dependency] private readonly ServerInventorySystem _inventorySystem = default!;
Expand Down Expand Up @@ -59,6 +59,11 @@ protected override void SelectBorgModule(Entity<BorgSwitchableTypeComponent> ent
}
}

// Begin DeltaV Code: Custom lawset patching
if (prototype.Lawset is {} lawset)
ConfigureLawset(ent, lawset);
// End DeltaV Code

// Configure special components
if (Prototypes.TryIndex(ent.Comp.SelectedBorgType, out var previousPrototype))
{
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Silicons/Laws/SiliconLawSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ private void OnEmagLawsAdded(EntityUid uid, SiliconLawProviderComponent componen
component.Lawset = GetLawset(component.Laws);

// Add the first emag law before the others
var name = CompOrNull<EmagSiliconLawComponent>(uid)?.OwnerName ?? Name(args.UserUid); // DeltaV: Reuse emagger name if possible
component.Lawset?.Laws.Insert(0, new SiliconLaw
{
LawString = Loc.GetString("law-emag-custom", ("name", Name(args.UserUid)), ("title", Loc.GetString(component.Lawset.ObeysTo))),
LawString = Loc.GetString("law-emag-custom", ("name", name), ("title", Loc.GetString(component.Lawset.ObeysTo))), // DeltaV: pass name from variable
Order = 0
});

Expand Down
8 changes: 8 additions & 0 deletions Content.Shared/Silicons/Borgs/BorgTypePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Shared.Inventory;
using Content.Shared.Radio;
using Content.Shared.Silicons.Borgs.Components;
using Content.Shared.Silicons.Laws; // DeltaV
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
Expand Down Expand Up @@ -83,6 +84,13 @@ public sealed partial class BorgTypePrototype : IPrototype
[DataField]
public EntProtoId[] DefaultModules = [];

/// <summary>
/// DeltaV: Lawset to use instead of crewsimov.
/// If the chassis is emagged or ion stormed this is ignored.
/// </summary>
[DataField]
public ProtoId<SiliconLawsetPrototype>? Lawset;

/// <summary>
/// Additional components to add to the borg entity when this type is selected.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/DeltaV/borg_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
- BorgModuleSecurityPatrol
- BorgModuleSecurityBastion

lawset: SiliconPolice

addComponents:
- type: SiliconLawProvider
laws: SiliconPolice
- type: FlashImmunity
- type: ShowMindShieldIcons
- type: ShowCriminalRecordIcons
Expand Down
12 changes: 4 additions & 8 deletions Resources/Prototypes/borg_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
- BorgModuleRCD
- BorgModuleCable

addComponents: # DeltaV: Custom lawset
- type: SiliconLawProvider
laws: Engineer
lawset: Engineer # DeltaV: Custom lawset

radioChannels:
- Engineering
Expand Down Expand Up @@ -123,9 +121,7 @@
- BorgModuleLightReplacer
- BorgModuleCleaning

addComponents: # DeltaV: Custom lawset
- type: SiliconLawProvider
laws: Janitor
lawset: Janitor # DeltaV: Custom lawset

radioChannels:
- Science
Expand Down Expand Up @@ -165,6 +161,8 @@
- Science
- Medical

lawset: Medical # DeltaV: Custom lawset

addComponents:
- type: SolutionScanner
- type: ShowHealthBars
Expand All @@ -174,8 +172,6 @@
damageContainers:
- Biological
- type: FabricateCandy # Nyanotrasen - The medical cyborg can generate candies filled with medicine.
- type: SiliconLawProvider # DeltaV: Custom lawset
laws: Medical

# Visual
inventoryTemplateId: borgDutch
Expand Down
Loading