Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 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
3 changes: 3 additions & 0 deletions Content.Client/Cargo/UI/FundingAllocationMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ private void BuildEntries()
{
var accountProto = _prototypeManager.Index(account);

if (accountProto.Independent == true)
Comment thread
Mehnix marked this conversation as resolved.
continue;

var accountNameLabel = new RichTextLabel
{
Modulate = accountProto.Color,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public sealed partial class StationCargoOrderDatabaseComponent : Component
[DataField]
public List<ProtoId<CargoMarketPrototype>> Markets = new()
{
"market",
"market", // Request Consoles
"salvage", // Salvage Requisition Console
};

// TODO: Can probably dump this
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Content.Shared.Interaction;
using Content.Shared.Labels.Components;
using Content.Shared.Paper;
using Content.Shared.Stacks;
using Content.Shared.Station.Components;
using JetBrains.Annotations;
using Robust.Shared.Map;
Expand Down Expand Up @@ -95,7 +96,7 @@ private void OnInteractUsingSlip(Entity<CargoOrderConsoleComponent> ent, ref Int

private void OnInteractUsing(EntityUid uid, CargoOrderConsoleComponent component, ref InteractUsingEvent args)
{
if (HasComp<CashComponent>(args.Used))
if (TryComp<StackComponent>(args.Used, out var stackComp) && stackComp.StackTypeId == component.CashType)
{
OnInteractUsingCash(uid, component, ref args);
}
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Lathe/LatheSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ public void FinishProducing(EntityUid uid, LatheComponent? comp = null, LathePro
_puddle.TrySpillAt(uid, toAdd, out _);
}
}

var ev = new LatheFinishPrintingEvent(_proto.Index(comp.CurrentRecipe));
RaiseLocalEvent(uid, ref ev);
}

comp.CurrentRecipe = null;
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/Materials/MaterialReclaimerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ public override void Reclaim(EntityUid uid,
SpawnChemicalsFromComposition(uid, item, completion, true, component, xform);
}

var ev = new ReclaimFinishedEvent(item);
RaiseLocalEvent(uid, ref ev);
QueueDel(item);
}

Expand Down
38 changes: 38 additions & 0 deletions Content.Server/TicketPrinter/TicketPrinterSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Shared.TicketPrinter;
using Robust.Shared.Prototypes;
using Content.Server.Stack;
Comment thread
Mehnix marked this conversation as resolved.
Outdated

namespace Content.Server.TicketPrinter;

public sealed class TicketPrinterSystem : SharedTicketPrinterSystem
{
[Dependency] private readonly StackSystem _stack = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
public override void Initialize()
{
base.Initialize();
}

/// <summary>
/// Applies ticket multiplier and spawns tickets, stores any remainder for future spawns
/// </summary>
/// <param name="ent">Entity spawning the tickets</param>
/// <param name="amount">Base amount of tickets to spawn</param>
protected override void PrintTickets(Entity<TicketPrinterComponent> ent, float amount)
{
if (!_proto.Resolve(ent.Comp.TicketProtoId, out var proto)) //does it exist?
return; //Will return Invalid EntProtoId errors if trying to spawn an entity proto ID that doesn't exist.

var spawnAmount = ent.Comp.Remainder + amount * ent.Comp.TicketMultiplier; //apply multiplier, then add on any remainders of previous prints.

if (spawnAmount <= 0) //if we're somehow less than zero don't print
return;

var tickets = _stack.SpawnMultipleAtPosition(proto, (int)Math.Floor(spawnAmount), Transform(ent).Coordinates);

foreach (var ticket in tickets)
_stack.TryMergeToContacts(ticket); //try to make into a single stack

ent.Comp.Remainder = spawnAmount - (float)Math.Floor(spawnAmount); //can't spawn fractional tickets so store for the future
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public sealed partial class CargoOrderConsoleComponent : Component
public TimeSpan UnboundedAccountActionDelay = TimeSpan.FromSeconds(10);

/// <summary>
/// The stack representing cash dispensed on withdrawals.
/// The stack prototype accepted by the console as cash and dispensed on withdrawals.
/// </summary>
[DataField]
public ProtoId<StackPrototype> CashType = "Credit";
Expand All @@ -81,9 +81,6 @@ public sealed partial class CargoOrderConsoleComponent : Component
public List<ProtoId<CargoMarketPrototype>> AllowedGroups = new()
{
"market",
"SalvageJobReward2",
"SalvageJobReward3",
"SalvageJobRewardMAX",
};

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public sealed partial class StationBankAccountComponent : Component
{ "Science", 1000 },
{ "Security", 1000 },
{ "Service", 1000 },
{ "Salvage", 1000 },
};

/// <summary>
Expand All @@ -55,6 +56,7 @@ public sealed partial class StationBankAccountComponent : Component
{ "Science", 0.20 },
{ "Security", 0.20 },
{ "Service", 0.20 },
{ "Salvage", 0 },
};

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Cargo/Prototypes/CargoAccountPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,10 @@ public sealed partial class CargoAccountPrototype : IPrototype
/// </summary>
[DataField]
public EntProtoId AcquisitionSlip;

/// <summary>
/// Whether the account is Independently operated, and so should not appear within the funding allocation console
/// </summary>
[DataField]
public bool Independent = false;
}
6 changes: 6 additions & 0 deletions Content.Shared/Lathe/LatheComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,10 @@ public LatheRecipeBatch(ProtoId<LatheRecipePrototype> recipe, int itemsPrinted,
/// </summary>
[ByRefEvent]
public readonly record struct LatheStartPrintingEvent(LatheRecipePrototype Recipe);

/// <summary>
/// Event raised on a lathe when it finishes producing a recipe.
/// </summary>
[ByRefEvent]
public readonly record struct LatheFinishPrintingEvent(LatheRecipePrototype Recipe);
}
6 changes: 6 additions & 0 deletions Content.Shared/Materials/SharedMaterialReclaimerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,9 @@ public override void Update(float frameTime)

