Fix a few warnings (#11576)

This commit is contained in:
metalgearsloth
2022-10-04 14:24:19 +11:00
committed by GitHub
parent a6d20803a6
commit 600c0e3255
43 changed files with 185 additions and 167 deletions

View File

@@ -19,13 +19,14 @@ namespace Content.Shared.Actions;
public abstract class SharedActionsSystem : EntitySystem
{
[Dependency] protected readonly IGameTiming GameTiming = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly RotateToFaceSystem _rotateToFaceSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] protected readonly IGameTiming GameTiming = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
@@ -325,8 +326,7 @@ public abstract class SharedActionsSystem : EntitySystem
var filter = Filter.Pvs(performer).RemoveWhereAttachedEntity(e => e == performer);
if (action.Sound != null)
SoundSystem.Play(action.Sound.GetSound(), filter, performer, action.AudioParams);
_audio.Play(action.Sound, filter, performer, action.AudioParams);
if (string.IsNullOrWhiteSpace(action.Popup))
return true;

View File

@@ -23,15 +23,16 @@ namespace Content.Shared.Blocking;
public sealed class BlockingSystem : EntitySystem
{
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly FixtureSystem _fixtureSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
public override void Initialize()
{
@@ -231,7 +232,7 @@ public sealed class BlockingSystem : EntitySystem
_actionsSystem.SetToggled(component.BlockingToggleAction, false);
_fixtureSystem.DestroyFixture(physicsComponent, BlockingComponent.BlockFixtureID);
physicsComponent.BodyType = blockingUserComponent.OriginalBodyType;
_physics.SetBodyType(physicsComponent, blockingUserComponent.OriginalBodyType);
_popupSystem.PopupEntity(msgUser, user, Filter.Entities(user));
_popupSystem.PopupEntity(msgOther, user, Filter.Pvs(user).RemoveWhereAttachedEntity(e => e == user));
}

View File

@@ -13,6 +13,7 @@ public sealed class BlockingUserSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly BlockingSystem _blockingSystem = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
@@ -71,7 +72,7 @@ public sealed class BlockingUserSystem : EntitySystem
if (_proto.TryIndex(blockingComponent.ActiveBlockDamageModifier, out DamageModifierSetPrototype? activeBlockModifier) && blockingComponent.IsBlocking)
{
args.Damage = DamageSpecifier.ApplyModifierSet(args.Damage, activeBlockModifier);
SoundSystem.Play(blockingComponent.BlockSound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, AudioHelpers.WithVariation(0.2f));
_audio.PlayPvs(blockingComponent.BlockSound, component.Owner, AudioParams.Default.WithVariation(0.2f));
}
}
}

View File

@@ -392,7 +392,7 @@ namespace Content.Shared.CCVar
CVarDef.Create("database.pg_database", "ss14", CVar.SERVERONLY);
public static readonly CVarDef<string> DatabasePgUsername =
CVarDef.Create("database.pg_username", "", CVar.SERVERONLY);
CVarDef.Create("database.pg_username", "postgres", CVar.SERVERONLY);
public static readonly CVarDef<string> DatabasePgPassword =
CVarDef.Create("database.pg_password", "", CVar.SERVERONLY | CVar.CONFIDENTIAL);

View File

@@ -90,7 +90,7 @@ namespace Content.Shared.Chemistry.Components
return "";
}
var majorReagent = Contents.OrderByDescending(reagent => reagent.Quantity).First();
var majorReagent = Contents.MaxBy(reagent => reagent.Quantity);
return majorReagent.ReagentId;
}
@@ -134,9 +134,11 @@ namespace Content.Shared.Chemistry.Components
/// <param name="scale">The scalar to modify the solution by.</param>
public void ScaleSolution(float scale)
{
if (scale == 1) return;
if (scale.Equals(1f))
return;
var tempContents = new List<ReagentQuantity>(Contents);
foreach(ReagentQuantity current in tempContents)
foreach(var current in tempContents)
{
if(scale > 1)
{
@@ -231,7 +233,7 @@ namespace Content.Shared.Chemistry.Components
Contents[i] = new ReagentQuantity(reagent.ReagentId, newQuantity);
}
TotalVolume = TotalVolume * ratio;
TotalVolume *= ratio;
}
public void RemoveAllSolution()
@@ -381,14 +383,10 @@ namespace Content.Shared.Chemistry.Components
return newSolution;
}
[Obsolete("Use ReactiveSystem.DoEntityReaction")]
public void DoEntityReaction(EntityUid uid, ReactionMethod method)
{
var chemistry = EntitySystem.Get<ReactiveSystem>();
foreach (var (reagentId, quantity) in Contents.ToArray())
{
chemistry.ReactionEntity(uid, method, reagentId, quantity, this);
}
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ReactiveSystem>().DoEntityReaction(uid, this, method);
}
[Serializable, NetSerializable]

