singulo distortion auto gen comp state (#15306)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -1,60 +1,31 @@
|
|||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Singularity.Components
|
namespace Content.Shared.Singularity.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
[NetworkedComponent]
|
[AutoGenerateComponentState]
|
||||||
public sealed class SingularityDistortionComponent : Component
|
public sealed partial class SingularityDistortionComponent : Component
|
||||||
{
|
{
|
||||||
|
// TODO: use access and remove this funny stuff
|
||||||
[DataField("intensity")]
|
[DataField("intensity")]
|
||||||
private float _intensity = 31.25f;
|
private float _intensity = 31.25f;
|
||||||
|
|
||||||
[DataField("falloffPower")]
|
[DataField("falloffPower")]
|
||||||
private float _falloffPower = MathF.Sqrt(2f);
|
private float _falloffPower = MathF.Sqrt(2f);
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||||
public float Intensity
|
public float Intensity
|
||||||
{
|
{
|
||||||
get => _intensity;
|
get => _intensity;
|
||||||
set => this.SetAndDirtyIfChanged(ref _intensity, value);
|
set => this.SetAndDirtyIfChanged(ref _intensity, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||||
public float FalloffPower
|
public float FalloffPower
|
||||||
{
|
{
|
||||||
get => _falloffPower;
|
get => _falloffPower;
|
||||||
set => this.SetAndDirtyIfChanged(ref _falloffPower, value);
|
set => this.SetAndDirtyIfChanged(ref _falloffPower, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ComponentState GetComponentState()
|
|
||||||
{
|
|
||||||
return new SingularityDistortionComponentState(Intensity, FalloffPower);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
|
||||||
{
|
|
||||||
base.HandleComponentState(curState, nextState);
|
|
||||||
|
|
||||||
if (curState is not SingularityDistortionComponentState state)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Intensity = state.Intensity;
|
|
||||||
FalloffPower = state.Falloff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public sealed class SingularityDistortionComponentState : ComponentState
|
|
||||||
{
|
|
||||||
public SingularityDistortionComponentState(float intensity, float falloff)
|
|
||||||
{
|
|
||||||
Intensity = intensity;
|
|
||||||
Falloff = falloff;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Intensity { get; }
|
|
||||||
public float Falloff { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user