This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
forked from new-frontiers-14/frontier-station-14
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shuttle records system (new-frontiers-14#2212)
- Loading branch information
1 parent
eac776d
commit b14b480
Showing
9 changed files
with
192 additions
and
72 deletions.
There are no files selected for viewing
143 changes: 80 additions & 63 deletions
143
Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Content.Server/_NF/ShuttleRecords/Components/SectorShuttleRecordsComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Content.Shared._NF.ShuttleRecords; | ||
|
||
namespace Content.Server._NF.ShuttleRecords.Components; | ||
|
||
/// <summary> | ||
/// A component that stores records for all shuttle purchases in the sector. | ||
/// Note: all purchases are currently added, will need to be filtered appropriately by viewing clients. | ||
/// </summary> | ||
[RegisterComponent] | ||
[Access(typeof(ShuttleRecordsSystem))] | ||
public sealed partial class SectorShuttleRecordsComponent : Component | ||
{ | ||
[DataField] | ||
public List<ShuttleRecord> ShuttleRecordsList = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Content.Server._NF.SectorServices; | ||
using Content.Server._NF.ShuttleRecords.Components; | ||
using Content.Shared._NF.ShuttleRecords; | ||
|
||
namespace Content.Server._NF.ShuttleRecords; | ||
|
||
public sealed partial class ShuttleRecordsSystem : SharedShuttleRecordsSystem | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
[Dependency] private readonly SectorServiceSystem _sectorService = default!; | ||
|
||
|
||
/** | ||
* Adds a record to the shuttle records list. | ||
* <param name="record">The record to add.</param> | ||
*/ | ||
public void AddRecord(ShuttleRecord record) | ||
{ | ||
if (!TryGetShuttleRecordsDataComponent(out var component)) | ||
return; | ||
|
||
component.ShuttleRecordsList.Add(record); | ||
} | ||
|
||
private bool TryGetShuttleRecordsDataComponent([NotNullWhen(true)] out SectorShuttleRecordsComponent? component) | ||
{ | ||
if (_entityManager.EnsureComponent<SectorShuttleRecordsComponent>( | ||
uid: _sectorService.GetServiceEntity(), | ||
out var shuttleRecordsComponent)) | ||
{ | ||
component = shuttleRecordsComponent; | ||
return true; | ||
} | ||
|
||
component = null; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Content.Shared/_NF/ShuttleRecords/SharedShuttleRecordsSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Content.Shared.Containers.ItemSlots; | ||
using Robust.Shared.Audio.Systems; | ||
|
||
namespace Content.Shared._NF.ShuttleRecords; | ||
|
||
public abstract class SharedShuttleRecordsSystem : EntitySystem | ||
{ | ||
// These dependencies are eventually needed for the consoles that are made for this system. | ||
[Dependency] protected readonly ItemSlotsSystem _itemSlotsSystem = default!; | ||
[Dependency] protected readonly SharedAudioSystem _audioSystem = default!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared._NF.ShuttleRecords; | ||
|
||
/** | ||
* A record of a shuttle that had been purchased. | ||
* This class is NOT a indication that the shuttle is still in the game, merely a transaction record of it. | ||
*/ | ||
[Virtual, NetSerializable, Serializable] | ||
public class ShuttleRecord( | ||
string name, | ||
string suffix, | ||
string ownerName, | ||
NetEntity entityUid | ||
) | ||
{ | ||
[ViewVariables] | ||
public string Name { get; set; } = name; | ||
|
||
[ViewVariables] | ||
public string? Suffix { get; set; } = suffix; | ||
|
||
[ViewVariables] | ||
public string OwnerName { get; set; } = ownerName; | ||
|
||
/** | ||
* Entity is deleted when the ship gets sold. | ||
* Use EntityManager.EntityExists(EntityUid) to check if the entity still exists. | ||
*/ | ||
[ViewVariables] | ||
public NetEntity EntityUid { get; set; } = entityUid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters