Remove IClientSingularityInstance, move visual effects to SingularityDistortionComponent (#4194)
* Remove IClientSingularityInstance * In and out 5 minute refactor * Component states for singularity distortion * Fix distortion states * Address reviews
This commit is contained in:
@@ -2,25 +2,43 @@ using System;
|
||||
using Content.Shared.NetIDs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Singularity.Components
|
||||
{
|
||||
|
||||
public abstract class SharedSingularityComponent : Component
|
||||
{
|
||||
public override string Name => "Singularity";
|
||||
public override uint? NetID => ContentNetIDs.SINGULARITY;
|
||||
|
||||
[DataField("deleteFixture")] public string? DeleteFixtureId { get; } = default;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class SingularityComponentState : ComponentState
|
||||
/// <summary>
|
||||
/// Changed by <see cref="SharedSingularitySystem.ChangeSingularityLevel"/>
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public int Level { get; set; }
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
public int Level { get; }
|
||||
|
||||
public SingularityComponentState(int level) : base(ContentNetIDs.SINGULARITY)
|
||||
if (curState is not SingularityComponentState state)
|
||||
{
|
||||
Level = level;
|
||||
return;
|
||||
}
|
||||
|
||||
EntitySystem.Get<SharedSingularitySystem>().ChangeSingularityLevel(this, state.Level);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class SingularityComponentState : ComponentState
|
||||
{
|
||||
public int Level { get; }
|
||||
|
||||
public SingularityComponentState(int level) : base(ContentNetIDs.SINGULARITY)
|
||||
{
|
||||
Level = level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using Content.Shared.NetIDs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Singularity.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class SingularityDistortionComponent : Component
|
||||
{
|
||||
public override string Name => "SingularityDistortion";
|
||||
public override uint? NetID => ContentNetIDs.SINGULARITY_DISTORTION;
|
||||
|
||||
[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) : base(ContentNetIDs.SINGULARITY_DISTORTION)
|
||||
{
|
||||
Intensity = intensity;
|
||||
Falloff = falloff;
|
||||
}
|
||||
|
||||
public float Intensity { get; }
|
||||
public float Falloff { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user