Skip to content

Commit 602ae8d

Browse files
authored
Almost exclusively bugfixes
2 parents c8e48e0 + 871efd2 commit 602ae8d

56 files changed

Lines changed: 2003 additions & 170 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/directory-validator.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ jobs:
1111
- name: Checkout repository
1212
uses: actions/checkout@v3
1313

14-
- name: List Prototypes directory
15-
run: ls -l Resources/Prototypes
16-
17-
- name: Check for Resources/Prototypes/_StarLight directory
14+
- name: Check for StarLight folders
1815
run: |
19-
if [ -d "Resources/Prototypes/_StarLight" ]; then
20-
echo "::error::Directory Resources/Prototypes/_StarLight exists! It should be _Starlight."
16+
bad_paths="$(find . -path './.git' -prune -o -type d -name '*StarLight*' -print)"
17+
18+
if [ -n "$bad_paths" ]; then
19+
echo "::error::Found folders using StarLight. They should use Starlight."
20+
echo "$bad_paths"
2121
exit 1
2222
else
23-
echo "No typo directory found."
23+
echo "No StarLight folders found."
2424
fi
2525
2626
- name: Validate _Starlight namespaces
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Content.Shared._Starlight.Cargo.TamperSeal;
2+
using Content.Shared._Starlight.Cargo.TamperSeal.Components;
3+
using Robust.Shared.GameObjects;
4+
5+
namespace Content.Client._Starlight.Cargo.TamperSeal;
6+
7+
/// <inheritdoc/>
8+
public sealed class TamperSealSystem : SharedTamperSealSystem
9+
{
10+
public override void Initialize()
11+
{
12+
base.Initialize();
13+
SubscribeLocalEvent<TamperSealComponent, AfterAutoHandleStateEvent>(OnAfterHandleState);
14+
}
15+
16+
/// <summary>
17+
/// Trigger a visuals update on state change. This makes VV writes trigger a visuals update.
18+
/// </summary>
19+
private void OnAfterHandleState(EntityUid uid, TamperSealComponent seal, ref AfterAutoHandleStateEvent args)
20+
{
21+
if (TryComp<AppearanceComponent>(uid, out var appearance))
22+
Appearance.QueueUpdate(uid, appearance);
23+
}
24+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Content.Shared._Starlight.Cargo.TamperSeal.Components;
2+
using Robust.Client.GameObjects;
3+
4+
namespace Content.Client._Starlight.Cargo.TamperSeal;
5+
6+
/// <summary>
7+
/// Visualizes a container that is tamper-sealed.
8+
/// </summary>
9+
public sealed partial class TamperSealVisualizerSystem : VisualizerSystem<TamperSealComponent>
10+
{
11+
[Dependency] private AppearanceSystem _appearance = default!;
12+
[Dependency] private SpriteSystem _sprite = default!;
13+
14+
protected override void OnAppearanceChange(EntityUid uid, TamperSealComponent component,
15+
ref AppearanceChangeEvent args)
16+
{
17+
if (args.Sprite == null)
18+
return;
19+
20+
var opened = component.Opened;
21+
var destroyed = component.Destroyed;
22+
var color = component.Color;
23+
24+
var ent = (uid, args.Sprite);
25+
ShowLayerConditional(ent, TamperSealLayers.Base, color, true);
26+
ShowLayerConditional(ent, TamperSealLayers.Sealed, color, !opened);
27+
ShowLayerConditional(ent, TamperSealLayers.Opened, color, opened);
28+
ShowLayerConditional(ent, TamperSealLayers.Destroyed, color, opened && destroyed);
29+
}
30+
31+
/// <summary>
32+
/// Sets layer visibility and color if it exists.
33+
/// </summary>
34+
private void ShowLayerConditional(Entity<SpriteComponent?> sprite, Enum layerKey, Color color, bool value)
35+
{
36+
if (_sprite.LayerMapTryGet(sprite, layerKey, out var layer, false))
37+
{
38+
_sprite.LayerSetVisible(sprite, layer, value);
39+
_sprite.LayerSetColor(sprite, layer, color);
40+
}
41+
}
42+
43+
}

Content.Client/_Starlight/ViewVariables/ClientViewVariablesSystem.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Content.Shared._Starlight.ViewVariables;
22
using Robust.Client.Console;
3+
using Robust.Client.ViewVariables;
4+
using Robust.Shared.Localization;
35

46
namespace Content.Client._Starlight.ViewVariables;
57

@@ -9,11 +11,14 @@ namespace Content.Client._Starlight.ViewVariables;
911
public sealed partial class ClientViewVariablesSystem : EntitySystem
1012
{
1113
[Dependency] private IClientConsoleHost _shell = default!;
14+
[Dependency] private IViewVariableControlFactory _vvFactory = default!;
1215

1316
public override void Initialize()
1417
{
1518
base.Initialize();
1619

20+
_vvFactory.RegisterForType<LocId>(_ => new VVPropEditorLocId());
21+
1722
SubscribeNetworkEvent<OpenViewVariablesEvent>(OnOpenViewVariables);
1823
}
1924

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Robust.Client.UserInterface;
2+
using Robust.Client.UserInterface.Controls;
3+
using Robust.Client.ViewVariables;
4+
5+
namespace Content.Client._Starlight.ViewVariables;
6+
7+
/// <summary>
8+
/// Adds a text editor field for LocId properties in ViewVariables.
9+
/// </summary>
10+
// ReSharper disable once InconsistentNaming
11+
internal sealed class VVPropEditorLocId : VVPropEditor
12+
{
13+
protected override Control MakeUI(object? value)
14+
{
15+
var locId = value is LocId l ? l : default;
16+
var lineEdit = new LineEdit
17+
{
18+
Text = locId.Id ?? "",
19+
Editable = !ReadOnly,
20+
HorizontalExpand = true,
21+
};
22+
23+
if (!ReadOnly)
24+
lineEdit.OnTextEntered += e => ValueChanged(new LocId(e.Text));
25+
26+
return lineEdit;
27+
}
28+
}

Content.IntegrationTests/Tests/_StarLight/Body/LegTest.cs renamed to Content.IntegrationTests/Tests/_Starlight/Body/LegTest.cs

File renamed without changes.

Content.IntegrationTests/Tests/_StarLight/Body/LungTest.cs renamed to Content.IntegrationTests/Tests/_Starlight/Body/LungTest.cs

File renamed without changes.

Content.IntegrationTests/Tests/_StarLight/Body/SaveLoadReparentTest.cs renamed to Content.IntegrationTests/Tests/_Starlight/Body/SaveLoadReparentTest.cs

File renamed without changes.

Content.IntegrationTests/Tests/_StarLight/Spawner/TimedSpawnerDespawnTest.cs renamed to Content.IntegrationTests/Tests/_Starlight/Spawner/TimedSpawnerDespawnTest.cs

File renamed without changes.

Content.Server/Cargo/Systems/CargoSystem.Orders.cs

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@
1313
using Content.Shared.Labels.Components;
1414
using Content.Shared.Paper;
1515
using Content.Shared.Station.Components;
16+
using Content.Shared.Tools;
1617
using JetBrains.Annotations;
1718
using Robust.Shared.Map;
1819
using Robust.Shared.Prototypes;
1920
using Robust.Shared.Timing;
2021
using Robust.Shared.Utility;
2122

23+
#region Starlight
24+
using Content.Shared._Starlight.Cargo.TamperSeal.Components;
25+
using Content.Server._Starlight.Cargo.TamperSeal.Components;
26+
using Content.Shared._Starlight.CCVar;
27+
using Content.Shared.Access;
28+
#endregion
29+
2230
namespace Content.Server.Cargo.Systems
2331
{
2432
public sealed partial class CargoSystem
@@ -27,6 +35,12 @@ public sealed partial class CargoSystem
2735
[Dependency] private EmagSystem _emag = default!;
2836
[Dependency] private IGameTiming _timing = default!;
2937

38+
#region Starlight
39+
private float _tamperSealRewardMultiplier = 0.1f;
40+
private float _tamperSealPenaltyMultiplier = 0.1f;
41+
private float _tamperSealRefundMultiplier = 0.5f;
42+
#endregion
43+
3044
private void InitializeConsole()
3145
{
3246
SubscribeLocalEvent<CargoOrderConsoleComponent, CargoConsoleAddOrderMessage>(OnAddOrderMessage);
@@ -36,6 +50,12 @@ private void InitializeConsole()
3650
SubscribeLocalEvent<CargoOrderConsoleComponent, ComponentInit>(OnInit);
3751
SubscribeLocalEvent<CargoOrderConsoleComponent, InteractUsingEvent>(OnInteractUsing);
3852
SubscribeLocalEvent<CargoOrderConsoleComponent, GotEmaggedEvent>(OnEmagged);
53+
54+
// Starlight BEGIN
55+
_cfg.OnValueChanged(StarlightCCVars.TamperSealRewardMultiplier, v => _tamperSealRewardMultiplier = v, true);
56+
_cfg.OnValueChanged(StarlightCCVars.TamperSealPenaltyMultiplier, v => _tamperSealPenaltyMultiplier = v, true);
57+
_cfg.OnValueChanged(StarlightCCVars.TamperSealRefundMultiplier, v => _tamperSealRefundMultiplier = v, true);
58+
// Starlight END
3959
}
4060

4161
private void OnInteractUsingCash(EntityUid uid, CargoOrderConsoleComponent component, ref InteractUsingEvent args)
@@ -76,7 +96,7 @@ private void OnInteractUsingSlip(Entity<CargoOrderConsoleComponent> ent, ref Int
7696
return;
7797

7898
var orderId = GenerateOrderId(orderDatabase);
79-
var data = new CargoOrderData(orderId, product.Product, product.Name, product.Cost, slip.OrderQuantity, slip.Requester, slip.Reason, slip.Account);
99+
var data = new CargoOrderData(orderId, product.Product, product.Name, product.Cost, slip.OrderQuantity, slip.Requester, slip.Reason, slip.Account, GetNetEntity(stationUid.Value)); // Starlight: +stationUid
80100

81101
if (!TryAddOrder(stationUid.Value, ent.Comp.Account, data, orderDatabase))
82102
{
@@ -386,7 +406,7 @@ private void OnAddOrderMessage(EntityUid uid, CargoOrderConsoleComponent compone
386406

387407
var targetAccount = component.Mode == CargoOrderConsoleMode.SendToPrimary ? bank.PrimaryAccount : component.Account;
388408

389-
var data = GetOrderData(args, product, GenerateOrderId(orderDatabase), component.Account);
409+
var data = new CargoOrderData(GenerateOrderId(orderDatabase), product.Product, product.Name, product.Cost, args.Amount, args.Requester, args.Reason, component.Account, GetNetEntity(stationUid.Value)); // Starlight: +stationUid
390410

391411
if (!TryAddOrder(stationUid.Value, targetAccount, data, orderDatabase))
392412
{
@@ -464,10 +484,15 @@ private void PlayDenySound(EntityUid uid, CargoOrderConsoleComponent component)
464484
}
465485
}
466486

487+
#region Starlight
488+
// This is an upstream method, but it is now unused due to our changes elsewhere in this file.
489+
/*
467490
private static CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id, ProtoId<CargoAccountPrototype> account)
468491
{
469492
return new CargoOrderData(id, cargoProduct.Product, cargoProduct.Name, cargoProduct.Cost, args.Amount, args.Requester, args.Reason, account);
470493
}
494+
*/
495+
#endregion
471496

472497
public int GetOutstandingOrderCount(Entity<StationCargoOrderDatabaseComponent> station, ProtoId<CargoAccountPrototype> account)
473498
{
@@ -534,7 +559,7 @@ Entity<StationDataComponent> stationData
534559
DebugTools.Assert(_protoMan.HasIndex<EntityPrototype>(spawnId));
535560
// Make an order
536561
var id = GenerateOrderId(component);
537-
var order = new CargoOrderData(id, spawnId, name, cost, qty, sender, description, account);
562+
var order = new CargoOrderData(id, spawnId, name, cost, qty, sender, description, account, GetNetEntity(stationData.Owner)); // Starlight: +stationUid
538563

539564
// Approve it now
540565
order.SetApproverData(dest, sender);
@@ -652,8 +677,37 @@ private bool FulfillOrder(CargoOrderData order, ProtoId<CargoAccountPrototype> a
652677
}
653678
}
654679

680+
// Starlight BEGIN
681+
// If the entity does not support tamper seals, do not apply one.
682+
if (!TryComp<TamperSealableComponent>(item, out var tamperSealable))
683+
return true;
684+
685+
var recipient = _protoMan.Index(account);
686+
687+
// Apply a tamper seal to the entity. This does the actual sealing logic.
688+
var seal = EnsureComp<TamperSealComponent>(item);
689+
seal.Recipient = account;
690+
seal.RecipientName = recipient.TamperSealName;
691+
seal.RecipientExamineColor = recipient.Color;
692+
seal.Color = recipient.TamperSealColor;
693+
seal.Accesses = new List<TamperSealAccessPattern>(recipient.TamperSealAccesses);
694+
seal.DestroyToolQualities = new HashSet<ProtoId<ToolQualityPrototype>>(tamperSealable.DestroyToolQualities);
695+
696+
// Attach a tamper seal value component to enable reward/penalty on unseal/destroy.
697+
var value = EnsureComp<TamperSealValueComponent>(item);
698+
value.StationId = GetEntity(order.StationId);
699+
value.Value = order.Price;
700+
value.Reward = (int) Math.Floor(_tamperSealRewardMultiplier * order.Price); // Rewards rounded down.
701+
value.Penalty = (int) Math.Ceiling(_tamperSealPenaltyMultiplier * order.Price); // Penalties rounded up.
702+
value.Refund = (int) Math.Ceiling(_tamperSealRefundMultiplier * order.Price); // Refunds rounded up.
703+
704+
// Attach an integrity component. This is used by the integrity system to detect repeat tampering.
705+
var integrity = EnsureComp<TamperSealIntegrityBeaconComponent>(item);
706+
integrity.StationId = GetEntity(order.StationId);
707+
708+
DirtyEntity(item);
655709
return true;
656-
710+
// Starlight END
657711
}
658712

659713
public List<ProtoId<CargoProductPrototype>> GetAvailableProducts(Entity<CargoOrderConsoleComponent> ent)

0 commit comments

Comments
 (0)