Fix a bunch of warnings (#11965)

Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2022-10-17 02:44:23 +11:00
committed by GitHub
parent d1c1c8ada3
commit 5373fec641
17 changed files with 91 additions and 101 deletions

View File

@@ -3,6 +3,6 @@ using Robust.Shared.GameObjects;
namespace Content.Client.Atmos.Components;
[RegisterComponent]
public class PipeColorVisualsComponent : Component
public sealed class PipeColorVisualsComponent : Component
{
}

View File

@@ -17,8 +17,7 @@ namespace Content.Client.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
EntitySystem.Get<MarkerSystem>()
.MarkersVisible ^= true;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<MarkerSystem>().MarkersVisible ^= true;
}
}
@@ -31,7 +30,7 @@ namespace Content.Client.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
EntitySystem.Get<SubFloorHideSystem>().ShowAll ^= true;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SubFloorHideSystem>().ShowAll ^= true;
}
}
@@ -47,17 +46,14 @@ namespace Content.Client.Commands
EntitySystem.Get<SubFloorHideSystem>().ShowAll = true;
var entMan = IoCManager.Resolve<IEntityManager>();
var components = entMan.EntityQuery<SubFloorHideComponent>(true);
var components = entMan.EntityQuery<SubFloorHideComponent, SpriteComponent>(true);
foreach (var component in components)
{
if (entMan.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
foreach (var (_, sprite) in components)
{
sprite.DrawDepth = (int) DrawDepth.Overlays;
}
}
}
}
internal sealed class NotifyCommand : IConsoleCommand
{
@@ -69,7 +65,7 @@ namespace Content.Client.Commands
{
var message = args[0];
EntitySystem.Get<PopupSystem>().PopupCursor(message);
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<PopupSystem>().PopupCursor(message);
}
}
}

View File

