Adds AddRecord/AddRecordEntry to StationRecordsSystem (#11732)

* adds an API to add station records from StationRecordsSystem

* removes a lingering comment

* adds a comment to AddRecord

* Update Content.Server/StationRecords/Systems/StationRecordsSystem.cs

Co-authored-by: wrexbe <81056464+wrexbe@users.noreply.github.com>

Co-authored-by: wrexbe <81056464+wrexbe@users.noreply.github.com>
This commit is contained in:
Flipp Syder
2022-10-07 22:59:33 -07:00
committed by GitHub
parent 76d632a7df
commit 5e07e8f8a5
2 changed files with 43 additions and 5 deletions

View File

@@ -124,9 +124,8 @@ public sealed class StationRecordsSystem : EntitySystem
DisplayPriority = jobPrototype.Weight
};
var key = records.Records.AddRecord(station);
records.Records.AddRecordEntry(key, record);
// entry.Entries.Add(typeof(GeneralStationRecord), record);
var key = AddRecord(station, records);
AddRecordEntry(key, record, records);
if (idUid != null)
{
@@ -204,6 +203,45 @@ public sealed class StationRecordsSystem : EntitySystem
return records.Records.GetRecordsOfType<T>();
}
/// <summary>
/// Adds a record to a station's record set.
/// </summary>
/// <param name="station">The station to add a record to.</param>
/// <param name="records">Station records component.</param>
/// <returns>
/// A station record key, which can be used to add and get records.
/// </returns>
/// <exception cref="ArgumentException">
/// Occurs when the entity given does not have a station records component.
/// </exception>
public StationRecordKey AddRecord(EntityUid station, StationRecordsComponent? records)
{
if (!Resolve(station, ref records))
{
throw new ArgumentException($"Could not retrieve a {nameof(StationRecordsComponent)} from entity {station}");
}
return records.Records.AddRecord(station);
}
/// <summary>
/// Adds a record entry to a station's record set.
/// </summary>
/// <param name="key">The key to add the record to.</param>
/// <param name="record">The record to add.</param>
/// <param name="records">Station records component.</param>
/// <typeparam name="T">The type of record to add.</typeparam>
public void AddRecordEntry<T>(StationRecordKey key, T record,
StationRecordsComponent? records = null)
{
if (!Resolve(key.OriginStation, ref records))
{
return;
}
records.Records.AddRecordEntry(key, record);
}
/// <summary>
/// Synchronizes a station's records with any systems that need it.
/// </summary>