[ByRefEvent]
public record struct GotReclaimedEvent(EntityCoordinates ReclaimerCoordinates);

/// <summary>
/// Event raised on a reclaimer when it finishes reclaiming an entity.
/// </summary>
[ByRefEvent]
public record struct ReclaimFinishedEvent(EntityUid Item);
79 changes: 79 additions & 0 deletions Content.Shared/TicketPrinter/SharedTicketPrinterSystem.cs
Comment thread
Mehnix marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using Content.Shared.Lathe;
using Content.Shared.Stacks;
using Content.Shared.Materials;
using Content.Shared.Whitelist;
using Robust.Shared.Prototypes;
using Robust.Shared.GameObjects;
Comment thread
Mehnix marked this conversation as resolved.
Outdated

namespace Content.Shared.TicketPrinter;

public abstract class SharedTicketPrinterSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<TicketPrinterComponent, LatheFinishPrintingEvent>(OnPrint);
SubscribeLocalEvent<TicketPrinterComponent, ReclaimFinishedEvent>(OnReclaimed);
}

/// <summary>
/// Print tickets when lathe prints entities with a ticket value
/// </summary>
/// <param name="ent">The lathe</param>
/// <param name="args">event containing recipe</param>
private void OnPrint(Entity<TicketPrinterComponent> ent, ref LatheFinishPrintingEvent args)
{
if (args.Recipe.Result is not { } resultProto) //is the result empty, if not set as resultProto
return;

var entProto = _proto.Index(resultProto);
if (!entProto.TryGetComponent<TicketValueComponent>(out var ticketComp, EntityManager.ComponentFactory)) //does component exist from EntityProtoId of recipe result
return;

if (entProto.TryGetComponent<StackComponent>(out var stackComp, EntityManager.ComponentFactory))//if a stack, produce tickets for each item in the stack
PrintTickets(ent, ticketComp.TicketValue * stackComp.Count);
else
PrintTickets(ent, ticketComp.TicketValue);
}

/// <summary>
/// print tickets when reclaimer reclaims entities with a ticket value
/// </summary>
/// <param name="ent">the reclaimer</param>
/// <param name="args">reclaim event containing reclaimed item</param>
private void OnReclaimed(Entity<TicketPrinterComponent> ent, ref ReclaimFinishedEvent args)
{
if (_whitelistSystem.IsWhitelistFail(ent.Comp.Whitelist, args.Item)) //plenty of things are reclaimable but only some salvagable, should only give tickets for salvage scrap.
return;

if (!TryComp<PhysicalCompositionComponent>(args.Item, out var physComp))
return;

foreach (var (material, amount) in physComp.MaterialComposition) //for each material making up the reclaimed item's physical composition
{
if (amount <= 0 || !_proto.TryIndex<MaterialPrototype>(material, out var materialProto) || materialProto.StackEntity == null) //get that material's Material Prototype
continue;
var entProto = _proto.Index<EntityPrototype>(materialProto.StackEntity); //use that to get its entity prototype

if (!entProto.TryGetComponent<TicketValueComponent>(out var ticketComp, EntityManager.ComponentFactory) ||
!entProto.TryGetComponent<PhysicalCompositionComponent>(out var matphysComp, EntityManager.ComponentFactory)) //use that to get TicketValue and PhysicalComposition Components
continue; //theoretically an entity may have some materials that do and some materials that don't have ticket values so we have to check them all.

PrintTickets(ent, ticketComp.TicketValue * amount / matphysComp.MaterialComposition[materialProto.ID]);
}
}

