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 36 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
71bcf32
Add basis of grid based shipments
Alkheemist Jan 12, 2025
89425a3
test
Temoffy Jan 12, 2025
9f9baf7
Cargo Voucher added
blackknight954 Jan 12, 2025
0d51d6c
reverted cargo voucher
blackknight954 Jan 12, 2025
3e2f2e4
code refactor
Alkheemist Jan 13, 2025
25844a6
test shipment
Temoffy Jan 13, 2025
6db361d
Revert "reverted cargo voucher"
blackknight954 Jan 13, 2025
e5bd06d
unwrench servers for power consumption
Temoffy Jan 13, 2025
8dfc392
Revert "test"
Temoffy Jan 13, 2025
14b8f7c
Merge branch 'new-frontiers-14:master' into teloscontainerships
Temoffy Jan 13, 2025
a66d981
Merge pull request #2 from Temoffy/teloscontainerships
Alkheemist Jan 13, 2025
5880a60
serverside recursive dock list method
Alkheemist Jan 13, 2025
b843305
added recursive "is it our dock" to the list of docks to view
Alkheemist Jan 13, 2025
fc20285
don't use recursive yet
Alkheemist Jan 13, 2025
cc60528
Revert "don't use recursive yet"
Alkheemist Jan 13, 2025
197a0fe
Revert "added recursive "is it our dock" to the list of docks to view"
Alkheemist Jan 13, 2025
50687ec
Revert "serverside recursive dock list method"
Alkheemist Jan 13, 2025
b5359b5
need to swap branches, committing unfinished
Temoffy Jan 19, 2025
fa239a0
barrel base freight fill item done
Temoffy Jan 19, 2025
aa9550b
crate base done as well
Temoffy Jan 19, 2025
06068a3
Merge pull request #3 from Temoffy/telosshipping2
Alkheemist Jan 19, 2025
95160ff
Cargo console and Voucher. Get sprite for Voucher
blackknight954 Jan 19, 2025
2cc985d
add special type of voucher that still requires money
Alkheemist Jan 21, 2025
f27a8f7
Merge branch 'new-frontiers-14:master' into container-ships
Alkheemist Jan 21, 2025
a4b9272
yml moment. (messed up parent)
Alkheemist Jan 21, 2025
7fc5e63
fix up cargo shipment voucher system UI
Alkheemist Jan 21, 2025
8cae644
Merge branch 'master' into container-ships
Alkheemist Jan 21, 2025
1e9f802
Shipping permit sprite, and major freight rework
Temoffy Jan 22, 2025
f144a7e
Merge branch 'container-ships' into CargoContainer
Alkheemist Jan 22, 2025
9bf8d1c
Merge pull request #5 from blackknight954/CargoContainer
Alkheemist Jan 22, 2025
8f45fa9
Merge branch 'container-ships' into telosshipping5
Alkheemist Jan 22, 2025
26b716c
Merge pull request #7 from Temoffy/telosshipping5
Alkheemist Jan 22, 2025
66a8d5a
add vending machine that stocks shipment dockets + misc stuff
Alkheemist Jan 22, 2025
1b0ca19
Gray? in my overly colorful mix? unthinkable
Temoffy Jan 22, 2025
c001d92
Merge branch 'telosshipping5' of https://github.com/Temoffy/frontier-…
Temoffy Jan 22, 2025
a29231a
Merge pull request #8 from Temoffy/telosshipping5
Alkheemist Jan 22, 2025
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@ public sealed partial class ShipyardVoucherComponent : Component
/// </summary>
[DataField(required: true)]
public ShipyardConsoleUiKey ConsoleType;

