using System.Numerics; using Content.Server.Cargo.Systems; using Content.Server.Interaction; using Content.Server.Power.EntitySystems; using Content.Server.Stunnable; using Content.Shared.Damage.Systems; using Content.Shared.Effects; using Content.Shared.Weapons.Ranged; using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Events; using Content.Shared.Weapons.Ranged.Systems; using Robust.Shared.Containers; using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Utility; namespace Content.Server.Weapons.Ranged.Systems; public sealed partial class GunSystem : SharedGunSystem { [Dependency] private readonly IComponentFactory _factory = default!; [Dependency] private readonly BatterySystem _battery = default!; [Dependency] private readonly DamageExamineSystem _damageExamine = default!; [Dependency] private readonly PricingSystem _pricing = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnBallisticPrice); } private void OnBallisticPrice(EntityUid uid, BallisticAmmoProviderComponent component, ref PriceCalculationEvent args) { if (string.IsNullOrEmpty(component.Proto) || component.UnspawnedCount == 0) return; if (!ProtoManager.TryIndex(component.Proto, out var proto)) { Log.Error($"Unable to find fill prototype for price on {component.Proto} on {ToPrettyString(uid)}"); return; } // Probably good enough for most. var price = _pricing.GetEstimatedPrice(proto); args.Price += price * component.UnspawnedCount; } protected override void Popup(string message, EntityUid? uid, EntityUid? user) { } protected override void CreateEffect(EntityUid gunUid, MuzzleFlashEvent message, EntityUid? user = null, EntityUid? player = null) { var filter = Filter.Pvs(gunUid, entityManager: EntityManager); if (TryComp(user, out var actor)) filter.RemovePlayer(actor.PlayerSession); if (GunPrediction && TryComp(player, out actor)) filter.RemovePlayer(actor.PlayerSession); RaiseNetworkEvent(message, filter); } // TODO: Pseudo RNG so the client can predict these. }