/// <summary>
/// spawn appropriate amount of tickets
/// considerations of stack amounts should occur before this point
/// Ticketprinter modifer applied in this function
/// </summary>
/// <param name="ent">the entity printing the tickets</param>
/// <param name="amount">amount of tickets </param>
protected virtual void PrintTickets(Entity<TicketPrinterComponent> ent, float amount)
{
}
}
34 changes: 34 additions & 0 deletions Content.Shared/TicketPrinter/TicketPrinterComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Content.Shared.Whitelist;
using Robust.Shared.Prototypes;

namespace Content.Shared.TicketPrinter;

[RegisterComponent]
///<summary>
/// Spawns bonus entities on creation of entities with a <see cref="TicketValueComponent"/> through crafting or reclaiming
///</summary>
public sealed partial class TicketPrinterComponent : Component
{
/// <summary>
/// Entity Prototype to spawn as the "Ticket"
/// </summary>
[DataField, ViewVariables]
public EntProtoId TicketProtoId = "SalvageTicket";

/// <summary>
/// How much to multiply the <see cref="TicketValueComponent"/> ticket value by, default 1.
/// </summary>
[DataField, ViewVariables]
public float TicketMultiplier = 1f;

[DataField, ViewVariables]
/// <summary>
/// Whitelist of allowed items that will produce tickets, if no whitelist everything is allowed
/// </summary>
public EntityWhitelist? Whitelist;

/// <summary>
/// If ticket value ends up less than 1, or has a remainder, store it for the future.
/// </summary>
public float Remainder = 0f;
}
14 changes: 14 additions & 0 deletions Content.Shared/TicketPrinter/TicketValueComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Content.Shared.TicketPrinter;

[RegisterComponent]
///<summary>
/// Contains the base amount of tickets that will be spawned by <see cref="TicketPrinterComponent"/> when this entity is crafted or reclaimed
///</summary>
public sealed partial class TicketValueComponent : Component
{
/// <summary>
/// Base amount of tickets to spawn
/// </summary>
[DataField]
public float TicketValue = 1f;
}
8 changes: 7 additions & 1 deletion Resources/Locale/en-US/cargo/bounties.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ bounty-item-flash = Flash
bounty-item-tooth-space-carp = Space Carp Tooth
bounty-item-tooth-sharkminnow = Sharkminnow Tooth
bounty-item-ring = Ring
bounty-item-remains = Hivelord Remains
bounty-item-hivelord-remains = Hivelord Remains
bounty-item-plates = Goliath Hide Plates
bounty-item-ore = Any Ore

bounty-description-artifact = NanoTrasen is in some hot water for stealing artifacts from non-spacefaring planets. Return one and we'll compensate you for it.
bounty-description-baseball-bat = Baseball fever is going on at CentComm! Be a dear and ship them some baseball bats, so that management can live out their childhood dream.
Expand Down Expand Up @@ -147,3 +148,8 @@ bounty-description-cotton-boll = A massive swarm of mothroaches ate all the pape
bounty-description-microwave-machine-board = Mr. Giggles thought it'd be funny to stick forks in all the kitchen microwaves. Help us replace them before the chefs start making clown burgers.
bounty-description-flashes = GREETINGS \[Station] WE REQUIRE 6 FLASHES DUE TO A NORMAL \[TrainingExercise] WITH SECURITY. EVERYTHING IS \[Normal].
bounty-description-ring = On this EXTRAORDINARY day there will be a wedding between the Gelts, but Mr. Gelt has lost the rings. They need a new pair.
bounty-description-tooth-space-carp = Our culinary research division has been trialing a new set of carp-tooth cutlery for our next gala event, could you provide us with some fishy dentures for the next batch?
bounty-description-ore = Station Delta's salvage team has yet to come back from their latest expedition, can you send them some ores? Their Science Department is threatening to revolt.
bounty-description-tooth-sharkminnow = We've received worrying news that a tribe of lava planet-dwelling lizard people have somehow managed to storm one of our stations. Their leader demands a crown of Sharkminnow teeth as a sign of amnesty, could you get us some so they go away?
bounty-description-diamond = Diamonds are a girl's best friend, and our industrial-grade machining lathe sure looks like she could use them, mind grabbing a few?
bounty-description-hivelord-remains = The Hivelord is a mysterious and wonderful creature, an enigma of natural evolution. Kill and gut one for us then send its remains, we'd like to see what makes it tick. Beware they rot quickly.
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/cargo/cargo-accounts.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ cargo-account-security-code = SEC