// Frontier
/// <summary>
/// Whether this voucher allows for free purchase/sale or if it still costs money to purchase. Useful for allowing multiple ships without multiple IDs.
/// </summary>
[DataField]
public bool NoValue = true;
}
25 changes: 14 additions & 11 deletions Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private void OnPurchaseMessage(EntityUid shipyardConsoleUid, ShipyardConsoleComp
// Keep track of whether or not a voucher was used.
// TODO: voucher purchase should be done in a separate function.
bool voucherUsed = false;
bool hasValue = false;
if (voucher is not null)
{
if (voucher!.RedemptionsLeft <= 0)
Expand All @@ -161,7 +162,8 @@ private void OnPurchaseMessage(EntityUid shipyardConsoleUid, ShipyardConsoleComp
voucher.RedemptionsLeft--;
voucherUsed = true;
}
else
// not using an else here because the voucher might still require a purchase cost
if (voucher is null || voucher.NoValue is false)
{
if (bank.Balance <= vessel.Price)
{
Expand All @@ -176,6 +178,7 @@ private void OnPurchaseMessage(EntityUid shipyardConsoleUid, ShipyardConsoleComp
PlayDenySound(player, shipyardConsoleUid, component);
return;
}
hasValue = true;
}


Expand Down Expand Up @@ -213,10 +216,10 @@ private void OnPurchaseMessage(EntityUid shipyardConsoleUid, ShipyardConsoleComp
var deedID = EnsureComp<ShuttleDeedComponent>(targetId);

var shuttleOwner = Name(player).Trim();
AssignShuttleDeedProperties(deedID, shuttleUid, name, shuttleOwner, voucherUsed);
AssignShuttleDeedProperties(deedID, shuttleUid, name, shuttleOwner, !hasValue); // replace voucherUsed with hasValue for this, so resale has some value.

var deedShuttle = EnsureComp<ShuttleDeedComponent>(shuttleUid);
AssignShuttleDeedProperties(deedShuttle, shuttleUid, name, shuttleOwner, voucherUsed);
AssignShuttleDeedProperties(deedShuttle, shuttleUid, name, shuttleOwner, !hasValue); // replace voucherUsed with hasValue for this, so resale has some value.

if (!voucherUsed)
{
Expand Down Expand Up @@ -267,7 +270,7 @@ private void OnPurchaseMessage(EntityUid shipyardConsoleUid, ShipyardConsoleComp
EnsureComp<LinkedLifecycleGridParentComponent>(shuttleUid);

var sellValue = 0;
if (!voucherUsed)
if (hasValue)
{
if (TryComp<ShuttleDeedComponent>(targetId, out var deed))
sellValue = (int)_pricing.AppraiseGrid((EntityUid)(deed?.ShuttleUid!));
Expand All @@ -281,7 +284,7 @@ private void OnPurchaseMessage(EntityUid shipyardConsoleUid, ShipyardConsoleComp
SendPurchaseMessage(shipyardConsoleUid, player, name, secretChannel, secret: true);

PlayConfirmSound(player, shipyardConsoleUid, component);
if (voucherUsed)
if (voucherUsed && !hasValue)
_adminLogger.Add(LogType.ShipYardUsage, LogImpact.Low, $"{ToPrettyString(player):actor} used {ToPrettyString(targetId)} to purchase shuttle {ToPrettyString(shuttleUid)} with a voucher via {ToPrettyString(component.Owner)}");
else
_adminLogger.Add(LogType.ShipYardUsage, LogImpact.Low, $"{ToPrettyString(player):actor} used {ToPrettyString(targetId)} to purchase shuttle {ToPrettyString(shuttleUid)} for {vessel.Price} credits via {ToPrettyString(component.Owner)}");
Expand All @@ -296,13 +299,13 @@ private void OnPurchaseMessage(EntityUid shipyardConsoleUid, ShipyardConsoleComp
suffix: deedShuttle.ShuttleNameSuffix ?? "",
ownerName: shuttleOwner,
entityUid: _entityManager.GetNetEntity(shuttleUid),
purchasedWithVoucher: voucherUsed,
purchasedWithVoucher: !hasValue, // replace voucherUsed with hasValue for this, so resale has some value.
purchasePrice: (uint)vessel.Price
)
);
}

RefreshState(shipyardConsoleUid, bank.Balance, true, name, sellValue, targetId, (ShipyardConsoleUiKey)args.UiKey, voucherUsed);
RefreshState(shipyardConsoleUid, bank.Balance, true, name, sellValue, targetId, (ShipyardConsoleUiKey)args.UiKey, !hasValue);
}

private void TryParseShuttleName(ShuttleDeedComponent deed, string name)
Expand Down Expand Up @@ -477,7 +480,7 @@ private void OnConsoleUIOpened(EntityUid uid, ShipyardConsoleComponent component
}
}

var voucherUsed = HasComp<ShipyardVoucherComponent>(targetId);
var voucherUsed = TryComp<ShipyardVoucherComponent>(targetId, out var voucher) && voucher.NoValue is true;

int sellValue = 0;
if (deed?.ShuttleUid != null)
Expand Down Expand Up @@ -569,11 +572,11 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component
}
}

var voucherUsed = HasComp<ShipyardVoucherComponent>(targetId);
var voucherUsed = TryComp<ShipyardVoucherComponent>(targetId, out var voucher) && voucher.NoValue is true;

int sellValue = 0;
if (deed?.ShuttleUid != null)
sellValue = (int) _pricing.AppraiseGrid(deed.ShuttleUid.Value);
sellValue = (int)_pricing.AppraiseGrid(deed.ShuttleUid.Value);

sellValue -= CalculateTotalSalesTax(component, sellValue);

Expand Down Expand Up @@ -795,7 +798,7 @@ private void OnInitDeedSpawner(EntityUid uid, StationDeedSpawnerComponent compon
if (xform.GridUid == null)
return;

if (!TryComp<ShuttleDeedComponent>(xform.GridUid.Value, out var shuttleDeed) || !TryComp<ShuttleComponent>(xform.GridUid.Value, out var shuttle) || !HasComp<TransformComponent>(xform.GridUid.Value) || shuttle == null || ShipyardMap == null)
if (!TryComp<ShuttleDeedComponent>(xform.GridUid.Value, out var shuttleDeed) || !TryComp<ShuttleComponent>(xform.GridUid.Value, out var shuttle) || !HasComp<TransformComponent>(xform.GridUid.Value) || shuttle == null || ShipyardMap == null)
return;

var output = Regex.Replace($"{shuttleDeed.ShuttleOwner}", @"\s*\([^()]*\)", ""); // Removes content inside parentheses along with parentheses and a preceding space
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 Content.Shared/Shipyard/SharedShipyardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum ShipyardConsoleUiKey : byte
Expedition,
Scrap,
Sr,
Cargo,
Medical,
// Add ships to this key if they are only available from mothership consoles. Shipyards using it are inherently empty and are populated using the ShipyardListingComponent.
Custom
Expand Down
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