Skip to content

Commit

Permalink
Merge branch 'master' into 2023-12-31-CrimeApp
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 authored Apr 4, 2024
2 parents 919b4e0 + 16a3b85 commit 71c8eec
Show file tree
Hide file tree
Showing 435 changed files with 48,243 additions and 37,643 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
36 changes: 36 additions & 0 deletions Content.Server/Chemistry/ReagentEffects/DisintegrateArtifact.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Content.Server.Xenoarchaeology.XenoArtifacts;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;

namespace Content.Server.Chemistry.ReagentEffects;

public sealed partial class DisintegrateArtifact : ReagentEffect
{

/// <summary>
/// Disintegrate chance
/// </summary>
[DataField("probabilityMin"), ViewVariables(VVAccess.ReadWrite)]
public float ProbabilityMax = 0.05f;

/// <summary>
/// Disintegrate chance
/// </summary>
[DataField("probabilityMax"), ViewVariables(VVAccess.ReadWrite)]
public float ProbabilityMin = 0.15f;

/// <summary>
/// The range around the artifact that it will spawn the entity
/// </summary>
[DataField("range")]
public float Range = 0.5f;

public override void Effect(ReagentEffectArgs args)
{
var artifact = args.EntityManager.EntitySysManager.GetEntitySystem<ArtifactSystem>();
artifact.DisintegrateArtifact(args.SolutionEntity, ProbabilityMin, ProbabilityMax, Range);
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
null;
}
10 changes: 9 additions & 1 deletion Content.Server/GameTicking/GameTicker.Spawning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,15 @@ private void SpawnPlayer(ICommonSession player, HumanoidCharacterProfile charact

_playTimeTrackings.PlayerRolesChanged(player);

var mobMaybe = _stationSpawning.SpawnPlayerCharacterOnStation(station, job, character);
// Delta-V: Add AlwaysUseSpawner.
var spawnPointType = SpawnPointType.Unset;
if (jobPrototype.AlwaysUseSpawner)
{
lateJoin = false;
spawnPointType = SpawnPointType.Job;
}

var mobMaybe = _stationSpawning.SpawnPlayerCharacterOnStation(station, job, character, spawnPointType: spawnPointType);
DebugTools.AssertNotNull(mobMaybe);
var mob = mobMaybe!.Value;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Server.GameTicking;
using Content.Server.GameTicking;
using Content.Server.Spawners.Components;
using Content.Server.Station.Systems;
using Robust.Server.Containers;
Expand All @@ -20,6 +20,10 @@ public void HandlePlayerSpawning(PlayerSpawningEvent args)
if (args.SpawnResult != null)
return;

// DeltaV - Ignore these two desired spawn types
if (args.DesiredSpawnPointType is SpawnPointType.Observer or SpawnPointType.LateJoin)
return;

var query = EntityQueryEnumerator<ContainerSpawnPointComponent, ContainerManagerComponent, TransformComponent>();
var possibleContainers = new List<Entity<ContainerSpawnPointComponent, ContainerManagerComponent, TransformComponent>>();

Expand Down
20 changes: 19 additions & 1 deletion Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Server.GameTicking;
using Content.Server.GameTicking;
using Content.Server.Spawners.Components;
using Content.Server.Station.Systems;
using Robust.Shared.Map;
Expand Down Expand Up @@ -32,6 +32,24 @@ private void OnPlayerSpawning(PlayerSpawningEvent args)
if (args.Station != null && _stationSystem.GetOwningStation(uid, xform) != args.Station)
continue;

// Delta-V: Allow setting a desired SpawnPointType
if (args.DesiredSpawnPointType != SpawnPointType.Unset)
{
var isMatchingJob = spawnPoint.SpawnType == SpawnPointType.Job &&
(args.Job == null || spawnPoint.Job?.ID == args.Job.Prototype);

switch (args.DesiredSpawnPointType)
{
case SpawnPointType.Job when isMatchingJob:
case SpawnPointType.LateJoin when spawnPoint.SpawnType == SpawnPointType.LateJoin:
case SpawnPointType.Observer when spawnPoint.SpawnType == SpawnPointType.Observer:
possiblePositions.Add(xform.Coordinates);
break;
default:
continue;
}
}

if (_gameTicker.RunLevel == GameRunLevel.InRound && spawnPoint.SpawnType == SpawnPointType.LateJoin)
{
possiblePositions.Add(xform.Coordinates);
Expand Down
14 changes: 11 additions & 3 deletions Content.Server/Station/Systems/StationSpawningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Content.Server.Spawners.Components; // DeltaV

namespace Content.Server.Station.Systems;

Expand Down Expand Up @@ -72,17 +73,19 @@ public override void Initialize()
/// <param name="job">The job to assign, if any.</param>
/// <param name="profile">The character profile to use, if any.</param>
/// <param name="stationSpawning">Resolve pattern, the station spawning component for the station.</param>
/// <param name="spawnPointType">Delta-V: Set desired spawn point type.</param>
/// <returns>The resulting player character, if any.</returns>
/// <exception cref="ArgumentException">Thrown when the given station is not a station.</exception>
/// <remarks>
/// This only spawns the character, and does none of the mind-related setup you'd need for it to be playable.
/// </remarks>
public EntityUid? SpawnPlayerCharacterOnStation(EntityUid? station, JobComponent? job, HumanoidCharacterProfile? profile, StationSpawningComponent? stationSpawning = null)
public EntityUid? SpawnPlayerCharacterOnStation(EntityUid? station, JobComponent? job, HumanoidCharacterProfile? profile, StationSpawningComponent? stationSpawning = null, SpawnPointType spawnPointType = SpawnPointType.Unset)
{
if (station != null && !Resolve(station.Value, ref stationSpawning))
throw new ArgumentException("Tried to use a non-station entity as a station!", nameof(station));

var ev = new PlayerSpawningEvent(job, profile, station);
// Delta-V: Set desired spawn point type.
var ev = new PlayerSpawningEvent(job, profile, station, spawnPointType);

if (station != null && profile != null)
{
Expand Down Expand Up @@ -276,11 +279,16 @@ public sealed class PlayerSpawningEvent : EntityEventArgs
/// The target station, if any.
/// </summary>
public readonly EntityUid? Station;
/// <summary>
/// Delta-V: Desired SpawnPointType, if any.
/// </summary>
public readonly SpawnPointType DesiredSpawnPointType;

public PlayerSpawningEvent(JobComponent? job, HumanoidCharacterProfile? humanoidCharacterProfile, EntityUid? station)
public PlayerSpawningEvent(JobComponent? job, HumanoidCharacterProfile? humanoidCharacterProfile, EntityUid? station, SpawnPointType spawnPointType = SpawnPointType.Unset)
{
Job = job;
HumanoidCharacterProfile = humanoidCharacterProfile;
Station = station;
DesiredSpawnPointType = spawnPointType;
}
}
Loading

0 comments on commit 71c8eec

Please sign in to comment.