Makes more stuff destructible/breakable (#4081)

This commit is contained in:
Swept
2021-06-19 19:34:01 +00:00
committed by GitHub
parent 6a646d25ca
commit a51305466e
17 changed files with 201 additions and 43 deletions

View File

@@ -1,4 +1,4 @@
using Content.Client.Sound; using Content.Client.Sound;
using Content.Shared.Kitchen.Components; using Content.Shared.Kitchen.Components;
using Content.Shared.Power; using Content.Shared.Power;
using Content.Shared.Sound; using Content.Shared.Sound;
@@ -25,6 +25,11 @@ namespace Content.Client.Kitchen.Visualizers
} }
switch (state) switch (state)
{ {
case MicrowaveVisualState.Broken:
sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mwb");
loopingSoundComponent?.StopAllSounds();
break;
case MicrowaveVisualState.Idle: case MicrowaveVisualState.Idle:
sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw"); sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw");
sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_unlit"); sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_unlit");

View File

@@ -11,6 +11,7 @@ using Content.Server.Items;
using Content.Server.Notification; using Content.Server.Notification;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Shared.Acts;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
using Content.Shared.Body.Part; using Content.Shared.Body.Part;
using Content.Shared.Chemistry; using Content.Shared.Chemistry;
@@ -37,7 +38,7 @@ namespace Content.Server.Kitchen.Components
{ {
[RegisterComponent] [RegisterComponent]
[ComponentReference(typeof(IActivate))] [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!; [Dependency] private readonly RecipeManager _recipeManager = default!;
@@ -56,6 +57,7 @@ namespace Content.Server.Kitchen.Components
[ViewVariables] [ViewVariables]
private bool _busy = false; private bool _busy = false;
private bool _broken;
/// <summary> /// <summary>
/// This is a fixed offset of 5. /// This is a fixed offset of 5.
@@ -160,6 +162,17 @@ namespace Content.Server.Kitchen.Components
_uiDirty = true; _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)) if (_uiDirty && Owner.TryGetComponent(out SolutionContainerComponent? solution))
{ {
UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState UserInterface?.SetState(new MicrowaveUpdateUserInterfaceState
@@ -176,12 +189,24 @@ namespace Content.Server.Kitchen.Components
private void SetAppearance(MicrowaveVisualState state) private void SetAppearance(MicrowaveVisualState state)
{ {
var finalState = state;
if (_broken)
{
finalState = MicrowaveVisualState.Broken;
}
if (Owner.TryGetComponent(out AppearanceComponent? appearance)) 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) void IActivate.Activate(ActivateEventArgs eventArgs)
{ {
if (!eventArgs.User.TryGetComponent(out ActorComponent? actor) || !Powered) if (!eventArgs.User.TryGetComponent(out ActorComponent? actor) || !Powered)
@@ -201,6 +226,12 @@ namespace Content.Server.Kitchen.Components
return false; return false;
} }
if (_broken)
{
Owner.PopupMessage(eventArgs.User, Loc.GetString("It's broken!"));
return false;
}
var itemEntity = eventArgs.User.GetComponent<HandsComponent>().GetActiveHand?.Owner; var itemEntity = eventArgs.User.GetComponent<HandsComponent>().GetActiveHand?.Owner;
if (itemEntity == null) if (itemEntity == null)

View File

@@ -1,4 +1,4 @@
#nullable enable #nullable enable
using System; using System;
using Content.Shared.Chemistry.Solution; using Content.Shared.Chemistry.Solution;
using Content.Shared.NetIDs; using Content.Shared.NetIDs;
@@ -89,7 +89,8 @@ namespace Content.Shared.Kitchen.Components
public enum MicrowaveVisualState public enum MicrowaveVisualState
{ {
Idle, Idle,
Cooking Cooking,
Broken
} }
[NetSerializable, Serializable] [NetSerializable, Serializable]

View File

@@ -24,6 +24,17 @@
- type: SecretStash - type: SecretStash
secretPartName: the plant secretPartName: the plant
- type: Pullable - 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 - type: entity
id: PottedPlantRandom id: PottedPlantRandom

View File

@@ -1,28 +1,26 @@
- type: entity - type: entity
id: SeedExtractor id: SeedExtractor
name: seed extractor name: seed extractor
parent: BaseMachinePowered
description: Extracts seeds from produce. description: Extracts seeds from produce.
placement:
mode: SnapgridCenter
components: components:
- type: Clickable - type: Sprite
- type: InteractionOutline sprite: Constructible/Hydroponics/machines.rsi
- type: Sprite layers:
sprite: Constructible/Hydroponics/machines.rsi - state: seedextractor-off
state: seedextractor - state: seedextractor-unlit
- type: Physics shader: unshaded
bodyType: Static netsync: false
fixtures: - type: Physics
- shape: bodyType: Static
!type:PhysShapeAabb fixtures:
bounds: "-0.4,-0.25,0.4,0.25" - shape:
mass: 25 !type:PhysShapeAabb
layer: bounds: "-0.4,-0.25,0.4,0.25"
- Opaque mass: 25
- Impassable layer:
- MobImpassable - MobMask
- VaultImpassable - Opaque
- type: SnapGrid mask:
- type: Anchorable - MobMask
- type: SeedExtractor - type: SeedExtractor
- type: PowerReceiver

View File

@@ -14,17 +14,13 @@
bounds: "-0.3,-0.4,0.3,0.4" bounds: "-0.3,-0.4,0.3,0.4"
mass: 25 mass: 25
mask: mask:
- Impassable - Impassable
- MobImpassable - VaultImpassable
- VaultImpassable - SmallImpassable
- SmallImpassable
layer: layer:
- Opaque - Opaque
- Impassable - MobImpassable
- MobImpassable - SmallImpassable
- VaultImpassable
- type: SnapGrid
- type: ReagentDispenser
- type: PowerReceiver - type: PowerReceiver
- type: UserInterface - type: UserInterface
interfaces: interfaces:
@@ -33,3 +29,15 @@
- type: LoopingSound - type: LoopingSound
- type: Anchorable - type: Anchorable
- type: Pullable - 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

View File

@@ -11,14 +11,22 @@
sprite: Constructible/Misc/kitchen.rsi sprite: Constructible/Misc/kitchen.rsi
state: spike state: spike
- type: Damageable - type: Damageable
resistances: metallicResistances
- type: Destructible - type: Destructible
thresholds: thresholds:
- trigger: - trigger:
!type:DamageTrigger !type:DamageTrigger
damage: 50 damage: 100
behaviors: behaviors:
- !type:DoActsBehavior - !type:DoActsBehavior
acts: ["Destruction"] acts: ["Destruction"]
- !type:PlaySoundBehavior
sound: /Audio/Effects/metalbreak.ogg
- !type:SpawnEntitiesBehavior
spawn:
SheetSteel1:
min: 1
max: 1
- type: KitchenSpike - type: KitchenSpike
- type: Anchorable - type: Anchorable
- type: Pullable - type: Pullable

View File

@@ -40,3 +40,13 @@
shader: unshaded shader: unshaded
map: ["enum.MicrowaveVisualizerLayers.BaseUnlit"] map: ["enum.MicrowaveVisualizerLayers.BaseUnlit"]
- type: PowerReceiver - type: PowerReceiver
- type: Damageable
resistances: metallicResistances
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 100
behaviors:
- !type:DoActsBehavior
acts: ["Breakage"]

View File

@@ -33,3 +33,15 @@
sprite: Constructible/Power/juicer.rsi sprite: Constructible/Power/juicer.rsi
state: juicer0 state: juicer0
drawdepth: Items 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

View File

@@ -24,6 +24,23 @@
- type: PowerReceiver - type: PowerReceiver
powerLoad: 200 powerLoad: 200
priority: Low 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 - type: entity
id: BaseResearchAndDevelopmentPointSource id: BaseResearchAndDevelopmentPointSource
@@ -61,3 +78,18 @@
visuals: visuals:
- type: PowerDeviceVisualizer - type: PowerDeviceVisualizer
- type: PowerReceiver - 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

View File

@@ -53,9 +53,10 @@
- type: entity - type: entity
id: chem_master_broken id: chem_master_broken
parent: BaseConstructibleDynamic parent: BaseConstructibleDynamic
name: ChemMaster 4000 [Broken] name: ChemMaster 4000
description: "An industrial grade chemical manipulator with pill and bottle production included. It's broken." description: "An industrial grade chemical manipulator with pill and bottle production included. It's broken."
abstract: true abstract: true
suffix: Broken
components: components:
- type: Sprite - type: Sprite
sprite: Constructible/Power/mixer.rsi sprite: Constructible/Power/mixer.rsi

View File

@@ -41,10 +41,17 @@
thresholds: thresholds:
- trigger: - trigger:
!type:DamageTrigger !type:DamageTrigger
damage: 100 damage: 150
behaviors: behaviors:
- !type:DoActsBehavior - !type:DoActsBehavior
acts: ["Destruction"] acts: ["Destruction"]
- !type:PlaySoundBehavior
sound: /Audio/Effects/metalbreak.ogg
- !type:SpawnEntitiesBehavior
spawn:
SheetSteel1:
min: 1
max: 1
- type: Appearance - type: Appearance
visuals: visuals:
- type: StorageVisualizer - type: StorageVisualizer

View File

@@ -18,3 +18,18 @@
- state: welded - state: welded
visible: false visible: false
map: ["enum.StorageVisualLayers.Welded"] 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

View File

@@ -27,6 +27,8 @@
behaviors: behaviors:
- !type:DoActsBehavior - !type:DoActsBehavior
acts: ["Destruction"] acts: ["Destruction"]
- !type:PlaySoundBehavior
sound: /Audio/Effects/metalbreak.ogg
- type: entity - type: entity
abstract: true abstract: true
@@ -34,4 +36,3 @@
id: BaseMachinePowered id: BaseMachinePowered
components: components:
- type: PowerReceiver - type: PowerReceiver

View File

@@ -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" "name": "spawner"
}, },

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB