From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Sat, 7 Jun 2025 00:14:11 +0000 (-0400) Subject: Fix serialization of `SunShadowCycleComponent` (#38002) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=8324aa9bea52ec9c9dd7107d05ba2f1175ae7936;p=space-station-14.git Fix serialization of `SunShadowCycleComponent` (#38002) * Use a struct to hold the items for `Directions` in `SunShadowComponent`, fix serialization. * actually make them datafields... * Add NetSerializable to datadef * this is why we can't have nice things --- diff --git a/Content.Shared/Light/Components/SunShadowCycleComponent.cs b/Content.Shared/Light/Components/SunShadowCycleComponent.cs index 0948091ecf..f8d39da850 100644 --- a/Content.Shared/Light/Components/SunShadowCycleComponent.cs +++ b/Content.Shared/Light/Components/SunShadowCycleComponent.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Numerics; using Robust.Shared.GameStates; +using Robust.Shared.Serialization; namespace Content.Shared.Light.Components; @@ -25,11 +26,32 @@ public sealed partial class SunShadowCycleComponent : Component /// Time to have each direction applied. Will lerp from the current value to the next one. /// [DataField, AutoNetworkedField] - public List<(float Ratio, Vector2 Direction, float Alpha)> Directions = new() + public List Directions = new() { - (0f, new Vector2(0f, 3f), 0f), - (0.25f, new Vector2(-3f, -0.1f), 0.5f), - (0.5f, new Vector2(0f, -3f), 0.8f), - (0.75f, new Vector2(3f, -0.1f), 0.5f), + new SunShadowCycleDirection(0f, new Vector2(0f, 3f), 0f), + new SunShadowCycleDirection(0.25f, new Vector2(-3f, -0.1f), 0.5f), + new SunShadowCycleDirection(0.5f, new Vector2(0f, -3f), 0.8f), + new SunShadowCycleDirection(0.75f, new Vector2(3f, -0.1f), 0.5f), }; -} +}; + +[DataDefinition] +[Serializable, NetSerializable] +public partial record struct SunShadowCycleDirection +{ + [DataField] + public float Ratio; + + [DataField] + public Vector2 Direction; + + [DataField] + public float Alpha; + + public SunShadowCycleDirection(float ratio, Vector2 direction, float alpha) + { + Ratio = ratio; + Direction = direction; + Alpha = alpha; + } +};