]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix borg mobstates (#21307)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Thu, 9 Nov 2023 23:14:06 +0000 (18:14 -0500)
committerGitHub <noreply@github.com>
Thu, 9 Nov 2023 23:14:06 +0000 (16:14 -0700)
* Add dead states to borgs

* this?

* ack

17 files changed:
Content.Client/Silicons/Borgs/BorgSystem.cs
Content.Server/Medical/DefibrillatorSystem.cs
Content.Server/Silicons/Borgs/BorgSystem.cs
Content.Server/Zombies/ZombieSystem.Transform.cs
Content.Shared/Alert/AlertType.cs
Content.Shared/Mobs/Systems/MobStateSystem.StateMachine.cs
Resources/Prototypes/Alerts/alerts.yml
Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml
Resources/Textures/Interface/Alerts/borg_alive.rsi/health0.png
Resources/Textures/Interface/Alerts/borg_alive.rsi/health1.png
Resources/Textures/Interface/Alerts/borg_alive.rsi/health2.png
Resources/Textures/Interface/Alerts/borg_alive.rsi/health3.png
Resources/Textures/Interface/Alerts/borg_alive.rsi/health4.png
Resources/Textures/Interface/Alerts/borg_critical.rsi/critical.png [new file with mode: 0644]
Resources/Textures/Interface/Alerts/borg_critical.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Interface/Alerts/borg_dead.rsi/dead.png [new file with mode: 0644]
Resources/Textures/Interface/Alerts/borg_dead.rsi/meta.json [new file with mode: 0644]

index 5d2e5fa070be323de46b840beed48e9e95d869de..e92ce5cc777417417faa49b8fab2a20b9ed2a120 100644 (file)
@@ -1,4 +1,5 @@
-using Content.Shared.Silicons.Borgs;
+using Content.Shared.Mobs;
+using Content.Shared.Silicons.Borgs;
 using Content.Shared.Silicons.Borgs.Components;
 using Robust.Client.GameObjects;
 using Robust.Shared.Containers;
@@ -22,7 +23,7 @@ public sealed class BorgSystem : SharedBorgSystem
     {
         if (args.Sprite == null)
             return;
-        UpdateBorgAppearnce(uid, component, args.Component, args.Sprite);
+        UpdateBorgAppearance(uid, component, args.Component, args.Sprite);
     }
 
     protected override void OnInserted(EntityUid uid, BorgChassisComponent component, EntInsertedIntoContainerMessage args)
@@ -31,7 +32,7 @@ public sealed class BorgSystem : SharedBorgSystem
             return;
 
         base.OnInserted(uid, component, args);
-        UpdateBorgAppearnce(uid, component);
+        UpdateBorgAppearance(uid, component);
     }
 
     protected override void OnRemoved(EntityUid uid, BorgChassisComponent component, EntRemovedFromContainerMessage args)
@@ -40,10 +41,10 @@ public sealed class BorgSystem : SharedBorgSystem
             return;
 
         base.OnRemoved(uid, component, args);
-        UpdateBorgAppearnce(uid, component);
+        UpdateBorgAppearance(uid, component);
     }
 
