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.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");

View File

@@ -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;
/// <summary>
/// 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<HandsComponent>().GetActiveHand?.Owner;
if (itemEntity == null)

View File

@@ -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]

View File

@@ -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

View File

@@ -1,15 +1,16 @@
- 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
layers:
- state: seedextractor-off
- state: seedextractor-unlit
shader: unshaded
netsync: false
- type: Physics
bodyType: Static
fixtures:
@@ -18,11 +19,8 @@
bounds: "-0.4,-0.25,0.4,0.25"
mass: 25
layer:
- MobMask
- Opaque
- Impassable
- MobImpassable
- VaultImpassable
- type: SnapGrid
- type: Anchorable
mask:
- MobMask
- type: SeedExtractor
- type: PowerReceiver

View File

@@ -15,16 +15,12 @@
mass: 25
mask:
- Impassable
- MobImpassable
- VaultImpassable
- SmallImpassable
layer:
- Opaque
- Impassable
- MobImpassable
- VaultImpassable
- type: SnapGrid
- type: ReagentDispenser
- 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

View File

@@ -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

View File

@@ -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"]

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -27,6 +27,8 @@
behaviors:
- !type:DoActsBehavior
acts: ["Destruction"]
- !type:PlaySoundBehavior
sound: /Audio/Effects/metalbreak.ogg
- type: entity
abstract: true
@@ -34,4 +36,3 @@
id: BaseMachinePowered
components:
- 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"
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB