]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Some fixes to magboots (#15392)
authorMenshin <Menshin@users.noreply.github.com>
Sat, 22 Apr 2023 10:42:36 +0000 (12:42 +0200)
committerGitHub <noreply@github.com>
Sat, 22 Apr 2023 10:42:36 +0000 (20:42 +1000)
Content.Client/Clothing/MagbootsSystem.cs
Content.Server/Clothing/MagbootsSystem.cs
Content.Shared/Clothing/MagbootsComponent.cs
Content.Shared/Clothing/SharedMagbootsSystem.cs
Resources/Prototypes/Entities/Clothing/Shoes/magboots.yml

index d8b9119e09fc37db33f13a700439ddf35712023d..a3d39eafded856650d6da9ca93600871068bed30 100644 (file)
@@ -1,27 +1,8 @@
 using Content.Shared.Clothing;
-using Robust.Shared.GameStates;
-using static Content.Shared.Clothing.MagbootsComponent;
 
 namespace Content.Client.Clothing;
 
 public sealed class MagbootsSystem : SharedMagbootsSystem
 {
-    public override void Initialize()
-    {
-        base.Initialize();
 
-        SubscribeLocalEvent<MagbootsComponent, ComponentHandleState>(OnHandleState);
-    }
-
-    private void OnHandleState(EntityUid uid, MagbootsComponent component, ref ComponentHandleState args)
-    {
-        if (args.Current is not MagbootsComponentState componentState)
-            return;
-
-        if (component.On == componentState.On) return;
-        
-        component.On = componentState.On;
-        OnChanged(component);
-    }
 }
-
index 1b3820d8d7f86ad880ef98ec9e7539ecda7ddaac..bc6880552fce6c4026ad2307edd0a58f17af02ed 100644 (file)
@@ -1,19 +1,13 @@
 using Content.Server.Atmos.Components;
-using Content.Server.Clothing.Components;
 using Content.Shared.Alert;
 using Content.Shared.Clothing;
-using Content.Shared.Clothing.EntitySystems;
-using Content.Shared.Inventory;
 using Content.Shared.Inventory.Events;
-using Robust.Shared.Containers;
-using Robust.Shared.GameStates;
-using static Content.Shared.Clothing.MagbootsComponent;
 
 namespace Content.Server.Clothing;
 
 public sealed class MagbootsSystem : SharedMagbootsSystem
 {
-    [Dependency] private readonly AlertsSystem _alertsSystem = default!;
+    [Dependency] private readonly AlertsSystem _alerts = default!;
 
     public override void Initialize()
     {
@@ -21,7 +15,6 @@ public sealed class MagbootsSystem : SharedMagbootsSystem
 
         SubscribeLocalEvent<MagbootsComponent, GotEquippedEvent>(OnGotEquipped);
         SubscribeLocalEvent<MagbootsComponent, GotUnequippedEvent>(OnGotUnequipped);
-        SubscribeLocalEvent<MagbootsComponent, ComponentGetState>(OnGetState);
     }
 
     protected override void UpdateMagbootEffects(EntityUid parent, EntityUid uid, bool state, MagbootsComponent? component)
@@ -37,11 +30,11 @@ public sealed class MagbootsSystem : SharedMagbootsSystem
 
         if (state)
         {
-            _alertsSystem.ShowAlert(parent, AlertType.Magboots);
+            _alerts.ShowAlert(parent, AlertType.Magboots);
         }
         else
         {
-            _alertsSystem.ClearAlert(parent, AlertType.Magboots);
+            _alerts.ClearAlert(parent, AlertType.Magboots);
         }
     }
 
@@ -60,9 +53,4 @@ public sealed class MagbootsSystem : SharedMagbootsSystem
             UpdateMagbootEffects(args.Equipee, uid, true, component);
         }
     }
-
-    private void OnGetState(EntityUid uid, MagbootsComponent component, ref ComponentGetState args)
-    {
-        args.State = new MagbootsComponentState(component.On);
-    }
 }
index 744cf964f5ada32e1732f4d891e3266bc6e918f0..f9980c8014517ccd44f6173590817bb39a115b3b 100644 (file)
@@ -1,26 +1,15 @@
 using Content.Shared.Actions.ActionTypes;
 using Robust.Shared.GameStates;
-using Robust.Shared.Serialization;
 
 namespace Content.Shared.Clothing;
 
