Update trivial components to use auto comp states (#20539)

This commit is contained in:
DrSmugleaf
2023-09-28 16:20:29 -07:00
committed by GitHub
parent 14cfe44ece
commit a44fa86b68
158 changed files with 806 additions and 2866 deletions

View File

@@ -5,7 +5,6 @@ using Content.Shared.IdentityManagement.Components;
using Content.Shared.Prototypes;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
@@ -22,22 +21,13 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
{
base.Initialize();
SubscribeLocalEvent<ChameleonClothingComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<ChameleonClothingComponent, ComponentGetState>(GetState);
SubscribeLocalEvent<ChameleonClothingComponent, GetVerbsEvent<InteractionVerb>>(OnVerb);
SubscribeLocalEvent<ChameleonClothingComponent, ChameleonPrototypeSelectedMessage>(OnSelected);
}
private void OnMapInit(EntityUid uid, ChameleonClothingComponent component, MapInitEvent args)
{
SetSelectedPrototype(uid, component.SelectedId, true, component);
}
private void GetState(EntityUid uid, ChameleonClothingComponent component, ref ComponentGetState args)
{
args.State = new ChameleonClothingComponentState
{
SelectedId = component.SelectedId
};
SetSelectedPrototype(uid, component.Default, true, component);
}
private void OnVerb(EntityUid uid, ChameleonClothingComponent component, GetVerbsEvent<InteractionVerb> args)
@@ -72,7 +62,7 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
if (!Resolve(uid, ref component))
return;
var state = new ChameleonBoundUserInterfaceState(component.Slot, component.SelectedId);
var state = new ChameleonBoundUserInterfaceState(component.Slot, component.Default);
_uiSystem.TrySetUiState(uid, ChameleonUiKey.Key, state);
}
@@ -87,7 +77,7 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
// check that wasn't already selected
// forceUpdate on component init ignores this check
if (component.SelectedId == protoId && !forceUpdate)
if (component.Default == protoId && !forceUpdate)
return;
// make sure that it is valid change
@@ -95,7 +85,7 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
return;
if (!IsValidTarget(proto, component.Slot))
return;
component.SelectedId = protoId;
component.Default = protoId;
UpdateIdentityBlocker(uid, component, proto);
UpdateVisuals(uid, component);