Sweeping changes/improvements to the microwave. (#997)
Co-authored-by: FL-OZ <anotherscuffed@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Robust.Client.GameObjects.Components.UserInterface;
|
using System;
|
||||||
|
using Robust.Client.GameObjects.Components.UserInterface;
|
||||||
using Content.Shared.Kitchen;
|
using Content.Shared.Kitchen;
|
||||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -7,10 +8,14 @@ using Content.Shared.Chemistry;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
|
||||||
|
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Client.Graphics.Drawing;
|
||||||
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components.Kitchen
|
namespace Content.Client.GameObjects.Components.Kitchen
|
||||||
{
|
{
|
||||||
@@ -50,12 +55,11 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
new SharedMicrowaveComponent.MicrowaveVaporizeReagentIndexedMessage(_reagents[args.ItemIndex]));
|
new SharedMicrowaveComponent.MicrowaveVaporizeReagentIndexedMessage(_reagents[args.ItemIndex]));
|
||||||
};
|
};
|
||||||
|
|
||||||
_menu.OnCookTimeSelected += args =>
|
_menu.OnCookTimeSelected += (args,buttonIndex) =>
|
||||||
{
|
{
|
||||||
var actualButton = args.Button as Button;
|
var actualButton = (MicrowaveMenu.MicrowaveCookTimeButton) args.Button ;
|
||||||
var newTime = (uint) int.Parse(actualButton.Text);
|
var newTime = actualButton.CookTime;
|
||||||
_menu.VisualCookTime = newTime;
|
SendMessage(new SharedMicrowaveComponent.MicrowaveSelectCookTimeMessage(buttonIndex,actualButton.CookTime));
|
||||||
SendMessage(new SharedMicrowaveComponent.MicrowaveSelectCookTimeMessage(newTime));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -79,45 +83,259 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_menu.ToggleBusyDisableOverlayPanel(cstate.IsMicrowaveBusy);
|
_menu.ToggleBusyDisableOverlayPanel(cstate.IsMicrowaveBusy);
|
||||||
RefreshContentsDisplay(cstate.ReagentsReagents, cstate.ContainedSolids);
|
RefreshContentsDisplay(cstate.ReagentQuantities, cstate.ContainedSolids);
|
||||||
|
var currentlySelectedTimeButton = (Button) _menu.CookTimeButtonVbox.GetChild(cstate.ActiveButtonIndex);
|
||||||
|
currentlySelectedTimeButton.Pressed = true;
|
||||||
|
var label = cstate.ActiveButtonIndex <= 0 ? Loc.GetString("INSTANT") : cstate.CurrentCookTime.ToString();
|
||||||
|
_menu._cookTimeInfoLabel.Text = $"{Loc.GetString("COOK TIME")}: {label}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RefreshContentsDisplay(Solution.ReagentQuantity[] reagents, EntityUid[] containedSolids)
|
||||||
private void RefreshContentsDisplay(IReadOnlyList<Solution.ReagentQuantity> reagents, List<EntityUid> solids)
|
|
||||||
{
|
{
|
||||||
_reagents.Clear();
|
_reagents.Clear();
|
||||||
_menu.IngredientsListReagents.Clear();
|
_menu.IngredientsListReagents.Clear();
|
||||||
foreach (var reagent in reagents)
|
for (var i = 0; i < reagents.Length; i++)
|
||||||
{
|
{
|
||||||
_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto);
|
_prototypeManager.TryIndex(reagents[i].ReagentId, out ReagentPrototype proto);
|
||||||
var reagentAdded = _menu.IngredientsListReagents.AddItem($"{reagent.Quantity} {proto.Name}");
|
var reagentAdded = _menu.IngredientsListReagents.AddItem($"{reagents[i].Quantity} {proto.Name}");
|
||||||
var reagentIndex = _menu.IngredientsListReagents.IndexOf(reagentAdded);
|
var reagentIndex = _menu.IngredientsListReagents.IndexOf(reagentAdded);
|
||||||
_reagents.Add(reagentIndex, reagent);
|
_reagents.Add(reagentIndex, reagents[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_solids.Clear();
|
_solids.Clear();
|
||||||
_menu.IngredientsList.Clear();
|
_menu.IngredientsList.Clear();
|
||||||
foreach (var entityID in solids)
|
for (var j = 0; j < containedSolids.Length; j++)
|
||||||
{
|
{
|
||||||
if (!_entityManager.TryGetEntity(entityID, out var entity))
|
if (!_entityManager.TryGetEntity(containedSolids[j], out var entity))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (entity.Deleted || !entity.TryGetComponent(out IconComponent icon))
|
||||||
if (!entity.Deleted && entity.TryGetComponent(out IconComponent icon))
|
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var solidItem = _menu.IngredientsList.AddItem(entity.Name, icon.Icon.Default);
|
var solidItem = _menu.IngredientsList.AddItem(entity.Name, icon.Icon.Default);
|
||||||
|
|
||||||
var solidIndex = _menu.IngredientsList.IndexOf(solidItem);
|
var solidIndex = _menu.IngredientsList.IndexOf(solidItem);
|
||||||
_solids.Add(solidIndex, entityID);
|
_solids.Add(solidIndex, containedSolids[j]);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class MicrowaveMenu : SS14Window
|
||||||
|
{
|
||||||
|
|
||||||
|
public class MicrowaveCookTimeButton : Button
|
||||||
|
{
|
||||||
|
public uint CookTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override Vector2? CustomSize => (512, 256);
|
||||||
|
|
||||||
|
private MicrowaveBoundUserInterface Owner { get; set; }
|
||||||
|
|
||||||
|
public event Action<BaseButton.ButtonEventArgs, int> OnCookTimeSelected;
|
||||||
|
|
||||||
|
public Button StartButton { get; }
|
||||||
|
public Button EjectButton { get; }
|
||||||
|
|
||||||
|
public PanelContainer TimerFacePlate { get; }
|
||||||
|
|
||||||
|
public ButtonGroup CookTimeButtonGroup { get; }
|
||||||
|
public VBoxContainer CookTimeButtonVbox { get; }
|
||||||
|
|
||||||
|
private VBoxContainer ButtonGridContainer { get; }
|
||||||
|
|
||||||
|
private PanelContainer DisableCookingPanelOverlay { get; }
|
||||||
|
|
||||||
|
|
||||||
|
public ItemList IngredientsList { get; }
|
||||||
|
|
||||||
|
public ItemList IngredientsListReagents { get; }
|
||||||
|
public Label _cookTimeInfoLabel { get; }
|
||||||
|
|
||||||
|
public MicrowaveMenu(MicrowaveBoundUserInterface owner = null)
|
||||||
|
{
|
||||||
|
Owner = owner;
|
||||||
|
Title = Loc.GetString("Microwave");
|
||||||
|
DisableCookingPanelOverlay = new PanelContainer
|
||||||
|
{
|
||||||
|
MouseFilter = MouseFilterMode.Stop,
|
||||||
|
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Black.WithAlpha(0.60f)},
|
||||||
|
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||||
|
SizeFlagsVertical = SizeFlags.Fill,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var hSplit = new HBoxContainer
|
||||||
|
{
|
||||||
|
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||||
|
SizeFlagsVertical = SizeFlags.Fill
|
||||||
|
};
|
||||||
|
|
||||||
|
IngredientsListReagents = new ItemList
|
||||||
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
SelectMode = ItemList.ItemListSelectMode.Button,
|
||||||
|
SizeFlagsStretchRatio = 2,
|
||||||
|
CustomMinimumSize = (100, 128)
|
||||||
|
};
|
||||||
|
|
||||||
|
IngredientsList = new ItemList
|
||||||
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
SelectMode = ItemList.ItemListSelectMode.Button,
|
||||||
|
SizeFlagsStretchRatio = 2,
|
||||||
|
CustomMinimumSize = (100, 128)
|
||||||
|
};
|
||||||
|
|
||||||
|
hSplit.AddChild(IngredientsListReagents);
|
||||||
|
//Padding between the lists.
|
||||||
|
hSplit.AddChild(new Control
|
||||||
|
{
|
||||||
|
CustomMinimumSize = (0, 5),
|
||||||
|
});
|
||||||
|
|
||||||
|
hSplit.AddChild(IngredientsList);
|
||||||
|
|
||||||
|
var vSplit = new VBoxContainer
|
||||||
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
};
|
||||||
|
|
||||||
|
hSplit.AddChild(vSplit);
|
||||||
|
|
||||||
|
ButtonGridContainer = new VBoxContainer
|
||||||
|
{
|
||||||
|
Align = BoxContainer.AlignMode.Center,
|
||||||
|
SizeFlagsStretchRatio = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
StartButton = new Button
|
||||||
|
{
|
||||||
|
Text = Loc.GetString("Start"),
|
||||||
|
TextAlign = Label.AlignMode.Center,
|
||||||
|
};
|
||||||
|
|
||||||
|
EjectButton = new Button
|
||||||
|
{
|
||||||
|
Text = Loc.GetString("Eject All Contents"),
|
||||||
|
ToolTip = Loc.GetString("This vaporizes all reagents, but ejects any solids."),
|
||||||
|
TextAlign = Label.AlignMode.Center,
|
||||||
|
};
|
||||||
|
|
||||||
|
ButtonGridContainer.AddChild(StartButton);
|
||||||
|
ButtonGridContainer.AddChild(EjectButton);
|
||||||
|
vSplit.AddChild(ButtonGridContainer);
|
||||||
|
|
||||||
|
//Padding
|
||||||
|
vSplit.AddChild(new Control
|
||||||
|
{
|
||||||
|
CustomMinimumSize = (0, 15),
|
||||||
|
SizeFlagsVertical = SizeFlags.Fill,
|
||||||
|
});
|
||||||
|
|
||||||
|
CookTimeButtonGroup = new ButtonGroup();
|
||||||
|
CookTimeButtonVbox = new VBoxContainer
|
||||||
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
Align = BoxContainer.AlignMode.Center,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
for (var i = 0; i <= 6; i++)
|
||||||
|
{
|
||||||
|
var newButton = new MicrowaveCookTimeButton
|
||||||
|
{
|
||||||
|
Text = index <= 0 ? Loc.GetString("INSTANT") : index.ToString(),
|
||||||
|
CookTime = (uint)index,
|
||||||
|
TextAlign = Label.AlignMode.Center,
|
||||||
|
ToggleMode = true,
|
||||||
|
Group = CookTimeButtonGroup,
|
||||||
|
};
|
||||||
|
CookTimeButtonVbox.AddChild(newButton);
|
||||||
|
newButton.OnToggled += args =>
|
||||||
|
{
|
||||||
|
OnCookTimeSelected?.Invoke(args, newButton.GetPositionInParent());
|
||||||
|
|
||||||
|
};
|
||||||
|
index += 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
var cookTimeOneSecondButton = (Button) CookTimeButtonVbox.GetChild(0);
|
||||||
|
cookTimeOneSecondButton.Pressed = true;
|
||||||
|
|
||||||
|
|
||||||
|
_cookTimeInfoLabel = new Label
|
||||||
|
{
|
||||||
|
Text = Loc.GetString("COOK TIME: 1"),
|
||||||
|
Align = Label.AlignMode.Center,
|
||||||
|
Modulate = Color.White,
|
||||||
|
SizeFlagsVertical = SizeFlags.ShrinkCenter
|
||||||
|
};
|
||||||
|
|
||||||
|
var innerTimerPanel = new PanelContainer
|
||||||
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
ModulateSelfOverride = Color.Red,
|
||||||
|
CustomMinimumSize = (100, 128),
|
||||||
|
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Black.WithAlpha(0.5f)},
|
||||||
|
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
new VBoxContainer
|
||||||
|
{
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
new PanelContainer
|
||||||
|
{
|
||||||
|
PanelOverride = new StyleBoxFlat() {BackgroundColor = Color.Gray.WithAlpha(0.2f)},
|
||||||
|
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
_cookTimeInfoLabel
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
new ScrollContainer()
|
||||||
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
CookTimeButtonVbox,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TimerFacePlate = new PanelContainer()
|
||||||
|
{
|
||||||
|
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||||
|
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||||
|
Children =
|
||||||
|
{
|
||||||
|
innerTimerPanel
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
vSplit.AddChild(TimerFacePlate);
|
||||||
|
Contents.AddChild(hSplit);
|
||||||
|
Contents.AddChild(DisableCookingPanelOverlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ToggleBusyDisableOverlayPanel(bool shouldDisable)
|
||||||
|
{
|
||||||
|
DisableCookingPanelOverlay.Visible = shouldDisable;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,231 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Robust.Client.Graphics.Drawing;
|
|
||||||
using Robust.Client.UserInterface;
|
|
||||||
using Robust.Client.UserInterface.Controls;
|
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components.Kitchen
|
|
||||||
{
|
|
||||||
public class MicrowaveMenu : SS14Window
|
|
||||||
{
|
|
||||||
protected override Vector2? CustomSize => (512, 256);
|
|
||||||
|
|
||||||
private MicrowaveBoundUserInterface Owner { get; set; }
|
|
||||||
|
|
||||||
public event Action<BaseButton.ButtonEventArgs> OnCookTimeSelected;
|
|
||||||
|
|
||||||
public uint VisualCookTime = 1;
|
|
||||||
|
|
||||||
public Button StartButton { get;}
|
|
||||||
public Button EjectButton { get;}
|
|
||||||
|
|
||||||
public PanelContainer TimerFacePlate { get; }
|
|
||||||
|
|
||||||
public ButtonGroup CookTimeButtonGroup { get; }
|
|
||||||
private VBoxContainer CookTimeButtonVbox { get; }
|
|
||||||
|
|
||||||
private VBoxContainer ButtonGridContainer { get; }
|
|
||||||
|
|
||||||
private PanelContainer DisableCookingPanelOverlay { get;}
|
|
||||||
|
|
||||||
|
|
||||||
public ItemList IngredientsList { get;}
|
|
||||||
|
|
||||||
public ItemList IngredientsListReagents { get; }
|
|
||||||
private Label _cookTimeInfoLabel { get; }
|
|
||||||
|
|
||||||
public MicrowaveMenu(MicrowaveBoundUserInterface owner = null)
|
|
||||||
{
|
|
||||||
Owner = owner;
|
|
||||||
Title = Loc.GetString("Microwave");
|
|
||||||
DisableCookingPanelOverlay = new PanelContainer
|
|
||||||
{
|
|
||||||
MouseFilter = MouseFilterMode.Stop,
|
|
||||||
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Black.WithAlpha(0.60f)},
|
|
||||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
|
||||||
SizeFlagsVertical = SizeFlags.Fill,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
var hSplit = new HBoxContainer
|
|
||||||
{
|
|
||||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
|
||||||
SizeFlagsVertical = SizeFlags.Fill
|
|
||||||
};
|
|
||||||
|
|
||||||
IngredientsListReagents = new ItemList
|
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
|
||||||
SelectMode = ItemList.ItemListSelectMode.Button,
|
|
||||||
SizeFlagsStretchRatio = 2,
|
|
||||||
CustomMinimumSize = (100,128)
|
|
||||||
};
|
|
||||||
|
|
||||||
IngredientsList = new ItemList
|
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
|
||||||
SelectMode = ItemList.ItemListSelectMode.Button,
|
|
||||||
SizeFlagsStretchRatio = 2,
|
|
||||||
CustomMinimumSize = (100,128)
|
|
||||||
};
|
|
||||||
|
|
||||||
hSplit.AddChild(IngredientsListReagents);
|
|
||||||
//Padding between the lists.
|
|
||||||
hSplit.AddChild(new Control
|
|
||||||
{
|
|
||||||
CustomMinimumSize = (0,5),
|
|
||||||
});
|
|
||||||
|
|
||||||
hSplit.AddChild(IngredientsList);
|
|
||||||
|
|
||||||
var vSplit = new VBoxContainer
|
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
|
||||||
};
|
|
||||||
|
|
||||||
hSplit.AddChild(vSplit);
|
|
||||||
|
|
||||||
ButtonGridContainer = new VBoxContainer
|
|
||||||
{
|
|
||||||
Align = BoxContainer.AlignMode.Center,
|
|
||||||
SizeFlagsStretchRatio = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
StartButton = new Button
|
|
||||||
{
|
|
||||||
Text = Loc.GetString("Start"),
|
|
||||||
TextAlign = Label.AlignMode.Center,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
EjectButton = new Button
|
|
||||||
{
|
|
||||||
Text = Loc.GetString("Eject All Contents"),
|
|
||||||
ToolTip = Loc.GetString("This vaporizes all reagents, but ejects any solids."),
|
|
||||||
TextAlign = Label.AlignMode.Center,
|
|
||||||
};
|
|
||||||
|
|
||||||
ButtonGridContainer.AddChild(StartButton);
|
|
||||||
ButtonGridContainer.AddChild(EjectButton);
|
|
||||||
vSplit.AddChild(ButtonGridContainer);
|
|
||||||
|
|
||||||
//Padding
|
|
||||||
vSplit.AddChild(new Control
|
|
||||||
{
|
|
||||||
CustomMinimumSize = (0, 15),
|
|
||||||
SizeFlagsVertical = SizeFlags.Fill,
|
|
||||||
});
|
|
||||||
|
|
||||||
CookTimeButtonGroup = new ButtonGroup();
|
|
||||||
CookTimeButtonVbox = new VBoxContainer
|
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
Align = BoxContainer.AlignMode.Center,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
var index = 0;
|
|
||||||
for (var i = 0; i <= 12; i++)
|
|
||||||
{
|
|
||||||
var newButton = new Button
|
|
||||||
{
|
|
||||||
Text = (index <= 0 ? 1 : index).ToString(),
|
|
||||||
TextAlign = Label.AlignMode.Center,
|
|
||||||
ToggleMode = true,
|
|
||||||
Group = CookTimeButtonGroup,
|
|
||||||
};
|
|
||||||
CookTimeButtonVbox.AddChild(newButton);
|
|
||||||
newButton.OnToggled += args =>
|
|
||||||
{
|
|
||||||
OnCookTimeSelected?.Invoke(args);
|
|
||||||
_cookTimeInfoLabel.Text = $"{Loc.GetString("COOK TIME")}: {VisualCookTime}";
|
|
||||||
};
|
|
||||||
index+=5;
|
|
||||||
}
|
|
||||||
|
|
||||||
var cookTimeOneSecondButton = (Button)CookTimeButtonVbox.GetChild(0);
|
|
||||||
cookTimeOneSecondButton.Pressed = true;
|
|
||||||
|
|
||||||
|
|
||||||
_cookTimeInfoLabel = new Label
|
|
||||||
{
|
|
||||||
Text = Loc.GetString($"COOK TIME: {VisualCookTime}"),
|
|
||||||
Align = Label.AlignMode.Center,
|
|
||||||
Modulate = Color.White,
|
|
||||||
SizeFlagsVertical = SizeFlags.ShrinkCenter
|
|
||||||
};
|
|
||||||
|
|
||||||
var innerTimerPanel = new PanelContainer
|
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
ModulateSelfOverride = Color.Red,
|
|
||||||
CustomMinimumSize = (100, 128),
|
|
||||||
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Black.WithAlpha(0.5f)},
|
|
||||||
|
|
||||||
Children =
|
|
||||||
{
|
|
||||||
|
|
||||||
new VBoxContainer
|
|
||||||
{
|
|
||||||
|
|
||||||
Children =
|
|
||||||
{
|
|
||||||
|
|
||||||
new PanelContainer
|
|
||||||
{
|
|
||||||
PanelOverride = new StyleBoxFlat(){BackgroundColor = Color.Gray.WithAlpha(0.2f)},
|
|
||||||
|
|
||||||
Children =
|
|
||||||
{
|
|
||||||
_cookTimeInfoLabel
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
new ScrollContainer()
|
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
|
|
||||||
Children =
|
|
||||||
{
|
|
||||||
CookTimeButtonVbox,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TimerFacePlate = new PanelContainer()
|
|
||||||
{
|
|
||||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
|
||||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
|
||||||
Children =
|
|
||||||
{
|
|
||||||
|
|
||||||
innerTimerPanel
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
vSplit.AddChild(TimerFacePlate);
|
|
||||||
Contents.AddChild(hSplit);
|
|
||||||
Contents.AddChild(DisableCookingPanelOverlay);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ToggleBusyDisableOverlayPanel(bool shouldDisable)
|
|
||||||
{
|
|
||||||
DisableCookingPanelOverlay.Visible = shouldDisable;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,6 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
public sealed class MicrowaveVisualizer : AppearanceVisualizer
|
public sealed class MicrowaveVisualizer : AppearanceVisualizer
|
||||||
{
|
{
|
||||||
private SoundComponent _soundComponent;
|
private SoundComponent _soundComponent;
|
||||||
private const string MicrowaveSoundLoop = "/Audio/machines/microwave_loop.ogg";
|
|
||||||
|
|
||||||
public override void OnChangeData(AppearanceComponent component)
|
public override void OnChangeData(AppearanceComponent component)
|
||||||
{
|
{
|
||||||
@@ -38,8 +37,9 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
var audioParams = AudioParams.Default;
|
var audioParams = AudioParams.Default;
|
||||||
audioParams.Loop = true;
|
audioParams.Loop = true;
|
||||||
var schedSound = new ScheduledSound();
|
var schedSound = new ScheduledSound();
|
||||||
schedSound.Filename = MicrowaveSoundLoop;
|
schedSound.Filename = "/Audio/machines/microwave_loop.ogg";
|
||||||
schedSound.AudioParams = audioParams;
|
schedSound.AudioParams = audioParams;
|
||||||
|
_soundComponent.StopAllSounds();
|
||||||
_soundComponent.AddScheduledSound(schedSound);
|
_soundComponent.AddScheduledSound(schedSound);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -51,11 +51,8 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
var glowingPartsVisible = !(component.TryGetData(PowerDeviceVisuals.Powered, out bool powered) && !powered);
|
var glowingPartsVisible = !(component.TryGetData(PowerDeviceVisuals.Powered, out bool powered) && !powered);
|
||||||
sprite.LayerSetVisible(MicrowaveVisualizerLayers.BaseUnlit, glowingPartsVisible);
|
sprite.LayerSetVisible(MicrowaveVisualizerLayers.BaseUnlit, glowingPartsVisible);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private enum MicrowaveVisualizerLayers
|
private enum MicrowaveVisualizerLayers
|
||||||
{
|
{
|
||||||
Base,
|
Base,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Robust.Shared.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Content.Server.GameObjects.Components.Chemistry;
|
using Content.Server.GameObjects.Components.Chemistry;
|
||||||
using Content.Server.GameObjects.Components.Nutrition;
|
|
||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
@@ -21,7 +20,6 @@ using Robust.Server.GameObjects.Components.UserInterface;
|
|||||||
using Robust.Server.Interfaces.GameObjects;
|
using Robust.Server.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
using Content.Server.Utility;
|
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Content.Server.Interfaces.GameObjects;
|
using Content.Server.Interfaces.GameObjects;
|
||||||
using Content.Server.Interfaces.Chat;
|
using Content.Server.Interfaces.Chat;
|
||||||
@@ -32,7 +30,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[ComponentReference(typeof(IActivate))]
|
[ComponentReference(typeof(IActivate))]
|
||||||
public class KitchenMicrowaveComponent : SharedMicrowaveComponent, IActivate, IInteractUsing, ISolutionChange, ISuicideAct
|
public class MicrowaveComponent : SharedMicrowaveComponent, IActivate, IInteractUsing, ISolutionChange
|
||||||
{
|
{
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
||||||
@@ -62,25 +60,22 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
/// For right now, I don't think any recipe cook time should be greater than 60 seconds.
|
/// For right now, I don't think any recipe cook time should be greater than 60 seconds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private uint _currentCookTimerTime { get; set; } = 1;
|
private uint _currentCookTimerTime = 1;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private bool Powered => _powerDevice.Powered;
|
private bool _powered => _powerDevice.Powered;
|
||||||
|
private bool _hasContents => _solution.ReagentList.Count > 0 || _storage.ContainedEntities.Count > 0;
|
||||||
private bool HasContents => _solution.ReagentList.Count > 0 || _storage.ContainedEntities.Count > 0;
|
private bool _uiDirty = true;
|
||||||
|
private bool _lostPower = false;
|
||||||
void ISolutionChange.SolutionChanged(SolutionChangeEventArgs eventArgs) => UpdateUserInterface();
|
private int _currentCookTimeButtonIndex = 0;
|
||||||
|
|
||||||
|
void ISolutionChange.SolutionChanged(SolutionChangeEventArgs eventArgs) => _uiDirty = true;
|
||||||
private AudioSystem _audioSystem;
|
private AudioSystem _audioSystem;
|
||||||
|
|
||||||
private AppearanceComponent _appearance;
|
private AppearanceComponent _appearance;
|
||||||
private PowerDeviceComponent _powerDevice;
|
private PowerDeviceComponent _powerDevice;
|
||||||
|
|
||||||
private BoundUserInterface _userInterface;
|
private BoundUserInterface _userInterface;
|
||||||
|
|
||||||
private Container _storage;
|
private Container _storage;
|
||||||
|
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
@@ -109,7 +104,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
private void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage message)
|
private void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage message)
|
||||||
{
|
{
|
||||||
if (!Powered || _busy)
|
if (!_powered || _busy)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,43 +114,74 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
case MicrowaveStartCookMessage msg :
|
case MicrowaveStartCookMessage msg :
|
||||||
wzhzhzh();
|
wzhzhzh();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MicrowaveEjectMessage msg :
|
case MicrowaveEjectMessage msg :
|
||||||
if (HasContents)
|
if (_hasContents)
|
||||||
{
|
{
|
||||||
VaporizeReagents();
|
VaporizeReagents();
|
||||||
EjectSolids();
|
EjectSolids();
|
||||||
ClickSound();
|
ClickSound();
|
||||||
UpdateUserInterface();
|
_uiDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MicrowaveEjectSolidIndexedMessage msg:
|
case MicrowaveEjectSolidIndexedMessage msg:
|
||||||
if (HasContents)
|
if (_hasContents)
|
||||||
{
|
{
|
||||||
EjectSolidWithIndex(msg.EntityID);
|
EjectSolid(msg.EntityID);
|
||||||
ClickSound();
|
ClickSound();
|
||||||
UpdateUserInterface();
|
_uiDirty = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MicrowaveVaporizeReagentIndexedMessage msg:
|
case MicrowaveVaporizeReagentIndexedMessage msg:
|
||||||
if (HasContents)
|
if (_hasContents)
|
||||||
{
|
{
|
||||||
VaporizeReagentWithReagentQuantity(msg.ReagentQuantity);
|
VaporizeReagentQuantity(msg.ReagentQuantity);
|
||||||
ClickSound();
|
ClickSound();
|
||||||
UpdateUserInterface();
|
_uiDirty = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MicrowaveSelectCookTimeMessage msg:
|
case MicrowaveSelectCookTimeMessage msg:
|
||||||
_currentCookTimerTime = msg.newCookTime;
|
_currentCookTimeButtonIndex = msg.ButtonIndex;
|
||||||
|
_currentCookTimerTime = msg.NewCookTime;
|
||||||
ClickSound();
|
ClickSound();
|
||||||
UpdateUserInterface();
|
_uiDirty = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnUpdate()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!_powered)
|
||||||
|
{
|
||||||
|
//TODO:If someone cuts power currently, microwave magically keeps going. FIX IT!
|
||||||
|
SetAppearance(MicrowaveVisualState.Idle);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_busy && !_powered)
|
||||||
|
{
|
||||||
|
//we lost power while we were cooking/busy!
|
||||||
|
_lostPower = true;
|
||||||
|
VaporizeReagents();
|
||||||
|
EjectSolids();
|
||||||
|
_busy = false;
|
||||||
|
_uiDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_uiDirty)
|
||||||
|
{
|
||||||
|
_userInterface.SetState(new MicrowaveUpdateUserInterfaceState
|
||||||
|
(
|
||||||
|
_solution.Solution.Contents.ToArray(),
|
||||||
|
_storage.ContainedEntities.Select(item => item.Uid).ToArray(),
|
||||||
|
_busy,
|
||||||
|
_currentCookTimeButtonIndex,
|
||||||
|
_currentCookTimerTime
|
||||||
|
));
|
||||||
|
_uiDirty = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SetAppearance(MicrowaveVisualState state)
|
private void SetAppearance(MicrowaveVisualState state)
|
||||||
{
|
{
|
||||||
if (_appearance != null || Owner.TryGetComponent(out _appearance))
|
if (_appearance != null || Owner.TryGetComponent(out _appearance))
|
||||||
@@ -165,42 +191,29 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateUserInterface()
|
|
||||||
{
|
|
||||||
var solidsVisualList = new List<EntityUid>();
|
|
||||||
foreach(var item in _storage.ContainedEntities)
|
|
||||||
{
|
|
||||||
solidsVisualList.Add(item.Uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
_userInterface.SetState(new MicrowaveUpdateUserInterfaceState(_solution.Solution.Contents, solidsVisualList, _busy));
|
|
||||||
}
|
|
||||||
|
|
||||||
void IActivate.Activate(ActivateEventArgs eventArgs)
|
void IActivate.Activate(ActivateEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (!eventArgs.User.TryGetComponent(out IActorComponent actor) || !Powered)
|
if (!eventArgs.User.TryGetComponent(out IActorComponent actor) || !_powered)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_uiDirty = true;
|
||||||
UpdateUserInterface();
|
|
||||||
_userInterface.Open(actor.playerSession);
|
_userInterface.Open(actor.playerSession);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InteractUsing(InteractUsingEventArgs eventArgs)
|
public bool InteractUsing(InteractUsingEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
|
if (!_powered)
|
||||||
|
{
|
||||||
|
_notifyManager.PopupMessage(Owner.Transform.GridPosition, eventArgs.User,
|
||||||
|
Loc.GetString("It has no power!"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var itemEntity = eventArgs.User.GetComponent<HandsComponent>().GetActiveHand.Owner;
|
var itemEntity = eventArgs.User.GetComponent<HandsComponent>().GetActiveHand.Owner;
|
||||||
|
|
||||||
if(itemEntity.TryGetComponent<PourableComponent>(out var attackPourable))
|
if(itemEntity.TryGetComponent<PourableComponent>(out var attackPourable))
|
||||||
{
|
{
|
||||||
//Get target and check if it can be poured into
|
|
||||||
if (!Owner.TryGetComponent<SolutionComponent>(out var mySolution)
|
|
||||||
|| !mySolution.CanPourIn)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!itemEntity.TryGetComponent<SolutionComponent>(out var attackSolution)
|
if (!itemEntity.TryGetComponent<SolutionComponent>(out var attackSolution)
|
||||||
|| !attackSolution.CanPourOut)
|
|| !attackSolution.CanPourOut)
|
||||||
{
|
{
|
||||||
@@ -208,7 +221,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Get transfer amount. May be smaller than _transferAmount if not enough room
|
//Get transfer amount. May be smaller than _transferAmount if not enough room
|
||||||
var realTransferAmount = ReagentUnit.Min(attackPourable.TransferAmount, mySolution.EmptyVolume);
|
var realTransferAmount = ReagentUnit.Min(attackPourable.TransferAmount, _solution.EmptyVolume);
|
||||||
if (realTransferAmount <= 0) //Special message if container is full
|
if (realTransferAmount <= 0) //Special message if container is full
|
||||||
{
|
{
|
||||||
_notifyManager.PopupMessage(Owner.Transform.GridPosition, eventArgs.User,
|
_notifyManager.PopupMessage(Owner.Transform.GridPosition, eventArgs.User,
|
||||||
@@ -218,7 +231,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
//Move units from attackSolution to targetSolution
|
//Move units from attackSolution to targetSolution
|
||||||
var removedSolution = attackSolution.SplitSolution(realTransferAmount);
|
var removedSolution = attackSolution.SplitSolution(realTransferAmount);
|
||||||
if (!mySolution.TryAddSolution(removedSolution))
|
if (!_solution.TryAddSolution(removedSolution))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -228,24 +241,18 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!itemEntity.TryGetComponent(typeof(FoodComponent), out var food))
|
itemEntity.TryGetComponent(typeof(ItemComponent), out var food);
|
||||||
{
|
|
||||||
|
|
||||||
_notifyManager.PopupMessage(Owner, eventArgs.User, "That won't work!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var ent = food.Owner; //Get the entity of the ItemComponent.
|
var ent = food.Owner; //Get the entity of the ItemComponent.
|
||||||
_storage.Insert(ent);
|
_storage.Insert(ent);
|
||||||
UpdateUserInterface();
|
_uiDirty = true;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//This is required. It's 'cook'.
|
// ReSharper disable once InconsistentNaming
|
||||||
|
// ReSharper disable once IdentifierTypo
|
||||||
private void wzhzhzh()
|
private void wzhzhzh()
|
||||||
{
|
{
|
||||||
if (!HasContents)
|
if (!_hasContents)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -267,25 +274,23 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
// Check recipes
|
// Check recipes
|
||||||
FoodRecipePrototype recipeToCook = null;
|
FoodRecipePrototype recipeToCook = null;
|
||||||
foreach(var r in _recipeManager.Recipes)
|
foreach (var r in _recipeManager.Recipes.Where(r => CanSatisfyRecipe(r, solidsDict)))
|
||||||
{
|
{
|
||||||
if (!CanSatisfyRecipe(r, solidsDict))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
recipeToCook = r;
|
recipeToCook = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
var goodMeal = (recipeToCook != null)
|
var goodMeal = (recipeToCook != null)
|
||||||
&&
|
&&
|
||||||
(_currentCookTimerTime == (uint)recipeToCook.CookTime) ? true : false;
|
(_currentCookTimerTime == (uint)recipeToCook.CookTime);
|
||||||
|
|
||||||
SetAppearance(MicrowaveVisualState.Cooking);
|
SetAppearance(MicrowaveVisualState.Cooking);
|
||||||
_audioSystem.Play(_startCookingSound, Owner, AudioParams.Default);
|
_audioSystem.Play(_startCookingSound, Owner, AudioParams.Default);
|
||||||
Timer.Spawn((int)(_currentCookTimerTime * _cookTimeMultiplier), () =>
|
Timer.Spawn((int)(_currentCookTimerTime * _cookTimeMultiplier), () =>
|
||||||
{
|
{
|
||||||
|
if (_lostPower)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (goodMeal)
|
if (goodMeal)
|
||||||
{
|
{
|
||||||
SubtractContents(recipeToCook);
|
SubtractContents(recipeToCook);
|
||||||
@@ -296,14 +301,19 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
VaporizeSolids();
|
VaporizeSolids();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (recipeToCook != null)
|
||||||
|
{
|
||||||
var entityToSpawn = goodMeal ? recipeToCook.Result : _badRecipeName;
|
var entityToSpawn = goodMeal ? recipeToCook.Result : _badRecipeName;
|
||||||
_entityManager.SpawnEntity(entityToSpawn, Owner.Transform.GridPosition);
|
_entityManager.SpawnEntity(entityToSpawn, Owner.Transform.GridPosition);
|
||||||
_audioSystem.Play(_cookingCompleteSound,Owner, AudioParams.Default);
|
}
|
||||||
|
_audioSystem.Play(_cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f));
|
||||||
SetAppearance(MicrowaveVisualState.Idle);
|
SetAppearance(MicrowaveVisualState.Idle);
|
||||||
_busy = false;
|
_busy = false;
|
||||||
UpdateUserInterface();
|
|
||||||
|
_uiDirty = true;
|
||||||
});
|
});
|
||||||
UpdateUserInterface();
|
_lostPower = false;
|
||||||
|
_uiDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void VaporizeReagents()
|
private void VaporizeReagents()
|
||||||
@@ -311,7 +321,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
_solution.RemoveAllSolution();
|
_solution.RemoveAllSolution();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void VaporizeReagentWithReagentQuantity(Solution.ReagentQuantity reagentQuantity)
|
private void VaporizeReagentQuantity(Solution.ReagentQuantity reagentQuantity)
|
||||||
{
|
{
|
||||||
_solution.TryRemoveReagent(reagentQuantity.ReagentId, reagentQuantity.Quantity);
|
_solution.TryRemoveReagent(reagentQuantity.ReagentId, reagentQuantity.Quantity);
|
||||||
}
|
}
|
||||||
@@ -335,7 +345,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EjectSolidWithIndex(EntityUid entityID)
|
private void EjectSolid(EntityUid entityID)
|
||||||
{
|
{
|
||||||
if (_entityManager.EntityExists(entityID))
|
if (_entityManager.EntityExists(entityID))
|
||||||
{
|
{
|
||||||
@@ -402,9 +412,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
|
|
||||||
private void ClickSound()
|
private void ClickSound()
|
||||||
{
|
{
|
||||||
|
|
||||||
_audioSystem.Play("/Audio/machines/machine_switch.ogg",Owner,AudioParams.Default.WithVolume(-2f));
|
_audioSystem.Play("/Audio/machines/machine_switch.ogg",Owner,AudioParams.Default.WithVolume(-2f));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuicideKind Suicide(IEntity victim, IChatManager chat)
|
public SuicideKind Suicide(IEntity victim, IChatManager chat)
|
||||||
@@ -423,7 +431,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
|
|||||||
chat.EntityMe(victim, Loc.GetPluralString("is trying to cook {0:their} head!", "is trying to cook {0:their} heads!", headCount, victim));
|
chat.EntityMe(victim, Loc.GetPluralString("is trying to cook {0:their} head!", "is trying to cook {0:their} heads!", headCount, victim));
|
||||||
_currentCookTimerTime = 10;
|
_currentCookTimerTime = 10;
|
||||||
ClickSound();
|
ClickSound();
|
||||||
UpdateUserInterface();
|
_uiDirty = true;
|
||||||
wzhzhzh();
|
wzhzhzh();
|
||||||
return SuicideKind.Heat;
|
return SuicideKind.Heat;
|
||||||
}
|
}
|
||||||
25
Content.Server/GameObjects/EntitySystems/MicrowaveSystem.cs
Normal file
25
Content.Server/GameObjects/EntitySystems/MicrowaveSystem.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using Content.Server.GameObjects.Components.Kitchen;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
|
{
|
||||||
|
public class MicrowaveSystem : EntitySystem
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
EntityQuery = new TypeEntityQuery(typeof(MicrowaveComponent));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
base.Update(frameTime);
|
||||||
|
foreach (var entity in RelevantEntities)
|
||||||
|
{
|
||||||
|
var comp = entity.GetComponent<MicrowaveComponent>();
|
||||||
|
comp.OnUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,28 +55,35 @@ namespace Content.Shared.Kitchen
|
|||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class MicrowaveSelectCookTimeMessage : BoundUserInterfaceMessage
|
public class MicrowaveSelectCookTimeMessage : BoundUserInterfaceMessage
|
||||||
{
|
{
|
||||||
public uint newCookTime;
|
public int ButtonIndex;
|
||||||
public MicrowaveSelectCookTimeMessage(uint inputTime)
|
public uint NewCookTime;
|
||||||
|
public MicrowaveSelectCookTimeMessage(int buttonIndex, uint inputTime)
|
||||||
{
|
{
|
||||||
newCookTime = inputTime;
|
ButtonIndex = buttonIndex;
|
||||||
|
NewCookTime = inputTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[NetSerializable, Serializable]
|
[NetSerializable, Serializable]
|
||||||
public class MicrowaveUpdateUserInterfaceState : BoundUserInterfaceState
|
public class MicrowaveUpdateUserInterfaceState : BoundUserInterfaceState
|
||||||
{
|
{
|
||||||
public readonly IReadOnlyList<Solution.ReagentQuantity> ReagentsReagents;
|
public Solution.ReagentQuantity[] ReagentQuantities;
|
||||||
public readonly List<EntityUid> ContainedSolids;
|
public EntityUid[] ContainedSolids;
|
||||||
public bool IsMicrowaveBusy;
|
public bool IsMicrowaveBusy;
|
||||||
public MicrowaveUpdateUserInterfaceState(IReadOnlyList<Solution.ReagentQuantity> reagents, List<EntityUid> solids, bool busyStatus)
|
public int ActiveButtonIndex;
|
||||||
|
public uint CurrentCookTime;
|
||||||
|
|
||||||
|
public MicrowaveUpdateUserInterfaceState(Solution.ReagentQuantity[] reagents, EntityUid[] containedSolids,
|
||||||
|
bool isMicrowaveBusy, int activeButtonIndex, uint currentCookTime)
|
||||||
{
|
{
|
||||||
ReagentsReagents = reagents;
|
ReagentQuantities = reagents;
|
||||||
ContainedSolids = solids;
|
ContainedSolids = containedSolids;
|
||||||
IsMicrowaveBusy = busyStatus;
|
IsMicrowaveBusy = isMicrowaveBusy;
|
||||||
|
ActiveButtonIndex = activeButtonIndex;
|
||||||
|
CurrentCookTime = currentCookTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
- type: Collidable
|
- type: Collidable
|
||||||
shapes:
|
shapes:
|
||||||
- !type:PhysShapeAabb
|
- !type:PhysShapeAabb
|
||||||
bounds: "-0.25,-0.4,0.25,0.4"
|
bounds: "-0.16,-0.3,0.16,0.3"
|
||||||
layer:
|
layer:
|
||||||
- Opaque
|
- Opaque
|
||||||
- Impassable
|
- Impassable
|
||||||
@@ -34,12 +34,14 @@
|
|||||||
- type: Sprite
|
- type: Sprite
|
||||||
netsync: false
|
netsync: false
|
||||||
sprite: Objects/Kitchen/microwave.rsi
|
sprite: Objects/Kitchen/microwave.rsi
|
||||||
|
drawdepth: Items
|
||||||
layers:
|
layers:
|
||||||
- state: mw0
|
- state: mw0
|
||||||
map: ["enum.MicrowaveVisualizerLayers.Base"]
|
map: ["enum.MicrowaveVisualizerLayers.Base"]
|
||||||
- state: mw_unlit
|
- state: mw_unlit
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
map: ["enum.MicrowaveVisualizerLayers.BaseUnlit"]
|
map: ["enum.MicrowaveVisualizerLayers.BaseUnlit"]
|
||||||
|
|
||||||
- type: PowerDevice
|
- type: PowerDevice
|
||||||
- type: Icon
|
- type: Icon
|
||||||
sprite: Objects/Kitchen/microwave.rsi
|
sprite: Objects/Kitchen/microwave.rsi
|
||||||
|
|||||||
@@ -10,6 +10,16 @@
|
|||||||
solids:
|
solids:
|
||||||
FoodMeat: 1
|
FoodMeat: 1
|
||||||
|
|
||||||
|
- type: microwaveMealRecipe
|
||||||
|
id: RecipeClownBurger
|
||||||
|
name: Clownburger Recipe
|
||||||
|
result: FoodClownBurger
|
||||||
|
time: 5
|
||||||
|
reagents:
|
||||||
|
chem.Flour: 5
|
||||||
|
solids:
|
||||||
|
MaskClown: 1
|
||||||
|
|
||||||
- type: microwaveMealRecipe
|
- type: microwaveMealRecipe
|
||||||
id: RecipeTofuBurger
|
id: RecipeTofuBurger
|
||||||
name: Tofu Burger Recipe
|
name: Tofu Burger Recipe
|
||||||
|
|||||||
Reference in New Issue
Block a user