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

Cargo Containers: An alternative to crate hauling #2703

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
1 change: 1 addition & 0 deletions Content.Server/Cargo/Systems/CargoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public override void Initialize()
InitializeBounty();
// Frontier: add specific initialization calls here.
InitializePirateBounty();
InitializeShipmentPrice();
// End Frontier
}

Expand Down
14 changes: 14 additions & 0 deletions Content.Server/_NF/Cargo/Components/ShipmentPriceComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Robust.Shared.Prototypes;

namespace Content.Server.Cargo.Components;

// Component to give an object an inflated apprasial price at certain shipyards.
[RegisterComponent]
public sealed partial class ShipmentPriceComponent : Component
{
/// <summary>
/// The price of the object at the destination shipyard.
/// </summary>
[DataField("bonusPrice", required: true)]
public int BonusPrice;
}
10 changes: 10 additions & 0 deletions Content.Server/_NF/Cargo/Components/ShipmentRecieveComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Robust.Shared.Prototypes;

namespace Content.Server.Cargo.Components;

// Component to mark a station as a valid destination for shipments
[RegisterComponent]
public sealed partial class ShipmentRecieveComponent : Component
{

}
36 changes: 36 additions & 0 deletions Content.Server/_NF/Cargo/Systems/ShipmentPriceSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Content.Server.Cargo.Components;
using Content.Server.Shuttles.Systems;

namespace Content.Server.Cargo.Systems; // Needs to collide with base namespace

public sealed partial class CargoSystem
{

[Dependency] private readonly DockingSystem _docking = default!;
private void InitializeShipmentPrice()
{
SubscribeLocalEvent<ShipmentPriceComponent, PriceCalculationEvent>(OnShipmentGetPriceEvent);
}

private void OnShipmentGetPriceEvent(Entity<ShipmentPriceComponent> entity, ref PriceCalculationEvent ev)
{
if (!TryComp(entity, out TransformComponent? xform))
{
return; //how do we not have a transform?
}
var currentShuttle = xform.GridUid;
if (currentShuttle != null)
{
var shuttleDocks = _docking.GetDocks((EntityUid)currentShuttle); //check we're docked to a destination grid
foreach (var shuttleDock in shuttleDocks)
{
// If the ship we're on is docked with a dock that is on a grid that is tagged, add bonus price and break.
if (shuttleDock.Comp.DockedWith != null && TryComp<TransformComponent>(shuttleDock.Comp.DockedWith, out var dock) && HasComp<ShipmentRecieveComponent>(dock.GridUid))
{
ev.Price = entity.Comp.BonusPrice;
break;
}
}
}
}
}
1 change: 1 addition & 0 deletions Resources/Maps/_NF/POI/trade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2516,6 +2516,7 @@ entities:
- type: NavMap
- type: BecomesStation
id: Trade
- type: ShipmentRecieve
- proto: AirAlarm
entities:
- uid: 6079
Expand Down
1 change: 1 addition & 0 deletions Resources/Maps/_NF/POI/trademall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5326,6 +5326,7 @@ entities:
- type: IFF
- type: StationMember
- type: NavMap
- type: ShipmentRecieve
- proto: AirAlarm
entities:
- uid: 216
Expand Down
Loading
Loading