Посылки больше не приходят боргам и ИИ (#2074)
This commit is contained in:
parent
495a16a950
commit
e13d8a92ca
3 changed files with 36 additions and 7 deletions
|
|
@ -52,7 +52,19 @@ public sealed partial class DeliverySystem : SharedDeliverySystem
|
|||
if (_station.GetStationInMap(Transform(ent).MapID) is not { } stationId)
|
||||
return;
|
||||
|
||||
if (!_records.TryGetRandomRecord<GeneralStationRecord>(stationId, out var entry))
|
||||
// Sunrise-Start
|
||||
HashSet<uint> siliconIds = new();
|
||||
if (_records.GetRecordsOfType<GeneralStationRecord>(stationId, null) is { } records)
|
||||
{
|
||||
foreach (var (id, record) in records)
|
||||
{
|
||||
if (record.Silicon)
|
||||
siliconIds.Add(id);
|
||||
}
|
||||
}
|
||||
// Sunrise-End
|
||||
|
||||
if (!_records.TryGetRandomRecord<GeneralStationRecord>(stationId, out var entry, siliconIds)) // Sunrise-Edit
|
||||
return;
|
||||
|
||||
ent.Comp.RecipientName = entry.Name;
|
||||
|
|
|
|||
|
|
@ -8,10 +8,14 @@ using Content.Shared.Inventory;
|
|||
using Content.Shared.PDA;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Silicons.Borgs.Components;
|
||||
using Content.Shared.Silicons.StationAi;
|
||||
using Content.Shared.StationRecords;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
namespace Content.Server.StationRecords.Systems;
|
||||
|
||||
|
|
@ -99,12 +103,14 @@ public sealed class StationRecordsSystem : SharedStationRecordsSystem
|
|||
idUid = player;
|
||||
name = MetaData(player).EntityName;
|
||||
}
|
||||
|
||||
var silicon = HasComp<BorgChassisComponent>(player) || HasComp<StationAiHeldComponent>(player);
|
||||
// Sunrise-End
|
||||
|
||||
TryComp<FingerprintComponent>(player, out var fingerprintComponent);
|
||||
TryComp<DnaComponent>(player, out var dnaComponent);
|
||||
|
||||
CreateGeneralRecord(station, idUid, name, profile.Age, profile.Species, profile.Gender, jobId, fingerprintComponent?.Fingerprint, dnaComponent?.DNA, profile, records);
|
||||
CreateGeneralRecord(station, idUid, name, profile.Age, profile.Species, profile.Gender, jobId, fingerprintComponent?.Fingerprint, dnaComponent?.DNA, profile, records, silicon); // Sunrise-Edit
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -146,7 +152,8 @@ public sealed class StationRecordsSystem : SharedStationRecordsSystem
|
|||
string? mobFingerprint,
|
||||
string? dna,
|
||||
HumanoidCharacterProfile profile,
|
||||
StationRecordsComponent records)
|
||||
StationRecordsComponent records,
|
||||
bool silicon = false) // Sunrise-Edit
|
||||
{
|
||||
if (!_prototypeManager.TryIndex<JobPrototype>(jobId, out var jobPrototype))
|
||||
throw new ArgumentException($"Invalid job prototype ID: {jobId}");
|
||||
|
|
@ -170,7 +177,8 @@ public sealed class StationRecordsSystem : SharedStationRecordsSystem
|
|||
Gender = gender,
|
||||
DisplayPriority = jobPrototype.RealDisplayWeight,
|
||||
Fingerprint = mobFingerprint,
|
||||
DNA = dna
|
||||
DNA = dna,
|
||||
Silicon = silicon, // Sunrise-Edit
|
||||
};
|
||||
|
||||
var key = AddRecordEntry(station, record);
|
||||
|
|
@ -249,18 +257,24 @@ public sealed class StationRecordsSystem : SharedStationRecordsSystem
|
|||
/// <param name="entry">The resulting entry.</param>
|
||||
/// <typeparam name="T">Type to get from the record set.</typeparam>
|
||||
/// <returns>True if a record was obtained. False otherwise.</returns>
|
||||
public bool TryGetRandomRecord<T>(Entity<StationRecordsComponent?> ent, [NotNullWhen(true)] out T? entry)
|
||||
public bool TryGetRandomRecord<T>(Entity<StationRecordsComponent?> ent, [NotNullWhen(true)] out T? entry, HashSet<uint> ignoredIds) // Sunrise-Edit
|
||||
{
|
||||
entry = default;
|
||||
|
||||
if (!Resolve(ent.Owner, ref ent.Comp))
|
||||
return false;
|
||||
|
||||
if (ent.Comp.Records.Keys.Count == 0)
|
||||
// Sunrise-Start
|
||||
var keys = ent.Comp.Records.Keys;
|
||||
if (keys.Count == 0)
|
||||
return false;
|
||||
|
||||
var key = _random.Pick(ent.Comp.Records.Keys);
|
||||
var filtered = keys.Where(id => !ignoredIds.Contains(id)).ToList();
|
||||
if (!filtered.Any())
|
||||
return false;
|
||||
// Sunrise-End
|
||||
|
||||
var key = _random.Pick(filtered); // Sunrise-Edit
|
||||
return ent.Comp.Records.TryGetRecordEntry(key, out entry);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,4 +68,7 @@ public sealed record GeneralStationRecord
|
|||
/// </summary>
|
||||
[DataField]
|
||||
public string? DNA;
|
||||
|
||||
[DataField]
|
||||
public bool Silicon; // Sunrise-Edit
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue