Skip to content

Commit

Permalink
Jetpack Server Config
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Sep 11, 2024
1 parent 88451f1 commit eb0b23f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2467,5 +2467,21 @@ public static readonly CVarDef<float>
CVarDef.Create("reclaimer.allow_gibbing", true, CVar.SERVER);

#endregion

#region Jetpack System

/// <summary>
/// When true, Jetpacks can be enabled anywhere, even in gravity.
/// </summary>
public static readonly CVarDef<bool> JetpackEnableAnywhere =
CVarDef.Create("jetpack.enable_anywhere", false, CVar.REPLICATED);

/// <summary>
/// When true, jetpacks can be enabled on grids that have zero gravity.
/// </summary>
public static readonly CVarDef<bool> JetpackEnableInNoGravity =
CVarDef.Create("jetpack.enable_in_no_gravity", true, CVar.REPLICATED);

#endregion
}
}
10 changes: 8 additions & 2 deletions Content.Shared/Movement/Systems/SharedJetpackSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Content.Shared.Actions;
using Content.Shared.CCVar;
using Content.Shared.Gravity;
using Content.Shared.Interaction.Events;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Popups;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
Expand All @@ -20,6 +22,7 @@ public abstract class SharedJetpackSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
[Dependency] private readonly IConfigurationManager _config = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -125,8 +128,11 @@ private void OnJetpackToggle(EntityUid uid, JetpackComponent component, ToggleJe

private bool CanEnableOnGrid(EntityUid? gridUid)
{
return gridUid == null ||
(!HasComp<GravityComponent>(gridUid));
return _config.GetCVar(CCVars.JetpackEnableAnywhere)
|| gridUid == null
|| _config.GetCVar(CCVars.JetpackEnableInNoGravity)
&& TryComp<GravityComponent>(gridUid, out var comp)
&& comp.Enabled;
}

private void OnJetpackGetAction(EntityUid uid, JetpackComponent component, GetItemActionsEvent args)
Expand Down

0 comments on commit eb0b23f

Please sign in to comment.