Fixed some map saving bugs with ID cards/PDAs.

This commit is contained in:
Pieter-Jan Briers
2021-01-15 17:20:02 +01:00
parent a668e545ed
commit e51f74a1f1
2 changed files with 9 additions and 4 deletions

View File

@@ -67,7 +67,7 @@ namespace Content.Server.GameObjects.Components.Access
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
_ownerOriginalName = Owner.Name; _ownerOriginalName ??= Owner.Name;
UpdateEntityName(); UpdateEntityName();
} }
@@ -77,6 +77,7 @@ namespace Content.Server.GameObjects.Components.Access
serializer.DataField(ref _fullName, "fullName", string.Empty); serializer.DataField(ref _fullName, "fullName", string.Empty);
serializer.DataField(ref _jobTitle, "jobTitle", string.Empty); serializer.DataField(ref _jobTitle, "jobTitle", string.Empty);
serializer.DataField(ref _ownerOriginalName, "originalOwnerName", null);
} }
} }
} }

View File

@@ -36,7 +36,7 @@ namespace Content.Server.GameObjects.Components.PDA
[RegisterComponent] [RegisterComponent]
[ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IActivate))]
[ComponentReference(typeof(IAccess))] [ComponentReference(typeof(IAccess))]
public class PDAComponent : SharedPDAComponent, IInteractUsing, IActivate, IUse, IAccess public class PDAComponent : SharedPDAComponent, IInteractUsing, IActivate, IUse, IAccess, IMapInit
{ {
[Dependency] private readonly IPDAUplinkManager _uplinkManager = default!; [Dependency] private readonly IPDAUplinkManager _uplinkManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
@@ -86,6 +86,11 @@ namespace Content.Server.GameObjects.Components.PDA
UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage; UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
} }
UpdatePDAAppearance();
}
public void MapInit()
{
if (!string.IsNullOrEmpty(_startingIdCard)) if (!string.IsNullOrEmpty(_startingIdCard))
{ {
var idCard = _entityManager.SpawnEntity(_startingIdCard, Owner.Transform.Coordinates); var idCard = _entityManager.SpawnEntity(_startingIdCard, Owner.Transform.Coordinates);
@@ -99,8 +104,6 @@ namespace Content.Server.GameObjects.Components.PDA
var pen = _entityManager.SpawnEntity(_startingPen, Owner.Transform.Coordinates); var pen = _entityManager.SpawnEntity(_startingPen, Owner.Transform.Coordinates);
_penSlot.Insert(pen); _penSlot.Insert(pen);
} }
UpdatePDAAppearance();
} }
private void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage message) private void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage message)
@@ -434,6 +437,7 @@ namespace Content.Server.GameObjects.Components.PDA
} }
ISet<string> IAccess.Tags => _accessSet; ISet<string> IAccess.Tags => _accessSet;
bool IAccess.IsReadOnly => true; bool IAccess.IsReadOnly => true;
void IAccess.SetTags(IEnumerable<string> newTags) void IAccess.SetTags(IEnumerable<string> newTags)