-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a system for modifying entity names without causing conflicts #27863
Conversation
That's not what that did, dummy This reverts commit 712549f.
Just realized that specifying prefix/postfix in the code is bad for localization, since what might be a prefix in one language can be a postfix in another ("lubricated crowbar" -> "palanca lubricada"). I'll rework this to ditch the prefix/postfix concept and use Loc strings for formatting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, just some details, also I think master RT submodule still doesnt have the required merged pr
Also, remember to write something for codebase changes after this is merged
Content.Shared/NameModifier/EntitySystems/NameModifierSystem.cs
Outdated
Show resolved
Hide resolved
Content.Shared/NameModifier/EntitySystems/NameModifierSystem.cs
Outdated
Show resolved
Hide resolved
Content.Shared/NameModifier/EntitySystems/NameModifierSystem.cs
Outdated
Show resolved
Hide resolved
Content.Shared/NameModifier/EntitySystems/NameModifierSystem.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks aight
Requires space-wizards/RobustToolbox#5216
About the PR
Adds NameModifierSystem, which aims to fix the problems that arise from different systems renaming entities.
Modifies a bunch of systems that previously could cause renaming conflicts when used on the same entity. Specifically, this fixes issues with metamorphic glasses, glue, lube, flares/glowsticks, forensic pads, DNA scrambler implants, PAIs, baby animals, borgs, zombies, cluwnes, chameleon clothing, and the admin renaming command and verbs.
Also includes ModifyWearerName Component/System both as a demo and to make it easier to add clothing that does simple name modifications. It's not used on anything in this PR though.
Why / Balance
See #27670 for an explanation of the issues that can come up with multiple systems renaming things. In short, the old method for renaming an entity was to copy the old name into a component field and then copy it back to revert the name. This meant that any additional changes to the name between those actions would be bulldozed. This system prevents that and makes it easy to add and remove name modifications. You can now have a "glued lubed mojito glass (for nerds)" and refill it to make a "glued lubed screwdriver glass (for nerds)" without issues.
Fixes #27670
Technical details
When
NameModifierSystem.RefreshNameModifiers
is called, aRefreshNameModifiersEvent
is passed around the entity and any subscribed components can add modifiers to to it. The event is also relayed to equipped items.A bunch of existing systems that temporarily changed entity names have been modified to use NameModifierSystem instead. Systems that make permanent changes still work and will have their changes respected by this system.
This PR also includes ModifyWearerNameComponent/System, but doesn't use it on anything. I used it quite a bit in testing, and it nicely demonstrates the integration with InventoryRelayEvent. It's a simple component that can be added to clothing prototypes to make them add a prefix, postfix, or override to the wearer's name while equipped. For example, the lawyer's badge can add the "Attorney" title to a wearer's name with just a little yml:
Media
Multiple modifiers surviving changes:
This may not make a lot of sense, but at least the name behaves properly:
ModifyWearerNameComponent:
Screen.Recording.2024-05-07.at.7.30.02.PM.mov
Breaking changes
Systems that apply reversible changes to entity names should be changed to use NameModifierSystem so they don't conflict with other name changes.
Changelog
Nah.