Add water cups to water coolers (#22073)
* add water cup bin to water cooler * Fix punctuation, and add proper components/tags on init * I forgor and refactoring event construction
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -31,6 +34,13 @@ public sealed class BinSystem : EntitySystem
|
||||
SubscribeLocalEvent<BinComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
||||
SubscribeLocalEvent<BinComponent, InteractHandEvent>(OnInteractHand);
|
||||
SubscribeLocalEvent<BinComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
||||
SubscribeLocalEvent<BinComponent, GetVerbsEvent<AlternativeVerb>>(OnAltInteractHand);
|
||||
SubscribeLocalEvent<BinComponent, ExaminedEvent>(OnExamined);
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid uid, BinComponent component, ExaminedEvent args)
|
||||
{
|
||||
args.PushText(Loc.GetString("bin-component-on-examine-text", ("count", component.Items.Count)));
|
||||
}
|
||||
|
||||
private void OnStartup(EntityUid uid, BinComponent component, ComponentStartup args)
|
||||
@@ -76,19 +86,38 @@ public sealed class BinSystem : EntitySystem
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alt interact acts the same as interacting with your hands normally, but allows fallback interaction if the item
|
||||
/// has priority. E.g. a water cup on a water cooler fills itself on a normal click,
|
||||
/// but you can use alternative interactions to restock the cup bin
|
||||
/// </summary>
|
||||
private void OnAltInteractHand(EntityUid uid, BinComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (args.Using != null)
|
||||
{
|
||||
var canReach = args.CanAccess && args.CanInteract;
|
||||
InsertIntoBin(args.User, args.Target, (EntityUid) args.Using, component, false, canReach);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAfterInteractUsing(EntityUid uid, BinComponent component, AfterInteractUsingEvent args)
|
||||
{
|
||||
if (args.Handled || !args.CanReach)
|
||||
InsertIntoBin(args.User, uid, args.Used, component, args.Handled, args.CanReach);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void InsertIntoBin(EntityUid user, EntityUid target, EntityUid itemInHand, BinComponent component, bool handled, bool canReach)
|
||||
{
|
||||
if (handled || !canReach)
|
||||
return;
|
||||
|
||||
if (!_timing.IsFirstTimePredicted)
|
||||
return;
|
||||
|
||||
if (!TryInsertIntoBin(uid, args.Used, component))
|
||||
if (!TryInsertIntoBin(target, itemInHand, component))
|
||||
return;
|
||||
|
||||
_admin.Add(LogType.Pickup, LogImpact.Low, $"{ToPrettyString(uid):player} inserted {ToPrettyString(args.User)} into bin {ToPrettyString(uid)}.");
|
||||
args.Handled = true;
|
||||
_admin.Add(LogType.Pickup, LogImpact.Low, $"{ToPrettyString(target):player} inserted {ToPrettyString(user)} into bin {ToPrettyString(target)}.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
1
Resources/Locale/en-US/entity-systems/bin/bin-system.ftl
Normal file
1
Resources/Locale/en-US/entity-systems/bin/bin-system.ftl
Normal file
@@ -0,0 +1 @@
|
||||
bin-component-on-examine-text = Looks like there's {$count} items left.
|
||||
@@ -14,7 +14,7 @@ ent-WaterTankFull = { ent-WaterTank }
|
||||
.desc = { ent-WaterTank.desc }
|
||||
|
||||
ent-WaterCooler = water cooler
|
||||
.desc = Seems like a good place to stand and waste time.
|
||||
.desc = Seems like a good place to stand and waste time. It has a stock of paper cups on the side.
|
||||
|
||||
ent-WaterTankHighCapacity = high-capacity water tank
|
||||
.desc = A highly pressurized water tank made to hold gargantuan amounts of water.
|
||||
|
||||
@@ -309,12 +309,6 @@
|
||||
name: water cup
|
||||
description: A paper water cup.
|
||||
components:
|
||||
- type: SolutionContainerManager
|
||||
solutions:
|
||||
drink:
|
||||
reagents:
|
||||
- ReagentId: Water
|
||||
Quantity: 20
|
||||
- type: Drink
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/water_cup.rsi
|
||||
@@ -326,5 +320,8 @@
|
||||
- type: SolutionContainerVisuals
|
||||
maxFillLevels: 1
|
||||
fillBaseName: icon-
|
||||
- type: Tag
|
||||
tags:
|
||||
- Trash
|
||||
- type: TrashOnSolutionEmpty
|
||||
solution: drink
|
||||
|
||||
@@ -127,6 +127,27 @@
|
||||
reagents:
|
||||
- ReagentId: Water
|
||||
Quantity: 500
|
||||
- type: ContainerContainer
|
||||
containers:
|
||||
bin-container: !type:Container
|
||||
- type: Bin
|
||||
initialContents:
|
||||
- DrinkWaterCup
|
||||
- DrinkWaterCup
|
||||
- DrinkWaterCup
|
||||
- DrinkWaterCup
|
||||
- DrinkWaterCup
|
||||
- DrinkWaterCup
|
||||
- DrinkWaterCup
|
||||
- DrinkWaterCup
|
||||
- DrinkWaterCup
|
||||
- DrinkWaterCup
|
||||
whitelist:
|
||||
requireAll: true
|
||||
components:
|
||||
- FitsInDispenser
|
||||
tags:
|
||||
- Trash
|
||||
|
||||
- type: entity
|
||||
parent: StorageTank
|
||||
|
||||
Reference in New Issue
Block a user