Skip to content

Commit

Permalink
Remove server and shared sprite component (#15917)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroJr authored and Vordenburg committed May 7, 2023
1 parent 47076c2 commit 885d9fa
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Content.Client/AirlockPainter/AirlockPainterSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Robust.Client.ResourceManagement;
using Robust.Shared.Utility;
using System.Linq;
using static Robust.Shared.GameObjects.SharedSpriteComponent;
using Robust.Shared.Serialization.TypeSerializers.Implementations;

namespace Content.Client.AirlockPainter
{
Expand All @@ -28,7 +28,7 @@ public override void Initialize()
continue;
}

RSIResource doorRsi = _resourceCache.GetResource<RSIResource>(TextureRoot / new ResPath(iconPath));
RSIResource doorRsi = _resourceCache.GetResource<RSIResource>(SpriteSpecifierSerializer.TextureRoot / new ResPath(iconPath));
if (!doorRsi.RSI.TryGetState("closed", out var icon))
{
Entries.Add(new AirlockPainterEntry(style, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.ResourceManagement;
using Robust.Shared.Serialization.TypeSerializers.Implementations;

namespace Content.Client.Atmos.EntitySystems;

Expand All @@ -27,7 +28,7 @@ private void OnInit(EntityUid uid, PipeAppearanceComponent component, ComponentI
if (!TryComp(uid, out SpriteComponent? sprite))
return;

if (!_resCache.TryGetResource(SharedSpriteComponent.TextureRoot / component.RsiPath, out RSIResource? rsi))
if (!_resCache.TryGetResource(SpriteSpecifierSerializer.TextureRoot / component.RsiPath, out RSIResource? rsi))
{
Logger.Error($"{nameof(AtmosPipeAppearanceSystem)} could not load to load RSI {component.RsiPath}.");
return;
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Clothing/ClientClothingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
using static Robust.Client.GameObjects.SpriteComponent;
using static Robust.Shared.GameObjects.SharedSpriteComponent;

namespace Content.Client.Clothing;

Expand Down Expand Up @@ -131,7 +131,7 @@ private bool TryGetDefaultVisuals(EntityUid uid, ClothingComponent clothing, str
RSI? rsi = null;

if (clothing.RsiPath != null)
rsi = _cache.GetResource<RSIResource>(TextureRoot / clothing.RsiPath).RSI;
rsi = _cache.GetResource<RSIResource>(SpriteSpecifierSerializer.TextureRoot / clothing.RsiPath).RSI;
else if (TryComp(uid, out SpriteComponent? sprite))
rsi = sprite.BaseRSI;

Expand Down
6 changes: 3 additions & 3 deletions Content.Client/Doors/DoorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using Robust.Client.GameObjects;
using Robust.Client.ResourceManagement;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
using Robust.Shared.Timing;

namespace Content.Client.Doors;
Expand Down Expand Up @@ -80,7 +80,7 @@ private void OnAppearanceChange(EntityUid uid, DoorComponent comp, ref Appearanc

if (AppearanceSystem.TryGetData<string>(uid, DoorVisuals.BaseRSI, out var baseRsi, args.Component))
{
if (!_resourceCache.TryGetResource<RSIResource>(SharedSpriteComponent.TextureRoot / baseRsi, out var res))
if (!_resourceCache.TryGetResource<RSIResource>(SpriteSpecifierSerializer.TextureRoot / baseRsi, out var res))
{
Logger.Error("Unable to load RSI '{0}'. Trace:\n{1}", baseRsi, Environment.StackTrace);
}
Expand All @@ -89,7 +89,7 @@ private void OnAppearanceChange(EntityUid uid, DoorComponent comp, ref Appearanc
layer.Rsi = res?.RSI;
}
}

TryComp<AnimationPlayerComponent>(uid, out var animPlayer);
if (_animationSystem.HasRunningAnimation(uid, animPlayer, DoorComponent.AnimationKey))
_animationSystem.Stop(uid, animPlayer, DoorComponent.AnimationKey); // Halt all running anomations.
Expand Down
20 changes: 17 additions & 3 deletions Content.Client/Items/Systems/ItemSystem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Hands;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Containers;
using static Robust.Shared.GameObjects.SharedSpriteComponent;
using Robust.Shared.Serialization.TypeSerializers.Implementations;

namespace Content.Client.Items.Systems;

Expand All @@ -19,6 +19,20 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<ItemComponent, GetInhandVisualsEvent>(OnGetVisuals);

// TODO is this still needed? Shouldn't containers occlude them?
SubscribeLocalEvent<SpriteComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<SpriteComponent, GotUnequippedEvent>(OnUnequipped);
}

private void OnUnequipped(EntityUid uid, SpriteComponent component, GotUnequippedEvent args)
{
component.Visible = true;
}

private void OnEquipped(EntityUid uid, SpriteComponent component, GotEquippedEvent args)
{
component.Visible = false;
}

#region InhandVisuals
Expand Down Expand Up @@ -75,7 +89,7 @@ private bool TryGetDefaultVisuals(EntityUid uid, ItemComponent item, string defa
RSI? rsi = null;

if (item.RsiPath != null)
rsi = _resCache.GetResource<RSIResource>(TextureRoot / item.RsiPath).RSI;
rsi = _resCache.GetResource<RSIResource>(SpriteSpecifierSerializer.TextureRoot / item.RsiPath).RSI;
else if (TryComp(uid, out SpriteComponent? sprite))
rsi = sprite.BaseRSI;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Content.Shared.Hands.Components;
using static Robust.Shared.GameObjects.SharedSpriteComponent;

namespace Content.Client.Toggleable;

Expand Down
2 changes: 1 addition & 1 deletion Content.MapRenderer/Painters/GridPainter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private ConcurrentDictionary<EntityUid, List<EntityData>> GetEntities()

foreach (var entity in _sEntityManager.GetEntities())
{
if (!_sEntityManager.HasComponent<SharedSpriteComponent>(entity))
if (!_sEntityManager.HasComponent<SpriteComponent>(entity))
{
continue;
}
Expand Down
11 changes: 6 additions & 5 deletions Content.Server/Nyanotrasen/Arachne/ArachneSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,12 @@ private void OnCocoonDoAfter(EntityUid uid, ArachneComponent component, ArachneC
return;

// todo: our species should use scale visuals probably...
if (spawnProto == "CocoonedHumanoid" && TryComp<SpriteComponent>(args.Args.Target.Value, out var sprite))
{
// why the fuck is this only available as a console command.
_host.ExecuteCommand(null, "scale " + cocoon + " " + sprite.Scale.Y);
} else if (TryComp<PhysicsComponent>(args.Args.Target.Value, out var physics))
// TODO: We need a client-accessible notion of scale influence here.
/* if (spawnProto == "CocoonedHumanoid" && TryComp<SpriteComponent>(args.Args.Target.Value, out var sprite)) */
/* { */
/* // why the fuck is this only available as a console command. */
/* _host.ExecuteCommand(null, "scale " + cocoon + " " + sprite.Scale.Y); */
if (TryComp<PhysicsComponent>(args.Args.Target.Value, out var physics))
{
var scale = Math.Clamp(1 / (35 / physics.FixturesMass), 0.35, 2.5);
_host.ExecuteCommand(null, "scale " + cocoon + " " + scale);
Expand Down
1 change: 0 additions & 1 deletion Content.Shared/Clothing/ClothingEvents.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using static Robust.Shared.GameObjects.SharedSpriteComponent;

namespace Content.Shared.Clothing;

Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Clothing/Components/ClothingComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed class ClothingComponent : Component
{
[DataField("clothingVisuals")]
[Access(typeof(ClothingSystem), typeof(InventorySystem), Other = AccessPermissions.ReadExecute)] // TODO remove execute permissions.
public Dictionary<string, List<SharedSpriteComponent.PrototypeLayerData>> ClothingVisuals = new();
public Dictionary<string, List<PrototypeLayerData>> ClothingVisuals = new();

[ViewVariables(VVAccess.ReadWrite)]
[DataField("quickEquip")]
Expand Down
2 changes: 0 additions & 2 deletions Content.Shared/Hands/HandEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using static Robust.Shared.GameObjects.SharedSpriteComponent;


namespace Content.Shared.Hands
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Item/ItemComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class ItemComponent : Component

[Access(typeof(SharedItemSystem))]
[DataField("inhandVisuals")]
public Dictionary<HandLocation, List<SharedSpriteComponent.PrototypeLayerData>> InhandVisuals = new();
public Dictionary<HandLocation, List<PrototypeLayerData>> InhandVisuals = new();

[Access(typeof(SharedItemSystem))]
[ViewVariables(VVAccess.ReadWrite)]
Expand Down
18 changes: 0 additions & 18 deletions Content.Shared/Item/SharedItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ItemComponent, GetVerbsEvent<InteractionVerb>>(AddPickupVerb);

SubscribeLocalEvent<SharedSpriteComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<SharedSpriteComponent, GotUnequippedEvent>(OnUnequipped);
SubscribeLocalEvent<ItemComponent, InteractHandEvent>(OnHandInteract);

SubscribeLocalEvent<ItemComponent, ComponentGetState>(OnGetState);
Expand Down Expand Up @@ -92,21 +89,6 @@ private void OnGetState(EntityUid uid, ItemComponent component, ref ComponentGet
args.State = new ItemComponentState(component.Size, component.HeldPrefix);
}

// Although netsync is being set to false for items client can still update these
// Realistically:
// Container should already hide these
// Client is the only thing that matters.

private void OnUnequipped(EntityUid uid, SharedSpriteComponent component, GotUnequippedEvent args)
{
component.Visible = true;
}

private void OnEquipped(EntityUid uid, SharedSpriteComponent component, GotEquippedEvent args)
{
component.Visible = false;
}

private void AddPickupVerb(EntityUid uid, ItemComponent component, GetVerbsEvent<InteractionVerb> args)
{
if (args.Hands == null ||
Expand Down

0 comments on commit 885d9fa

Please sign in to comment.