Fix jetpack warnings (#18227)
This commit is contained in:
@@ -14,7 +14,7 @@ public sealed class JetpackSystem : SharedJetpackSystem
|
|||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
[Dependency] private readonly ClothingSystem _clothing = default!;
|
[Dependency] private readonly ClothingSystem _clothing = default!;
|
||||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -22,7 +22,7 @@ public sealed class JetpackSystem : SharedJetpackSystem
|
|||||||
SubscribeLocalEvent<JetpackComponent, AppearanceChangeEvent>(OnJetpackAppearance);
|
SubscribeLocalEvent<JetpackComponent, AppearanceChangeEvent>(OnJetpackAppearance);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool CanEnable(JetpackComponent component)
|
protected override bool CanEnable(EntityUid uid, JetpackComponent component)
|
||||||
{
|
{
|
||||||
// No predicted atmos so you'd have to do a lot of funny to get this working.
|
// No predicted atmos so you'd have to do a lot of funny to get this working.
|
||||||
return false;
|
return false;
|
||||||
@@ -30,7 +30,7 @@ public sealed class JetpackSystem : SharedJetpackSystem
|
|||||||
|
|
||||||
private void OnJetpackAppearance(EntityUid uid, JetpackComponent component, ref AppearanceChangeEvent args)
|
private void OnJetpackAppearance(EntityUid uid, JetpackComponent component, ref AppearanceChangeEvent args)
|
||||||
{
|
{
|
||||||
_appearance.TryGetData<bool>(uid, JetpackVisuals.Enabled, out var enabled, args.Component);
|
Appearance.TryGetData<bool>(uid, JetpackVisuals.Enabled, out var enabled, args.Component);
|
||||||
|
|
||||||
var state = "icon" + (enabled ? "-on" : "");
|
var state = "icon" + (enabled ? "-on" : "");
|
||||||
args.Sprite?.LayerSetState(0, state);
|
args.Sprite?.LayerSetState(0, state);
|
||||||
@@ -43,16 +43,21 @@ public sealed class JetpackSystem : SharedJetpackSystem
|
|||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|
||||||
if (!_timing.IsFirstTimePredicted) return;
|
if (!_timing.IsFirstTimePredicted)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (var comp in EntityQuery<ActiveJetpackComponent>())
|
// TODO: Please don't copy-paste this I beg
|
||||||
|
// make a generic particle emitter system / actual particles instead.
|
||||||
|
var query = EntityQueryEnumerator<ActiveJetpackComponent>();
|
||||||
|
|
||||||
|
while (query.MoveNext(out var uid, out var comp))
|
||||||
{
|
{
|
||||||
if (_timing.CurTime < comp.TargetTime)
|
if (_timing.CurTime < comp.TargetTime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
comp.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(comp.EffectCooldown);
|
comp.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(comp.EffectCooldown);
|
||||||
|
|
||||||
CreateParticles(comp.Owner);
|
CreateParticles(uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +67,9 @@ public sealed class JetpackSystem : SharedJetpackSystem
|
|||||||
if (Container.TryGetContainingContainer(uid, out var container) &&
|
if (Container.TryGetContainingContainer(uid, out var container) &&
|
||||||
TryComp<PhysicsComponent>(container.Owner, out var body) &&
|
TryComp<PhysicsComponent>(container.Owner, out var body) &&
|
||||||
body.LinearVelocity.LengthSquared() < 1f)
|
body.LinearVelocity.LengthSquared() < 1f)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var uidXform = Transform(uid);
|
var uidXform = Transform(uid);
|
||||||
var coordinates = uidXform.Coordinates;
|
var coordinates = uidXform.Coordinates;
|
||||||
@@ -70,19 +77,17 @@ public sealed class JetpackSystem : SharedJetpackSystem
|
|||||||
|
|
||||||
if (_mapManager.TryGetGrid(gridUid, out var grid))
|
if (_mapManager.TryGetGrid(gridUid, out var grid))
|
||||||
{
|
{
|
||||||
coordinates = new EntityCoordinates(grid.Owner, grid.WorldToLocal(coordinates.ToMapPos(EntityManager)));
|
coordinates = new EntityCoordinates(gridUid.Value, grid.WorldToLocal(coordinates.ToMapPos(EntityManager, _transform)));
|
||||||
}
|
}
|
||||||
else if (uidXform.MapUid != null)
|
else if (uidXform.MapUid != null)
|
||||||
{
|
{
|
||||||
coordinates = new EntityCoordinates(uidXform.MapUid.Value, uidXform.WorldPosition);
|
coordinates = new EntityCoordinates(uidXform.MapUid.Value, _transform.GetWorldPosition(uidXform));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ent = Spawn("JetpackEffect", coordinates);
|
Spawn("JetpackEffect", coordinates);
|
||||||
var xform = Transform(ent);
|
|
||||||
xform.Coordinates = coordinates;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,38 +12,40 @@ public sealed class JetpackSystem : SharedJetpackSystem
|
|||||||
[Dependency] private readonly GasTankSystem _gasTank = default!;
|
[Dependency] private readonly GasTankSystem _gasTank = default!;
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
|
|
||||||
private const float UpdateCooldown = 0.5f;
|
protected override bool CanEnable(EntityUid uid, JetpackComponent component)
|
||||||
|
|
||||||
protected override bool CanEnable(JetpackComponent component)
|
|
||||||
{
|
{
|
||||||
return base.CanEnable(component) && TryComp<GasTankComponent>(component.Owner, out var gasTank) && !(gasTank.Air.TotalMoles < component.MoleUsage);
|
return base.CanEnable(uid, component) &&
|
||||||
|
TryComp<GasTankComponent>(uid, out var gasTank) &&
|
||||||
|
!(gasTank.Air.TotalMoles < component.MoleUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|
||||||
var toDisable = new ValueList<JetpackComponent>();
|
var toDisable = new ValueList<(EntityUid Uid, JetpackComponent Component)>();
|
||||||
|
var query = EntityQueryEnumerator<ActiveJetpackComponent, JetpackComponent, GasTankComponent>();
|
||||||
|
|
||||||
foreach (var (active, comp, gasTank) in EntityQuery<ActiveJetpackComponent, JetpackComponent, GasTankComponent>())
|
while (query.MoveNext(out var uid, out var active, out var comp, out var gasTank))
|
||||||
{
|
{
|
||||||
if (_timing.CurTime < active.TargetTime) continue;
|
if (_timing.CurTime < active.TargetTime)
|
||||||
|
continue;
|
||||||
|
|
||||||
active.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(active.EffectCooldown);
|
active.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(active.EffectCooldown);
|
||||||
var air = _gasTank.RemoveAir(gasTank, comp.MoleUsage);
|
var air = _gasTank.RemoveAir(gasTank, comp.MoleUsage);
|
||||||
|
|
||||||
if (air == null || !MathHelper.CloseTo(air.TotalMoles, comp.MoleUsage, 0.001f))
|
if (air == null || !MathHelper.CloseTo(air.TotalMoles, comp.MoleUsage, 0.001f))
|
||||||
{
|
{
|
||||||
toDisable.Add(comp);
|
toDisable.Add((uid, comp));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_gasTank.UpdateUserInterface(gasTank);
|
_gasTank.UpdateUserInterface(gasTank);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var comp in toDisable)
|
foreach (var (uid, comp) in toDisable)
|
||||||
{
|
{
|
||||||
SetEnabled(comp, false);
|
SetEnabled(uid, comp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ public abstract class SharedDoorSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] protected readonly IGameTiming GameTiming = default!;
|
[Dependency] protected readonly IGameTiming GameTiming = default!;
|
||||||
[Dependency] protected readonly SharedPhysicsSystem PhysicsSystem = default!;
|
[Dependency] protected readonly SharedPhysicsSystem PhysicsSystem = default!;
|
||||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||||
[Dependency] protected readonly TagSystem Tags = default!;
|
[Dependency] protected readonly TagSystem Tags = default!;
|
||||||
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
[Dependency] protected readonly SharedAudioSystem Audio = default!;
|
||||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||||
[Dependency] protected readonly SharedAppearanceSystem AppearanceSystem = default!;
|
[Dependency] protected readonly SharedAppearanceSystem AppearanceSystem = default!;
|
||||||
[Dependency] private readonly OccluderSystem _occluder = default!;
|
[Dependency] private readonly OccluderSystem _occluder = default!;
|
||||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A body must have an intersection percentage larger than this in order to be considered as colliding with a
|
/// A body must have an intersection percentage larger than this in order to be considered as colliding with a
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
|||||||
|
|
||||||
namespace Content.Shared.Implants.Components;
|
namespace Content.Shared.Implants.Components;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implanters are used to implant or extract implants from an entity
|
/// Implanters are used to implant or extract implants from an entity.
|
||||||
/// Some can be single use (implant only) or some can draw out an implant
|
/// Some can be single use (implant only) or some can draw out an implant
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//TODO: Rework drawing to work with implant cases when surgery is in
|
//TODO: Rework drawing to work with implant cases when surgery is in
|
||||||
|
|||||||
@@ -59,9 +59,9 @@ public abstract class SharedImplanterSystem : EntitySystem
|
|||||||
implantContainer.Insert(implant.Value);
|
implantContainer.Insert(implant.Value);
|
||||||
|
|
||||||
if (component.CurrentMode == ImplanterToggleMode.Inject && !component.ImplantOnly)
|
if (component.CurrentMode == ImplanterToggleMode.Inject && !component.ImplantOnly)
|
||||||
DrawMode(component);
|
DrawMode(implanter, component);
|
||||||
else
|
else
|
||||||
ImplantMode(component);
|
ImplantMode(implanter, component);
|
||||||
|
|
||||||
Dirty(component);
|
Dirty(component);
|
||||||
}
|
}
|
||||||
@@ -74,8 +74,8 @@ public abstract class SharedImplanterSystem : EntitySystem
|
|||||||
[NotNullWhen(true)] out EntityUid? implant,
|
[NotNullWhen(true)] out EntityUid? implant,
|
||||||
[NotNullWhen(true)] out SubdermalImplantComponent? implantComp)
|
[NotNullWhen(true)] out SubdermalImplantComponent? implantComp)
|
||||||
{
|
{
|
||||||
implant = component.ImplanterSlot.ContainerSlot?.ContainedEntities?.FirstOrDefault();
|
implant = component.ImplanterSlot.ContainerSlot?.ContainedEntities.FirstOrDefault();
|
||||||
if (!TryComp<SubdermalImplantComponent>(implant, out implantComp))
|
if (!TryComp(implant, out implantComp))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var ev = new AddImplantAttemptEvent(user, target, implant.Value, implanter);
|
var ev = new AddImplantAttemptEvent(user, target, implant.Value, implanter);
|
||||||
@@ -101,7 +101,7 @@ public abstract class SharedImplanterSystem : EntitySystem
|
|||||||
foreach (var implant in implantContainer.ContainedEntities)
|
foreach (var implant in implantContainer.ContainedEntities)
|
||||||
{
|
{
|
||||||
if (!implantCompQuery.TryGetComponent(implant, out var implantComp))
|
if (!implantCompQuery.TryGetComponent(implant, out var implantComp))
|
||||||
return;
|
continue;
|
||||||
|
|
||||||
//Don't remove a permanent implant and look for the next that can be drawn
|
//Don't remove a permanent implant and look for the next that can be drawn
|
||||||
if (!implantContainer.CanRemove(implant))
|
if (!implantContainer.CanRemove(implant))
|
||||||
@@ -124,27 +124,27 @@ public abstract class SharedImplanterSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (component.CurrentMode == ImplanterToggleMode.Draw && !component.ImplantOnly && !permanentFound)
|
if (component.CurrentMode == ImplanterToggleMode.Draw && !component.ImplantOnly && !permanentFound)
|
||||||
ImplantMode(component);
|
ImplantMode(implanter, component);
|
||||||
|
|
||||||
Dirty(component);
|
Dirty(component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ImplantMode(ImplanterComponent component)
|
private void ImplantMode(EntityUid uid, ImplanterComponent component)
|
||||||
{
|
{
|
||||||
component.CurrentMode = ImplanterToggleMode.Inject;
|
component.CurrentMode = ImplanterToggleMode.Inject;
|
||||||
ChangeOnImplantVisualizer(component);
|
ChangeOnImplantVisualizer(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawMode(ImplanterComponent component)
|
private void DrawMode(EntityUid uid, ImplanterComponent component)
|
||||||
{
|
{
|
||||||
component.CurrentMode = ImplanterToggleMode.Draw;
|
component.CurrentMode = ImplanterToggleMode.Draw;
|
||||||
ChangeOnImplantVisualizer(component);
|
ChangeOnImplantVisualizer(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeOnImplantVisualizer(ImplanterComponent component)
|
private void ChangeOnImplantVisualizer(EntityUid uid, ImplanterComponent component)
|
||||||
{
|
{
|
||||||
if (!TryComp<AppearanceComponent>(component.Owner, out var appearance))
|
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool implantFound;
|
bool implantFound;
|
||||||
@@ -156,17 +156,17 @@ public abstract class SharedImplanterSystem : EntitySystem
|
|||||||
implantFound = false;
|
implantFound = false;
|
||||||
|
|
||||||
if (component.CurrentMode == ImplanterToggleMode.Inject && !component.ImplantOnly)
|
if (component.CurrentMode == ImplanterToggleMode.Inject && !component.ImplantOnly)
|
||||||
_appearance.SetData(component.Owner, ImplanterVisuals.Full, implantFound, appearance);
|
_appearance.SetData(uid, ImplanterVisuals.Full, implantFound, appearance);
|
||||||
|
|
||||||
else if (component.CurrentMode == ImplanterToggleMode.Inject && component.ImplantOnly)
|
else if (component.CurrentMode == ImplanterToggleMode.Inject && component.ImplantOnly)
|
||||||
{
|
{
|
||||||
_appearance.SetData(component.Owner, ImplanterVisuals.Full, implantFound, appearance);
|
_appearance.SetData(uid, ImplanterVisuals.Full, implantFound, appearance);
|
||||||
_appearance.SetData(component.Owner, ImplanterImplantOnlyVisuals.ImplantOnly, component.ImplantOnly,
|
_appearance.SetData(uid, ImplanterImplantOnlyVisuals.ImplantOnly, component.ImplantOnly,
|
||||||
appearance);
|
appearance);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
_appearance.SetData(component.Owner, ImplanterVisuals.Full, implantFound, appearance);
|
_appearance.SetData(uid, ImplanterVisuals.Full, implantFound, appearance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,20 +6,17 @@ using Content.Shared.Movement.Events;
|
|||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Network;
|
|
||||||
using Robust.Shared.Player;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Timing;
|
|
||||||
|
|
||||||
namespace Content.Shared.Movement.Systems;
|
namespace Content.Shared.Movement.Systems;
|
||||||
|
|
||||||
public abstract class SharedJetpackSystem : EntitySystem
|
public abstract class SharedJetpackSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] protected readonly MovementSpeedModifierSystem MovementSpeedModifier = default!;
|
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
|
||||||
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
||||||
[Dependency] protected readonly SharedContainerSystem Container = default!;
|
[Dependency] protected readonly SharedContainerSystem Container = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
[Dependency] private readonly SharedMoverController _mover = default!;
|
||||||
[Dependency] private readonly SharedMoverController _mover = default!;
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -55,14 +52,16 @@ public abstract class SharedJetpackSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
_popup.PopupClient(Loc.GetString("jetpack-to-grid"), uid, uid);
|
_popup.PopupClient(Loc.GetString("jetpack-to-grid"), uid, uid);
|
||||||
|
|
||||||
SetEnabled(jetpack, false, uid);
|
SetEnabled(user.Jetpack, jetpack, false, uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnJetpackUserHandleState(EntityUid uid, JetpackUserComponent component, ref ComponentHandleState args)
|
private void OnJetpackUserHandleState(EntityUid uid, JetpackUserComponent component, ref ComponentHandleState args)
|
||||||
{
|
{
|
||||||
if (args.Current is not JetpackUserComponentState state) return;
|
if (args.Current is not JetpackUserComponentState state)
|
||||||
|
return;
|
||||||
|
|
||||||
component.Jetpack = state.Jetpack;
|
component.Jetpack = state.Jetpack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnJetpackDropped(EntityUid uid, JetpackComponent component, DroppedEvent args)
|
private void OnJetpackDropped(EntityUid uid, JetpackComponent component, DroppedEvent args)
|
||||||
{
|
{
|
||||||
SetEnabled(component, false, args.User);
|
SetEnabled(uid, component, false, args.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnJetpackUserCanWeightless(EntityUid uid, JetpackUserComponent component, ref CanWeightlessMoveEvent args)
|
private void OnJetpackUserCanWeightless(EntityUid uid, JetpackUserComponent component, ref CanWeightlessMoveEvent args)
|
||||||
@@ -89,22 +88,24 @@ public abstract class SharedJetpackSystem : EntitySystem
|
|||||||
if (TryComp<JetpackComponent>(component.Jetpack, out var jetpack) &&
|
if (TryComp<JetpackComponent>(component.Jetpack, out var jetpack) &&
|
||||||
!CanEnableOnGrid(args.Transform.GridUid))
|
!CanEnableOnGrid(args.Transform.GridUid))
|
||||||
{
|
{
|
||||||
SetEnabled(jetpack, false, uid);
|
SetEnabled(component.Jetpack, jetpack, false, uid);
|
||||||
|
|
||||||
_popup.PopupClient(Loc.GetString("jetpack-to-grid"), uid, uid);
|
_popup.PopupClient(Loc.GetString("jetpack-to-grid"), uid, uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupUser(EntityUid uid, JetpackComponent component)
|
private void SetupUser(EntityUid user, EntityUid jetpackUid)
|
||||||
{
|
{
|
||||||
var user = EnsureComp<JetpackUserComponent>(uid);
|
var userComp = EnsureComp<JetpackUserComponent>(user);
|
||||||
_mover.SetRelay(uid, component.Owner);
|
_mover.SetRelay(user, jetpackUid);
|
||||||
user.Jetpack = component.Owner;
|
userComp.Jetpack = jetpackUid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveUser(EntityUid uid)
|
private void RemoveUser(EntityUid uid)
|
||||||
{
|
{
|
||||||
if (!RemComp<JetpackUserComponent>(uid)) return;
|
if (!RemComp<JetpackUserComponent>(uid))
|
||||||
|
return;
|
||||||
|
|
||||||
RemComp<RelayInputMoverComponent>(uid);
|
RemComp<RelayInputMoverComponent>(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetEnabled(component, !IsEnabled(uid));
|
SetEnabled(uid, component, !IsEnabled(uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanEnableOnGrid(EntityUid? gridUid)
|
private bool CanEnableOnGrid(EntityUid? gridUid)
|
||||||
@@ -139,44 +140,48 @@ public abstract class SharedJetpackSystem : EntitySystem
|
|||||||
return HasComp<ActiveJetpackComponent>(uid);
|
return HasComp<ActiveJetpackComponent>(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetEnabled(JetpackComponent component, bool enabled, EntityUid? user = null)
|
public void SetEnabled(EntityUid uid, JetpackComponent component, bool enabled, EntityUid? user = null)
|
||||||
{
|
{
|
||||||
if (IsEnabled(component.Owner) == enabled ||
|
if (IsEnabled(uid) == enabled ||
|
||||||
enabled && !CanEnable(component)) return;
|
enabled && !CanEnable(uid, component))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
EnsureComp<ActiveJetpackComponent>(component.Owner);
|
EnsureComp<ActiveJetpackComponent>(uid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RemComp<ActiveJetpackComponent>(component.Owner);
|
RemComp<ActiveJetpackComponent>(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
Container.TryGetContainingContainer(component.Owner, out var container);
|
Container.TryGetContainingContainer(uid, out var container);
|
||||||
user = container?.Owner;
|
user = container?.Owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't activate if no one's using.
|
// Can't activate if no one's using.
|
||||||
if (user == null && enabled) return;
|
if (user == null && enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
SetupUser(user.Value, component);
|
SetupUser(user.Value, uid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RemoveUser(user.Value);
|
RemoveUser(user.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MovementSpeedModifier.RefreshMovementSpeedModifiers(user.Value);
|
_movementSpeedModifier.RefreshMovementSpeedModifiers(user.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Appearance.SetData(component.Owner, JetpackVisuals.Enabled, enabled);
|
Appearance.SetData(uid, JetpackVisuals.Enabled, enabled);
|
||||||
Dirty(component);
|
Dirty(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +190,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
|||||||
return HasComp<JetpackUserComponent>(uid);
|
return HasComp<JetpackUserComponent>(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool CanEnable(JetpackComponent component)
|
protected virtual bool CanEnable(EntityUid uid, JetpackComponent component)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user