From a51305466e70a1560f7738f7adfdac18d23d08fb Mon Sep 17 00:00:00 2001 From: Swept Date: Sat, 19 Jun 2021 19:34:01 +0000 Subject: [PATCH] Makes more stuff destructible/breakable (#4081) --- .../Visualizers/MicrowaveVisualizer.cs | 7 ++- .../Kitchen/Components/MicrowaveComponent.cs | 35 +++++++++++++- .../Components/SharedMicrowaveComponent.cs | 5 +- .../Constructible/Furniture/potted_plants.yml | 11 +++++ .../Constructible/Power/seed_extractor.yml | 44 +++++++++--------- .../Dispensers/reagent_dispenser_base.yml | 28 +++++++---- .../Specific/Kitchen/meat_spike.yml | 10 +++- .../Specific/Kitchen/microwave.yml | 10 ++++ .../Specific/Kitchen/reagent_grinder.yml | 12 +++++ .../Specific/Research/research.yml | 32 +++++++++++++ .../Constructible/Specific/chem_master.yml | 3 +- .../Constructible/Storage/Closets/closet.yml | 9 +++- .../Storage/Closets/closet_secure.yml | 15 ++++++ .../Entities/Constructible/base_machine.yml | 5 +- .../Hydroponics/machines.rsi/meta.json | 18 +++++++ .../machines.rsi/seedextractor-off.png | Bin 0 -> 699 bytes .../machines.rsi/seedextractor-unlit.png | Bin 0 -> 1230 bytes 17 files changed, 201 insertions(+), 43 deletions(-) create mode 100644 Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-off.png create mode 100644 Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-unlit.png diff --git a/Content.Client/Kitchen/Visualizers/MicrowaveVisualizer.cs b/Content.Client/Kitchen/Visualizers/MicrowaveVisualizer.cs index d82f37f32f..97d2bf0e7c 100644 --- a/Content.Client/Kitchen/Visualizers/MicrowaveVisualizer.cs +++ b/Content.Client/Kitchen/Visualizers/MicrowaveVisualizer.cs @@ -1,4 +1,4 @@ -using Content.Client.Sound; +using Content.Client.Sound; using Content.Shared.Kitchen.Components; using Content.Shared.Power; using Content.Shared.Sound; @@ -25,6 +25,11 @@ namespace Content.Client.Kitchen.Visualizers } switch (state) { + case MicrowaveVisualState.Broken: + sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mwb"); + loopingSoundComponent?.StopAllSounds(); + break; + case MicrowaveVisualState.Idle: sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw"); sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_unlit"); diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index 3e8a2ffa05..cfb257b596 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -11,6 +11,7 @@ using Content.Server.Items; using Content.Server.Notification; using Content.Server.Power.Components; using Content.Server.UserInterface; +using Content.Shared.Acts; using Content.Shared.Body.Components; using Content.Shared.Body.Part; using Content.Shared.Chemistry; @@ -37,7 +38,7 @@ namespace Content.Server.Kitchen.Components { [RegisterComponent] [ComponentReference(typeof(IActivate))] - public class MicrowaveComponent : SharedMicrowaveComponent, IActivate, IInteractUsing, ISolutionChange, ISuicideAct + public class MicrowaveComponent : SharedMicrowaveComponent, IActivate, IInteractUsing, ISolutionChange, ISuicideAct, IBreakAct { [Dependency] private readonly RecipeManager _recipeManager = default!; @@ -56,6 +57,7 @@ namespace Content.Server.Kitchen.Components [ViewVariables] private bool _busy = false; + private bool _broken; /// /// This is a fixed offset of 5. @@ -160,6 +162,17 @@ namespace Content.Server.Kitchen.Components _uiDirty = true; } + if (_busy && _broken) + { + SetAppearance(MicrowaveVisualState.Broken); + //we broke while we were cooking/busy! + _lostPower = true; + VaporizeReagents(); + EjectSolids(); + _busy = false; + _uiDirty = true; + } + if (_uiDirty && Owner.TryGetComponent(out SolutionContainerComponent? solution)) { UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState @@ -176,12 +189,24 @@ namespace Content.Server.Kitchen.Components private void SetAppearance(MicrowaveVisualState state) { + var finalState = state; + if (_broken) + { + finalState = MicrowaveVisualState.Broken; + } + if (Owner.TryGetComponent(out AppearanceComponent? appearance)) { - appearance.SetData(PowerDeviceVisuals.VisualState, state); + appearance.SetData(PowerDeviceVisuals.VisualState, finalState); } } + public void OnBreak(BreakageEventArgs eventArgs) + { + _broken = true; + SetAppearance(MicrowaveVisualState.Broken); + } + void IActivate.Activate(ActivateEventArgs eventArgs) { if (!eventArgs.User.TryGetComponent(out ActorComponent? actor) || !Powered) @@ -201,6 +226,12 @@ namespace Content.Server.Kitchen.Components return false; } + if (_broken) + { + Owner.PopupMessage(eventArgs.User, Loc.GetString("It's broken!")); + return false; + } + var itemEntity = eventArgs.User.GetComponent().GetActiveHand?.Owner; if (itemEntity == null) diff --git a/Content.Shared/Kitchen/Components/SharedMicrowaveComponent.cs b/Content.Shared/Kitchen/Components/SharedMicrowaveComponent.cs index a378b15323..fb607f37e8 100644 --- a/Content.Shared/Kitchen/Components/SharedMicrowaveComponent.cs +++ b/Content.Shared/Kitchen/Components/SharedMicrowaveComponent.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using System; using Content.Shared.Chemistry.Solution; using Content.Shared.NetIDs; @@ -89,7 +89,8 @@ namespace Content.Shared.Kitchen.Components public enum MicrowaveVisualState { Idle, - Cooking + Cooking, + Broken } [NetSerializable, Serializable] diff --git a/Resources/Prototypes/Entities/Constructible/Furniture/potted_plants.yml b/Resources/Prototypes/Entities/Constructible/Furniture/potted_plants.yml index cdb8d58fdd..2f04ab3d3c 100644 --- a/Resources/Prototypes/Entities/Constructible/Furniture/potted_plants.yml +++ b/Resources/Prototypes/Entities/Constructible/Furniture/potted_plants.yml @@ -24,6 +24,17 @@ - type: SecretStash secretPartName: the plant - type: Pullable + - type: Damageable + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 50 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: /Audio/Effects/plant_rustle.ogg - type: entity id: PottedPlantRandom diff --git a/Resources/Prototypes/Entities/Constructible/Power/seed_extractor.yml b/Resources/Prototypes/Entities/Constructible/Power/seed_extractor.yml index 99bfc821e7..ea36f6c59c 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/seed_extractor.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/seed_extractor.yml @@ -1,28 +1,26 @@ - type: entity id: SeedExtractor name: seed extractor + parent: BaseMachinePowered description: Extracts seeds from produce. - placement: - mode: SnapgridCenter components: - - type: Clickable - - type: InteractionOutline - - type: Sprite - sprite: Constructible/Hydroponics/machines.rsi - state: seedextractor - - type: Physics - bodyType: Static - fixtures: - - shape: - !type:PhysShapeAabb - bounds: "-0.4,-0.25,0.4,0.25" - mass: 25 - layer: - - Opaque - - Impassable - - MobImpassable - - VaultImpassable - - type: SnapGrid - - type: Anchorable - - type: SeedExtractor - - type: PowerReceiver + - type: Sprite + sprite: Constructible/Hydroponics/machines.rsi + layers: + - state: seedextractor-off + - state: seedextractor-unlit + shader: unshaded + netsync: false + - type: Physics + bodyType: Static + fixtures: + - shape: + !type:PhysShapeAabb + bounds: "-0.4,-0.25,0.4,0.25" + mass: 25 + layer: + - MobMask + - Opaque + mask: + - MobMask + - type: SeedExtractor diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Dispensers/reagent_dispenser_base.yml b/Resources/Prototypes/Entities/Constructible/Specific/Dispensers/reagent_dispenser_base.yml index a542c67926..dd6a6ac8c1 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Dispensers/reagent_dispenser_base.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Dispensers/reagent_dispenser_base.yml @@ -14,17 +14,13 @@ bounds: "-0.3,-0.4,0.3,0.4" mass: 25 mask: - - Impassable - - MobImpassable - - VaultImpassable - - SmallImpassable + - Impassable + - VaultImpassable + - SmallImpassable layer: - - Opaque - - Impassable - - MobImpassable - - VaultImpassable - - type: SnapGrid - - type: ReagentDispenser + - Opaque + - MobImpassable + - SmallImpassable - type: PowerReceiver - type: UserInterface interfaces: @@ -33,3 +29,15 @@ - type: LoopingSound - type: Anchorable - type: Pullable + - type: Damageable + resistances: metallicResistances + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 200 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: /Audio/Effects/metalbreak.ogg diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/meat_spike.yml b/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/meat_spike.yml index d43d40e1da..5b9aee0f82 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/meat_spike.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/meat_spike.yml @@ -11,14 +11,22 @@ sprite: Constructible/Misc/kitchen.rsi state: spike - type: Damageable + resistances: metallicResistances - type: Destructible thresholds: - trigger: !type:DamageTrigger - damage: 50 + damage: 100 behaviors: - !type:DoActsBehavior acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: /Audio/Effects/metalbreak.ogg + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel1: + min: 1 + max: 1 - type: KitchenSpike - type: Anchorable - type: Pullable diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/microwave.yml b/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/microwave.yml index 6a22095168..8a29b60620 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/microwave.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/microwave.yml @@ -40,3 +40,13 @@ shader: unshaded map: ["enum.MicrowaveVisualizerLayers.BaseUnlit"] - type: PowerReceiver + - type: Damageable + resistances: metallicResistances + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: + - !type:DoActsBehavior + acts: ["Breakage"] diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/reagent_grinder.yml b/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/reagent_grinder.yml index 5d8fa6511a..9ab61d3506 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/reagent_grinder.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Kitchen/reagent_grinder.yml @@ -33,3 +33,15 @@ sprite: Constructible/Power/juicer.rsi state: juicer0 drawdepth: Items + - type: Damageable + resistances: metallicResistances + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 100 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: /Audio/Effects/metalbreak.ogg diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Research/research.yml b/Resources/Prototypes/Entities/Constructible/Specific/Research/research.yml index 1c59e2cc4f..10efe5da0d 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Research/research.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Research/research.yml @@ -24,6 +24,23 @@ - type: PowerReceiver powerLoad: 200 priority: Low + - type: Damageable + resistances: metallicResistances + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 300 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: /Audio/Effects/metalbreak.ogg + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel1: + min: 1 + max: 2 - type: entity id: BaseResearchAndDevelopmentPointSource @@ -61,3 +78,18 @@ visuals: - type: PowerDeviceVisualizer - type: PowerReceiver + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 200 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: /Audio/Effects/metalbreak.ogg + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel1: + min: 1 + max: 1 diff --git a/Resources/Prototypes/Entities/Constructible/Specific/chem_master.yml b/Resources/Prototypes/Entities/Constructible/Specific/chem_master.yml index cadc8ed5b1..7b1653ced2 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/chem_master.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/chem_master.yml @@ -53,9 +53,10 @@ - type: entity id: chem_master_broken parent: BaseConstructibleDynamic - name: ChemMaster 4000 [Broken] + name: ChemMaster 4000 description: "An industrial grade chemical manipulator with pill and bottle production included. It's broken." abstract: true + suffix: Broken components: - type: Sprite sprite: Constructible/Power/mixer.rsi diff --git a/Resources/Prototypes/Entities/Constructible/Storage/Closets/closet.yml b/Resources/Prototypes/Entities/Constructible/Storage/Closets/closet.yml index f291a87e2e..66f9fc8910 100644 --- a/Resources/Prototypes/Entities/Constructible/Storage/Closets/closet.yml +++ b/Resources/Prototypes/Entities/Constructible/Storage/Closets/closet.yml @@ -41,10 +41,17 @@ thresholds: - trigger: !type:DamageTrigger - damage: 100 + damage: 150 behaviors: - !type:DoActsBehavior acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: /Audio/Effects/metalbreak.ogg + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel1: + min: 1 + max: 1 - type: Appearance visuals: - type: StorageVisualizer diff --git a/Resources/Prototypes/Entities/Constructible/Storage/Closets/closet_secure.yml b/Resources/Prototypes/Entities/Constructible/Storage/Closets/closet_secure.yml index 38e957b6bd..5655c8c250 100644 --- a/Resources/Prototypes/Entities/Constructible/Storage/Closets/closet_secure.yml +++ b/Resources/Prototypes/Entities/Constructible/Storage/Closets/closet_secure.yml @@ -18,3 +18,18 @@ - state: welded visible: false map: ["enum.StorageVisualLayers.Welded"] + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 300 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: /Audio/Effects/metalbreak.ogg + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel1: + min: 1 + max: 2 diff --git a/Resources/Prototypes/Entities/Constructible/base_machine.yml b/Resources/Prototypes/Entities/Constructible/base_machine.yml index f9a73bc11e..14928a150b 100644 --- a/Resources/Prototypes/Entities/Constructible/base_machine.yml +++ b/Resources/Prototypes/Entities/Constructible/base_machine.yml @@ -27,11 +27,12 @@ behaviors: - !type:DoActsBehavior acts: ["Destruction"] - + - !type:PlaySoundBehavior + sound: /Audio/Effects/metalbreak.ogg + - type: entity abstract: true parent: BaseMachine id: BaseMachinePowered components: - type: PowerReceiver - diff --git a/Resources/Textures/Constructible/Hydroponics/machines.rsi/meta.json b/Resources/Textures/Constructible/Hydroponics/machines.rsi/meta.json index 4e2c0cc4de..2c0ad715ce 100644 --- a/Resources/Textures/Constructible/Hydroponics/machines.rsi/meta.json +++ b/Resources/Textures/Constructible/Hydroponics/machines.rsi/meta.json @@ -22,6 +22,24 @@ ] ] }, + { + "name": "seedextractor-unlit", + "delays": [ + [ + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1 + ] + ] + }, + { + "name": "seedextractor-off" + }, { "name": "spawner" }, diff --git a/Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-off.png b/Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-off.png new file mode 100644 index 0000000000000000000000000000000000000000..29a0fa69787b88c3f5fded7e81368c610b0540b8 GIT binary patch literal 699 zcmV;s0!00ZP)vFk- z`FtKpL{jz8aU5DK79)|%@I}xtA|44q@@lmjo18<+M0f!*d9T-tM2O=Y$6?D51j!K39_k)<7pIdM9@~NC1z_h8p0!t0(QIIF(lC8aLAVO{QM={ z-i`sqa1llUgoL(qD>ymUGK>Opxm+wV$pzWEcRC%oy!-@%!GJyVJWs?b1)!nCaYBv{ z08j$}qds zBjMz=S`E70ZftTSMgcen&xTxIT)Y7Slx>QBzt8sxc_83W=*WXLlKaB<0uE-62%Z7e zDEt(ol66vFph{#gRuxY_f2Y*_P3f1_--3PqKB^U)GNpa@?5V!5`zB-?Ech%4zLtD5 z#(^yZl<#sIcnqF~p!mCApzSNa2e_d~IcHJp16=w~8EvA#tfxdN9V1S6|1I$wb@-w%YbLWFS`$IP(AC hqu)DCrv6s|z#r6)a9T_4*17-y002ovPDHLkV1h1zIE?@R literal 0 HcmV?d00001 diff --git a/Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-unlit.png b/Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-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