using Content.Client.Parallax.Managers;
using Content.Shared.Parallax;
using Robust.Client.Graphics;
-using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
{
base.Initialize();
_overlay.AddOverlay(new ParallaxOverlay());
- SubscribeLocalEvent<ParallaxComponent, ComponentHandleState>(OnParallaxHandleState);
_protoManager.PrototypesReloaded += OnReload;
+
+ SubscribeLocalEvent<ParallaxComponent, AfterAutoHandleStateEvent>(OnAfterAutoHandleState);
}
private void OnReload(PrototypesReloadedEventArgs obj)
_protoManager.PrototypesReloaded -= OnReload;
}
- private void OnParallaxHandleState(EntityUid uid, ParallaxComponent component, ref ComponentHandleState args)
+ private void OnAfterAutoHandleState(EntityUid uid, ParallaxComponent component, ref AfterAutoHandleStateEvent args)
{
- if (args.Current is not ParallaxComponentState state) return;
- component.Parallax = state.Parallax;
-
if (!_parallax.IsLoaded(component.Parallax))
{
_parallax.LoadParallaxByName(component.Parallax);
using Content.Shared.Parallax;
-using Robust.Shared.GameStates;
namespace Content.Server.Parallax;
-public sealed class ParallaxSystem : SharedParallaxSystem
-{
- public override void Initialize()
- {
- base.Initialize();
-
- SubscribeLocalEvent<ParallaxComponent, ComponentGetState>(OnParallaxGetState);
- }
-
- private void OnParallaxGetState(EntityUid uid, ParallaxComponent component, ref ComponentGetState args)
- {
- args.State = new ParallaxComponentState
- {
- Parallax = component.Parallax
- };
- }
-
-}
+public sealed class ParallaxSystem : SharedParallaxSystem { }
/// <summary>
/// Handles per-map parallax
/// </summary>
-[RegisterComponent, NetworkedComponent]
-public sealed class ParallaxComponent : Component
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class ParallaxComponent : Component
{
// I wish I could use a typeserializer here but parallax is extremely client-dependent.
- [DataField("parallax")]
+ [DataField("parallax"), AutoNetworkedField]
public string Parallax = "Default";
[UsedImplicitly, ViewVariables(VVAccess.ReadWrite)]