View File

@@ -25,6 +25,14 @@ namespace Content.Shared.Chemistry
}
}
public void DoEntityReaction(EntityUid uid, Solution solution, ReactionMethod method)
{
foreach (var (reagentId, quantity) in solution.Contents.ToArray())
{
ReactionEntity(uid, method, reagentId, quantity, solution);
}
}
public void ReactionEntity(EntityUid uid, ReactionMethod method, string reagentId, FixedPoint2 reactVolume, Solution? source)
{
// We throw if the reagent specified doesn't exist.

View File

@@ -11,12 +11,13 @@ namespace Content.Shared.Clothing;
public abstract class SharedMagbootsSystem : EntitySystem
{
[Dependency] private readonly SharedActionsSystem _sharedActions = default!;
[Dependency] private readonly ClothingSpeedModifierSystem _clothingSpeedModifier = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedItemSystem _item = default!;
[Dependency] private readonly ClothingSystem _clothing = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedActionsSystem _sharedActions = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedContainerSystem _sharedContainer = default!;
[Dependency] private readonly SharedItemSystem _item = default!;
public override void Initialize()
{
@@ -46,9 +47,7 @@ public abstract class SharedMagbootsSystem : EntitySystem
_clothing.SetEquippedPrefix(uid, component.On ? "on" : null);
}
if (TryComp(uid, out AppearanceComponent? appearance))
appearance.SetData(ToggleVisuals.Toggled, component.On);
_appearance.SetData(uid, ToggleVisuals.Toggled, component.Owner);
OnChanged(component);
Dirty(component);
}

View File

@@ -11,7 +11,8 @@ namespace Content.Shared.Construction.Conditions
{
public bool Condition(EntityUid user, EntityCoordinates location, Direction direction)
{
var tagSystem = EntitySystem.Get<TagSystem>();
var tagSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<TagSystem>();
foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.Anchored))
{
if (tagSystem.HasTag(entity, "Window"))

View File

@@ -33,11 +33,11 @@ namespace Content.Shared.Construction.Conditions
return false;
// now we need to check that user actually tries to build wallmount on a wall
var physics = EntitySystem.Get<SharedPhysicsSystem>();
var physics = entManager.System<SharedPhysicsSystem>();
var rUserToObj = new CollisionRay(userWorldPosition, userToObject.Normalized, (int) CollisionGroup.Impassable);
var length = userToObject.Length;
var tagSystem = EntitySystem.Get<TagSystem>();
var tagSystem = entManager.System<TagSystem>();
var userToObjRaycastResults = physics.IntersectRayWithPredicate(entManager.GetComponent<TransformComponent>(user).MapID, rUserToObj, maxLength: length,
predicate: (e) => !tagSystem.HasTag(e, "Wall"));

View File

@@ -15,6 +15,7 @@ namespace Content.Shared.Damage
public sealed class DamageableSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
@@ -121,9 +122,9 @@ namespace Content.Shared.Damage
if (EntityManager.TryGetComponent<AppearanceComponent>(component.Owner, out var appearance) && damageDelta != null)
{
var data = new DamageVisualizerGroupData(damageDelta.GetDamagePerGroup(_prototypeManager).Keys.ToList());
appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, data);
_appearance.SetData(component.Owner, DamageVisualizerKeys.DamageUpdateGroups, data, appearance);
}
RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);
RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters));
}
/// <summary>

View File

@@ -1,6 +1,4 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
namespace Content.Shared.Disease

