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 0000000000..29a0fa6978 Binary files /dev/null and b/Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-off.png differ diff --git a/Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-unlit.png b/Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-unlit.png new file mode 100644 index 0000000000..cd07184a20 Binary files /dev/null and b/Resources/Textures/Constructible/Hydroponics/machines.rsi/seedextractor-unlit.png differ