This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
forked from estacaoespacialpirata/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Deep Fryer And Its Powers The Deep Fryer has been implemented. It uses Corn Oil, Ghee, and Olive Oil to fry. Other features include: 1. Mixing Oil and Water at a certain temperature causes smoke. 2. When throwing an object at the Deep Fryer, a Chef will *always* land the shot, but anyone else has a chance of missing. 3. When an item is sliced, an event is triggered that other items can see. * Update meal_recipes.yml * Reworking the effects so they won't trigger on init. * Create DeepFryerTest.cs * Commenting out the UnsafeOilVolumeEffects part of the .yml. Something about the sound script inside of it breaks UnintializedSaveTest and it's not necessary for a smoke reaction to occur anyway. * Update DeepFryerSystem.cs
- Loading branch information
Showing
60 changed files
with
2,564 additions
and
8 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
Content.Client/Nyanotrasen/Kitchen/Components/DeepFriedComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Content.Shared.Kitchen.Components; | ||
|
||
namespace Content.Client.Kitchen.Components | ||
{ | ||
[RegisterComponent] | ||
//Unnecessary item: [ComponentReference(typeof(SharedDeepFriedComponent))] | ||
public sealed partial class DeepFriedComponent : SharedDeepFriedComponent | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Content.Client/Nyanotrasen/Kitchen/Components/DeepFryerComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Content.Shared.Kitchen.Components; | ||
|
||
namespace Content.Client.Kitchen.Components | ||
{ | ||
[RegisterComponent] | ||
// Unnecessary line: [ComponentReference(typeof(SharedDeepFryerComponent))] | ||
public sealed partial class DeepFryerComponent : SharedDeepFryerComponent | ||
{ | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
Content.Client/Nyanotrasen/Kitchen/UI/DeepFryerBoundUserInterface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Robust.Client.GameObjects; | ||
using Content.Shared.Kitchen.UI; | ||
|
||
namespace Content.Client.Nyanotrasen.Kitchen.UI | ||
{ | ||
public sealed class DeepFryerBoundUserInterface : BoundUserInterface | ||
{ | ||
private DeepFryerWindow? _window; | ||
|
||
private NetEntity[] _entities = default!; | ||
|
||
public DeepFryerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
base.Open(); | ||
_window = new DeepFryerWindow(); | ||
_window.OnClose += Close; | ||
_window.ItemList.OnItemSelected += args => | ||
{ | ||
SendMessage(new DeepFryerRemoveItemMessage(_entities[args.ItemIndex])); | ||
}; | ||
_window.InsertItem.OnPressed += _ => | ||
{ | ||
SendMessage(new DeepFryerInsertItemMessage()); | ||
}; | ||
_window.ScoopVat.OnPressed += _ => | ||
{ | ||
SendMessage(new DeepFryerScoopVatMessage()); | ||
}; | ||
_window.ClearSlag.OnPressed += args => | ||
{ | ||
SendMessage(new DeepFryerClearSlagMessage()); | ||
}; | ||
_window.RemoveAllItems.OnPressed += _ => | ||
{ | ||
SendMessage(new DeepFryerRemoveAllItemsMessage()); | ||
}; | ||
_window.OpenCentered(); | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
|
||
if (_window == null) | ||
return; | ||
|
||
if (state is not DeepFryerBoundUserInterfaceState cast) | ||
return; | ||
|
||
_entities = cast.ContainedEntities; | ||
_window.UpdateState(cast); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
|
||
if (!disposing) | ||
return; | ||
|
||
_window?.Dispose(); | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
Content.Client/Nyanotrasen/Kitchen/UI/DeepFryerWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<DefaultWindow xmlns="https://spacestation14.io" | ||
Title="{Loc 'deep-fryer-window-title'}" | ||
MinSize="600 400" | ||
> | ||
<BoxContainer Orientation="Horizontal" VerticalExpand="True"> | ||
<BoxContainer | ||
Orientation="Vertical" | ||
HorizontalExpand="True" | ||
> | ||
<Label | ||
Text="{Loc 'deep-fryer-label-baskets'}" | ||
Align="Left"/> | ||
<ItemList Name="ItemList" | ||
Access="Public" | ||
VerticalExpand="True" | ||
HorizontalExpand="True" | ||
SelectMode="Button"> | ||
</ItemList> | ||
</BoxContainer> | ||
<BoxContainer | ||
Orientation="Vertical" | ||
Margin="8 0" | ||
MinSize="200 0" | ||
> | ||
<Label Text="{Loc 'deep-fryer-label-oil-level'}"/> | ||
<ProgressBar Name="OilLevel" | ||
HorizontalExpand="True" | ||
MinValue="0" | ||
MaxValue="1" | ||
Page="0" | ||
Value="1"> | ||
</ProgressBar> | ||
<Label Text="{Loc 'deep-fryer-label-oil-purity'}"/> | ||
<ProgressBar Name="OilPurity" | ||
HorizontalExpand="True" | ||
MinValue="0" | ||
MaxValue="1" | ||
Page="0" | ||
Value="1"> | ||
</ProgressBar> | ||
<Button Name="InsertItem" | ||
Access="Public" | ||
TextAlign="Center" | ||
HorizontalExpand="True" | ||
Text="{Loc 'deep-fryer-button-insert-item'}" | ||
ToolTip="{Loc 'deep-fryer-button-insert-item-tooltip'}"/> | ||
<Button Name="ScoopVat" | ||
Access="Public" | ||
TextAlign="Center" | ||
HorizontalExpand="True" | ||
Text="{Loc 'deep-fryer-button-scoop-vat'}" | ||
ToolTip="{Loc 'deep-fryer-button-scoop-vat-tooltip'}"/> | ||
<Button Name="ClearSlag" | ||
Access="Public" | ||
TextAlign="Center" | ||
HorizontalExpand="True" | ||
Text="{Loc 'deep-fryer-button-clear-slag'}" | ||
ToolTip="{Loc 'deep-fryer-button-clear-slag-tooltip'}"/> | ||
<Button Name="RemoveAllItems" | ||
Access="Public" | ||
TextAlign="Center" | ||
HorizontalExpand="True" | ||
Text="{Loc 'deep-fryer-button-remove-all-items'}" | ||
ToolTip="{Loc 'deep-fryer-button-remove-all-items-tooltip'}"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</DefaultWindow> |
71 changes: 71 additions & 0 deletions
71
Content.Client/Nyanotrasen/Kitchen/UI/DeepFryerWindow.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Content.Shared.Kitchen.UI; | ||
|
||
namespace Content.Client.Nyanotrasen.Kitchen.UI | ||
{ | ||
[GenerateTypedNameReferences] | ||
[Access(typeof(DeepFryerBoundUserInterface))] | ||
public sealed partial class DeepFryerWindow : DefaultWindow | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
|
||
private static readonly Color WarningColor = Color.FromHsv(new Vector4(0.0f, 1.0f, 0.8f, 1.0f)); | ||
|
||
public DeepFryerWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
} | ||
|
||
public void UpdateState(DeepFryerBoundUserInterfaceState state) | ||
{ | ||
OilLevel.Value = (float) state.OilLevel; | ||
OilPurity.Value = (float) state.OilPurity; | ||
|
||
if (state.OilPurity < state.FryingOilThreshold) | ||
{ | ||
if (OilPurity.ForegroundStyleBoxOverride == null) | ||
{ | ||
OilPurity.ForegroundStyleBoxOverride = new StyleBoxFlat(); | ||
|
||
var oilPurityStyle = (StyleBoxFlat) OilPurity.ForegroundStyleBoxOverride; | ||
oilPurityStyle.BackgroundColor = WarningColor; | ||
} | ||
} | ||
else | ||
{ | ||
OilPurity.ForegroundStyleBoxOverride = null; | ||
} | ||
|
||
ItemList.Clear(); | ||
|
||
foreach (var netEntity in state.ContainedEntities) | ||
{ | ||
var entity = _entityManager.GetEntity(netEntity); | ||
if (_entityManager.Deleted(entity)) | ||
continue; | ||
|
||
// Duplicated from MicrowaveBoundUserInterface.cs: keep an eye on that file for when it changes. | ||
Texture? texture; | ||
if (_entityManager.TryGetComponent(entity, out IconComponent? iconComponent)) | ||
{ | ||
texture = _entityManager.System<SpriteSystem>().GetIcon(iconComponent); | ||
} | ||
else if (_entityManager.TryGetComponent(entity, out SpriteComponent? spriteComponent)) | ||
{ | ||
texture = spriteComponent.Icon?.Default; | ||
} | ||
else | ||
{ | ||
continue; | ||
} | ||
|
||
ItemList.AddItem(_entityManager.GetComponent<MetaDataComponent>(entity).EntityName, texture); | ||
} | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
Content.Client/Nyanotrasen/Kitchen/Visualizers/DeepFriedVisualizer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System.Linq; | ||
using Robust.Client.GameObjects; | ||
using static Robust.Client.GameObjects.SpriteComponent; | ||
using Content.Client.Kitchen.Components; | ||
using Content.Shared.Clothing; | ||
using Content.Shared.Hands; | ||
using Content.Shared.Kitchen.Components; | ||
|
||
namespace Content.Client.Kitchen.Visualizers | ||
{ | ||
public sealed class DeepFriedVisualizerSystem : VisualizerSystem<DeepFriedComponent> | ||
{ | ||
private readonly static string ShaderName = "Crispy"; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<DeepFriedComponent, HeldVisualsUpdatedEvent>(OnHeldVisualsUpdated); | ||
SubscribeLocalEvent<DeepFriedComponent, EquipmentVisualsUpdatedEvent>(OnEquipmentVisualsUpdated); | ||
} | ||
|
||
protected override void OnAppearanceChange(EntityUid uid, DeepFriedComponent component, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite == null) | ||
return; | ||
|
||
if (!args.Component.TryGetData(DeepFriedVisuals.Fried, out bool isFried)) | ||
return; | ||
|
||
for (var i = 0; i < args.Sprite.AllLayers.Count(); ++i) | ||
args.Sprite.LayerSetShader(i, ShaderName); | ||
} | ||
|
||
private void OnHeldVisualsUpdated(EntityUid uid, DeepFriedComponent component, HeldVisualsUpdatedEvent args) | ||
{ | ||
if (args.RevealedLayers.Count == 0) | ||
{ | ||
return; | ||
} | ||
|
||
if (!TryComp(args.User, out SpriteComponent? sprite)) | ||
return; | ||
|
||
foreach (var key in args.RevealedLayers) | ||
{ | ||
if (!sprite.LayerMapTryGet(key, out var index) || sprite[index] is not Layer layer) | ||
continue; | ||
|
||
sprite.LayerSetShader(index, ShaderName); | ||
} | ||
} | ||
|
||
private void OnEquipmentVisualsUpdated(EntityUid uid, DeepFriedComponent component, EquipmentVisualsUpdatedEvent args) | ||
{ | ||
if (args.RevealedLayers.Count == 0) | ||
{ | ||
return; | ||
} | ||
|
||
if (!TryComp(args.Equipee, out SpriteComponent? sprite)) | ||
return; | ||
|
||
foreach (var key in args.RevealedLayers) | ||
{ | ||
if (!sprite.LayerMapTryGet(key, out var index) || sprite[index] is not Layer layer) | ||
continue; | ||
|
||
sprite.LayerSetShader(index, ShaderName); | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Content.Client/Nyanotrasen/Kitchen/Visualizers/DeepFryerVisualizer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Robust.Client.GameObjects; | ||
using Content.Client.Chemistry.Visualizers; | ||
using Content.Client.Kitchen.Components; | ||
using Content.Shared.Kitchen.Components; | ||
|
||
namespace Content.Client.Kitchen.Visualizers | ||
{ | ||
public sealed class DeepFryerVisualizerSystem : VisualizerSystem<DeepFryerComponent> | ||
{ | ||
protected override void OnAppearanceChange(EntityUid uid, DeepFryerComponent component, ref AppearanceChangeEvent args) | ||
{ | ||
if (!args.Component.TryGetData(DeepFryerVisuals.Bubbling, out bool isBubbling) || | ||
!TryComp<SolutionContainerVisualsComponent>(uid, out var scvComponent)) | ||
{ | ||
return; | ||
} | ||
|
||
scvComponent.FillBaseName = isBubbling ? "on-" : "off-"; | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Content.IntegrationTests/Tests/Nyanotrasen/DeepFryerTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#nullable enable annotations | ||
using Content.Server.Kitchen.Components; | ||
using Content.Server.Kitchen.EntitySystems; | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Reflection; | ||
|
||
namespace Content.IntegrationTests.Tests.DeepFryer | ||
{ | ||
[TestFixture] | ||
[TestOf(typeof(DeepFriedComponent))] | ||
[TestOf(typeof(DeepFryerSystem))] | ||
[TestOf(typeof(DeepFryerComponent))] | ||
public sealed class DeepFryerTest | ||
{ | ||
|
||
[TestPrototypes] | ||
private const string Prototypes = @" | ||
- type: entity | ||
name: DeepFryerDummy | ||
id: DeepFryerDummy | ||
components: | ||
- type: DeepFryer | ||
entryDelay: 0 | ||
draggedEntryDelay: 0 | ||
flushTime: 0 | ||
- type: Anchorable | ||
- type: ApcPowerReceiver | ||
- type: Physics | ||
bodyType: Static | ||
- type: Fixtures | ||
fixtures: | ||
fix1: | ||
shape: | ||
!type:PhysShapeCircle | ||
radius: 0.35 | ||
"; | ||
|
||
[Test] | ||
public async Task Test() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(); | ||
var server = pair.Server; | ||
|
||
var testMap = await pair.CreateTestMap(); | ||
|
||
EntityUid unitUid = default; | ||
|
||
var entityManager = server.ResolveDependency<IEntityManager>(); | ||
var xformSystem = entityManager.System<SharedTransformSystem>(); | ||
var deepFryerSystem = entityManager.System<DeepFryerSystem>(); | ||
await server.WaitAssertion(() => | ||
{ | ||
Assert.That(deepFryerSystem, Is.Not.Null); | ||
}); | ||
await pair.CleanReturnAsync(); | ||
} | ||
} | ||
} |
Oops, something went wrong.