cargo-account-service-name = Collective Service Holdings
cargo-account-service-code = SRV

cargo-account-salvage-name = Salvage Requisitions
cargo-account-salvage-code = SLV
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/materials/units.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ materials-unit-boll = boll
# bills of spesos... not very good but they are not (yet?) used for crafting anything
# also the lathe/atm would need bigger denominations to output...
materials-unit-bill = bill

# stacks of tokens
materials-unit-ticket = stack
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ cargoproduct-category-name-science = Science
cargoproduct-category-name-security = Security
cargoproduct-category-name-service = Service
cargoproduct-category-name-shuttle = Shuttle

cargoproduct-category-name-salv-equipment = Equipment
cargoproduct-category-name-salv-hardsuits = Hardsuits
cargoproduct-category-name-salv-weapons = Weapons
cargoproduct-category-name-salv-other = Other
28 changes: 0 additions & 28 deletions Resources/Locale/en-US/salvage/job-board.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,3 @@ job-board-label-text = [head=2]Salvage Job Shipment[/head]


{"[italic]Shipments are subject to inspection by the Donk corporation[/italic]"}

salv-job-board-name-BountyTeethSpaceCarp = Space Carp
salv-job-board-name-BountySalvageScrap = Deep-Space Debris
salv-job-board-name-BountySalvageOreGold = Gold (Ore)
salv-job-board-name-BountySalvageOreSilver = Silver (Ore)

salv-job-board-name-BountySalvageOreUranium = Uranium (Ore)
salv-job-board-name-BountySalvageOrePlasma = Plasma (Ore)
salv-job-board-name-BountySalvageOreBananium = Bananium (Ore)
salv-job-board-name-BountyTeethSharkminnow = Sharkminnow

salv-job-board-name-BountyGoliathPlates = Goliath
salv-job-board-name-BountyHivelordRemains = Hivelord
salv-job-board-name-BountySalvageDiamond = Diamond

bounty-description-tooth-space-carp = We need you to get a sample of some space carp teeth. You can find these guys on all kinds of salvage debris. Just be careful about their bite.
bounty-description-salvage-scrap = We are researching the effects of deep space on station materials, and we need some samples. Find some old junk off of debris and bring it to us.
bounty-description-salvage-ore-gold = We are engaging in an experimental new electronics manufacturing process. Deliver us a large sum of unrefined gold ore. It can come from any source.
bounty-description-salvage-ore-silver = We are studying the material effects of silver based on the refining methods. Send us a large amount of unrefined silver ore. It can come from any source.

bounty-description-tooth-sharkminnow = We need you to get a sample of some Sharkminnow teeth. These guys are a fair bit nastier than the smaller carp you're familiar with. Take care to not let them bite you: they'll suck out your blood and heal.
bounty-description-salvage-ore-plasma = We need a shipment of plasma ore to send over to the research station. Please provide us with some so that we can continue our testing. It can come from any source.
bounty-description-salvage-ore-uranium = We need a sample of uranium ore for our ongoing experiments on nuclear devices. Be aware that while the uranium does glow slightly, it will probably not harm you. It can come from any source.
bounty-description-salvage-ore-bananium = We have an ongoing project to decode the mystifying clown genomic sequence. We believe a sample of raw bananium will help us achieve this. Note that this only comes from the rarest of deep-space asteroids.

bounty-description-remains = We need you to get a sample of a few Hivelord cores. Be aware that Hivelords can replicate infinitely if the core is not destroyed. Take care not to get overwhelmed.
bounty-description-plates = We need you to get a couple sheets of Goliath hide. These guys are pretty slow, but be careful about the tentacles: they'll grab you and pull you to the ground. You don't want to know what happens next.
bounty-description-diamond = We need you to acquire a few diamonds for some advanced fabrication. These can either be found in the mining asteroid nearby or cut out of the basilisk creature. Whichever way you want to do it, get us some.
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/stack/stacks.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ stack-artifact-fragment = artifact {$amount ->
*[other] fragments
}

stack-salvage-ticket = {$amount ->
[1] token
*[other] tokens
}

# best materials
stack-ground-tobacco = ground tobacco
stack-ground-cannabis = ground cannabis
Expand Down
Loading
Loading