Fix jetpack warnings (#18227)
This commit is contained in:
@@ -23,14 +23,14 @@ public abstract class SharedDoorSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly IGameTiming GameTiming = default!;
|
||||
[Dependency] protected readonly SharedPhysicsSystem PhysicsSystem = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||
[Dependency] protected readonly TagSystem Tags = 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] private readonly OccluderSystem _occluder = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||
[Dependency] private readonly OccluderSystem _occluder = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
/// <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
|
||||
/// </summary>
|
||||
//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);
|
||||
|
||||
if (component.CurrentMode == ImplanterToggleMode.Inject && !component.ImplantOnly)
|
||||
DrawMode(component);
|
||||
DrawMode(implanter, component);
|
||||
else
|
||||
ImplantMode(component);
|
||||
ImplantMode(implanter, component);
|
||||
|
||||
Dirty(component);
|
||||
}
|
||||
@@ -74,8 +74,8 @@ public abstract class SharedImplanterSystem : EntitySystem
|
||||
[NotNullWhen(true)] out EntityUid? implant,
|
||||
[NotNullWhen(true)] out SubdermalImplantComponent? implantComp)
|
||||
{
|
||||
implant = component.ImplanterSlot.ContainerSlot?.ContainedEntities?.FirstOrDefault();
|
||||
if (!TryComp<SubdermalImplantComponent>(implant, out implantComp))
|
||||
implant = component.ImplanterSlot.ContainerSlot?.ContainedEntities.FirstOrDefault();
|
||||
if (!TryComp(implant, out implantComp))
|
||||
return false;
|
||||
|
||||
var ev = new AddImplantAttemptEvent(user, target, implant.Value, implanter);
|
||||
@@ -101,7 +101,7 @@ public abstract class SharedImplanterSystem : EntitySystem
|
||||
foreach (var implant in implantContainer.ContainedEntities)
|
||||
{
|
||||
if (!implantCompQuery.TryGetComponent(implant, out var implantComp))
|
||||
return;
|
||||
continue;
|
||||
|
||||
//Don't remove a permanent implant and look for the next that can be drawn
|
||||
if (!implantContainer.CanRemove(implant))
|
||||
@@ -124,27 +124,27 @@ public abstract class SharedImplanterSystem : EntitySystem
|
||||
}
|
||||
|
||||
if (component.CurrentMode == ImplanterToggleMode.Draw && !component.ImplantOnly && !permanentFound)
|
||||
ImplantMode(component);
|
||||
ImplantMode(implanter, component);
|
||||
|
||||
Dirty(component);
|
||||
}
|
||||
}
|
||||
|
||||
private void ImplantMode(ImplanterComponent component)
|
||||
private void ImplantMode(EntityUid uid, ImplanterComponent component)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
|
||||
bool implantFound;
|
||||
@@ -156,17 +156,17 @@ public abstract class SharedImplanterSystem : EntitySystem
|
||||
implantFound = false;
|
||||
|
||||
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)
|
||||
{
|
||||
_appearance.SetData(component.Owner, ImplanterVisuals.Full, implantFound, appearance);
|
||||
_appearance.SetData(component.Owner, ImplanterImplantOnlyVisuals.ImplantOnly, component.ImplantOnly,
|
||||
_appearance.SetData(uid, ImplanterVisuals.Full, implantFound, appearance);
|
||||
_appearance.SetData(uid, ImplanterImplantOnlyVisuals.ImplantOnly, component.ImplantOnly,
|
||||
appearance);
|
||||
}
|
||||
|
||||
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 Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Movement.Systems;
|
||||
|
||||
public abstract class SharedJetpackSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly MovementSpeedModifierSystem MovementSpeedModifier = default!;
|
||||
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
|
||||
[Dependency] protected readonly SharedAppearanceSystem Appearance = 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()
|
||||
{
|
||||
@@ -55,14 +52,16 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
{
|
||||
_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)
|
||||
{
|
||||
if (args.Current is not JetpackUserComponentState state) return;
|
||||
if (args.Current is not JetpackUserComponentState state)
|
||||
return;
|
||||
|
||||
component.Jetpack = state.Jetpack;
|
||||
}
|
||||
|
||||
@@ -76,7 +75,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
|
||||
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)
|
||||
@@ -89,22 +88,24 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
if (TryComp<JetpackComponent>(component.Jetpack, out var jetpack) &&
|
||||
!CanEnableOnGrid(args.Transform.GridUid))
|
||||
{
|
||||
SetEnabled(jetpack, false, uid);
|
||||
SetEnabled(component.Jetpack, jetpack, false, 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);
|
||||
_mover.SetRelay(uid, component.Owner);
|
||||
user.Jetpack = component.Owner;
|
||||
var userComp = EnsureComp<JetpackUserComponent>(user);
|
||||
_mover.SetRelay(user, jetpackUid);
|
||||
userComp.Jetpack = jetpackUid;
|
||||
}
|
||||
|
||||
private void RemoveUser(EntityUid uid)
|
||||
{
|
||||
if (!RemComp<JetpackUserComponent>(uid)) return;
|
||||
if (!RemComp<JetpackUserComponent>(uid))
|
||||
return;
|
||||
|
||||
RemComp<RelayInputMoverComponent>(uid);
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
SetEnabled(component, !IsEnabled(uid));
|
||||
SetEnabled(uid, component, !IsEnabled(uid));
|
||||
}
|
||||
|
||||
private bool CanEnableOnGrid(EntityUid? gridUid)
|
||||
@@ -139,44 +140,48 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
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 ||
|
||||
enabled && !CanEnable(component)) return;
|
||||
if (IsEnabled(uid) == enabled ||
|
||||
enabled && !CanEnable(uid, component))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
EnsureComp<ActiveJetpackComponent>(component.Owner);
|
||||
EnsureComp<ActiveJetpackComponent>(uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemComp<ActiveJetpackComponent>(component.Owner);
|
||||
RemComp<ActiveJetpackComponent>(uid);
|
||||
}
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
Container.TryGetContainingContainer(component.Owner, out var container);
|
||||
Container.TryGetContainingContainer(uid, out var container);
|
||||
user = container?.Owner;
|
||||
}
|
||||
|
||||
// Can't activate if no one's using.
|
||||
if (user == null && enabled) return;
|
||||
if (user == null && enabled)
|
||||
return;
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
SetupUser(user.Value, component);
|
||||
SetupUser(user.Value, uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -185,7 +190,7 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
return HasComp<JetpackUserComponent>(uid);
|
||||
}
|
||||
|
||||
protected virtual bool CanEnable(JetpackComponent component)
|
||||
protected virtual bool CanEnable(EntityUid uid, JetpackComponent component)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user