Files
tbd-station-14/Content.Shared/Standing/StandingStateComponent.cs
Acruid 59e5cc5e3c Remove Static Component NetIds (#4247)
* Remove the unnecessary NetID property from ComponentState.

* Remove Component.NetworkSynchronizeExistence.

* Removed Component.NetID.

* Adds component netID automatic generation.

* Removed NetIdAttribute from serverside components with no corresponding clientside registration.

* Completely remove static NetIds.

* Renamed NetIDAttribute to NetworkedComponentAttribute.

* Add GenerateNetIds calls to client and server entry points.
Add test to make sure auto generated NetIds are identical.

* Component changes when rebasing that I am too lazy to rewrite into the branch.

Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
2021-07-12 10:32:10 +02:00

54 lines
1.6 KiB
C#

using System;
using Content.Shared.EffectBlocker;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Shared.Standing
{
[RegisterComponent]
[NetworkedComponent]
public sealed class StandingStateComponent : Component, IEffectBlocker
{
public override string Name => "StandingState";
[ViewVariables(VVAccess.ReadWrite)]
[DataField("downSoundCollection")]
public string? DownSoundCollection { get; } = "BodyFall";
[ViewVariables]
[DataField("standing")]
public bool Standing { get; set; } = true;
public bool CanFall() => Standing;
public override ComponentState GetComponentState(ICommonSession player)
{
return new StandingComponentState(Standing);
}
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
if (curState is not StandingComponentState state) return;
Standing = state.Standing;
}
// I'm not calling it StandingStateComponentState
[Serializable, NetSerializable]
private sealed class StandingComponentState : ComponentState
{
public bool Standing { get; }
public StandingComponentState(bool standing)
{
Standing = standing;
}
}
}
}