-    private void UpdateBorgAppearnce(EntityUid uid,
+    private void UpdateBorgAppearance(EntityUid uid,
         BorgChassisComponent? component = null,
         AppearanceComponent? appearance = null,
         SpriteComponent? sprite = null)
@@ -51,6 +52,15 @@ public sealed class BorgSystem : SharedBorgSystem
         if (!Resolve(uid, ref component, ref appearance, ref sprite))
             return;
 
+        if (_appearance.TryGetData<MobState>(uid, MobStateVisuals.State, out var state, appearance))
+        {
+            if (state != MobState.Alive)
+            {
+                sprite.LayerSetVisible(BorgVisualLayers.Light, false);
+                return;
+            }
+        }
+
         if (!_appearance.TryGetData<bool>(uid, BorgVisuals.HasPlayer, out var hasPlayer, appearance))
             hasPlayer = false;
 
index dd9f1ec91e84461a1942d1975e19209ad5df9046..a1e2d53d17f5b4e947a628ec8d8e3f018a0624c1 100644 (file)
@@ -218,11 +218,9 @@ public sealed class DefibrillatorSystem : EntitySystem
         }
         else
         {
-            _mobThreshold.SetAllowRevives(target, true, thresholds);
             if (_mobState.IsDead(target, mob))
                 _damageable.TryChangeDamage(target, component.ZapHeal, true, origin: uid);
             _mobState.ChangeMobState(target, MobState.Critical, mob, uid);
-            _mobThreshold.SetAllowRevives(target, false, thresholds);
 
             if (_mind.TryGetMind(target, out var mindId, out var mind) &&
                 mind.Session is { } playerSession)
index 883cb3b3d84a87caf576cca802a9a700b556855d..7de351a70f3111c69c54920db275ad48160b9fa9 100644 (file)
@@ -11,6 +11,8 @@ using Content.Shared.IdentityManagement;
 using Content.Shared.Interaction;
 using Content.Shared.Mind;
 using Content.Shared.Mind.Components;
+using Content.Shared.Mobs;
+using Content.Shared.Mobs.Systems;
 using Content.Shared.Movement.Systems;
 using Content.Shared.PowerCell;
 using Content.Shared.PowerCell.Components;
@@ -39,6 +41,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
     [Dependency] private readonly HandsSystem _hands = default!;
     [Dependency] private readonly MetaDataSystem _metaData = default!;
     [Dependency] private readonly SharedMindSystem _mind = default!;
+    [Dependency] private readonly MobStateSystem _mobState = default!;
     [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
     [Dependency] private readonly PowerCellSystem _powerCell = default!;
     [Dependency] private readonly ThrowingSystem _throwing = default!;
@@ -56,6 +59,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
         SubscribeLocalEvent<BorgChassisComponent, AfterInteractUsingEvent>(OnChassisInteractUsing);
         SubscribeLocalEvent<BorgChassisComponent, MindAddedMessage>(OnMindAdded);
         SubscribeLocalEvent<BorgChassisComponent, MindRemovedMessage>(OnMindRemoved);
+        SubscribeLocalEvent<BorgChassisComponent, MobStateChangedEvent>(OnMobStateChanged);
         SubscribeLocalEvent<BorgChassisComponent, PowerCellChangedEvent>(OnPowerCellChanged);
         SubscribeLocalEvent<BorgChassisComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
         SubscribeLocalEvent<BorgChassisComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
@@ -98,7 +102,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
         {
             if (_mind.TryGetMind(used, out _, out var mind) && mind.Session != null)
             {
-                if (!CanPlayerBeBorgged(mind.Session))
+                if (!CanPlayerBeBorged(mind.Session))
                 {
                     Popup.PopupEntity(Loc.GetString("borg-player-not-allowed"), used, args.User);
                     return;
@@ -154,6 +158,19 @@ public sealed partial class BorgSystem : SharedBorgSystem
         BorgDeactivate(uid, component);
     }
 
+    private void OnMobStateChanged(EntityUid uid, BorgChassisComponent component, MobStateChangedEvent args)
+    {
+        if (args.NewMobState == MobState.Alive)
+        {
+            if (_mind.TryGetMind(uid, out _, out _))
+                _powerCell.SetPowerCellDrawEnabled(uid, true);
+        }
+        else
+        {
+            _powerCell.SetPowerCellDrawEnabled(uid, false);
+        }
+    }
+
     private void OnPowerCellChanged(EntityUid uid, BorgChassisComponent component, PowerCellChangedEvent args)
     {
         UpdateBatteryAlert(uid);
@@ -172,7 +189,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
         if (_powerCell.HasDrawCharge(uid, draw))
         {
             // only reenable the powerdraw if a player has the role.
-            if (!draw.Drawing && _mind.TryGetMind(uid, out _, out _))
+            if (!draw.Drawing && _mind.TryGetMind(uid, out _, out _) && _mobState.IsAlive(uid))
                 _powerCell.SetPowerCellDrawEnabled(uid, true);
 
             EnableBorgAbilities(uid, component);
@@ -213,7 +230,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
         if (!_mind.TryGetMind(uid, out var mindId, out var mind) || mind.Session == null)
             return;
 
-        if (!CanPlayerBeBorgged(mind.Session))
+        if (!CanPlayerBeBorged(mind.Session))
         {
             Popup.PopupEntity(Loc.GetString("borg-player-not-allowed-eject"), uid);
             Container.RemoveEntity(containerEnt, uid);
@@ -249,7 +266,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
     /// <summary>
     /// Activates the borg, enabling all of its modules.
     /// </summary>
-    public void EnableBorgAbilities(EntityUid uid, BorgChassisComponent component)
+    public void EnableBorgAbilities(EntityUid uid, BorgChassisComponent component, PowerCellDrawComponent? powerCell = null)
     {
         if (component.Activated)
             return;
@@ -302,7 +319,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
     /// Checks that a player has fulfilled the requirements for the borg job.
     /// If they don't have enough hours, they cannot be placed into a chassis.
     /// </summary>
-    public bool CanPlayerBeBorgged(ICommonSession session)
+    public bool CanPlayerBeBorged(ICommonSession session)
     {
         if (_banManager.GetJobBans(session.UserId)?.Contains(BorgJobId) == true)
             return false;
index 18bbd7e7a8eee4e02f7d2daf0416d5f7a80aa736..9c51b052feb3fb088bcfe8545f055baa3c1f60e6 100644 (file)
@@ -198,12 +198,10 @@ namespace Content.Server.Zombies
             if (TryComp<TemperatureComponent>(target, out var tempComp))
                 tempComp.ColdDamage.ClampMax(0);
 
-            _mobThreshold.SetAllowRevives(target, true);
             //Heals the zombie from all the damage it took while human
             if (TryComp<DamageableComponent>(target, out var damageablecomp))
                 _damageable.SetAllDamage(target, damageablecomp, 0);
             _mobState.ChangeMobState(target, MobState.Alive);
-            _mobThreshold.SetAllowRevives(target, false);
 
             var factionComp = EnsureComp<NpcFactionMemberComponent>(target);
             foreach (var id in new List<string>(factionComp.Factions))
index e0a7ac99f85ee65b43db5bdad378b5702b357b8b..68db360231089a320be6866af3e6f0efe61b9845 100644 (file)
@@ -49,7 +49,9 @@ namespace Content.Shared.Alert
         Debug5,
         Debug6,
         SuitPower,
-        BorgHealth
+        BorgHealth,
+        BorgCrit,
+        BorgDead
     }
 
 }
index 25b63d5b80bbf9d8d340e35d139fdf753b1c100a..2fa522dea59655d0df2c61199cfa9ed9cf40d68f 100644 (file)
@@ -36,7 +36,8 @@ public partial class MobStateSystem
     }
 
     /// <summary>
-    /// Change the MobState and trigger MobState update events
+    /// Change the MobState without triggering UpdateMobState events.
+    /// WARNING: use this sparingly when you need to override other systems (MobThresholds)
     /// </summary>
     /// <param name="entity">Target Entity we want to change the MobState of</param>
     /// <param name="mobState">The new MobState we want to set</param>
@@ -48,9 +49,7 @@ public partial class MobStateSystem
         if (!Resolve(entity, ref component))
             return;
 
-        var ev = new UpdateMobStateEvent {Target = entity, Component = component, Origin = origin, State = mobState};
-        RaiseLocalEvent(entity, ref ev);
-        ChangeState(entity, component, ev.State);
+        ChangeState(entity, component, mobState, origin: origin);
     }
 
     #endregion
index e71a8ed38190ea78f9d6ed0c4201274465336b3a..bc3137b07f4e33da302cf70631f4b8ae096b48c6 100644 (file)
   minSeverity: 0
   maxSeverity: 4
 
+- type: alert
+  id: BorgCrit
+  category: Health
+  icons:
+  - sprite: /Textures/Interface/Alerts/borg_critical.rsi
+    state: critical
+  name: alerts-crit-name
+  description: alerts-crit-desc
+
+- type: alert
+  id: BorgDead
+  category: Health
+  icons:
+  - sprite: /Textures/Interface/Alerts/borg_dead.rsi
+    state: dead
+  name: alerts-dead-name
+  description: alerts-dead-desc
+
 - type: alert
   id: BorgBattery
   category: Battery
index c0b89e783b7caaaca272c87c783648b97920a00c..42fea8fda445ba1e25cd291e99884642cbc53958 100644 (file)
@@ -1,4 +1,5 @@
 - type: entity
+  parent: BaseMob
   id: BaseBorgChassis
   name: cyborg
   description: A man-machine hybrid that assists in station activity. They love being asked to state their laws over and over.
@@ -8,23 +9,16 @@
   - type: Reactive
     groups:
       Acidic: [Touch]
-  - type: Input
-    context: "human"
-  - type: InputMover
   - type: DamageOnHighSpeedImpact
     damage:
       types:
         Blunt: 5
     soundHit:
       path: /Audio/Effects/hit_kick.ogg
-  - type: Clickable
   - type: CombatMode
   - type: NoSlip
   - type: StaticPrice
     price: 1250
-  - type: InteractionOutline
-  - type: Physics
-    bodyType: KinematicController
   - type: Fixtures
     fixtures:
       fix1:
     baseSprintSpeed : 4.5
   - type: Sprite
     sprite: Mobs/Silicon/chassis.rsi
-    noRot: true
-    drawdepth: Mobs
+  - type: RotationVisuals
+    horizontalRotation: 90
   - type: MobState
     allowedStates:
     - Alive
+    - Critical
+    - Dead
   - type: MobThresholds
     thresholds:
       0: Alive
-      150: Dead
+      100: Critical
+      200: Dead
     stateAlertDict:
       Alive: BorgHealth
+      Critical: BorgCrit
+      Dead: BorgDead
     showOverlays: false
+    allowRevives: true
   - type: HealthExaminable
     examinableTypes:
       - Blunt
     slots:
       cell_slot:
         name: power-cell-slot-component-slot-name-default
-  - type: DoAfter
-  - type: Eye
   - type: Body
   - type: StatusEffects
     allowed:
     - Stun
     - KnockedDown
     - SlowedDown
-  - type: Actions
   - type: TypingIndicator
     proto: robot
   - type: Speech
             volume: 5
     - trigger:
         !type:DamageTrigger
-        damage: 150
+        damage: 300
       behaviors:
       - !type:PlaySoundBehavior
         sound: /Audio/Effects/metalbreak.ogg
   - type: Pullable
   - type: Puller
     needsHands: false
-  - type: Examiner
-  - type: Appearance
   - type: StandingState
-  - type: Alerts
   - type: Tag
     tags:
     - ShoesRequiredStepTriggerImmune
index b94d636d0f5f9a3d2f8e1eacc33cf755ac4c798b..ab8c3ac9ca3cc5a4aca390f767f8cfb772303a9b 100644 (file)
Binary files a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health0.png and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health0.png differ
index c58c73f60466d35e85881277ace5f0fe58fd1eea..507f2548827114c32e506af99330bd3a39b42cb9 100644 (file)
Binary files a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health1.png and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health1.png differ
index 2447ba0fe3bcd6de867ecc76345965a57a84fa9b..160f153af8d60f740bf1a7bc070020f7e19dbf3b 100644 (file)
Binary files a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health2.png and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health2.png differ
index fd4e7ccde30ca282745241a75cb9d3db18478f44..be9ff364eb73252c4ff6090edb604026d155b12f 100644 (file)
Binary files a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health3.png and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health3.png differ
index 449d4428b8efe36edd15e5f6d206ec6bf43d3050..1ef65e48a0017bbd509b4d29b5b94c9a619930e6 100644 (file)
Binary files a/Resources/Textures/Interface/Alerts/borg_alive.rsi/health4.png and b/Resources/Textures/Interface/Alerts/borg_alive.rsi/health4.png differ
diff --git a/Resources/Textures/Interface/Alerts/borg_critical.rsi/critical.png b/Resources/Textures/Interface/Alerts/borg_critical.rsi/critical.png
new file mode 100644 (file)
index 0000000..cd11538
Binary files /dev/null and b/Resources/Textures/Interface/Alerts/borg_critical.rsi/critical.png differ
diff --git a/Resources/Textures/Interface/Alerts/borg_critical.rsi/meta.json b/Resources/Textures/Interface/Alerts/borg_critical.rsi/meta.json
new file mode 100644 (file)
index 0000000..cc39066
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "version": 1,
+  "license": "CC-BY-SA-3.0",
+  "copyright": "https://github.com/tgstation/tgstation/blob/42ebbb4202b472cf94561974a30e00a0b00e11bc/icons/mob/screen1_robot.dmi",
+  "size": {
+    "x": 32,
+    "y": 32
+  },
+  "states": [
+    {
+      "name": "critical",
+      "delays": [
+        [
+          0.1,
+          0.1,
+          0.1
+        ]
+      ]
+    }
+  ]
+}
diff --git a/Resources/Textures/Interface/Alerts/borg_dead.rsi/dead.png b/Resources/Textures/Interface/Alerts/borg_dead.rsi/dead.png
new file mode 100644 (file)
index 0000000..c060f9b
Binary files /dev/null and b/Resources/Textures/Interface/Alerts/borg_dead.rsi/dead.png differ
diff --git a/Resources/Textures/Interface/Alerts/borg_dead.rsi/meta.json b/Resources/Textures/Interface/Alerts/borg_dead.rsi/meta.json
new file mode 100644 (file)
index 0000000..bb68e6e
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "version": 1,
+  "license": "CC-BY-SA-3.0",
+  "copyright": "https://github.com/tgstation/tgstation/blob/42ebbb4202b472cf94561974a30e00a0b00e11bc/icons/mob/screen1_robot.dmi",
+  "size": {
+    "x": 32,
+    "y": 32
+  },
+  "states": [
+    {
+      "name": "dead"
+    }
+  ]
+}