Makes more stuff destructible/breakable (#4081)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user