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; namespace Content.Client.Atmos.Components;
[RegisterComponent] [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) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
EntitySystem.Get<MarkerSystem>() IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<MarkerSystem>().MarkersVisible ^= true;
.MarkersVisible ^= true;
} }
} }
@@ -31,7 +30,7 @@ namespace Content.Client.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
EntitySystem.Get<SubFloorHideSystem>().ShowAll ^= true; IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SubFloorHideSystem>().ShowAll ^= true;
} }
} }
@@ -47,14 +46,11 @@ namespace Content.Client.Commands
EntitySystem.Get<SubFloorHideSystem>().ShowAll = true; EntitySystem.Get<SubFloorHideSystem>().ShowAll = true;
var entMan = IoCManager.Resolve<IEntityManager>(); var entMan = IoCManager.Resolve<IEntityManager>();
var components = entMan.EntityQuery<SubFloorHideComponent>(true); var components = entMan.EntityQuery<SubFloorHideComponent, SpriteComponent>(true);
foreach (var component in components) foreach (var (_, sprite) in components)
{ {
if (entMan.TryGetComponent(component.Owner, out ISpriteComponent? sprite)) sprite.DrawDepth = (int) DrawDepth.Overlays;
{
sprite.DrawDepth = (int) DrawDepth.Overlays;
}
} }
} }
} }
@@ -69,7 +65,7 @@ namespace Content.Client.Commands
{ {
var message = args[0]; 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>(); var mobStateSystem = _entities.EntitySysManager.GetEntitySystem<MobStateSystem>();
FixedPoint2 threshold; FixedPoint2 threshold;
if (mobState.IsAlive()) if (mobStateSystem.IsAlive(mobState.Owner, mobState))
{ {
if (!mobStateSystem.TryGetEarliestCriticalState(mobState, damageable.TotalDamage, out _, out threshold)) 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.Ratio = 1 - (damageable.TotalDamage / threshold).Float();
HealthBar.Visible = true; HealthBar.Visible = true;
} }
else if (mobState.IsCritical()) else if (mobStateSystem.IsCritical(mobState.Owner, mobState))
{ {
HealthBar.Ratio = 0; HealthBar.Ratio = 0;
HealthBar.Visible = false; HealthBar.Visible = false;
@@ -121,7 +121,7 @@ namespace Content.Client.HealthOverlay.UI
((damageable.TotalDamage - critThreshold) / ((damageable.TotalDamage - critThreshold) /
(deadThreshold - critThreshold)).Float(); (deadThreshold - critThreshold)).Float();
} }
else if (mobState.IsDead()) else if (mobStateSystem.IsDead(mobState.Owner, mobState))
{ {
CritBar.Ratio = 0; CritBar.Ratio = 0;
CritBar.Visible = false; CritBar.Visible = false;
@@ -158,7 +158,8 @@ namespace Content.Client.HealthOverlay.UI
{ {
base.Dispose(disposing); base.Dispose(disposing);
if (!disposing) return; if (!disposing)
return;
HealthBar.Dispose(); HealthBar.Dispose();
} }

View File

@@ -2,6 +2,6 @@ using Content.Shared.IdentityManagement;
namespace Content.Client.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()); RaiseNetworkEvent(new RequestRulesMessage());
} }
protected void OnRulesReceived(RulesMessage message, EntitySessionEventArgs eventArgs) private void OnRulesReceived(RulesMessage message, EntitySessionEventArgs eventArgs)
{ {
Logger.DebugS("info", "Received server rules."); Logger.DebugS("info", "Received server rules.");
Rules = message; Rules = message;

View File

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

View File

@@ -11,9 +11,6 @@ namespace Content.Client.Info;
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public sealed partial class RulesControl : BoxContainer 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!; [Dependency] private readonly RulesManager _rules = default!;
public RulesControl() public RulesControl()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -49,7 +49,7 @@ namespace Content.Server.Vehicle
/// </summary> /// </summary>
private void OnMobStateChanged(EntityUid uid, RiderComponent rider, MobStateChangedEvent args) 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); UnbuckleFromVehicle(uid);
} }

View File

