]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fragile Deliveries (#36980)
authorScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Sun, 27 Apr 2025 23:04:39 +0000 (01:04 +0200)
committerGitHub <noreply@github.com>
Sun, 27 Apr 2025 23:04:39 +0000 (01:04 +0200)
* epic

* tweaks

Content.Shared/Delivery/DeliveryFragileComponent.cs [new file with mode: 0644]
Content.Shared/Delivery/DeliveryModifierSystem.cs
Content.Shared/Delivery/DeliveryPriorityComponent.cs
Content.Shared/Delivery/SharedDeliverySystem.cs
Resources/Locale/en-US/delivery/delivery-component.ftl
Resources/Prototypes/Entities/Objects/Deliveries/deliveries.yml

diff --git a/Content.Shared/Delivery/DeliveryFragileComponent.cs b/Content.Shared/Delivery/DeliveryFragileComponent.cs
new file mode 100644 (file)
index 0000000..df8b0f1
--- /dev/null
@@ -0,0 +1,31 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Delivery;
+
+/// <summary>
+/// Component given to deliveries.
+/// Allows the delivery to be broken.
+/// If intact, applies a small multiplier, otherwise substracts it.
+/// </summary>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+[Access(typeof(DeliveryModifierSystem))]
+public sealed partial class DeliveryFragileComponent : Component
+{
+    /// <summary>
+    /// Multiplier to use when the delivery is intact.
+    /// </summary>
+    [DataField]
+    public float IntactMultiplierOffset = 0.15f;
+
+    /// <summary>
+    /// Multiplier to use when the delivery is broken.
+    /// </summary>
+    [DataField]
+    public float BrokenMultiplierOffset = -0.33f;
+
+    /// <summary>
+    /// Whether this priority has already been broken or not.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public bool Broken;
+}
index c4ad1bb3a65a76f1fc8a7dd3622dde0590c6f0e5..15a903537b7fedbae9b74c9d12c624ac17cf12f4 100644 (file)
@@ -1,5 +1,5 @@
+using Content.Shared.Destructible;
 using Content.Shared.Examine;
-using Content.Shared.GameTicking;
 using Content.Shared.NameModifier.EntitySystems;
 using Robust.Shared.Random;
 using Robust.Shared.Serialization;
@@ -27,6 +27,11 @@ public sealed partial class DeliveryModifierSystem : EntitySystem
         SubscribeLocalEvent<DeliveryPriorityComponent, MapInitEvent>(OnPriorityMapInit);
         SubscribeLocalEvent<DeliveryPriorityComponent, ExaminedEvent>(OnPriorityExamine);
         SubscribeLocalEvent<DeliveryPriorityComponent, GetDeliveryMultiplierEvent>(OnGetPriorityMultiplier);
+
+        SubscribeLocalEvent<DeliveryFragileComponent, MapInitEvent>(OnFragileMapInit);
+        SubscribeLocalEvent<DeliveryFragileComponent, BreakageEventArgs>(OnFragileBreakage);
+        SubscribeLocalEvent<DeliveryFragileComponent, ExaminedEvent>(OnFragileExamine);
+        SubscribeLocalEvent<DeliveryFragileComponent, GetDeliveryMultiplierEvent>(OnGetFragileMultiplier);
     }
 
     #region Random
@@ -70,6 +75,38 @@ public sealed partial class DeliveryModifierSystem : EntitySystem
     }
     #endregion
 