View File

@@ -3,9 +3,11 @@ using Content.Shared.Disposal.Components;
using Content.Shared.DragDrop;
using Content.Shared.Item;
using Content.Shared.MobState.Components;
using Content.Shared.MobState.EntitySystems;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Physics.Events;
using Robust.Shared.Timing;
@@ -16,6 +18,7 @@ namespace Content.Shared.Disposal
public abstract class SharedDisposalUnitSystem : EntitySystem
{
[Dependency] protected readonly IGameTiming GameTiming = default!;
[Dependency] private readonly SharedMobStateSystem _mobState = default!;
protected static TimeSpan ExitAttemptDelay = TimeSpan.FromSeconds(0.5);
@@ -68,20 +71,16 @@ namespace Content.Shared.Disposal
}
//Check if the entity is a mob and if mobs can be inserted
if (EntityManager.HasComponent<MobStateComponent>(entity) && !component.MobsCanEnter)
if (TryComp<MobStateComponent>(entity, out var damageState) && !component.MobsCanEnter)
return false;
if (!EntityManager.TryGetComponent(entity, out IPhysBody? physics) ||
!physics.CanCollide && storable == null)
if (EntityManager.TryGetComponent(entity, out PhysicsComponent? physics) &&
(physics.CanCollide || storable != null))
{
if (!(EntityManager.TryGetComponent(entity, out MobStateComponent? damageState) &&
(!component.MobsCanEnter || damageState.IsDead())))
{
return false;
}
return true;
}
return true;
return damageState != null && (!component.MobsCanEnter || _mobState.IsDead(entity, damageState));
}
}
}

View File

@@ -5,6 +5,7 @@ namespace Content.Shared.Doors.Systems;
public abstract class SharedAirlockSystem : EntitySystem
{
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
[Dependency] protected readonly SharedDoorSystem DoorSystem = default!;
public override void Initialize()
@@ -39,10 +40,7 @@ public abstract class SharedAirlockSystem : EntitySystem
public void UpdateEmergencyLightStatus(SharedAirlockComponent component)
{
if (TryComp<AppearanceComponent>(component.Owner, out var appearanceComponent))
{
appearanceComponent.SetData(DoorVisuals.EmergencyLights, component.EmergencyAccess);
}
Appearance.SetData(component.Owner, DoorVisuals.EmergencyLights, component.EmergencyAccess);
}
public void ToggleEmergencyAccess(SharedAirlockComponent component)

View File

@@ -21,11 +21,11 @@ namespace Content.Shared.Doors.Systems;
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] protected readonly TagSystem Tags = default!;
[Dependency] protected readonly IGameTiming GameTiming = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
@@ -380,7 +380,7 @@ public abstract class SharedDoorSystem : EntitySystem
return;
if (Resolve(uid, ref physics, false))
physics.CanCollide = collidable;
PhysicsSystem.SetCanCollide(physics, collidable);
if (!collidable)
door.CurrentlyCrushing.Clear();

View File

@@ -8,18 +8,13 @@ public abstract partial class SharedMobStateSystem
public virtual void EnterCritState(EntityUid uid)
{
Alerts.ShowAlert(uid, AlertType.HumanCrit);
Standing.Down(uid);
if (TryComp<AppearanceComponent>(uid, out var appearance))
{
appearance.SetData(DamageStateVisuals.State, DamageState.Critical);
}
_standing.Down(uid);
_appearance.SetData(uid, DamageStateVisuals.State, DamageState.Critical);
}
public virtual void ExitCritState(EntityUid uid)
{
Standing.Stand(uid);
_standing.Stand(uid);
}
public virtual void UpdateCritState(EntityUid entity, FixedPoint2 threshold) {}

View File

