Rename fix (#31654)
* Localize RenameCommand and delegate most of the process to MetaDataSystem.SetEntityName() * Make renaming rely on the EntityRenamedEvent. Fix issue where renaming would keep old Examine text Requires engine change * Fix localisation strings * Make PDA search be based on a renamed entity's Uid instead of its old name To do this the pda component now has an PdaOwner field which gets assigned when it is given as a loadout to a player * Fix bad merge??? huh * Use AllEntityQuery
This commit is contained in:
@@ -55,9 +55,23 @@ namespace Content.Server.PDA
|
||||
SubscribeLocalEvent<PdaComponent, CartridgeLoaderNotificationSentEvent>(OnNotification);
|
||||
|
||||
SubscribeLocalEvent<StationRenamedEvent>(OnStationRenamed);
|
||||
SubscribeLocalEvent<EntityRenamedEvent>(OnEntityRenamed);
|
||||
SubscribeLocalEvent<AlertLevelChangedEvent>(OnAlertLevelChanged);
|
||||
}
|
||||
|
||||
private void OnEntityRenamed(ref EntityRenamedEvent ev)
|
||||
{
|
||||
var query = EntityQueryEnumerator<PdaComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
{
|
||||
if (comp.PdaOwner == ev.Uid)
|
||||
{
|
||||
SetOwner(uid, comp, ev.Uid, ev.NewName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnComponentInit(EntityUid uid, PdaComponent pda, ComponentInit args)
|
||||
{
|
||||
base.OnComponentInit(uid, pda, args);
|
||||
@@ -94,9 +108,10 @@ namespace Content.Server.PDA
|
||||
UpdatePdaUi(uid, pda);
|
||||
}
|
||||
|
||||
public void SetOwner(EntityUid uid, PdaComponent pda, string ownerName)
|
||||
public void SetOwner(EntityUid uid, PdaComponent pda, EntityUid owner, string ownerName)
|
||||
{
|
||||
pda.OwnerName = ownerName;
|
||||
pda.PdaOwner = owner;
|
||||
UpdatePdaUi(uid, pda);
|
||||
}
|
||||
|
||||
@@ -112,7 +127,7 @@ namespace Content.Server.PDA
|
||||
|
||||
private void UpdateAllPdaUisOnStation()
|
||||
{
|
||||
var query = EntityQueryEnumerator<PdaComponent>();
|
||||
var query = AllEntityQuery<PdaComponent>();
|
||||
while (query.MoveNext(out var ent, out var comp))
|
||||
{
|
||||
UpdatePdaUi(ent, comp);
|
||||
|
||||
Reference in New Issue
Block a user