@@ -90,7 +90,7 @@ namespace Content.Client.HealthOverlay.UI
var mobStateSystem = _entities.EntitySysManager.GetEntitySystem<MobStateSystem>();
FixedPoint2 threshold;
if (mobState.IsAlive())
if (mobStateSystem.IsAlive(mobState.Owner, mobState))
{
if (!mobStateSystem.TryGetEarliestCriticalState(mobState, damageable.TotalDamage, out _, out threshold))
{
@@ -104,7 +104,7 @@ namespace Content.Client.HealthOverlay.UI
HealthBar.Ratio = 1 - (damageable.TotalDamage / threshold).Float();
HealthBar.Visible = true;
}
else if (mobState.IsCritical())
else if (mobStateSystem.IsCritical(mobState.Owner, mobState))
{
HealthBar.Ratio = 0;
HealthBar.Visible = false;
@@ -121,7 +121,7 @@ namespace Content.Client.HealthOverlay.UI
((damageable.TotalDamage - critThreshold) /
(deadThreshold - critThreshold)).Float();
}
else if (mobState.IsDead())
else if (mobStateSystem.IsDead(mobState.Owner, mobState))
{
CritBar.Ratio = 0;
CritBar.Visible = false;
@@ -158,7 +158,8 @@ namespace Content.Client.HealthOverlay.UI
{
base.Dispose(disposing);
if (!disposing) return;
if (!disposing)
return;
HealthBar.Dispose();
}

View File

@@ -2,6 +2,6 @@ using Content.Shared.IdentityManagement;
namespace Content.Client.IdentityManagement;
public class IdentitySystem : SharedIdentitySystem
public sealed class IdentitySystem : SharedIdentitySystem
{
}

View File

@@ -16,7 +16,7 @@ public sealed class InfoSystem : EntitySystem
RaiseNetworkEvent(new RequestRulesMessage());
}
protected void OnRulesReceived(RulesMessage message, EntitySessionEventArgs eventArgs)
private void OnRulesReceived(RulesMessage message, EntitySessionEventArgs eventArgs)
{
Logger.DebugS("info", "Received server rules.");
Rules = message;

View File

@@ -11,8 +11,6 @@ namespace Content.Client.Info
public sealed class RulesAndInfoWindow : DefaultWindow
{
[Dependency] private readonly IResourceCache _resourceManager = default!;
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
[Dependency] private readonly RulesManager _rules = default!;
public RulesAndInfoWindow()

View File

@@ -11,9 +11,6 @@ namespace Content.Client.Info;
[GenerateTypedNameReferences]
public sealed partial class RulesControl : BoxContainer
{
[Dependency] private readonly IResourceCache _resourceManager = default!;
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
[Dependency] private readonly RulesManager _rules = default!;
public RulesControl()

View File

@@ -24,10 +24,7 @@ namespace Content.Client.Lobby
{
[Dependency] private readonly IBaseClient _baseClient = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
@@ -43,7 +40,7 @@ namespace Content.Client.Lobby
protected override void Startup()
{
_gameTicker = EntitySystem.Get<ClientGameTicker>();
_gameTicker = _entityManager.System<ClientGameTicker>();
_characterSetup = new CharacterSetupGui(_entityManager, _resourceCache, _preferencesManager,
_prototypeManager, _configurationManager);
LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide);
@@ -113,10 +110,10 @@ namespace Content.Client.Lobby
public override void FrameUpdate(FrameEventArgs e)
{
if (_lobby == null) return;
if (_lobby == null)
return;
var gameTicker = EntitySystem.Get<ClientGameTicker>();
if (gameTicker.IsGameStarted)
if (_gameTicker.IsGameStarted)
{
_lobby.StartTime.Text = string.Empty;
_lobby.StationTime.Text = Loc.GetString("lobby-state-player-status-station-time", ("stationTime", _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan).ToString("hh\\:mm")));
@@ -125,13 +122,13 @@ namespace Content.Client.Lobby
string text;
if (gameTicker.Paused)
if (_gameTicker.Paused)
{
text = Loc.GetString("lobby-state-paused");
}
else
{
var difference = gameTicker.StartTime - _gameTiming.CurTime;
var difference = _gameTicker.StartTime - _gameTiming.CurTime;
var seconds = difference.TotalSeconds;
if (seconds < 0)
{
@@ -156,16 +153,15 @@ namespace Content.Client.Lobby
private void LobbyLateJoinStatusUpdated()
{
if (_lobby == null) return;
_lobby.ReadyButton.Disabled = EntitySystem.Get<ClientGameTicker>().DisallowedLateJoin;
_lobby.ReadyButton.Disabled = _gameTicker.DisallowedLateJoin;
}
private void UpdateLobbyUi()
{
if (_lobby == null) return;
if (_lobby == null)
return;
var gameTicker = EntitySystem.Get<ClientGameTicker>();
if (gameTicker.IsGameStarted)
if (_gameTicker.IsGameStarted)
{
_lobby.ReadyButton.Text = Loc.GetString("lobby-state-ready-button-join-state");
_lobby.ReadyButton.ToggleMode = false;
@@ -178,19 +174,21 @@ namespace Content.Client.Lobby
_lobby.ReadyButton.Text = Loc.GetString("lobby-state-ready-button-ready-up-state");
_lobby.ReadyButton.ToggleMode = true;
_lobby.ReadyButton.Disabled = false;
_lobby.ReadyButton.Pressed = gameTicker.AreWeReady;
_lobby.ReadyButton.Pressed = _gameTicker.AreWeReady;
_lobby.ObserveButton.Disabled = true;
}
if (gameTicker.ServerInfoBlob != null)
if (_gameTicker.ServerInfoBlob != null)
{
_lobby.ServerInfo.SetInfoBlob(gameTicker.ServerInfoBlob);
_lobby.ServerInfo.SetInfoBlob(_gameTicker.ServerInfoBlob);
}
}
private void UpdateLobbyBackground()
{
if (_lobby == null) return;
if (_lobby == null)
return;
if (_gameTicker.LobbyBackground != null)
{
_lobby.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground );
@@ -204,7 +202,7 @@ namespace Content.Client.Lobby
private void SetReady(bool newReady)
{
if (EntitySystem.Get<ClientGameTicker>().IsGameStarted)
if (_gameTicker.IsGameStarted)
{
return;
}

View File

@@ -11,6 +11,7 @@ namespace Content.Client.Pinpointer
public sealed class ClientPinpointerSystem : SharedPinpointerSystem
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
public override void Initialize()
{
@@ -36,7 +37,9 @@ namespace Content.Client.Pinpointer
private void HandleCompState(EntityUid uid, PinpointerComponent pinpointer, ref ComponentHandleState args)
{
if (args.Current is not PinpointerComponentState state) return;
if (args.Current is not PinpointerComponentState state)
return;
SetActive(uid, state.IsActive, pinpointer);
SetDirection(uid, state.DirectionToTarget, pinpointer);
SetDistance(uid, state.DistanceToTarget, pinpointer);
@@ -48,8 +51,8 @@ namespace Content.Client.Pinpointer
if (!Resolve(uid, ref pinpointer, ref appearance))
return;
appearance.SetData(PinpointerVisuals.IsActive, pinpointer.IsActive);
appearance.SetData(PinpointerVisuals.TargetDistance, pinpointer.DistanceToTarget);
_appearance.SetData(uid, PinpointerVisuals.IsActive, pinpointer.IsActive, appearance);
_appearance.SetData(uid, PinpointerVisuals.TargetDistance, pinpointer.DistanceToTarget, appearance);
}
private void UpdateDirAppearance(EntityUid uid, Direction dir,PinpointerComponent? pinpointer = null,
@@ -58,7 +61,7 @@ namespace Content.Client.Pinpointer
if (!Resolve(uid, ref pinpointer, ref appearance))
return;
appearance.SetData(PinpointerVisuals.TargetDirection, dir);
_appearance.SetData(uid, PinpointerVisuals.TargetDirection, dir, appearance);
}
/// <summary>

View File

@@ -38,8 +38,10 @@ namespace Content.Client.Preferences
public void SelectCharacter(int slot)
{
Preferences = new PlayerPreferences(Preferences.Characters, slot, Preferences.AdminOOCColor);
var msg = _netManager.CreateNetMessage<MsgSelectCharacter>();
msg.SelectedCharacterIndex = slot;
var msg = new MsgSelectCharacter
{
SelectedCharacterIndex = slot
};
_netManager.ClientSendMessage(msg);
}
@@ -48,9 +50,11 @@ namespace Content.Client.Preferences
profile.EnsureValid();
var characters = new Dictionary<int, ICharacterProfile>(Preferences.Characters) {[slot] = profile};
Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex, Preferences.AdminOOCColor);
var msg = _netManager.CreateNetMessage<MsgUpdateCharacter>();
msg.Profile = profile;
msg.Slot = slot;
var msg = new MsgUpdateCharacter
{
Profile = profile,
Slot = slot
};
_netManager.ClientSendMessage(msg);
}
@@ -82,8 +86,10 @@ namespace Content.Client.Preferences
{
var characters = Preferences.Characters.Where(p => p.Key != slot);
Preferences = new PlayerPreferences(characters, Preferences.SelectedCharacterIndex, Preferences.AdminOOCColor);
var msg = _netManager.CreateNetMessage<MsgDeleteCharacter>();
msg.Slot = slot;
var msg = new MsgDeleteCharacter
{
Slot = slot
};
_netManager.ClientSendMessage(msg);
}

View File

@@ -187,7 +187,7 @@ public sealed partial class GunSystem : SharedGunSystem
{
SetCartridgeSpent(cartridge, true);
MuzzleFlash(gun.Owner, cartridge, user);
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundGunshot, gun.Owner, user);
Recoil(user, direction);
// TODO: Can't predict entity deletions.
//if (cartridge.DeleteOnSpawn)
@@ -195,7 +195,7 @@ public sealed partial class GunSystem : SharedGunSystem
}
else
{
PlaySound(gun.Owner, gun.SoundEmpty?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundEmpty, gun.Owner, user);
}
if (cartridge.Owner.IsClientSide())
@@ -204,7 +204,7 @@ public sealed partial class GunSystem : SharedGunSystem
break;
case AmmoComponent newAmmo:
MuzzleFlash(gun.Owner, newAmmo, user);
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundGunshot, gun.Owner, user);
Recoil(user, direction);
if (newAmmo.Owner.IsClientSide())
Del(newAmmo.Owner);
@@ -212,7 +212,7 @@ public sealed partial class GunSystem : SharedGunSystem
RemComp<AmmoComponent>(newAmmo.Owner);
break;
case HitscanPrototype:
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundGunshot, gun.Owner, user);
Recoil(user, direction);
break;
}
@@ -225,12 +225,6 @@ public sealed partial class GunSystem : SharedGunSystem
_recoil.KickCamera(user.Value, recoil.Normalized * 0.5f);
}
protected override void PlaySound(EntityUid gun, string? sound, EntityUid? user = null)
{
if (string.IsNullOrEmpty(sound) || user == null || !Timing.IsFirstTimePredicted) return;
SoundSystem.Play(sound, Filter.Local(), gun);
}
protected override void Popup(string message, EntityUid? uid, EntityUid? user)
{
if (uid == null || user == null || !Timing.IsFirstTimePredicted) return;

View File

@@ -23,6 +23,8 @@ namespace Content.Server.Toilet
public sealed class ToiletSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SecretStashSystem _secretStash = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly ToolSystem _toolSystem = default!;
@@ -42,7 +44,8 @@ namespace Content.Server.Toilet
private void OnSuicide(EntityUid uid, ToiletComponent component, SuicideEvent args)
{
if (args.Handled) return;
if (args.Handled)
return;
// Check that victim has a head
if (EntityManager.TryGetComponent<SharedBodyComponent>(args.Victim, out var body) &&
@@ -180,19 +183,17 @@ namespace Content.Server.Toilet
return;
component.IsSeatUp = !component.IsSeatUp;
SoundSystem.Play(component.ToggleSound.GetSound(), Filter.Pvs(uid),
uid, AudioHelpers.WithVariation(0.05f));
_audio.PlayPvs(component.ToggleSound, uid, AudioParams.Default.WithVariation(0.05f));
UpdateSprite(uid, component);
}
private void UpdateSprite(EntityUid uid, ToiletComponent component)
{
if (!EntityManager.TryGetComponent(uid,out AppearanceComponent? appearance))
if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
return;
appearance.SetData(ToiletVisuals.LidOpen, component.LidOpen);
appearance.SetData(ToiletVisuals.SeatUp, component.IsSeatUp);
_appearance.SetData(uid, ToiletVisuals.LidOpen, component.LidOpen, appearance);
_appearance.SetData(uid, ToiletVisuals.SeatUp, component.IsSeatUp, appearance);
}
}

View File

@@ -51,7 +51,8 @@ public sealed class IntrinsicUISystem : EntitySystem
var attempt = new IntrinsicUIOpenAttemptEvent(uid, key);
RaiseLocalEvent(uid, attempt, false);
if (attempt.Cancelled) return false;
if (attempt.Cancelled)
return false;
ui.Toggle(actor.PlayerSession);
return true;

View File

@@ -49,7 +49,7 @@ namespace Content.Server.Vehicle
/// </summary>
private void OnMobStateChanged(EntityUid uid, RiderComponent rider, MobStateChangedEvent args)
{
if (args.Component.IsCritical() || args.Component.IsDead())
if (args.CurrentMobState is DamageState.Critical or DamageState.Dead)
{
UnbuckleFromVehicle(uid);
}

View File

@@ -131,18 +131,18 @@ public sealed partial class GunSystem : SharedGunSystem
RaiseLocalEvent(cartridge.Owner, new AmmoShotEvent()
{
FiredProjectiles = shotProjectiles,
}, false);
});
SetCartridgeSpent(cartridge, true);
MuzzleFlash(gun.Owner, cartridge, user);
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundGunshot, gun.Owner, user);
if (cartridge.DeleteOnSpawn)
Del(cartridge.Owner);
}
else
{
PlaySound(gun.Owner, gun.SoundEmpty?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundEmpty, gun.Owner, user);
}
// Something like ballistic might want to leave it in the container still
@@ -155,7 +155,7 @@ public sealed partial class GunSystem : SharedGunSystem
case AmmoComponent newAmmo:
shotProjectiles.Add(newAmmo.Owner);
MuzzleFlash(gun.Owner, newAmmo, user);
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundGunshot, gun.Owner, user);
// Do a throw
if (!HasComp<ProjectileComponent>(newAmmo.Owner))
@@ -214,7 +214,8 @@ public sealed partial class GunSystem : SharedGunSystem
{
FireEffects(fromCoordinates, hitscan.MaxLength, mapDirection.ToAngle(), hitscan);
}
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundGunshot, gun.Owner, user);
break;
default:
throw new ArgumentOutOfRangeException();
@@ -231,7 +232,7 @@ public sealed partial class GunSystem : SharedGunSystem
{
var physics = EnsureComp<PhysicsComponent>(uid);
physics.BodyStatus = BodyStatus.InAir;
physics.LinearVelocity = direction.Normalized * speed;
Physics.SetLinearVelocity(physics, direction.Normalized * speed);
if (user != null)
{
@@ -276,13 +277,6 @@ public sealed partial class GunSystem : SharedGunSystem
return angle;
}
protected override void PlaySound(EntityUid gun, string? sound, EntityUid? user = null)
{
if (string.IsNullOrEmpty(sound)) return;
SoundSystem.Play(sound, Filter.Pvs(gun, entityManager: EntityManager).RemoveWhereAttachedEntity(e => e == user), gun);
}
protected override void Popup(string message, EntityUid? uid, EntityUid? user) {}
protected override void CreateEffect(EntityUid uid, MuzzleFlashEvent message, EntityUid? user = null)

View File

@@ -23,11 +23,13 @@ namespace Content.Server.Wires;
public sealed class WiresSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly DoAfterSystem _doAfter = default!;
[Dependency] private readonly ToolSystem _toolSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
private IRobustRandom _random = new RobustRandom();
@@ -476,12 +478,13 @@ public sealed class WiresSystem : EntitySystem
if (component.IsPanelOpen)
{
SoundSystem.Play(component.ScrewdriverOpenSound.GetSound(), Filter.Pvs(args.Target), args.Target);
_audio.PlayPvs(component.ScrewdriverOpenSound, args.Target);
}
else
{
SoundSystem.Play(component.ScrewdriverCloseSound.GetSound(), Filter.Pvs(args.Target), args.Target);
_uiSystem.GetUiOrNull(args.Target, WiresUiKey.Key)?.CloseAll();
_audio.PlayPvs(component.ScrewdriverCloseSound, args.Target);
var ui = _uiSystem.GetUiOrNull(args.Target, WiresUiKey.Key);
_uiSystem.CloseAll(ui);
}
}
@@ -548,7 +551,7 @@ public sealed class WiresSystem : EntitySystem
if (!Resolve(uid, ref appearance, ref wires, false))
return;
appearance.SetData(WiresVisuals.MaintenancePanelState, wires.IsPanelOpen && wires.IsPanelVisible);
_appearance.SetData(uid, WiresVisuals.MaintenancePanelState, wires.IsPanelOpen && wires.IsPanelVisible, appearance);
}
private void UpdateUserInterface(EntityUid uid, WiresComponent? wires = null, ServerUserInterfaceComponent? ui = null)
@@ -578,18 +581,18 @@ public sealed class WiresSystem : EntitySystem
statuses.Sort((a, b) => a.position.CompareTo(b.position));
_uiSystem.GetUiOrNull(uid, WiresUiKey.Key)?.SetState(
new WiresBoundUserInterfaceState(
_uiSystem.TrySetUiState(uid, WiresUiKey.Key, new WiresBoundUserInterfaceState(
clientList.ToArray(),
statuses.Select(p => new StatusEntry(p.key, p.value)).ToArray(),
wires.BoardName,
wires.SerialNumber,
wires.WireSeed));
wires.WireSeed), ui: ui);
}
public void OpenUserInterface(EntityUid uid, IPlayerSession player)
{
_uiSystem.GetUiOrNull(uid, WiresUiKey.Key)?.Open(player);
if (_uiSystem.TryGetUi(uid, WiresUiKey.Key, out var ui))
_uiSystem.OpenUi(ui, player);
}
/// <summary>
@@ -800,7 +803,7 @@ public sealed class WiresSystem : EntitySystem
wire.Action.Pulse(user, wire);
UpdateUserInterface(used);
SoundSystem.Play(wires.PulseSound.GetSound(), Filter.Pvs(used), used);
_audio.PlayPvs(wires.PulseSound, used);
break;
}

View File

@@ -316,8 +316,6 @@ public abstract partial class SharedGunSystem : EntitySystem
Shoot(gun, new List<IShootable>(1) { ammo }, fromCoordinates, toCoordinates, user);
}
protected abstract void PlaySound(EntityUid gun, string? sound, EntityUid? user = null);
protected abstract void Popup(string message, EntityUid? uid, EntityUid? user);
/// <summary>