@@ -8,28 +8,25 @@ public abstract partial class SharedMobStateSystem
public virtual void EnterDeadState(EntityUid uid)
{
EnsureComp<CollisionWakeComponent>(uid);
Standing.Down(uid);
_standing.Down(uid);
if (Standing.IsDown(uid) && TryComp<PhysicsComponent>(uid, out var physics))
if (_standing.IsDown(uid) && TryComp<PhysicsComponent>(uid, out var physics))
{
physics.CanCollide = false;
_physics.SetCanCollide(physics, false);
}
if (TryComp<AppearanceComponent>(uid, out var appearance))
{
appearance.SetData(DamageStateVisuals.State, DamageState.Dead);
}
_appearance.SetData(uid, DamageStateVisuals.State, DamageState.Dead);
}
public virtual void ExitDeadState(EntityUid uid)
{
RemComp<CollisionWakeComponent>(uid);
Standing.Stand(uid);
_standing.Stand(uid);
if (!Standing.IsDown(uid) && TryComp<PhysicsComponent>(uid, out var physics))
if (!_standing.IsDown(uid) && TryComp<PhysicsComponent>(uid, out var physics))
{
physics.CanCollide = true;
_physics.SetCanCollide(physics, true);
}
}

View File

@@ -6,12 +6,8 @@ public abstract partial class SharedMobStateSystem
{
public virtual void EnterNormState(EntityUid uid)
{
Standing.Stand(uid);
if (TryComp<AppearanceComponent>(uid, out var appearance))
{
appearance.SetData(DamageStateVisuals.State, DamageState.Alive);
}
_standing.Stand(uid);
_appearance.SetData(uid, DamageStateVisuals.State, DamageState.Alive);
}
public virtual void UpdateNormState(EntityUid entity, FixedPoint2 threshold) {}

View File

@@ -15,6 +15,7 @@ using Content.Shared.Speech;
using Content.Shared.Standing;
using Content.Shared.StatusEffect;
using Content.Shared.Throwing;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Serialization;
namespace Content.Shared.MobState.EntitySystems
@@ -22,9 +23,11 @@ namespace Content.Shared.MobState.EntitySystems
public abstract partial class SharedMobStateSystem : EntitySystem
{
[Dependency] protected readonly AlertsSystem Alerts = default!;
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] protected readonly StandingStateSystem Standing = default!;
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] protected readonly StatusEffectsSystem Status = default!;
[Dependency] private readonly StandingStateSystem _standing = default!;
public override void Initialize()
{

View File

@@ -13,8 +13,10 @@ namespace Content.Shared.Stacks
[UsedImplicitly]
public abstract class SharedStackSystem : EntitySystem
{
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
[Dependency] protected readonly SharedPopupSystem PopupSystem = default!;
[Dependency] protected readonly SharedHandsSystem HandsSystem = default!;
[Dependency] protected readonly SharedTransformSystem Xform = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override void Initialize()
@@ -153,10 +155,7 @@ namespace Content.Shared.Stacks
component.Count = amount;
Dirty(component);
// Change appearance data.
if (TryComp(uid, out AppearanceComponent? appearance))
appearance.SetData(StackVisuals.Actual, component.Count);
Appearance.SetData(uid, StackVisuals.Actual, component.Count);
RaiseLocalEvent(uid, new StackCountChangedEvent(old, component.Count), false);
}
@@ -189,9 +188,9 @@ namespace Content.Shared.Stacks
if (!TryComp(uid, out AppearanceComponent? appearance))
return;
appearance.SetData(StackVisuals.Actual, component.Count);
appearance.SetData(StackVisuals.MaxCount, component.MaxCount);
appearance.SetData(StackVisuals.Hide, false);
Appearance.SetData(uid, StackVisuals.Actual, component.Count, appearance);
Appearance.SetData(uid, StackVisuals.MaxCount, component.MaxCount, appearance);
Appearance.SetData(uid, StackVisuals.Hide, false, appearance);
}
private void OnStackGetState(EntityUid uid, SharedStackComponent component, ref ComponentGetState args)

View File

