Skip to content

Commit

Permalink
More popups
Browse files Browse the repository at this point in the history
  • Loading branch information
FaDeOkno committed Jul 14, 2024
1 parent c77f51c commit 5c12126
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
39 changes: 26 additions & 13 deletions Content.Shared/Movement/Pulling/Systems/PullingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -752,13 +752,36 @@ public bool TryGrab(Entity<PullableComponent?> pullable, Entity<PullerComponent?
if (puller.Comp.GrabStage == GrabStage.Hard && !_handsSystem.TryGetEmptyHand(puller, out _))
return false;

if (!puller.Comp.NeedsHands && puller.Comp.GrabStage == GrabStage.Soft)
{
if (_virtualSystem.TrySpawnVirtualItemInHand(pullable.Owner, puller.Owner, out var item2, true))
puller.Comp.SuffocateVirtualItems.Add(item2.Value);
else
{
_popup.PopupEntity(Loc.GetString("popup-grab-need-hand"), puller, puller, PopupType.Medium);
return false;
}
}

if (puller.Comp.GrabStage == GrabStage.Hard)
{
if (_virtualSystem.TrySpawnVirtualItemInHand(pullable.Owner, puller.Owner, out var item2, true))
puller.Comp.SuffocateVirtualItems.Add(item2.Value);
else
{
_popup.PopupEntity(Loc.GetString("popup-grab-need-hand"), puller, puller, PopupType.Medium);
return false;
}
}

_audio.PlayPvs(new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg"), pullable);
puller.Comp.NextStageChange = _timing.CurTime.Add(TimeSpan.FromSeconds(1.5f));
pullable.Comp.NextEscapeAttempt = _timing.CurTime.Add(TimeSpan.FromSeconds(1f));
_color.RaiseEffect(Color.Yellow, new List<EntityUid>() { pullable }, Filter.Pvs(pullable, entityManager: EntityManager));
Dirty(pullable.Owner, pullable.Comp);
Dirty(puller.Owner, puller.Comp);


puller.Comp.GrabStage += 1;
pullable.Comp.GrabStage = puller.Comp.GrabStage;

Expand All @@ -780,20 +803,13 @@ public bool TryGrab(Entity<PullableComponent?> pullable, Entity<PullerComponent?
_alertsSystem.ShowAlert(puller, puller.Comp.PullingAlert, 2);
_alertsSystem.ShowAlert(pullable, pullable.Comp.PulledAlert, 2);
popupType = PopupType.MediumCaution;
if (!puller.Comp.NeedsHands)
{
if (_virtualSystem.TrySpawnVirtualItemInHand(pullable.Owner, puller.Owner, out var item2, true))
puller.Comp.SuffocateVirtualItems.Add(item2.Value);
}
break;
case GrabStage.Suffocate:
pullable.Comp.GrabEscapeChance = puller.Comp.SuffocateStageEscapeChance;
_blocker.UpdateCanMove(pullable.Owner);
_alertsSystem.ShowAlert(puller, puller.Comp.PullingAlert, 3);
_alertsSystem.ShowAlert(pullable, pullable.Comp.PulledAlert, 3);
popupType = PopupType.LargeCaution;
if (_virtualSystem.TrySpawnVirtualItemInHand(pullable.Owner, puller.Owner, out var item, true))
puller.Comp.SuffocateVirtualItems.Add(item.Value);
break;
default:
pullable.Comp.GrabEscapeChance = 1f;
Expand Down Expand Up @@ -940,12 +956,9 @@ public bool TryLowerGrabStage(Entity<PullableComponent?> pullable, Entity<Puller
}

_modifierSystem.RefreshMovementSpeedModifiers(puller);
if (puller.Comp.GrabStage != GrabStage.No)
{
_popup.PopupEntity(Loc.GetString("popup-grab-" + puller.Comp.GrabStage.ToString().ToLower() + "-target", ("puller", Identity.Entity(puller, EntityManager))), pullable, pullable, popupType);
_popup.PopupEntity(Loc.GetString("popup-grab-" + puller.Comp.GrabStage.ToString().ToLower() + "-self", ("target", Identity.Entity(pullable, EntityManager))), pullable, puller, PopupType.Medium);
_popup.PopupEntity(Loc.GetString("popup-grab-" + puller.Comp.GrabStage.ToString().ToLower() + "-others", ("target", Identity.Entity(pullable, EntityManager)), ("puller", Identity.Entity(puller, EntityManager))), pullable, othersFilter, true, popupType);
}
_popup.PopupEntity(Loc.GetString("popup-grab-" + puller.Comp.GrabStage.ToString().ToLower() + "-target", ("puller", Identity.Entity(puller, EntityManager))), pullable, pullable, popupType);
_popup.PopupEntity(Loc.GetString("popup-grab-" + puller.Comp.GrabStage.ToString().ToLower() + "-self", ("target", Identity.Entity(pullable, EntityManager))), pullable, puller, PopupType.Medium);
_popup.PopupEntity(Loc.GetString("popup-grab-" + puller.Comp.GrabStage.ToString().ToLower() + "-others", ("target", Identity.Entity(pullable, EntityManager)), ("puller", Identity.Entity(puller, EntityManager))), pullable, othersFilter, true, popupType);

Dirty(pullable.Owner, pullable.Comp);
Dirty(puller.Owner, puller.Comp);
Expand Down
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/pulling/popups.ftl
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
popup-grab-soft-target = {CAPITALIZE($puller)} grabbed you softly.
popup-grab-hard-target = {CAPITALIZE($puller)} grabbed you hardly.
popup-grab-suffocate-target = {CAPITALIZE($puller)} started to choke you!
popup-grab-no-target = {CAPITALIZE($puller)} stopped grabbing you.
popup-grab-soft-self = You grabbed {CAPITALIZE($target)} softly.
popup-grab-hard-self = You grabbed {CAPITALIZE($target)} hardly.
popup-grab-suffocate-self = You started to choke {CAPITALIZE($target)}.
popup-grab-no-self = You stopped grabbing {CAPITALIZE($target)}.
popup-grab-soft-others = {CAPITALIZE($puller)} grabbed {CAPITALIZE($target)} softly.
popup-grab-hard-others = {CAPITALIZE($puller)} grabbed {CAPITALIZE($target)} hardly.
popup-grab-suffocate-others = {CAPITALIZE($puller)} started to choke {CAPITALIZE($target)}!
popup-grab-no-others = {CAPITALIZE($puller)} stopped grabbing {CAPITALIZE($target)}.
popup-grab-release-fail-self = You are trying to escape.
popup-grab-release-success-self = You escaped from grab!
popup-grab-release-success-puller = {CAPITALIZE($target)} escaped!
popup-grabbed-cant-speak = You can't breathe!
popup-grab-need-hand = You need a free hand!

0 comments on commit 5c12126

Please sign in to comment.