Kill UserInterfaceHelpers (#20912)
This commit is contained in:
@@ -74,7 +74,8 @@ public sealed class CrayonSystem : SharedCrayonSystem
|
||||
|
||||
// Decrease "Ammo"
|
||||
component.Charges--;
|
||||
Dirty(component);
|
||||
Dirty(uid, component);
|
||||
|
||||
_adminLogger.Add(LogType.CrayonDraw, LogImpact.Low, $"{EntityManager.ToPrettyString(args.User):user} drew a {component.Color:color} {component.SelectedState}");
|
||||
args.Handled = true;
|
||||
|
||||
@@ -89,17 +90,16 @@ public sealed class CrayonSystem : SharedCrayonSystem
|
||||
return;
|
||||
|
||||
if (!TryComp<ActorComponent>(args.User, out var actor) ||
|
||||
component.UserInterface == null)
|
||||
!_uiSystem.TryGetUi(uid, SharedCrayonComponent.CrayonUiKey.Key, out var ui))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_uiSystem.ToggleUi(component.UserInterface, actor.PlayerSession);
|
||||
|
||||
if (component.UserInterface?.SubscribedSessions.Contains(actor.PlayerSession) == true)
|
||||
_uiSystem.ToggleUi(ui, actor.PlayerSession);
|
||||
if (ui.SubscribedSessions.Contains(actor.PlayerSession))
|
||||
{
|
||||
// Tell the user interface the selected stuff
|
||||
_uiSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
|
||||
_uiSystem.SetUiState(ui, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color));
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
@@ -108,22 +108,22 @@ public sealed class CrayonSystem : SharedCrayonSystem
|
||||
private void OnCrayonBoundUI(EntityUid uid, CrayonComponent component, CrayonSelectMessage args)
|
||||
{
|
||||
// Check if the selected state is valid
|
||||
if (!_prototypeManager.TryIndex<DecalPrototype>(args.State, out var prototype) || !prototype.Tags.Contains("crayon")) return;
|
||||
if (!_prototypeManager.TryIndex<DecalPrototype>(args.State, out var prototype) || !prototype.Tags.Contains("crayon"))
|
||||
return;
|
||||
|
||||
component.SelectedState = args.State;
|
||||
|
||||
Dirty(component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnCrayonBoundUIColor(EntityUid uid, CrayonComponent component, CrayonColorMessage args)
|
||||
{
|
||||
// you still need to ensure that the given color is a valid color
|
||||
if (component.SelectableColor && args.Color != component.Color)
|
||||
{
|
||||
component.Color = args.Color;
|
||||
if (!component.SelectableColor || args.Color == component.Color)
|
||||
return;
|
||||
|
||||
Dirty(component);
|
||||
}
|
||||
component.Color = args.Color;
|
||||
Dirty(uid, component);
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public sealed class CrayonSystem : SharedCrayonSystem
|
||||
// Get the first one from the catalog and set it as default
|
||||
var decal = _prototypeManager.EnumeratePrototypes<DecalPrototype>().FirstOrDefault(x => x.Tags.Contains("crayon"));
|
||||
component.SelectedState = decal?.ID ?? string.Empty;
|
||||
Dirty(component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnCrayonDropped(EntityUid uid, CrayonComponent component, DroppedEvent args)
|
||||
|
||||
Reference in New Issue
Block a user