@@ -16,6 +16,8 @@ namespace Content.Shared.Standing
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly INetManager _netMan = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
// If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited.
private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable;
@@ -28,10 +30,11 @@ namespace Content.Shared.Standing
private void OnHandleState(EntityUid uid, StandingStateComponent component, ref ComponentHandleState args)
{
if (args.Current is not StandingComponentState state) return;
if (args.Current is not StandingComponentState state)
return;
component.Standing = state.Standing;
component.ChangedFixtures = new(state.ChangedFixtures);
component.ChangedFixtures = new List<string>(state.ChangedFixtures);
}
private void OnGetState(EntityUid uid, StandingStateComponent component, ref ComponentGetState args)
@@ -82,7 +85,7 @@ namespace Content.Shared.Standing
RaiseLocalEvent(uid, new DownedEvent(), false);
// Seemed like the best place to put it
appearance?.SetData(RotationVisuals.RotationState, RotationState.Horizontal);
_appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Horizontal, appearance);
// Change collision masks to allow going under certain entities like flaps and tables
if (TryComp(uid, out FixturesComponent? fixtureComponent))
@@ -100,10 +103,9 @@ namespace Content.Shared.Standing
if (!_gameTiming.IsFirstTimePredicted)
return true;
// TODO audio prediction
if (playSound && _netMan.IsServer)
if (playSound)
{
SoundSystem.Play(standingState.DownSound.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.25f));
_audio.PlayPredicted(standingState.DownSound, uid, uid, AudioParams.Default.WithVariation(0.25f));
}
return true;
@@ -133,7 +135,7 @@ namespace Content.Shared.Standing
Dirty(standingState);
RaiseLocalEvent(uid, new StoodEvent(), false);
appearance?.SetData(RotationVisuals.RotationState, RotationState.Vertical);
_appearance.SetData(uid, RotationVisuals.RotationState, RotationState.Vertical, appearance);
if (TryComp(uid, out FixturesComponent? fixtureComponent))
{

View File

@@ -13,6 +13,7 @@ namespace Content.Shared.Storage.EntitySystems
[UsedImplicitly]
public abstract class SharedItemMapperSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
/// <inheritdoc />
@@ -34,27 +35,28 @@ namespace Content.Shared.Storage.EntitySystems
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent))
{
var list = new List<string>(component.MapLayers.Keys);
appearanceComponent.SetData(StorageMapVisuals.InitLayers, new ShowLayerData(list));
_appearance.SetData(component.Owner, StorageMapVisuals.InitLayers, new ShowLayerData(list), appearanceComponent);
}
}
private void MapperEntityRemoved(EntityUid uid, ItemMapperComponent itemMapper,
EntRemovedFromContainerMessage args)
{
if (EntityManager.TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent)
&& TryGetLayers(args, itemMapper, out var containedLayers))
{
appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers));
}
UpdateAppearance(uid, itemMapper, args);
}
private void MapperEntityInserted(EntityUid uid, ItemMapperComponent itemMapper,
EntInsertedIntoContainerMessage args)
{
UpdateAppearance(uid, itemMapper, args);
}
private void UpdateAppearance(EntityUid uid, ItemMapperComponent itemMapper, ContainerModifiedMessage message)
{
if (EntityManager.TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent)
&& TryGetLayers(args, itemMapper, out var containedLayers))
&& TryGetLayers(message, itemMapper, out var containedLayers))
{
appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers));
_appearance.SetData(itemMapper.Owner, StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers), appearanceComponent);
}
}

View File

@@ -44,7 +44,7 @@ public abstract partial class SharedGunSystem
component.Entities.Add(args.Used);
component.Container.Insert(args.Used);
// Not predicted so
PlaySound(uid, component.SoundInsert?.GetSound(Random, ProtoManager), args.User);
Audio.PlayPredicted(component.SoundInsert, uid, args.User);
args.Handled = true;
UpdateBallisticAppearance(component);
Dirty(component);
@@ -80,10 +80,7 @@ public abstract partial class SharedGunSystem
}
Dirty(component);
var sound = component.SoundRack?.GetSound(Random, ProtoManager);
if (sound != null)
PlaySound(component.Owner, sound, user);
Audio.PlayPredicted(component.SoundRack, component.Owner, user);
var shots = GetBallisticShots(component);
component.Cycled = true;
@@ -208,9 +205,11 @@ public abstract partial class SharedGunSystem
private void UpdateBallisticAppearance(BallisticAmmoProviderComponent component)
{
if (!Timing.IsFirstTimePredicted || !TryComp<AppearanceComponent>(component.Owner, out var appearance)) return;
appearance.SetData(AmmoVisuals.AmmoCount, GetBallisticShots(component));
appearance.SetData(AmmoVisuals.AmmoMax, component.Capacity);
if (!Timing.IsFirstTimePredicted || !TryComp<AppearanceComponent>(component.Owner, out var appearance))
return;
Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoCount, GetBallisticShots(component), appearance);
Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoMax, component.Capacity, appearance);
}
[Serializable, NetSerializable]

