Added ability to drink from context menu (#7732)
Co-authored-by: Saakra <xfallenfighterswolfx@gmail.com>
This commit is contained in:
@@ -17,8 +17,10 @@ using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Verbs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -53,6 +55,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
SubscribeLocalEvent<DrinkComponent, LandEvent>(HandleLand);
|
||||
SubscribeLocalEvent<DrinkComponent, UseInHandEvent>(OnUse);
|
||||
SubscribeLocalEvent<DrinkComponent, AfterInteractEvent>(AfterInteract);
|
||||
SubscribeLocalEvent<DrinkComponent, GetVerbsEvent<AlternativeVerb>>(AddDrinkVerb);
|
||||
SubscribeLocalEvent<DrinkComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<DrinkComponent, SolutionTransferAttemptEvent>(OnTransferAttempt);
|
||||
SubscribeLocalEvent<SharedBodyComponent, DrinkEvent>(OnDrink);
|
||||
@@ -328,5 +331,34 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
{
|
||||
args.Drink.CancelToken = null;
|
||||
}
|
||||
|
||||
private void AddDrinkVerb(EntityUid uid, DrinkComponent component, GetVerbsEvent<AlternativeVerb> ev)
|
||||
{
|
||||
if (component.CancelToken != null)
|
||||
return;
|
||||
|
||||
if (uid == ev.User ||
|
||||
!ev.CanInteract ||
|
||||
!ev.CanAccess ||
|
||||
!EntityManager.TryGetComponent(ev.User, out SharedBodyComponent? body) ||
|
||||
!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(ev.User, out var stomachs, body))
|
||||
return;
|
||||
|
||||
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && mobState.IsAlive())
|
||||
return;
|
||||
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Act = () =>
|
||||
{
|
||||
TryDrink(ev.User, ev.User, component);
|
||||
},
|
||||
IconTexture = "/Textures/Interface/VerbIcons/drink.svg.192dpi.png",
|
||||
Text = Loc.GetString("drink-system-verb-drink"),
|
||||
Priority = -1
|
||||
};
|
||||
|
||||
ev.Verbs.Add(verb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,7 @@ drink-component-try-use-drink-had-enough-other = They can't drink more!
|
||||
drink-component-try-use-drink-success-slurp = Slurp
|
||||
drink-component-force-feed = {$user} is trying to make you drink something!
|
||||
drink-component-force-feed-success = {$user} forced you to drink something!
|
||||
drink-component-force-feed-success-user = You successfully feed {$target}
|
||||
drink-component-force-feed-success-user = You successfully feed {$target}
|
||||
|
||||
|
||||
drink-system-verb-drink = Drink
|
||||
61
Resources/Textures/Interface/VerbIcons/drink.svg
Normal file
61
Resources/Textures/Interface/VerbIcons/drink.svg
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
version="1"
|
||||
viewBox="0 0 128 128"
|
||||
id="svg6"
|
||||
sodipodi:docname="drink.svg"
|
||||
width="128"
|
||||
height="128"
|
||||
inkscape:export-filename="/home/rane/Downloads/drink.png"
|
||||
inkscape:export-xdpi="48"
|
||||
inkscape:export-ydpi="48"
|
||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs10" />
|
||||
<sodipodi:namedview
|
||||
id="namedview8"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
showgrid="true"
|
||||
width="128px"
|
||||
inkscape:lockguides="false"
|
||||
inkscape:zoom="2.8284271"
|
||||
inkscape:cx="46.138717"
|
||||
inkscape:cy="56.214989"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1011"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="32"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg6">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid1032" />
|
||||
</sodipodi:namedview>
|
||||
<path
|
||||
d="m 86.553,27.485 c -1.845,1.81 -4.336,2.516 -7.098,2.516 -3.506,0 -6.695,-1.445 -8.527,-4.18 -1.817,2.79 -5.02,4.18 -8.572,4.18 -3.5,0 -6.66,-1.475 -8.49,-4.21 -1.82,2.822 -5.02,4.21 -8.61,4.21 -2.59,0 -4.966,-0.59 -6.755,-2.197 l -1.36,-9.84 c 1.858,2.48 4.805,4.09 8.114,4.09 3.59,0 6.793,-1.78 8.612,-4.6 1.83,2.732 4.99,4.6 8.498,4.6 3.552,0 6.756,-1.78 8.573,-4.57 1.833,2.733 5.02,4.57 8.528,4.57 3.578,0 6.74,-1.865 8.544,-4.687 l -1.444,10.11 z"
|
||||
id="path2" />
|
||||
<path
|
||||
d="M 89.145,110.545 104.64,10.545 94.208,10.647 80.115,100 H 45 l -14.095,-89.353 -10.43,-0.102 15.496,100 z"
|
||||
id="path4" />
|
||||
<path
|
||||
style="fill:#ffffff;stroke-width:0.240096"
|
||||
d="m 36.112845,110.26516 c -0.01188,-0.0336 -3.497293,-22.426024 -7.745352,-49.760958 l -7.723743,-49.69988 5.019386,-0.0649 c 2.760663,-0.0357 5.047322,-0.0357 5.081466,0 0.03414,0.0357 3.225943,20.133929 7.092886,44.662741 L 44.868295,100 h 17.6905 17.690501 l 0.123981,-0.780312 c 0.06819,-0.429172 3.235964,-20.52521 7.039501,-44.657863 l 6.91552,-43.877551 h 5.079407 5.079405 l -0.34252,2.220888 c -0.18839,1.221489 -3.65717,23.613445 -7.708403,49.759904 l -7.365877,47.539014 -26.467928,0.0611 c -14.557362,0.0336 -26.477652,0.0336 -26.489537,0 z"
|
||||
id="path1108" />
|
||||
<path
|
||||
style="fill:#ffffff;stroke-width:0.240096"
|
||||
d="m 42.714697,29.644498 c -1.225269,-0.242922 -2.561546,-0.794174 -3.438024,-1.418281 -0.644686,-0.459057 -0.692768,-0.638836 -1.20573,-4.508233 -0.293847,-2.21656 -0.597652,-4.298226 -0.675121,-4.625924 -0.128534,-0.543704 -0.04015,-0.507176 1.010499,0.417645 2.377869,2.093085 5.493809,3.029323 8.416086,2.528758 2.228304,-0.381693 4.46973,-1.504319 5.866366,-2.938192 l 1.176041,-1.207397 1.29035,1.257645 c 4.09014,3.986471 10.507571,3.991566 14.534824,0.01154 l 1.262617,-1.247811 1.1683,1.168301 c 2.344526,2.344525 5.911378,3.496698 9.040211,2.920188 2.072425,-0.38186 4.05686,-1.391767 5.510135,-2.804187 1.119796,-1.088317 1.150021,-1.101211 1.022343,-0.436121 -0.07236,0.376944 -0.37734,2.468065 -0.677728,4.646937 -0.62528,4.535476 -0.661758,4.596952 -3.378963,5.69448 -3.865751,1.561445 -8.70612,0.666018 -11.499436,-2.127298 l -1.189088,-1.189088 -1.189087,1.189088 c -3.866075,3.866073 -10.811431,3.857213 -14.687382,-0.01874 l -1.207825,-1.207826 -1.188995,1.195243 c -2.397084,2.409684 -6.20966,3.442894 -9.960393,2.699273 z"
|
||||
id="path1147" />
|
||||
<path
|
||||
style="fill:#ffffff;stroke-width:0.03125"
|
||||
d=""
|
||||
id="path1186" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
BIN
Resources/Textures/Interface/VerbIcons/drink.svg.192dpi.png
Normal file
BIN
Resources/Textures/Interface/VerbIcons/drink.svg.192dpi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,2 @@
|
||||
sample:
|
||||
filter: true
|
||||
Reference in New Issue
Block a user