-[RegisterComponent, NetworkedComponent()]
-public sealed class MagbootsComponent : Component
+[RegisterComponent, NetworkedComponent(), AutoGenerateComponentState]
+[Access(typeof(SharedMagbootsSystem))]
+public sealed partial class MagbootsComponent : Component
 {
     [DataField("toggleAction", required: true)]
     public InstantAction ToggleAction = new();
 
-    [ViewVariables]
+    [DataField("on"), AutoNetworkedField]
     public bool On;
-
-    [Serializable, NetSerializable]
-    public sealed class MagbootsComponentState : ComponentState
-    {
-        public bool On { get; }
-
-        public MagbootsComponentState(bool @on)
-        {
-            On = on;
-        }
-    }
 }
index d3463089086806b28bc3b008d531c877899ef0e6..4feaa6eb800f0d9f2b8dc9b5cf82675e60cfa631 100644 (file)
@@ -35,29 +35,35 @@ public abstract class SharedMagbootsSystem : EntitySystem
             return;
 
         args.Handled = true;
-        component.On = !component.On;
+
+        ToggleMagboots(uid, component);
+    }
+
+    private void ToggleMagboots(EntityUid uid, MagbootsComponent magboots)
+    {
+        magboots.On = !magboots.On;
 
         if (_sharedContainer.TryGetContainingContainer(uid, out var container) &&
-            _inventory.TryGetSlotEntity(container.Owner, "shoes", out var entityUid) && entityUid == component.Owner)
-            UpdateMagbootEffects(container.Owner, uid, true, component);
+            _inventory.TryGetSlotEntity(container.Owner, "shoes", out var entityUid) && entityUid == uid)
+            UpdateMagbootEffects(container.Owner, uid, true, magboots);
 
         if (TryComp<ItemComponent>(uid, out var item))
         {
-            _item.SetHeldPrefix(uid, component.On ? "on" : null, item);
-            _clothing.SetEquippedPrefix(uid, component.On ? "on" : null);
+            _item.SetHeldPrefix(uid, magboots.On ? "on" : null, item);
+            _clothing.SetEquippedPrefix(uid, magboots.On ? "on" : null);
         }
 
-        _appearance.SetData(uid, ToggleVisuals.Toggled, component.Owner);
-        OnChanged(component);
-        Dirty(component);
+        _appearance.SetData(uid, ToggleVisuals.Toggled, magboots.On);
+        OnChanged(uid, magboots);
+        Dirty(magboots);
     }
 
     protected virtual void UpdateMagbootEffects(EntityUid parent, EntityUid uid, bool state, MagbootsComponent? component) { }
 
-    protected void OnChanged(MagbootsComponent component)
+    protected void OnChanged(EntityUid uid, MagbootsComponent component)
     {
         _sharedActions.SetToggled(component.ToggleAction, component.On);
-        _clothingSpeedModifier.SetClothingSpeedModifierEnabled(component.Owner, component.On);
+        _clothingSpeedModifier.SetClothingSpeedModifierEnabled(uid, component.On);
     }
 
     private void AddToggleVerb(EntityUid uid, MagbootsComponent component, GetVerbsEvent<ActivationVerb> args)
@@ -67,7 +73,7 @@ public abstract class SharedMagbootsSystem : EntitySystem
 
         ActivationVerb verb = new();
         verb.Text = Loc.GetString("toggle-magboots-verb-get-data-text");
-        verb.Act = () => component.On = !component.On;
+        verb.Act = () => ToggleMagboots(uid, component);
         // TODO VERB ICON add toggle icon? maybe a computer on/off symbol?
         args.Verbs.Add(verb);
     }
index 5b6bc6c3498e0d1b8a65200c05246e9d07a401f9..8df84887625fa142827ffbcbc4fb71801f8de329 100644 (file)
@@ -15,7 +15,7 @@
     - type: Magboots
       toggleAction:
         icon: { sprite: Clothing/Shoes/Boots/magboots.rsi, state: icon }
-        iconOn: Clothing/Shoes/Boots/magboots.rsi/icon-on.png
+        iconOn: { sprite : Clothing/Shoes/Boots/magboots.rsi, state: icon-on }
         name: action-name-magboot-toggle
         description: action-decription-magboot-toggle
         itemIconStyle: NoItem