View File

@@ -70,9 +70,10 @@ public abstract partial class SharedGunSystem
private void UpdateBasicEntityAppearance(BasicEntityAmmoProviderComponent component)
{
if (!Timing.IsFirstTimePredicted || !TryComp<AppearanceComponent>(component.Owner, out var appearance)) return;
appearance.SetData(AmmoVisuals.HasAmmo, component.Count != 0);
appearance.SetData(AmmoVisuals.AmmoCount, component.Count ?? int.MaxValue);
appearance.SetData(AmmoVisuals.AmmoMax, component.Capacity ?? int.MaxValue);
Appearance.SetData(appearance.Owner, AmmoVisuals.HasAmmo, component.Count != 0, appearance);
Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoCount, component.Count ?? int.MaxValue, appearance);
Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoMax, component.Capacity ?? int.MaxValue, appearance);
}
#region Public API

View File

@@ -69,7 +69,7 @@ public abstract partial class SharedGunSystem
else
component.NextFire += cooldown;
PlaySound(component.Owner, component.SoundModeToggle?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(component.SoundModeToggle, component.Owner, user);
Popup(Loc.GetString("gun-selected-mode", ("mode", GetLocSelector(fire))), component.Owner, user);
Dirty(component);
}

View File

@@ -58,8 +58,10 @@ public abstract partial class SharedGunSystem
private void OnMagazineSlotChange(EntityUid uid, MagazineAmmoProviderComponent component, ref ItemSlotChangedEvent args)
{
UpdateAmmoCount(uid);
if (!TryComp<AppearanceComponent>(uid, out var appearance)) return;
appearance.SetData(AmmoVisuals.MagLoaded, GetMagazineEntity(uid) != null);
if (!TryComp<AppearanceComponent>(uid, out var appearance))
return;
Appearance.SetData(uid, AmmoVisuals.MagLoaded, GetMagazineEntity(uid) != null, appearance);
}
protected (int, int) GetMagazineCountCapacity(MagazineAmmoProviderComponent component)
@@ -93,7 +95,7 @@ public abstract partial class SharedGunSystem
if (magEntity == null)
{
appearance?.SetData(AmmoVisuals.MagLoaded, false);
Appearance.SetData(uid, AmmoVisuals.MagLoaded, false, appearance);
return;
}
@@ -112,7 +114,7 @@ public abstract partial class SharedGunSystem
if (component.AutoEject && args.Ammo.Count == 0)
{
EjectMagazine(component);
PlaySound(uid, component.SoundAutoEject?.GetSound(Random, ProtoManager), args.User);
Audio.PlayPredicted(component.SoundAutoEject, uid, args.User);
}
UpdateMagazineAppearance(appearance, true, count, capacity);
@@ -144,11 +146,14 @@ public abstract partial class SharedGunSystem
private void UpdateMagazineAppearance(AppearanceComponent? appearance, bool magLoaded, int count, int capacity)
{
if (appearance == null)
return;
// Copy the magazine's appearance data
appearance?.SetData(AmmoVisuals.MagLoaded, magLoaded);
appearance?.SetData(AmmoVisuals.HasAmmo, count != 0);
appearance?.SetData(AmmoVisuals.AmmoCount, count);
appearance?.SetData(AmmoVisuals.AmmoMax, capacity);
Appearance.SetData(appearance.Owner, AmmoVisuals.MagLoaded, magLoaded, appearance);
Appearance.SetData(appearance.Owner, AmmoVisuals.HasAmmo, count != 0, appearance);
Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoCount, count, appearance);
Appearance.SetData(appearance.Owner, AmmoVisuals.AmmoMax, capacity, appearance);
}
private void EjectMagazine(MagazineAmmoProviderComponent component)

View File

