From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Fri, 14 Apr 2023 19:46:17 +0000 (+0000) Subject: ghost auto gen comp state (#15304) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=450de8099363f3076f94d22599efe3266777bdb5;p=space-station-14.git ghost auto gen comp state (#15304) Co-authored-by: deltanedas <@deltanedas:kde.org> --- diff --git a/Content.Shared/Ghost/SharedGhostComponent.cs b/Content.Shared/Ghost/SharedGhostComponent.cs index c4075cc309..07ae1ff81b 100644 --- a/Content.Shared/Ghost/SharedGhostComponent.cs +++ b/Content.Shared/Ghost/SharedGhostComponent.cs @@ -3,9 +3,11 @@ using Robust.Shared.Serialization; namespace Content.Shared.Ghost { - [NetworkedComponent()] - public abstract class SharedGhostComponent : Component + [NetworkedComponent] + [AutoGenerateComponentState] + public abstract partial class SharedGhostComponent : Component { + // TODO: instead of this funny stuff just give it access and update in system dirtying when needed [ViewVariables(VVAccess.ReadWrite)] public bool CanGhostInteract { @@ -18,7 +20,7 @@ namespace Content.Shared.Ghost } } - [DataField("canInteract")] + [DataField("canInteract"), AutoNetworkedField] private bool _canGhostInteract; /// @@ -37,41 +39,8 @@ namespace Content.Shared.Ghost } } - [DataField("canReturnToBody")] + [DataField("canReturnToBody"), AutoNetworkedField] private bool _canReturnToBody; - - public override ComponentState GetComponentState() - { - return new GhostComponentState(CanReturnToBody, CanGhostInteract); - } - - public override void HandleComponentState(ComponentState? curState, ComponentState? nextState) - { - base.HandleComponentState(curState, nextState); - - if (curState is not GhostComponentState state) - { - return; - } - - CanReturnToBody = state.CanReturnToBody; - CanGhostInteract = state.CanGhostInteract; - } - } - - [Serializable, NetSerializable] - public sealed class GhostComponentState : ComponentState - { - public bool CanReturnToBody { get; } - public bool CanGhostInteract { get; } - - public GhostComponentState( - bool canReturnToBody, - bool canGhostInteract) - { - CanReturnToBody = canReturnToBody; - CanGhostInteract = canGhostInteract; - } } }