Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Merge branch 'new-frontiers-14:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonsant authored Apr 7, 2024
2 parents 7b876de + e56e34f commit 4b17cb6
Show file tree
Hide file tree
Showing 25 changed files with 16,672 additions and 8,037 deletions.
5 changes: 3 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

## About the PR
<!-- What did you change in this PR? -->
<!-- If this is a code change, summarize at high level how your new code works. This makes it easier to review. -->

## Why / Balance
<!-- Why was it changed? Link any discussions or issues here. Please discuss how this would affect game balance. -->

## Technical details
<!-- If this is a code change, summarize at high level how your new code works. This makes it easier to review. -->
## How to test
<!-- Describe the way it can be tested -->

## Media
<!--
Expand Down
35 changes: 18 additions & 17 deletions .github/mapchecker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@
ILLEGAL_MATCHES = [
"DO NOT MAP",
"DEBUG",
"CaptainSabre",
"ClothingBeltSheath",
"MagazinePistolHighCapacity",
"MagazinePistolHighCapacityRubber",
"EncryptionKeyCommand",
"SurveillanceCameraWireless",
"CrewMonitoringServer",
"APCHighCapacity",
"APCSuperCapacity",
"APCHyperCapacity",
"PDA",
"SpawnPointPassenger",
"Python",
"SalvageShuttleMarker",
"FTLPoint",
"Admeme",
"CaptainSabre",
"ClothingBeltSheath",
"MagazinePistolHighCapacity",
"MagazinePistolHighCapacityRubber",
"EncryptionKeyCommand",
"SurveillanceCameraWireless",
"CrewMonitoringServer",
"APCHighCapacity",
"APCSuperCapacity",
"APCHyperCapacity",
"PDA",
"SpawnPointPassenger",
"Python",
"SalvageShuttleMarker",
"FTLPoint",
]
# List of matchers that are illegal to use, unless the map is a ship and the ship belongs to the keyed shipyard.
CONDITIONALLY_ILLEGAL_MATCHES = {
"Security": [ # These matchers are illegal unless the ship is part of the security shipyard.
"Security", # Anything with the word security in it should also only be appearing on security ships.
"Plastitanium", # Plastitanium walls should only be appearing on security ships.
"Kammerer", # Opportunity
"HighSecDoor",
"Kammerer", # Opportunity
"HighSecDoor",
],
"BlackMarket": [
"Plastitanium", # And also on blackmarket ships cause syndicate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ public sealed partial class CargoPalletConsoleComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("cashType", customTypeSerializer:typeof(PrototypeIdSerializer<StackPrototype>))]
public string CashType = "Credit";

// Frontier
// The distance in a radius around the console to check for cargo pallets
// Can be modified individually when mapping, so that consoles have a further reach
[DataField("palletDistance")]
public int PalletDistance = 8;
}
57 changes: 45 additions & 12 deletions Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public sealed partial class CargoSystem
* Handles cargo shuttle / trade mechanics.
*/

// Frontier addition:
// The maximum distance from the console to look for pallets.
private const int DefaultPalletDistance = 8;

private static readonly SoundPathSpecifier ApproveSound = new("/Audio/Effects/Cargo/ping.ogg");

private void InitializeShuttle()
Expand Down Expand Up @@ -63,7 +67,7 @@ private void UpdatePalletConsoleInterface(EntityUid uid)
new CargoPalletConsoleInterfaceState(0, 0, false));
return;
}
GetPalletGoods(gridUid, out var toSell, out var amount);
GetPalletGoods(uid, gridUid, out var toSell, out var amount);
if (TryComp<MarketModifierComponent>(uid, out var priceMod))
{
amount *= priceMod.Mod;
Expand Down Expand Up @@ -111,7 +115,7 @@ private void UpdateShuttleState(EntityUid uid, EntityUid? station = null)
TryComp<StationCargoOrderDatabaseComponent>(station, out var orderDatabase);
TryComp<CargoShuttleComponent>(orderDatabase?.Shuttle, out var shuttle);

var orders = GetProjectedOrders(station ?? EntityUid.Invalid, orderDatabase, shuttle);
var orders = GetProjectedOrders(uid, station ?? EntityUid.Invalid, orderDatabase, shuttle);
var shuttleName = orderDatabase?.Shuttle != null ? MetaData(orderDatabase.Shuttle.Value).EntityName : string.Empty;

if (_uiSystem.TryGetUi(uid, CargoConsoleUiKey.Shuttle, out var bui))
Expand Down Expand Up @@ -139,6 +143,7 @@ private void OnTradeSplit(EntityUid uid, TradeStationComponent component, ref Gr
/// Returns the orders that can fit on the cargo shuttle.
/// </summary>
private List<CargoOrderData> GetProjectedOrders(
EntityUid consoleUid,
EntityUid shuttleUid,
StationCargoOrderDatabaseComponent? component = null,
CargoShuttleComponent? shuttle = null)
Expand All @@ -148,7 +153,7 @@ private List<CargoOrderData> GetProjectedOrders(
if (component == null || shuttle == null || component.Orders.Count == 0)
return orders;

var spaceRemaining = GetCargoSpace(shuttleUid);
var spaceRemaining = GetCargoSpace(consoleUid, shuttleUid);
for (var i = 0; i < component.Orders.Count && spaceRemaining > 0; i++)
{
var order = component.Orders[i];
Expand Down Expand Up @@ -177,21 +182,49 @@ private List<CargoOrderData> GetProjectedOrders(
/// <summary>
/// Get the amount of space the cargo shuttle can fit for orders.
/// </summary>
private int GetCargoSpace(EntityUid gridUid)
private int GetCargoSpace(EntityUid consoleUid, EntityUid gridUid)
{
var space = GetCargoPallets(gridUid).Count;
var space = GetCargoPallets(consoleUid, gridUid).Count;
return space;
}

private List<(EntityUid Entity, CargoPalletComponent Component, TransformComponent PalletXform)> GetCargoPallets(EntityUid gridUid)
/// <summary>
/// Frontier addition - calculates distance between two EntityCoordinates
/// Used to check for cargo pallets around the console instead of on the grid.
/// </summary>
/// <param name="point1">first point to get distance between</param>
/// <param name="point2">second point to get distance between</param>
/// <returns></returns>
public static double CalculateDistance(EntityCoordinates point1, EntityCoordinates point2)
{
var xDifference = point2.X - point1.X;
var yDifference = point2.Y - point1.Y;

return Math.Sqrt(xDifference * xDifference + yDifference * yDifference);
}

private List<(EntityUid Entity, CargoPalletComponent Component, TransformComponent PalletXform)> GetCargoPallets(EntityUid consoleUid, EntityUid gridUid)
{
_pads.Clear();
var query = AllEntityQuery<CargoPalletComponent, TransformComponent>();

while (query.MoveNext(out var uid, out var comp, out var compXform))
{
// Frontier addition - To support multiple cargo selling stations we add a distance check for the pallets.
var distance = CalculateDistance(compXform.Coordinates, Transform(consoleUid).Coordinates);
var maxPalletDistance = DefaultPalletDistance;

// Get the mapped checking distance from the console
if (TryComp<CargoPalletConsoleComponent>(consoleUid, out var cargoShuttleComponent))
{
maxPalletDistance = cargoShuttleComponent.PalletDistance;
}

var isTooFarAway = distance > maxPalletDistance;
// End of Frontier addition

if (compXform.ParentUid != gridUid ||
!compXform.Anchored)
!compXform.Anchored || isTooFarAway)
{
continue;
}
Expand Down Expand Up @@ -227,10 +260,10 @@ private int GetCargoSpace(EntityUid gridUid)

#region Station

private bool SellPallets(EntityUid gridUid, EntityUid? station, out double amount)
private bool SellPallets(EntityUid consoleUid, EntityUid gridUid, EntityUid? station, out double amount)
{
station ??= _station.GetOwningStation(gridUid);
GetPalletGoods(gridUid, out var toSell, out amount);
GetPalletGoods(consoleUid, gridUid, out var toSell, out amount);

Log.Debug($"Cargo sold {toSell.Count} entities for {amount}");

Expand All @@ -251,12 +284,12 @@ private bool SellPallets(EntityUid gridUid, EntityUid? station, out double amoun
return true;
}

private void GetPalletGoods(EntityUid gridUid, out HashSet<EntityUid> toSell, out double amount)
private void GetPalletGoods(EntityUid consoleUid, EntityUid gridUid, out HashSet<EntityUid> toSell, out double amount)
{
amount = 0;
toSell = new HashSet<EntityUid>();

foreach (var (palletUid, _, _) in GetCargoPallets(gridUid))
foreach (var (palletUid, _, _) in GetCargoPallets(consoleUid, gridUid))
{
// Containers should already get the sell price of their children so can skip those.
_setEnts.Clear();
Expand Down Expand Up @@ -340,7 +373,7 @@ private void OnPalletSale(EntityUid uid, CargoPalletConsoleComponent component,
return;
}

if (!SellPallets(gridUid, null, out var price))
if (!SellPallets(uid, gridUid, null, out var price))
return;

if (TryComp<MarketModifierComponent>(uid, out var priceMod))
Expand Down
18 changes: 18 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3932,3 +3932,21 @@ Entries:
message: Station Representative has full access now.
id: 4899
time: '2024-04-03T09:49:12.0000000+00:00'
- author: Leander
changes:
- type: Tweak
message: NFSD hour requirements have been updated.
id: 4900
time: '2024-04-04T14:38:28.0000000+00:00'
- author: Tych0theSynth
changes:
- type: Add
message: Added the SBB Lyrae, a new medium sized research vessel.
id: 4901
time: '2024-04-07T00:32:09.0000000+00:00'
- author: MoistBiscuits
changes:
- type: Add
message: 'Added the NC Piecrust: a combination ranch and pie bakery vessel'
id: 4902
time: '2024-04-07T02:37:35.0000000+00:00'
Loading

0 comments on commit 4b17cb6

Please sign in to comment.