@@ -131,18 +131,18 @@ public sealed partial class GunSystem : SharedGunSystem
RaiseLocalEvent(cartridge.Owner, new AmmoShotEvent() RaiseLocalEvent(cartridge.Owner, new AmmoShotEvent()
{ {
FiredProjectiles = shotProjectiles, FiredProjectiles = shotProjectiles,
}, false); });
SetCartridgeSpent(cartridge, true); SetCartridgeSpent(cartridge, true);
MuzzleFlash(gun.Owner, cartridge, user); MuzzleFlash(gun.Owner, cartridge, user);
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user); Audio.PlayPredicted(gun.SoundGunshot, gun.Owner, user);
if (cartridge.DeleteOnSpawn) if (cartridge.DeleteOnSpawn)
Del(cartridge.Owner); Del(cartridge.Owner);
} }
else 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 // 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: case AmmoComponent newAmmo:
shotProjectiles.Add(newAmmo.Owner); shotProjectiles.Add(newAmmo.Owner);
MuzzleFlash(gun.Owner, newAmmo, user); MuzzleFlash(gun.Owner, newAmmo, user);
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user); Audio.PlayPredicted(gun.SoundGunshot, gun.Owner, user);
// Do a throw // Do a throw
if (!HasComp<ProjectileComponent>(newAmmo.Owner)) if (!HasComp<ProjectileComponent>(newAmmo.Owner))
@@ -214,7 +214,8 @@ public sealed partial class GunSystem : SharedGunSystem
{ {
FireEffects(fromCoordinates, hitscan.MaxLength, mapDirection.ToAngle(), hitscan); FireEffects(fromCoordinates, hitscan.MaxLength, mapDirection.ToAngle(), hitscan);
} }
PlaySound(gun.Owner, gun.SoundGunshot?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundGunshot, gun.Owner, user);
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
@@ -231,7 +232,7 @@ public sealed partial class GunSystem : SharedGunSystem
{ {
var physics = EnsureComp<PhysicsComponent>(uid); var physics = EnsureComp<PhysicsComponent>(uid);
physics.BodyStatus = BodyStatus.InAir; physics.BodyStatus = BodyStatus.InAir;
physics.LinearVelocity = direction.Normalized * speed; Physics.SetLinearVelocity(physics, direction.Normalized * speed);
if (user != null) if (user != null)
{ {
@@ -276,13 +277,6 @@ public sealed partial class GunSystem : SharedGunSystem
return angle; 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 Popup(string message, EntityUid? uid, EntityUid? user) {}
protected override void CreateEffect(EntityUid uid, MuzzleFlashEvent message, EntityUid? user = null) 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 public sealed class WiresSystem : EntitySystem
{ {
[Dependency] private readonly IPrototypeManager _protoMan = default!; [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 ToolSystem _toolSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = 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(); private IRobustRandom _random = new RobustRandom();
@@ -476,12 +478,13 @@ public sealed class WiresSystem : EntitySystem
if (component.IsPanelOpen) if (component.IsPanelOpen)
{ {
SoundSystem.Play(component.ScrewdriverOpenSound.GetSound(), Filter.Pvs(args.Target), args.Target); _audio.PlayPvs(component.ScrewdriverOpenSound, args.Target);
} }
else else
{ {
SoundSystem.Play(component.ScrewdriverCloseSound.GetSound(), Filter.Pvs(args.Target), args.Target); _audio.PlayPvs(component.ScrewdriverCloseSound, args.Target);
_uiSystem.GetUiOrNull(args.Target, WiresUiKey.Key)?.CloseAll(); 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)) if (!Resolve(uid, ref appearance, ref wires, false))
return; 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) 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)); statuses.Sort((a, b) => a.position.CompareTo(b.position));
_uiSystem.GetUiOrNull(uid, WiresUiKey.Key)?.SetState( _uiSystem.TrySetUiState(uid, WiresUiKey.Key, new WiresBoundUserInterfaceState(
new WiresBoundUserInterfaceState( clientList.ToArray(),
clientList.ToArray(), statuses.Select(p => new StatusEntry(p.key, p.value)).ToArray(),
statuses.Select(p => new StatusEntry(p.key, p.value)).ToArray(), wires.BoardName,
wires.BoardName, wires.SerialNumber,
wires.SerialNumber, wires.WireSeed), ui: ui);
wires.WireSeed));
} }
public void OpenUserInterface(EntityUid uid, IPlayerSession player) 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> /// <summary>
@@ -800,7 +803,7 @@ public sealed class WiresSystem : EntitySystem
wire.Action.Pulse(user, wire); wire.Action.Pulse(user, wire);
UpdateUserInterface(used); UpdateUserInterface(used);
SoundSystem.Play(wires.PulseSound.GetSound(), Filter.Pvs(used), used); _audio.PlayPvs(wires.PulseSound, used);
break; break;
} }

View File

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