From 45fe7d5093636949b6d060b48d7850d0d00d8438 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Sun, 13 Jul 2025 22:05:18 -0400 Subject: [PATCH] Remove prototype caching from `ZombieComponent` (#38979) Remove prototype caching from ZombieComponent --- Content.Server/Zombies/ZombieSystem.cs | 14 ++++---------- Content.Shared/Zombies/ZombieComponent.cs | 6 ++---- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Content.Server/Zombies/ZombieSystem.cs b/Content.Server/Zombies/ZombieSystem.cs index 55d226ca5e..11185da61f 100644 --- a/Content.Server/Zombies/ZombieSystem.cs +++ b/Content.Server/Zombies/ZombieSystem.cs @@ -5,7 +5,6 @@ using Content.Server.Body.Systems; using Content.Server.Chat; using Content.Server.Chat.Systems; using Content.Server.Emoting.Systems; -using Content.Server.GameTicking.Rules.Components; using Content.Server.Speech.EntitySystems; using Content.Server.Roles; using Content.Shared.Anomaly.Components; @@ -61,7 +60,6 @@ namespace Content.Server.Zombies { base.Initialize(); - SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnEmote, before: new[] { typeof(VocalSystem), typeof(BodyEmotesSystem) }); @@ -179,19 +177,15 @@ namespace Content.Server.Zombies args.Unrevivable = true; } - private void OnStartup(EntityUid uid, ZombieComponent component, ComponentStartup args) - { - if (component.EmoteSoundsId == null) - return; - _protoManager.TryIndex(component.EmoteSoundsId, out component.EmoteSounds); - } - private void OnEmote(EntityUid uid, ZombieComponent component, ref EmoteEvent args) { // always play zombie emote sounds and ignore others if (args.Handled) return; - args.Handled = _chat.TryPlayEmoteSound(uid, component.EmoteSounds, args.Emote); + + _protoManager.TryIndex(component.EmoteSoundsId, out var sounds); + + args.Handled = _chat.TryPlayEmoteSound(uid, sounds, args.Emote); } private void OnMobState(EntityUid uid, ZombieComponent component, MobStateChangedEvent args) diff --git a/Content.Shared/Zombies/ZombieComponent.cs b/Content.Shared/Zombies/ZombieComponent.cs index 47ae35b4c5..2a69a7553f 100644 --- a/Content.Shared/Zombies/ZombieComponent.cs +++ b/Content.Shared/Zombies/ZombieComponent.cs @@ -93,10 +93,8 @@ public sealed partial class ZombieComponent : Component [DataField("beforeZombifiedEyeColor")] public Color BeforeZombifiedEyeColor; - [DataField("emoteId", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? EmoteSoundsId = "Zombie"; - - public EmoteSoundsPrototype? EmoteSounds; + [DataField("emoteId")] + public ProtoId? EmoteSoundsId = "Zombie"; [DataField("nextTick", customTypeSerializer:typeof(TimeOffsetSerializer))] public TimeSpan NextTick; -- 2.52.0