diff --git a/Content.Client/_CorvaxNext/Medical/SmartFridge/SmartFridgeBoundUserInterface.cs b/Content.Client/_CorvaxNext/Medical/SmartFridge/SmartFridgeBoundUserInterface.cs deleted file mode 100644 index fa75dec559f..00000000000 --- a/Content.Client/_CorvaxNext/Medical/SmartFridge/SmartFridgeBoundUserInterface.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Content.Client.UserInterface.Controls; -using Robust.Client.UserInterface; -using Robust.Shared.Input; -using System.Linq; -using Content.Shared._CorvaxNext.Medical.SmartFridge; -using SmartFridgeMenu = Content.Client._CorvaxNext.Medical.SmartFridge.UI.SmartFridgeMenu; - -namespace Content.Client._CorvaxNext.Medical.SmartFridge; - -public sealed class SmartFridgeBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) -{ - [ViewVariables] - private SmartFridgeMenu? _menu; - - [ViewVariables] - private List _cachedInventory = []; - - protected override void Open() - { - base.Open(); - - _menu = this.CreateWindow(); - _menu.OpenCenteredLeft(); - _menu.Title = EntMan.GetComponent(Owner).EntityName; - _menu.OnItemSelected += OnItemSelected; - Refresh(); - } - - public void Refresh() - { - var system = EntMan.System(); - _cachedInventory = system.GetInventoryClient(Owner); - - _menu?.Populate(_cachedInventory); - } - - private void OnItemSelected(GUIBoundKeyEventArgs args, ListData data) - { - if (args.Function != EngineKeyFunctions.UIClick) - return; - - if (data is not VendorItemsListData { ItemIndex: var itemIndex }) - return; - - if (_cachedInventory.Count == 0) - return; - - var selectedItem = _cachedInventory.ElementAtOrDefault(itemIndex); - - if (selectedItem == null) - return; - - SendMessage(new SmartFridgeEjectMessage(selectedItem.StorageSlotId)); - } -} diff --git a/Content.Client/_CorvaxNext/Medical/SmartFridge/SmartFridgeSystem.cs b/Content.Client/_CorvaxNext/Medical/SmartFridge/SmartFridgeSystem.cs deleted file mode 100644 index d5296c1b763..00000000000 --- a/Content.Client/_CorvaxNext/Medical/SmartFridge/SmartFridgeSystem.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Content.Shared._CorvaxNext.Medical.SmartFridge; -using SmartFridgeComponent = Content.Shared._CorvaxNext.Medical.SmartFridge.SmartFridgeComponent; - -namespace Content.Client._CorvaxNext.Medical.SmartFridge; - -public sealed class SmartFridgeSystem : SharedSmartFridgeSystem -{ - [Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!; - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnVendingAfterState); - } - - private void OnVendingAfterState(EntityUid uid, SmartFridgeComponent component, ref AfterAutoHandleStateEvent args) - { - if (_uiSystem.TryGetOpenUi(uid, SmartFridgeUiKey.Key, out var bui)) - { - bui.Refresh(); - } - } -} diff --git a/Content.Client/_CorvaxNext/Medical/SmartFridge/UI/SmartFridgeMenu.xaml b/Content.Client/_CorvaxNext/Medical/SmartFridge/UI/SmartFridgeMenu.xaml deleted file mode 100644 index 0fd1f95f2f6..00000000000 --- a/Content.Client/_CorvaxNext/Medical/SmartFridge/UI/SmartFridgeMenu.xaml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/Content.Client/_CorvaxNext/Medical/SmartFridge/UI/SmartFridgeMenu.xaml.cs b/Content.Client/_CorvaxNext/Medical/SmartFridge/UI/SmartFridgeMenu.xaml.cs deleted file mode 100644 index fd0963c7a0b..00000000000 --- a/Content.Client/_CorvaxNext/Medical/SmartFridge/UI/SmartFridgeMenu.xaml.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Numerics; -using Content.Client.UserInterface.Controls; -using Content.Client.VendingMachines.UI; -using Content.Shared._CorvaxNext.Medical.SmartFridge; -using Robust.Client.AutoGenerated; -using Robust.Client.UserInterface.Controls; -using Robust.Client.UserInterface.XAML; -using Robust.Client.UserInterface; -using Robust.Shared.Prototypes; - -namespace Content.Client._CorvaxNext.Medical.SmartFridge.UI; - -[GenerateTypedNameReferences] -public sealed partial class SmartFridgeMenu : FancyWindow -{ - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - [Dependency] private readonly IEntityManager _entityManager = default!; - - private readonly Dictionary _dummies = []; - - public event Action? OnItemSelected; - - public SmartFridgeMenu() - { - RobustXamlLoader.Load(this); - IoCManager.InjectDependencies(this); - - VendingContents.SearchBar = SearchBar; - VendingContents.DataFilterCondition += DataFilterCondition; - VendingContents.GenerateItem += GenerateButton; - VendingContents.ItemKeyBindDown += (args, data) => OnItemSelected?.Invoke(args, data); - } - - private static bool DataFilterCondition(string filter, ListData data) - { - if (data is not VendorItemsListData { ItemText: var text }) - return false; - - return string.IsNullOrEmpty(filter) || text.Contains(filter, StringComparison.CurrentCultureIgnoreCase); - } - - private void GenerateButton(ListData data, ListContainerButton button) - { - if (data is not VendorItemsListData { ItemProtoID: var protoId, ItemText: var text }) - return; - - button.AddChild(new VendingMachineItem(protoId, text)); - button.ToolTip = text; - } - - public void Populate(List inventory) - { - if (inventory.Count == 0) - { - SearchBar.Visible = false; - VendingContents.Visible = false; - OutOfStockLabel.Visible = true; - return; - } - - SearchBar.Visible = true; - VendingContents.Visible = true; - OutOfStockLabel.Visible = false; - - var listData = new List(); - - for (var i = 0; i < inventory.Count; i++) - { - var entry = inventory[i]; - - if (!_prototypeManager.TryIndex(entry.Id, out var prototype)) - continue; - - if (!_dummies.TryGetValue(entry.Id, out var dummy)) - { - dummy = _entityManager.Spawn(entry.Id); - _dummies.Add(entry.Id, dummy); - } - - var itemText = $"{entry.ItemName} [{entry.Quantity}]"; - listData.Add(new VendorItemsListData(prototype.ID, itemText, i)); - } - - VendingContents.PopulateList(listData); - } -} diff --git a/Content.Server/_CorvaxNext/Medical/SmartFridge/SmartFridgeSystem.cs b/Content.Server/_CorvaxNext/Medical/SmartFridge/SmartFridgeSystem.cs deleted file mode 100644 index 4d772d9c449..00000000000 --- a/Content.Server/_CorvaxNext/Medical/SmartFridge/SmartFridgeSystem.cs +++ /dev/null @@ -1,203 +0,0 @@ -using Content.Server.Interaction; -using Content.Server.Power.EntitySystems; -using Content.Shared._CorvaxNext.Medical.SmartFridge; -using Content.Shared.Construction.EntitySystems; -using Content.Shared.Containers.ItemSlots; -using Content.Shared.Interaction; -using Content.Shared.Tag; -using Robust.Server.Audio; -using Robust.Shared.Containers; -using Robust.Shared.Prototypes; -using Content.Server.Labels; -using Content.Shared.Chemistry.Components.SolutionManager; -using Content.Server.Chemistry.Containers.EntitySystems; -using Content.Shared.Chemistry.Components; -using Content.Shared.Chemistry.Reagent; -using Content.Shared.Verbs; - -namespace Content.Server._CorvaxNext.Medical.SmartFridge; - -public sealed class SmartFridgeSystem : SharedSmartFridgeSystem -{ - [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!; - [Dependency] private readonly AnchorableSystem _anchorable = default!; - [Dependency] private readonly IEntityManager _entityManager = default!; - [Dependency] private readonly TagSystem _tags = default!; - [Dependency] private readonly AudioSystem _audio = default!; - - [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; - [Dependency] private readonly LabelSystem _label = default!; - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - - public override void Initialize() - { - base.Initialize(); - - Subs.BuiEvents(SmartFridgeUiKey.Key, - subs => - { - subs.Event(OnSmartFridgeEjectMessage); - }); - - SubscribeLocalEvent(MapInit, before: [typeof(ItemSlotsSystem)]); - SubscribeLocalEvent(OnItemEjectEvent); - SubscribeLocalEvent(OnInteractEvent); - } - - private void OnInteractEvent(EntityUid entity, SmartFridgeComponent component, ref InteractUsingEvent ev) - { - if (_tags.HasTag(ev.Used, "Wrench")) - { - _anchorable.TryToggleAnchor(entity, ev.User, ev.Used); - ev.Handled = true; - } - - if (!_anchorable.IsPowered(entity, _entityManager)) - { - ev.Handled = true; - return; - } - - if (component.StorageWhitelist != null) - { - if (!_tags.HasAnyTag(ev.Used, component.StorageWhitelist.Tags!.ToArray())) - { - ev.Handled = true; - return; - } - } - - if (!_itemSlotsSystem.TryInsertEmpty(ev.Target, ev.Used, ev.User, true)) - return; - - if (_solutionContainerSystem.TryGetDrainableSolution(ev.Used, out _, out var sol)) - { - ReagentId? reagentId = sol.GetPrimaryReagentId(); - if (reagentId is not null && _prototypeManager.TryIndex(reagentId.Value.Prototype, out var reagent)) - { - var reagentQuantity = sol.GetReagentQuantity(reagentId.Value); - var totalQuantity = sol.Volume; - - if (reagentQuantity == totalQuantity) - _label.Label(ev.Used, reagent.LocalizedName); - else - { - _label.Label(ev.Used, Loc.GetString("reagent-dispenser-component-impure-auto-label", - ("reagent", reagent.LocalizedName), - ("purity", 100.0f * reagentQuantity / totalQuantity))); - } - } - } - - component.Inventory = GetInventory(entity); - Dirty(entity, component); - - ev.Handled = true; - } - - private void OnItemEjectEvent(EntityUid entity, SmartFridgeComponent component, ref ItemSlotEjectAttemptEvent ev) - { - if (component.SlotToEjectFrom == ev.Slot) - { - Dirty(entity, component); - return; - } - - ev.Cancelled = !component.Ejecting; - } - - public override void Update(float frameTime) - { - base.Update(frameTime); - - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out var comp)) - { - if (!comp.Ejecting) - continue; - - comp.EjectAccumulator += frameTime; - if (!(comp.EjectAccumulator >= comp.EjectDelay)) - continue; - - comp.EjectAccumulator = 0f; - comp.Ejecting = false; - - EjectItem(uid, comp); - } - } - - private void MapInit(EntityUid uid, SmartFridgeComponent component, MapInitEvent _) - { - SetupSmartFridge(uid, component); - } - - private void OnSmartFridgeEjectMessage(EntityUid uid, SmartFridgeComponent component, SmartFridgeEjectMessage args) - { - if (!this.IsPowered(uid, EntityManager)) - return; - - if (args.Actor is not { Valid: true } entity || Deleted(entity)) - return; - - VendFromSlot(uid, args.Id); - Dirty(uid, component); - } - - private void VendFromSlot(EntityUid uid, string itemSlotToEject, SmartFridgeComponent? component = null) - { - if (!Resolve(uid, ref component)) - return; - - if (!this.IsPowered(uid, EntityManager)) - { - return; - } - - var item = _itemSlotsSystem.GetItemOrNull(uid, itemSlotToEject); - - if (item == null) - return; - - if (!_itemSlotsSystem.TryGetSlot(uid, itemSlotToEject, out var itemSlot) && itemSlot == null) - return; - - component.Ejecting = true; - component.SlotToEjectFrom = itemSlot; - - _audio.PlayPvs(component.SoundVend, uid); - } - - private void EjectItem(EntityUid uid, SmartFridgeComponent component) - { - if (component.SlotToEjectFrom == null || - !_itemSlotsSystem.TryEject(uid, component.SlotToEjectFrom, null, out _)) - return; - - component.Inventory = GetInventory(uid); - component.SlotToEjectFrom = null; - - Dirty(uid, component); - } - - private void SetupSmartFridge(EntityUid uid, SmartFridgeComponent component) - { - for (var i = 0; i < component.NumSlots; i++) - { - var storageSlotId = SmartFridgeComponent.BaseStorageSlotId + i; - ItemSlot storageComponent = new() - { - Whitelist = component.StorageWhitelist, - Swap = false, - EjectOnBreak = true, - }; - - component.StorageSlotIds.Add(storageSlotId); - component.StorageSlots.Add(storageComponent); - component.StorageSlots[i].Name = "Storage Slot " + (i+1); - _itemSlotsSystem.AddItemSlot(uid, component.StorageSlotIds[i], component.StorageSlots[i]); - } - - _itemSlotsSystem.AddItemSlot(uid, "itemSlot", component.FridgeSlots); - } -} diff --git a/Content.Shared/_CorvaxNext/Medical/SmartFridge/SharedSmartFridgeSystem.cs b/Content.Shared/_CorvaxNext/Medical/SmartFridge/SharedSmartFridgeSystem.cs deleted file mode 100644 index 4e3c1d3b944..00000000000 --- a/Content.Shared/_CorvaxNext/Medical/SmartFridge/SharedSmartFridgeSystem.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Linq; -using Content.Shared.Containers.ItemSlots; -using Content.Shared.Labels.Components; - -namespace Content.Shared._CorvaxNext.Medical.SmartFridge; - -public abstract class SharedSmartFridgeSystem : EntitySystem -{ - [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!; - - public List GetInventoryClient(EntityUid uid, - SmartFridgeComponent? smartFridgeComponent = null) - { - if (!Resolve(uid, ref smartFridgeComponent)) - return []; - - var inventory = new List(); - - inventory.AddRange(smartFridgeComponent.Inventory); - - return inventory; - } - - protected List GetInventory(EntityUid uid, SmartFridgeComponent? smartFridgeComponent = null) - { - if (!Resolve(uid, ref smartFridgeComponent)) - return []; - - var repeatedItems = new Dictionary(); - for (var i = 0; i < smartFridgeComponent.NumSlots; i++) - { - var storageSlotId = SmartFridgeComponent.BaseStorageSlotId + i; - - var storedItem = _itemSlotsSystem.GetItemOrNull(uid, storageSlotId); - - if (storedItem == null) - continue; - - string itemLabel; - if (TryComp(storedItem, out var label) && !string.IsNullOrEmpty(label.CurrentLabel)) - itemLabel = label.CurrentLabel; - else - itemLabel = Name(storedItem.Value); - - if (repeatedItems.TryGetValue(itemLabel, out var item)) - { - item.Quantity += 1; - continue; - } - - var meta = MetaData(storedItem.Value); - - repeatedItems.Add(itemLabel, new SmartFridgeInventoryItem(meta.EntityPrototype!, storageSlotId, itemLabel, 1)); - } - - return repeatedItems.Values.ToList(); - } -} diff --git a/Content.Shared/_CorvaxNext/Medical/SmartFridge/SmartFridgeComponent.cs b/Content.Shared/_CorvaxNext/Medical/SmartFridge/SmartFridgeComponent.cs deleted file mode 100644 index f9440e3e25e..00000000000 --- a/Content.Shared/_CorvaxNext/Medical/SmartFridge/SmartFridgeComponent.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Content.Shared.Containers.ItemSlots; -using Content.Shared.FixedPoint; -using Content.Shared.Whitelist; -using Robust.Shared.Audio; -using Robust.Shared.GameStates; -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization; -using Component = Robust.Shared.GameObjects.Component; - -namespace Content.Shared._CorvaxNext.Medical.SmartFridge; - -[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] -public sealed partial class SmartFridgeComponent : Component -{ - /// - /// max slots in the SmartFridge, means they can store n items - /// - [DataField("numStorageSlots")] - public int NumSlots = 100; - - [DataField, AutoNetworkedField] - public ItemSlot FridgeSlots = new(); - - [DataField] - public List StorageSlotIds = []; - - [DataField] - public List StorageSlots = []; - - /// - /// latest available inventory - /// - [DataField, AutoNetworkedField] - public List Inventory = []; - - /// - /// Prefix for automatically-generated slot name for storage, up to NumSlots. - /// - public static readonly string BaseStorageSlotId = "SmartFridge-storageSlot"; - - /// - /// what types of things can people store in here - /// pill bottles, bottles, and food - /// - [DataField] - public EntityWhitelist? StorageWhitelist; - - /// - /// How long should the SmartFridge take to dispense something. In Seconds. - /// - [DataField] - public float EjectDelay = 1.2f; - - /// - /// If the SmartFridge is currently vending anything. - /// - [DataField] - public bool Ejecting; - - [DataField] - public float EjectAccumulator; - public ItemSlot? SlotToEjectFrom; - - [DataField] - // Grabbed from: https://github.com/tgstation/tgstation/blob/d34047a5ae911735e35cd44a210953c9563caa22/sound/machines/machine_vend.ogg - public SoundSpecifier SoundVend = new SoundPathSpecifier("/Audio/Machines/machine_vend.ogg") - { - Params = new AudioParams - { - Volume = -4f, - Variation = 0.15f, - }, - }; -} - -[Serializable, NetSerializable] -public sealed class SmartFridgeInventoryItem(EntProtoId id, string storageSlotId, string itemName, FixedPoint2 quantity) -{ - public EntProtoId Id = id; - public string StorageSlotId = storageSlotId; - public string ItemName = itemName; - public FixedPoint2 Quantity = quantity; -} - -[Serializable, NetSerializable] -public enum SmartFridgeUiKey -{ - Key -} - -// doing it here cuz idgaf -[Serializable, NetSerializable] -public sealed class SmartFridgeEjectMessage(string id) : BoundUserInterfaceMessage -{ - public readonly string Id = id; -} diff --git a/Resources/Locale/ru-RU/_corvaxnext/reagents/biological.ftl b/Resources/Locale/ru-RU/_corvaxnext/reagents/biological.ftl index 87c05a76ab2..09a5f4ebf3a 100644 --- a/Resources/Locale/ru-RU/_corvaxnext/reagents/biological.ftl +++ b/Resources/Locale/ru-RU/_corvaxnext/reagents/biological.ftl @@ -1,2 +1,4 @@ reagent-name-resomi-blood = Фиолетовая кровь reagent-desc-resomi-blood = Густая жидкость с резким аммиачным запахом + + diff --git a/Resources/Locale/ru-RU/_corvaxnext/smartfridge/smartfridge.ftl b/Resources/Locale/ru-RU/_corvaxnext/smartfridge/smartfridge.ftl deleted file mode 100644 index e6406bd2e36..00000000000 --- a/Resources/Locale/ru-RU/_corvaxnext/smartfridge/smartfridge.ftl +++ /dev/null @@ -1,2 +0,0 @@ -smart-fridge-title = умный холодильник -smart-fridge-search = умный фильтр diff --git a/Resources/Prototypes/Entities/Structures/Machines/smartfridge.yml b/Resources/Prototypes/Entities/Structures/Machines/smartfridge.yml index 20aaf657dda..5a8eb69b41e 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/smartfridge.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/smartfridge.yml @@ -4,24 +4,6 @@ name: SmartFridge description: A refrigerated storage unit for keeping items cold and fresh. components: - # Corvax-Next-SmartFridge-Start - - type: SmartFridge - storageWhitelist: - tags: - - PillCanister - - Meat - - Cooked - - ChemDispensable - - Bottle - - Syringe - - type: ActivatableUI - key: enum.SmartFridgeUiKey.Key - - type: ActivatableUIRequiresPower - - type: UserInterface - interfaces: - enum.SmartFridgeUiKey.Key: - type: SmartFridgeBoundUserInterface - # Corvax-Next-SmartFridge-End - type: StationAiWhitelist - type: Advertise pack: SmartFridgeAds @@ -36,13 +18,6 @@ - state: smartfridge_door map: ["enum.StorageVisualLayers.Door"] shader: unshaded - # Corvax-Next-SmartFridge-Start - - type: ApcPowerReceiver - powerLoad: 100 - - type: ExtensionCableReceiver - - type: LightningTarget - priority: 1 - # Corvax-Next-SmartFridge-End - type: EntityStorageVisuals stateBaseClosed: smartfridge stateDoorOpen: smartfridge_open @@ -51,30 +26,28 @@ radius: 1.5 energy: 1.6 color: "#9dc5c9" - # Corvax-Next-SmartFridge-Start - # - type: EntityStorage - # isCollidableWhenOpen: true - # closeSound: - # path: /Audio/Machines/windoor_open.ogg - # params: - # volume: -3 - # openSound: - # path: /Audio/Machines/windoor_open.ogg - # params: - # volume: -3 - # - type: ContainerContainer - # containers: - # entity_storage: !type:Container - # - type: UseDelay - # delay: 1 - # - type: AntiRottingContainer - # - type: ResistLocker - # Corvax-Next-SmartFridge-End + - type: EntityStorage + isCollidableWhenOpen: true + closeSound: + path: /Audio/Machines/windoor_open.ogg + params: + volume: -3 + openSound: + path: /Audio/Machines/windoor_open.ogg + params: + volume: -3 + - type: ContainerContainer + containers: + entity_storage: !type:Container + - type: UseDelay + delay: 1 + - type: AntiRottingContainer + - type: ResistLocker - type: Physics bodyType: Static - type: Transform noRot: true - anchored: true + anchored: True - type: Fixtures fixtures: fix1: