Skip to content

Commit

Permalink
jet-and-magboost-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirus59 committed Nov 15, 2024
1 parent a471451 commit fa86921
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
42 changes: 33 additions & 9 deletions Content.Shared/Movement/Systems/SharedJetpackSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void OnJetpackUserCanWeightless(EntityUid uid, JetpackUserComponent comp
private void OnJetpackUserEntParentChanged(EntityUid uid, JetpackUserComponent component, ref EntParentChangedMessage args)
{
if (TryComp<JetpackComponent>(component.Jetpack, out var jetpack) &&
!CanEnableOnGrid(args.Transform.GridUid))
(!CanEnableOnGrid(args.Transform.GridUid) || !CheckMagboots(uid))) // SS220 Magboots with jet fix
{
SetEnabled(component.Jetpack, jetpack, false, uid);

Expand Down Expand Up @@ -128,17 +128,15 @@ private void OnJetpackToggle(EntityUid uid, JetpackComponent component, ToggleJe
//ss220 magboots with jet on gravity fix end

//SS220 Magboots with jet fix begin
if (!CheckMagboots(args.Performer))
{
_popup.PopupClient(Loc.GetString("jetpack-no-magboots-on-grid"), uid, args.Performer);
return;
}

var slotEnumerator = _inventory.GetSlotEnumerator(args.Performer);
while (slotEnumerator.NextItem(out var item))
{
if (HasComp<MagbootsComponent>(item) &&
TryComp<ItemToggleComponent>(item, out var itemToggle) &&
itemToggle.Activated && !CanEnableOnGrid(xform.GridUid))
{
_popup.PopupClient(Loc.GetString("jetpack-no-magboots-on-gravity"), uid, args.Performer);
return;
}

// SS220 FIX JETPACK CAMERA START (fix: https://github.com/SerbiaStrong-220/space-station-14/issues/1746)
if (TryComp<BuckleComponent>(args.Performer, out var buckleComponent) && buckleComponent.BuckledTo != null)
{
Expand Down Expand Up @@ -181,6 +179,32 @@ private bool CanEnableOnGrid(EntityUid? gridUid)
//SS220 Fix jet in zero gravity end
}

// SS220 Magboots with jet fix begin
/// <summary>
/// Checks whether the entity can use jet with magboots
/// </summary>
/// <returns>
/// true if entity can use jet with magboots
/// </returns>
private bool CheckMagboots(EntityUid user)
{
var xform = Transform(user);
if (xform.GridUid is null)
return true;

var slotEnumerator = _inventory.GetSlotEnumerator(user);
while (slotEnumerator.NextItem(out var item))
{
if (HasComp<MagbootsComponent>(item) &&
TryComp<ItemToggleComponent>(item, out var itemToggle) &&
itemToggle.Activated)
return false;
}

return true;
}
// SS220 Magboots with jet fix end

private void OnJetpackGetAction(EntityUid uid, JetpackComponent component, GetItemActionsEvent args)
{
args.AddAction(ref component.ToggleActionEntity, component.ToggleAction);
Expand Down
2 changes: 1 addition & 1 deletion Resources/Locale/ru-RU/ss220/movement/jetpacks.ftl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
jetpack-no-magboots-on-gravity = Невозможно использовать джетпак вместе с магнитными сапогами в зоне гравитации
jetpack-no-magboots-on-grid = Невозможно использовать джетпак вместе с магнитными сапогами находясь на объекте

0 comments on commit fa86921

Please sign in to comment.