Add entity prototype save test (#10274)
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Kitchen.Components;
|
||||
using Content.Server.Popups;
|
||||
@@ -9,11 +5,11 @@ using Content.Shared.Access;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.PDA;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Server.Access.Systems
|
||||
{
|
||||
@@ -27,13 +23,15 @@ namespace Content.Server.Access.Systems
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<IdCardComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<IdCardComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<IdCardComponent, BeingMicrowavedEvent>(OnMicrowaved);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, IdCardComponent id, ComponentInit args)
|
||||
private void OnMapInit(EntityUid uid, IdCardComponent id, MapInitEvent args)
|
||||
{
|
||||
id.OriginalOwnerName ??= EntityManager.GetComponent<MetaDataComponent>(id.Owner).EntityName;
|
||||
// On one hand, these prototypes should default to having the correct name. On the other hand, id cards are
|
||||
// rarely ever spawned in on their own without an owner, so this is fine.
|
||||
id.OriginalEntityName ??= EntityManager.GetComponent<MetaDataComponent>(id.Owner).EntityName;
|
||||
UpdateEntityName(uid, id);
|
||||
}
|
||||
|
||||
@@ -139,7 +137,7 @@ namespace Content.Server.Access.Systems
|
||||
|
||||
if (string.IsNullOrWhiteSpace(id.FullName) && string.IsNullOrWhiteSpace(id.JobTitle))
|
||||
{
|
||||
EntityManager.GetComponent<MetaDataComponent>(id.Owner).EntityName = id.OriginalOwnerName;
|
||||
EntityManager.GetComponent<MetaDataComponent>(id.Owner).EntityName = id.OriginalEntityName;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,7 +145,7 @@ namespace Content.Server.Access.Systems
|
||||
|
||||
var val = string.IsNullOrWhiteSpace(id.FullName)
|
||||
? Loc.GetString("access-id-card-component-owner-name-job-title-text",
|
||||
("originalOwnerName", id.OriginalOwnerName),
|
||||
("originalOwnerName", id.OriginalEntityName),
|
||||
("jobSuffix", jobSuffix))
|
||||
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
|
||||
("fullName", id.FullName),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Access.Components;
|
||||
using Content.Server.Access.Components;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Inventory;
|
||||
@@ -66,7 +66,7 @@ public sealed class IdExaminableSystem : EntitySystem
|
||||
|
||||
var val = string.IsNullOrWhiteSpace(id.FullName)
|
||||
? Loc.GetString("access-id-card-component-owner-name-job-title-text",
|
||||
("originalOwnerName", id.OriginalOwnerName),
|
||||
("originalOwnerName", id.OriginalEntityName),
|
||||
("jobSuffix", jobSuffix))
|
||||
: Loc.GetString("access-id-card-component-owner-full-name-job-title-text",
|
||||
("fullName", id.FullName),
|
||||
|
||||
@@ -33,11 +33,11 @@ namespace Content.Server.Body.Components
|
||||
mechanism.Owner.RandomOffset(0.25f);
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
public void MapInitialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_mechanismContainer = Owner.EnsureContainer<Container>($"{Name}-{nameof(BodyPartComponent)}");
|
||||
_mechanismContainer = Owner.EnsureContainer<Container>(ContainerId);
|
||||
|
||||
// This is ran in Startup as entities spawned in Initialize
|
||||
// are not synced to the client since they are assumed to be
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Content.Server.Body.Systems
|
||||
SubscribeLocalEvent<BodyComponent, MoveInputEvent>(OnRelayMoveInput);
|
||||
SubscribeLocalEvent<BodyComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
|
||||
SubscribeLocalEvent<BodyComponent, BeingMicrowavedEvent>(OnBeingMicrowaved);
|
||||
SubscribeLocalEvent<BodyPartComponent, MapInitEvent>((_, c, _) => c.MapInitialize());
|
||||
}
|
||||
|
||||
private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveInputEvent args)
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
{
|
||||
public abstract class DisposalTubeComponent : Component, IDisposalTubeComponent
|
||||
{
|
||||
public const string ContainerId = "disposal-tube";
|
||||
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public static readonly TimeSpan ClangDelay = TimeSpan.FromSeconds(0.5);
|
||||
@@ -135,7 +137,7 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Contents = ContainerHelpers.EnsureContainer<Container>(Owner, Name);
|
||||
Contents = ContainerHelpers.EnsureContainer<Container>(Owner, ContainerId);
|
||||
Owner.EnsureComponent<AnchorableComponent>();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly DumpableSystem _dumpableSystem = default!;
|
||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
|
||||
private readonly List<DisposalUnitComponent> _activeDisposals = new();
|
||||
|
||||
@@ -293,7 +294,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
|
||||
private void HandleDisposalInit(EntityUid uid, DisposalUnitComponent component, ComponentInit args)
|
||||
{
|
||||
component.Container = component.Owner.EnsureContainer<Container>(component.Name);
|
||||
component.Container = _containerSystem.EnsureContainer<Container>(uid, SharedDisposalUnitComponent.ContainerId);
|
||||
|
||||
UpdateInterface(component, component.Powered);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public sealed class RenameCommand : IConsoleCommand
|
||||
{
|
||||
foreach (var idCardComponent in entMan.EntityQuery<IdCardComponent>())
|
||||
{
|
||||
if (idCardComponent.OriginalOwnerName != oldName)
|
||||
if (idCardComponent.OriginalEntityName != oldName)
|
||||
continue;
|
||||
idCardSystem.TryChangeFullName(idCardComponent.Owner, name, idCardComponent);
|
||||
}
|
||||
|
||||
@@ -182,9 +182,11 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
|
||||
UpdateAppearance(component);
|
||||
|
||||
// Synchronize solution in drink
|
||||
EnsureComp<RefillableSolutionComponent>(uid).Solution = component.SolutionName;
|
||||
EnsureComp<DrainableSolutionComponent>(uid).Solution = component.SolutionName;
|
||||
if (TryComp(uid, out RefillableSolutionComponent? refillComp))
|
||||
refillComp.Solution = component.SolutionName;
|
||||
|
||||
if (TryComp(uid, out DrainableSolutionComponent? drainComp))
|
||||
drainComp.Solution = component.SolutionName;
|
||||
}
|
||||
|
||||
private void OnSolutionChange(EntityUid uid, DrinkComponent component, SolutionChangedEvent args)
|
||||
|
||||
@@ -30,8 +30,6 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
|
||||
public void CheckSolutions(TrashOnEmptyComponent component)
|
||||
{
|
||||
EntityManager.EnsureComponent<TagComponent>(component.Owner);
|
||||
|
||||
if (!EntityManager.HasComponent<SolutionContainerManagerComponent>((component).Owner))
|
||||
return;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Content.Server.PDA.Ringer
|
||||
base.Initialize();
|
||||
|
||||
// General Event Subscriptions
|
||||
SubscribeLocalEvent<RingerComponent, ComponentInit>(RandomizeRingtone);
|
||||
SubscribeLocalEvent<RingerComponent, MapInitEvent>(RandomizeRingtone);
|
||||
// RingerBoundUserInterface Subscriptions
|
||||
SubscribeLocalEvent<RingerComponent, RingerSetRingtoneMessage>(OnSetRingtone);
|
||||
SubscribeLocalEvent<RingerComponent, RingerPlayRingtoneMessage>(RingerPlayRingtone);
|
||||
@@ -46,7 +46,7 @@ namespace Content.Server.PDA.Ringer
|
||||
UpdateRingerRingtone(ringer, args.Ringtone);
|
||||
}
|
||||
|
||||
public void RandomizeRingtone(EntityUid uid, RingerComponent ringer, ComponentInit args)
|
||||
public void RandomizeRingtone(EntityUid uid, RingerComponent ringer, MapInitEvent args)
|
||||
{
|
||||
// Default to using C pentatonic so it at least sounds not terrible.
|
||||
var notes = new[]
|
||||
|
||||
@@ -50,7 +50,7 @@ public sealed class EntityStorageSystem : EntitySystem
|
||||
component.Contents.OccludesLight = component.OccludesLight;
|
||||
|
||||
if (TryComp<ConstructionComponent>(uid, out var construction))
|
||||
_construction.AddContainer(uid, nameof(EntityStorageComponent), construction);
|
||||
_construction.AddContainer(uid, ContainerName, construction);
|
||||
|
||||
if (TryComp<PlaceableSurfaceComponent>(uid, out var placeable))
|
||||
_placeableSurface.SetPlaceable(uid, component.Open, placeable);
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
{
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -31,7 +32,7 @@ namespace Content.Server.Storage.EntitySystems
|
||||
component.SecretPartName = entityName;
|
||||
}
|
||||
|
||||
component.ItemContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(uid, "stash", out _);
|
||||
component.ItemContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, "stash", out _);
|
||||
}
|
||||
|
||||
private void OnDestroyed(EntityUid uid, SecretStashComponent component, DestructionEventArgs args)
|
||||
|
||||
Reference in New Issue
Block a user