Remove prototype caching from ZombieComponent (#38979)

Remove prototype caching from ZombieComponent
This commit is contained in:
Tayrtahn
2025-07-13 22:05:18 -04:00
committed by GitHub
parent 106cbe0e19
commit 45fe7d5093
2 changed files with 6 additions and 14 deletions

View File

@@ -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<ZombieComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ZombieComponent, EmoteEvent>(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)

View File

@@ -93,10 +93,8 @@ public sealed partial class ZombieComponent : Component
[DataField("beforeZombifiedEyeColor")]
public Color BeforeZombifiedEyeColor;
[DataField("emoteId", customTypeSerializer: typeof(PrototypeIdSerializer<EmoteSoundsPrototype>))]
public string? EmoteSoundsId = "Zombie";
public EmoteSoundsPrototype? EmoteSounds;
[DataField("emoteId")]
public ProtoId<EmoteSoundsPrototype>? EmoteSoundsId = "Zombie";
[DataField("nextTick", customTypeSerializer:typeof(TimeOffsetSerializer))]
public TimeSpan NextTick;