@@ -84,7 +84,7 @@ public partial class SharedGunSystem
component.AmmoSlots[index] = uid;
component.AmmoContainer.Insert(uid);
PlaySound(component.Owner, component.SoundInsert?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(component.SoundInsert, component.Owner, user);
Popup(Loc.GetString("gun-revolver-insert"), component.Owner, user);
UpdateRevolverAppearance(component);
UpdateAmmoCount(uid);
@@ -210,7 +210,7 @@ public partial class SharedGunSystem
if (anyEmpty)
{
PlaySound(component.Owner, component.SoundEject?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(component.SoundEject, component.Owner, user);
UpdateAmmoCount(component.Owner);
UpdateRevolverAppearance(component);
Dirty(component);
@@ -219,16 +219,18 @@ public partial class SharedGunSystem
private void UpdateRevolverAppearance(RevolverAmmoProviderComponent component)
{
if (!TryComp<AppearanceComponent>(component.Owner, out var appearance)) return;
if (!TryComp<AppearanceComponent>(component.Owner, out var appearance))
return;
var count = GetRevolverCount(component);
appearance.SetData(AmmoVisuals.HasAmmo, count != 0);
appearance.SetData(AmmoVisuals.AmmoCount, count);
appearance.SetData(AmmoVisuals.AmmoMax, component.Capacity);
Appearance.SetData(component.Owner, AmmoVisuals.HasAmmo, count != 0, appearance);
Appearance.SetData(component.Owner, AmmoVisuals.AmmoCount, count, appearance);
Appearance.SetData(component.Owner, AmmoVisuals.AmmoMax, component.Capacity, appearance);
}
protected virtual void SpinRevolver(RevolverAmmoProviderComponent component, EntityUid? user = null)
{
PlaySound(component.Owner, component.SoundSpin?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(component.SoundSpin, component.Owner, user);
Popup(Loc.GetString("gun-revolver-spun"), component.Owner, user);
}

View File

@@ -275,7 +275,7 @@ public abstract partial class SharedGunSystem : EntitySystem
// Don't spam safety sounds at gun fire rate, play it at a reduced rate.
// May cause prediction issues? Needs more tweaking
gun.NextFire = TimeSpan.FromSeconds(Math.Max(lastFire.TotalSeconds + SafetyNextFire, gun.NextFire.TotalSeconds));
PlaySound(gun.Owner, gun.SoundEmpty?.GetSound(Random, ProtoManager), user);
Audio.PlayPredicted(gun.SoundEmpty, gun.Owner, user);
Dirty(gun);
return;
}
@@ -351,15 +351,10 @@ public abstract partial class SharedGunSystem : EntitySystem
xform.LocalRotation = Random.NextAngle();
xform.Coordinates = coordinates;
string? sound = null;
if (TryComp<CartridgeAmmoComponent>(entity, out var cartridge))
if (playSound && TryComp<CartridgeAmmoComponent>(entity, out var cartridge))
{
sound = cartridge.EjectSound?.GetSound(Random, ProtoManager);
Audio.PlayPvs(cartridge.EjectSound, entity, AudioParams.Default.WithVariation(0.05f).WithVolume(-1f));
}
if (sound != null && playSound)
SoundSystem.Play(sound, Filter.Pvs(entity, entityManager: EntityManager), coordinates, AudioHelpers.WithVariation(0.05f).WithVolume(-1f));
}
protected void MuzzleFlash(EntityUid gun, AmmoComponent component, EntityUid? user = null)

View File

@@ -72,7 +72,7 @@ namespace Content.Shared.Whitelist
if (Components != null && _registrations == null)
UpdateRegistrations();
entityManager ??= IoCManager.Resolve<IEntityManager>();
IoCManager.Resolve(ref entityManager);
if (_registrations != null)
{
foreach (var reg in _registrations)
@@ -89,7 +89,7 @@ namespace Content.Shared.Whitelist
if (Tags != null && entityManager.TryGetComponent(uid, out TagComponent? tags))
{
var tagSystem = EntitySystem.Get<TagSystem>();
var tagSystem = entityManager.System<TagSystem>();
return RequireAll ? tagSystem.HasAllTags(tags, Tags) : tagSystem.HasAnyTag(tags, Tags);
}