more component ref removal + combining server/client comps (#13178)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using Content.Shared.Flash;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Flash
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using Content.Shared.Flash;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Flash
|
||||
{
|
||||
[ComponentReference(typeof(SharedFlashableComponent))]
|
||||
[RegisterComponent, Access(typeof(FlashSystem))]
|
||||
public sealed class FlashableComponent : SharedFlashableComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Humanoid.Markings;
|
||||
using Content.Shared.Humanoid.Prototypes;
|
||||
|
||||
namespace Content.Client.Humanoid;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class HumanoidComponent : SharedHumanoidComponent
|
||||
{
|
||||
[ViewVariables] public List<Marking> CurrentMarkings = new();
|
||||
|
||||
public Dictionary<HumanoidVisualLayers, HumanoidSpeciesSpriteLayer> BaseLayers = new();
|
||||
|
||||
public string LastSpecies = default!;
|
||||
}
|
||||
@@ -108,23 +108,23 @@ public sealed class HumanoidVisualizerSystem : VisualizerSystem<HumanoidComponen
|
||||
SpriteComponent sprite)
|
||||
{
|
||||
// skip this entire thing if both sets are empty
|
||||
if (humanoid.CurrentMarkings.Count == 0 && newMarkings.Count == 0)
|
||||
if (humanoid.CurrentClientMarkings.Count == 0 && newMarkings.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dirtyMarkings = new List<int>();
|
||||
var dirtyRangeStart = humanoid.CurrentMarkings.Count == 0 ? 0 : -1;
|
||||
var dirtyRangeStart = humanoid.CurrentClientMarkings.Count == 0 ? 0 : -1;
|
||||
|
||||
// edge cases:
|
||||
// humanoid.CurrentMarkings < newMarkings.Count
|
||||
// humanoid.CurrentClientMarkings < newMarkings.Count
|
||||
// - check if count matches this condition before diffing
|
||||
// - if count is unequal, set dirty range to start from humanoid.CurrentMarkings.Count
|
||||
// humanoid.CurrentMarkings > newMarkings.Count, no dirty markings
|
||||
// - if count is unequal, set dirty range to start from humanoid.CurrentClientMarkings.Count
|
||||
// humanoid.CurrentClientMarkings > newMarkings.Count, no dirty markings
|
||||
// - break count upon meeting this condition
|
||||
// - clear markings from newMarkings.Count to humanoid.CurrentMarkings.Count - newMarkings.Count
|
||||
// - clear markings from newMarkings.Count to humanoid.CurrentClientMarkings.Count - newMarkings.Count
|
||||
|
||||
for (var i = 0; i < humanoid.CurrentMarkings.Count; i++)
|
||||
for (var i = 0; i < humanoid.CurrentClientMarkings.Count; i++)
|
||||
{
|
||||
// if we've reached the end of the new set of markings,
|
||||
// then that means it's time to finish
|
||||
@@ -135,7 +135,7 @@ public sealed class HumanoidVisualizerSystem : VisualizerSystem<HumanoidComponen
|
||||
|
||||
// if the marking is different here, set the range start to i and break, we need
|
||||
// to rebuild all markings starting from i
|
||||
if (humanoid.CurrentMarkings[i].MarkingId != newMarkings[i].MarkingId)
|
||||
if (humanoid.CurrentClientMarkings[i].MarkingId != newMarkings[i].MarkingId)
|
||||
{
|
||||
dirtyRangeStart = i;
|
||||
break;
|
||||
@@ -146,7 +146,7 @@ public sealed class HumanoidVisualizerSystem : VisualizerSystem<HumanoidComponen
|
||||
// however: if the hidden layers are set to dirty, then we need to
|
||||
// instead just add every single marking, since we don't know ahead of time
|
||||
// where these markings go
|
||||
if (humanoid.CurrentMarkings[i] != newMarkings[i] || layersDirty)
|
||||
if (humanoid.CurrentClientMarkings[i] != newMarkings[i] || layersDirty)
|
||||
{
|
||||
dirtyMarkings.Add(i);
|
||||
}
|
||||
@@ -162,49 +162,49 @@ public sealed class HumanoidVisualizerSystem : VisualizerSystem<HumanoidComponen
|
||||
ApplyMarking(uid, dirtyMarking, newMarkings[i].MarkingColors, newMarkings[i].Visible, humanoid, sprite);
|
||||
}
|
||||
|
||||
if (humanoid.CurrentMarkings.Count < newMarkings.Count && dirtyRangeStart < 0)
|
||||
if (humanoid.CurrentClientMarkings.Count < newMarkings.Count && dirtyRangeStart < 0)
|
||||
{
|
||||
dirtyRangeStart = humanoid.CurrentMarkings.Count;
|
||||
dirtyRangeStart = humanoid.CurrentClientMarkings.Count;
|
||||
}
|
||||
|
||||
if (dirtyRangeStart >= 0)
|
||||
{
|
||||
var range = newMarkings.GetRange(dirtyRangeStart, newMarkings.Count - dirtyRangeStart);
|
||||
|
||||
if (humanoid.CurrentMarkings.Count > 0)
|
||||
if (humanoid.CurrentClientMarkings.Count > 0)
|
||||
{
|
||||
var oldRange = humanoid.CurrentMarkings.GetRange(dirtyRangeStart, humanoid.CurrentMarkings.Count - dirtyRangeStart);
|
||||
var oldRange = humanoid.CurrentClientMarkings.GetRange(dirtyRangeStart, humanoid.CurrentClientMarkings.Count - dirtyRangeStart);
|
||||
ClearMarkings(uid, oldRange, humanoid, sprite);
|
||||
}
|
||||
|
||||
ApplyMarkings(uid, range, humanoid, sprite);
|
||||
}
|
||||
else if (humanoid.CurrentMarkings.Count != newMarkings.Count)
|
||||
else if (humanoid.CurrentClientMarkings.Count != newMarkings.Count)
|
||||
{
|
||||
if (newMarkings.Count == 0)
|
||||
{
|
||||
ClearAllMarkings(uid, humanoid, sprite);
|
||||
}
|
||||
else if (humanoid.CurrentMarkings.Count > newMarkings.Count)
|
||||
else if (humanoid.CurrentClientMarkings.Count > newMarkings.Count)
|
||||
{
|
||||
var rangeStart = newMarkings.Count;
|
||||
var rangeCount = humanoid.CurrentMarkings.Count - newMarkings.Count;
|
||||
var range = humanoid.CurrentMarkings.GetRange(rangeStart, rangeCount);
|
||||
var rangeCount = humanoid.CurrentClientMarkings.Count - newMarkings.Count;
|
||||
var range = humanoid.CurrentClientMarkings.GetRange(rangeStart, rangeCount);
|
||||
|
||||
ClearMarkings(uid, range, humanoid, sprite);
|
||||
}
|
||||
}
|
||||
|
||||
if (dirtyMarkings.Count > 0 || dirtyRangeStart >= 0 || humanoid.CurrentMarkings.Count != newMarkings.Count)
|
||||
if (dirtyMarkings.Count > 0 || dirtyRangeStart >= 0 || humanoid.CurrentClientMarkings.Count != newMarkings.Count)
|
||||
{
|
||||
humanoid.CurrentMarkings = newMarkings;
|
||||
humanoid.CurrentClientMarkings = newMarkings;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearAllMarkings(EntityUid uid, HumanoidComponent humanoid,
|
||||
SpriteComponent spriteComp)
|
||||
{
|
||||
ClearMarkings(uid, humanoid.CurrentMarkings, humanoid, spriteComp);
|
||||
ClearMarkings(uid, humanoid.CurrentClientMarkings, humanoid, spriteComp);
|
||||
}
|
||||
|
||||
private void ClearMarkings(EntityUid uid, List<Marking> markings, HumanoidComponent humanoid,
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using Content.Shared.Projectiles;
|
||||
|
||||
namespace Content.Client.Projectiles
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedProjectileComponent))]
|
||||
public sealed class ProjectileComponent : SharedProjectileComponent {}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Content.Client.Singularity.EntitySystems;
|
||||
|
||||
namespace Content.Client.Singularity.Components;
|
||||
|
||||
/// <summary>
|
||||
/// The client-side version of <see cref="SharedSingularityComponent"/>.
|
||||
/// Primarily managed by <see cref="SingularitySystem"/>.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedSingularityComponent))]
|
||||
public sealed class SingularityComponent : SharedSingularityComponent
|
||||
{}
|
||||
@@ -14,7 +14,7 @@ public sealed class SingularitySystem : SharedSingularitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SharedSingularityComponent, ComponentHandleState>(HandleSingularityState);
|
||||
SubscribeLocalEvent<SingularityComponent, ComponentHandleState>(HandleSingularityState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -23,7 +23,7 @@ public sealed class SingularitySystem : SharedSingularitySystem
|
||||
/// <param name="uid">The uid of the singularity to sync.</param>
|
||||
/// <param name="comp">The state of the singularity to sync.</param>
|
||||
/// <param name="args">The event arguments including the state to sync the singularity with.</param>
|
||||
private void HandleSingularityState(EntityUid uid, SharedSingularityComponent comp, ref ComponentHandleState args)
|
||||
private void HandleSingularityState(EntityUid uid, SingularityComponent comp, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not SingularityComponentState state)
|
||||
return;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using Content.Client.Items.Components;
|
||||
using Content.Client.Message;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.Stacks;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Stack
|
||||
{
|
||||
[RegisterComponent, Access(typeof(StackSystem), typeof(StackStatusControl))]
|
||||
[ComponentReference(typeof(SharedStackComponent))]
|
||||
public sealed class StackComponent : SharedStackComponent
|
||||
{
|
||||
[ViewVariables]
|
||||
public bool UiUpdateNeeded { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Client.Message;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.Stacks;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Content.Client.Stack
|
||||
args.Controls.Add(new StackStatusControl(component));
|
||||
}
|
||||
|
||||
public override void SetCount(EntityUid uid, int amount, SharedStackComponent? component = null)
|
||||
public override void SetCount(EntityUid uid, int amount, StackComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
@@ -7,17 +7,6 @@ using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Tools.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedMultipleToolComponent))]
|
||||
public sealed class MultipleToolComponent : SharedMultipleToolComponent
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool UiUpdateNeeded;
|
||||
|
||||
[DataField("statusShowBehavior")]
|
||||
public bool StatusShowBehavior = true;
|
||||
}
|
||||
|
||||
public sealed class MultipleToolStatusControl : Control
|
||||
{
|
||||
private readonly MultipleToolComponent _parent;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Content.Client.Tools
|
||||
}
|
||||
|
||||
public override void SetMultipleTool(EntityUid uid,
|
||||
SharedMultipleToolComponent? multiple = null,
|
||||
MultipleToolComponent? multiple = null,
|
||||
ToolComponent? tool = null,
|
||||
bool playSound = false,
|
||||
EntityUid? user = null)
|
||||
@@ -29,7 +29,7 @@ namespace Content.Client.Tools
|
||||
return;
|
||||
|
||||
base.SetMultipleTool(uid, multiple, tool, playSound, user);
|
||||
((MultipleToolComponent)multiple).UiUpdateNeeded = true;
|
||||
multiple.UiUpdateNeeded = true;
|
||||
|
||||
// TODO replace this with appearance + visualizer
|
||||
// in order to convert this to a specifier, the manner in which the sprite is specified in yaml needs to be updated.
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
using Content.Shared.VendingMachines;
|
||||
|
||||
namespace Content.Client.VendingMachines;
|
||||
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedVendingMachineComponent))]
|
||||
[Access(typeof(VendingMachineSystem))]
|
||||
public sealed class VendingMachineComponent : SharedVendingMachineComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// RSI state for when the vending machine is unpowered.
|
||||
/// Will be displayed on the layer <see cref="VendingMachineVisualLayers.Base"/>
|
||||
/// </summary>
|
||||
[DataField("offState")]
|
||||
public string? OffState;
|
||||
|
||||
/// <summary>
|
||||
/// RSI state for the screen of the vending machine
|
||||
/// Will be displayed on the layer <see cref="VendingMachineVisualLayers.Screen"/>
|
||||
/// </summary>
|
||||
[DataField("screenState")]
|
||||
public string? ScreenState;
|
||||
|
||||
/// <summary>
|
||||
/// RSI state for the vending machine's normal state. Usually a looping animation.
|
||||
/// Will be displayed on the layer <see cref="VendingMachineVisualLayers.BaseUnshaded"/>
|
||||
/// </summary>
|
||||
[DataField("normalState")]
|
||||
public string? NormalState;
|
||||
|
||||
/// <summary>
|
||||
/// RSI state for the vending machine's eject animation.
|
||||
/// Will be displayed on the layer <see cref="VendingMachineVisualLayers.BaseUnshaded"/>
|
||||
/// </summary>
|
||||
[DataField("ejectState")]
|
||||
public string? EjectState;
|
||||
|
||||
/// <summary>
|
||||
/// RSI state for the vending machine's deny animation. Will either be played once as sprite flick
|
||||
/// or looped depending on how <see cref="LoopDenyAnimation"/> is set.
|
||||
/// Will be displayed on the layer <see cref="VendingMachineVisualLayers.BaseUnshaded"/>
|
||||
/// </summary>
|
||||
[DataField("denyState")]
|
||||
public string? DenyState;
|
||||
|
||||
/// <summary>
|
||||
/// RSI state for when the vending machine is unpowered.
|
||||
/// Will be displayed on the layer <see cref="VendingMachineVisualLayers.Base"/>
|
||||
/// </summary>
|
||||
[DataField("brokenState")]
|
||||
public string? BrokenState;
|
||||
|
||||
/// <summary>
|
||||
/// If set to <c>true</c> (default) will loop the animation of the <see cref="DenyState"/> for the duration
|
||||
/// of <see cref="SharedVendingMachineComponent.DenyDelay"/>. If set to <c>false</c> will play a sprite
|
||||
/// flick animation for the state and then linger on the final frame until the end of the delay.
|
||||
/// </summary>
|
||||
[DataField("loopDeny")]
|
||||
public bool LoopDenyAnimation = true;
|
||||
}
|
||||
@@ -137,19 +137,3 @@ public sealed class VendingMachineSystem : SharedVendingMachineSystem
|
||||
sprite.LayerSetVisible(actualLayer, false);
|
||||
}
|
||||
}
|
||||
|
||||
public enum VendingMachineVisualLayers : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Off / Broken. The other layers will overlay this if the machine is on.
|
||||
/// </summary>
|
||||
Base,
|
||||
/// <summary>
|
||||
/// Normal / Deny / Eject
|
||||
/// </summary>
|
||||
BaseUnshaded,
|
||||
/// <summary>
|
||||
/// Screens that are persistent (where the machine is not off or broken)
|
||||
/// </summary>
|
||||
Screen
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Content.Client.Projectiles;
|
||||
using Content.Shared.Projectiles;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
using Content.Shared.Weapons.Ranged.Systems;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
Reference in New Issue
Block a user