Files
tbd-station-14/Content.Shared/Singularity/Components/SingularityDistortionComponent.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

69 lines
1.9 KiB
C#

using System;
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.Singularity.Components
{
[RegisterComponent]
[NetworkedComponent]
public class SingularityDistortionComponent : Component
{
public override string Name => "SingularityDistortion";
[DataField("intensity")]
private float _intensity = 0.25f;
[DataField("falloff")]
private float _falloff = 2;
[ViewVariables(VVAccess.ReadWrite)]
public float Intensity
{
get => _intensity;
set => this.SetAndDirtyIfChanged(ref _intensity, value);
}
[ViewVariables(VVAccess.ReadWrite)]
public float Falloff
{
get => _falloff;
set => this.SetAndDirtyIfChanged(ref _falloff, value);
}
public override ComponentState GetComponentState(ICommonSession player)
{
return new SingularityDistortionComponentState(Intensity, Falloff);
}
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
{
base.HandleComponentState(curState, nextState);
if (curState is not SingularityDistortionComponentState state)
{
return;
}
Intensity = state.Intensity;
Falloff = state.Falloff;
}
}
[Serializable, NetSerializable]
public class SingularityDistortionComponentState : ComponentState
{
public SingularityDistortionComponentState(float intensity, float falloff)
{
Intensity = intensity;
Falloff = falloff;
}
public float Intensity { get; }
public float Falloff { get; }
}
}