Use ECS prototype-reload events (#22613)
* Use ECS prototype-reload events * better constructors * Maybe this fixes tests?
This commit is contained in:
@@ -67,7 +67,7 @@ public sealed partial class ContentAudioSystem
|
||||
_nextAudio = TimeSpan.MaxValue;
|
||||
|
||||
SetupAmbientSounds();
|
||||
_proto.PrototypesReloaded += OnProtoReload;
|
||||
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnProtoReload);
|
||||
_state.OnStateChanged += OnStateChange;
|
||||
// On round end summary OR lobby cut audio.
|
||||
SubscribeNetworkEvent<RoundEndMessageEvent>(OnRoundEndMessage);
|
||||
@@ -86,21 +86,14 @@ public sealed partial class ContentAudioSystem
|
||||
private void ShutdownAmbientMusic()
|
||||
{
|
||||
_configManager.UnsubValueChanged(CCVars.AmbientMusicVolume, AmbienceCVarChanged);
|
||||
_proto.PrototypesReloaded -= OnProtoReload;
|
||||
_state.OnStateChanged -= OnStateChange;
|
||||
_ambientMusicStream = _audio.Stop(_ambientMusicStream);
|
||||
}
|
||||
|
||||
private void OnProtoReload(PrototypesReloadedEventArgs obj)
|
||||
{
|
||||
if (!obj.ByType.ContainsKey(typeof(AmbientMusicPrototype)) &&
|
||||
!obj.ByType.ContainsKey(typeof(RulesPrototype)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ambientSounds.Clear();
|
||||
SetupAmbientSounds();
|
||||
if (obj.WasModified<AmbientMusicPrototype>() || obj.WasModified<RulesPrototype>())
|
||||
SetupAmbientSounds();
|
||||
}
|
||||
|
||||
private void OnStateChange(StateChangedEventArgs obj)
|
||||
@@ -114,6 +107,7 @@ public sealed partial class ContentAudioSystem
|
||||
|
||||
private void SetupAmbientSounds()
|
||||
{
|
||||
_ambientSounds.Clear();
|
||||
foreach (var ambience in _proto.EnumeratePrototypes<AmbientMusicPrototype>())
|
||||
{
|
||||
var tracks = _ambientSounds.GetOrNew(ambience.ID);
|
||||
|
||||
@@ -29,18 +29,13 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
|
||||
SubscribeLocalEvent<ChameleonClothingComponent, AfterAutoHandleStateEvent>(HandleState);
|
||||
|
||||
PrepareAllVariants();
|
||||
_proto.PrototypesReloaded += OnProtoReloaded;
|
||||
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnProtoReloaded);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
private void OnProtoReloaded(PrototypesReloadedEventArgs args)
|
||||
{
|
||||
base.Shutdown();
|
||||
_proto.PrototypesReloaded -= OnProtoReloaded;
|
||||
}
|
||||
|
||||
private void OnProtoReloaded(PrototypesReloadedEventArgs _)
|
||||
{
|
||||
PrepareAllVariants();
|
||||
if (args.WasModified<EntityPrototype>())
|
||||
PrepareAllVariants();
|
||||
}
|
||||
|
||||
private void HandleState(EntityUid uid, ChameleonClothingComponent component, ref AfterAutoHandleStateEvent args)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Client.GameTicking.Managers;
|
||||
using Content.Shared.CrewManifest;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -19,12 +18,7 @@ public sealed class CrewManifestSystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
BuildDepartmentLookup();
|
||||
_prototypeManager.PrototypesReloaded += OnPrototypesReload;
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
_prototypeManager.PrototypesReloaded -= OnPrototypesReload;
|
||||
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypesReload);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -36,16 +30,16 @@ public sealed class CrewManifestSystem : EntitySystem
|
||||
RaiseNetworkEvent(new RequestCrewManifestMessage(netEntity));
|
||||
}
|
||||
|
||||
private void OnPrototypesReload(PrototypesReloadedEventArgs _)
|
||||
private void OnPrototypesReload(PrototypesReloadedEventArgs args)
|
||||
{
|
||||
_jobDepartmentLookup.Clear();
|
||||
_departments.Clear();
|
||||
|
||||
BuildDepartmentLookup();
|
||||
if (args.WasModified<DepartmentPrototype>())
|
||||
BuildDepartmentLookup();
|
||||
}
|
||||
|
||||
private void BuildDepartmentLookup()
|
||||
{
|
||||
_jobDepartmentLookup.Clear();
|
||||
_departments.Clear();
|
||||
foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
|
||||
{
|
||||
_departments.Add(department.ID);
|
||||
|
||||
@@ -24,14 +24,13 @@ public sealed class ParallaxSystem : SharedParallaxSystem
|
||||
{
|
||||
base.Initialize();
|
||||
_overlay.AddOverlay(new ParallaxOverlay());
|
||||
_protoManager.PrototypesReloaded += OnReload;
|
||||
|
||||
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnReload);
|
||||
SubscribeLocalEvent<ParallaxComponent, AfterAutoHandleStateEvent>(OnAfterAutoHandleState);
|
||||
}
|
||||
|
||||
private void OnReload(PrototypesReloadedEventArgs obj)
|
||||
{
|
||||
if (!obj.ByType.ContainsKey(typeof(ParallaxPrototype)))
|
||||
if (!obj.WasModified<ParallaxPrototype>())
|
||||
return;
|
||||
|
||||
_parallax.UnloadParallax(Fallback);
|
||||
@@ -48,7 +47,6 @@ public sealed class ParallaxSystem : SharedParallaxSystem
|
||||
{
|
||||
base.Shutdown();
|
||||
_overlay.RemoveOverlay<ParallaxOverlay>();
|
||||
_protoManager.PrototypesReloaded -= OnReload;
|
||||
}
|
||||
|
||||
private void OnAfterAutoHandleState(EntityUid uid, ParallaxComponent component, ref AfterAutoHandleStateEvent args)
|
||||
|
||||
@@ -53,7 +53,8 @@ public sealed class DecalPlacerUIController : UIController, IOnStateExited<Gamep
|
||||
|
||||
private void OnPrototypesReloaded(PrototypesReloadedEventArgs obj)
|
||||
{
|
||||
ReloadPrototypes();
|
||||
if (obj.WasModified<DecalPrototype>())
|
||||
ReloadPrototypes();
|
||||
}
|
||||
|
||||
private void ReloadPrototypes()
|
||||
|
||||
Reference in New Issue
Block a user