+    #region Fragile
+    private void OnFragileMapInit(Entity<DeliveryFragileComponent> ent, ref MapInitEvent args)
+    {
+        _delivery.UpdateBrokenVisuals(ent, true);
+    }
+
+    private void OnFragileBreakage(Entity<DeliveryFragileComponent> ent, ref BreakageEventArgs args)
+    {
+        ent.Comp.Broken = true;
+        _delivery.UpdateBrokenVisuals(ent, true);
+        Dirty(ent);
+    }
+
+    private void OnFragileExamine(Entity<DeliveryFragileComponent> ent, ref ExaminedEvent args)
+    {
+        var trueName = _nameModifier.GetBaseName(ent.Owner);
+
+        if (ent.Comp.Broken)
+            args.PushMarkup(Loc.GetString("delivery-fragile-broken-examine", ("type", trueName)));
+        else
+            args.PushMarkup(Loc.GetString("delivery-fragile-examine", ("type", trueName)));
+    }
+
+    private void OnGetFragileMultiplier(Entity<DeliveryFragileComponent> ent, ref GetDeliveryMultiplierEvent args)
+    {
+        if (ent.Comp.Broken)
+            args.AdditiveMultiplier += ent.Comp.BrokenMultiplierOffset;
+        else
+            args.AdditiveMultiplier += ent.Comp.IntactMultiplierOffset;
+    }
+    #endregion
+
     #region Update Loops
     public override void Update(float frameTime)
     {
index 769c6af0f88f4d684a7ae8db7ca07dcf6e6b54c3..dc06af6239fcf5fe6d76d7843a39347ac4a1aa68 100644 (file)
@@ -12,13 +12,13 @@ namespace Content.Shared.Delivery;
 public sealed partial class DeliveryPriorityComponent : Component
 {
     /// <summary>
-    /// The highest the random multiplier can go.
+    /// The multiplier to apply when delivered in time.
     /// </summary>
     [DataField]
     public float InTimeMultiplierOffset = 0.2f;
 
     /// <summary>
-    /// The lowest the random multiplier can go.
+    /// The multiplier to apply when delivered late.
     /// </summary>
     [DataField]
     public float ExpiredMultiplierOffset = -0.1f;
index 0f67c3459e023af62cde44dfd2531bcd38d038ec..db5b849c751e6a7e2b944fbe99db9e5ee247d749 100644 (file)
@@ -231,6 +231,7 @@ public abstract class SharedDeliverySystem : EntitySystem
         }
     }
 
+    #region Visual Updates
     // TODO: generic updateVisuals from component data
     private void UpdateAntiTamperVisuals(EntityUid uid, bool isLocked)
     {
@@ -252,10 +253,17 @@ public abstract class SharedDeliverySystem : EntitySystem
         }
     }
 
+    public void UpdateBrokenVisuals(Entity<DeliveryFragileComponent> ent, bool isFragile)
+    {
+        _appearance.SetData(ent, DeliveryVisuals.IsBroken, ent.Comp.Broken);
+        _appearance.SetData(ent, DeliveryVisuals.IsFragile, isFragile);
+    }
+
     protected void UpdateDeliverySpawnerVisuals(EntityUid uid, int contents)
     {
         _appearance.SetData(uid, DeliverySpawnerVisuals.Contents, contents > 0);
     }
+    #endregion
 
     /// <summary>
     /// Gathers the total multiplier for a delivery.
index c7f2347da4ceb11cf0cfc0ea29a5222215f84531..54f45a578de3c3d39a79649323700dd1604fb23b 100644 (file)
@@ -25,3 +25,6 @@ delivery-teleporter-empty-verb = Take mail
 # modifiers
 delivery-priority-examine = This is a [color=orange]priority {$type}[/color]. You have [color=orange]{$time}[/color] left to deliver it to get a bonus.
 delivery-priority-expired-examine = This is a [color=orange]priority {$type}[/color]. It seems you ran out of time.
+
+delivery-fragile-examine = This is a [color=red]fragile {$type}[/color]. Deliver it intact for a bonus.
+delivery-fragile-broken-examine = This is a [color=red]fragile {$type}[/color]. It looks badly damaged.
index e90a99510ffb66e49b014c58839eaed2ad7e2f55..d1e9969bbbd65f0b0aa65e54b12fbb1314c3e623 100644 (file)
     children:
     - id: DeliveryModifierPriority
       prob: 0.25
+    - id: DeliveryModifierFragile
+      prob: 0.25
 
 - type: entity
   id: DeliveryModifierPriority
   categories: [ HideSpawnMenu ]
   components:
   - type: DeliveryPriority
+
+- type: entity
+  id: DeliveryModifierFragile
+  description: Components to add when a delivery is rolled as fragile.
+  categories: [ HideSpawnMenu ]
+  components:
+  - type: DeliveryFragile
+  - type: Damageable
+    damageContainer: Inorganic
+  - type: DamageOnHighSpeedImpact
+    minimumSpeed: 0.1
+    damage:
+      types:
+        Blunt: 1
+    soundHit:
+      collection: WeakHit
+  - type: DamageOnLand
+    damage:
+      types:
+        Blunt: 1
+  - type: Destructible
+    thresholds:
+    - trigger:
+        !type:DamageTrigger
+        damage: 1
+      behaviors:
+      - !type:PlaySoundBehavior
+        sound:
+          collection: DeliveryOpenSounds
+      - !type:DoActsBehavior
+        acts: [ "Breakage" ]