protected (int, int) GetMagazineCountCapacity(MagazineAmmoProviderComponent component)
    {
        var count    = 0;
        var capacity = 1;
        var magEnt   = GetMagazineEntity(component.Owner);

        if (magEnt != null)
        {
            var ev = new GetAmmoCountEvent();
            RaiseLocalEvent(magEnt.Value, ref ev, false);
            count    += ev.Count;
            capacity += ev.Capacity;
        }

        return(count, capacity);
    }
Ejemplo n.º 2
0
    private void OnChamberMagazineAmmoUpdate(EntityUid uid, ChamberMagazineAmmoProviderComponent component, UpdateAmmoCounterEvent args)
    {
        if (args.Control is not ChamberMagazineStatusControl control)
        {
            return;
        }

        var chambered   = GetChamberEntity(uid);
        var magEntity   = GetMagazineEntity(uid);
        var ammoCountEv = new GetAmmoCountEvent();

        if (magEntity != null)
        {
            RaiseLocalEvent(magEntity.Value, ref ammoCountEv, false);
        }

        control.Update(chambered != null, magEntity != null, ammoCountEv.Count, ammoCountEv.Capacity);
    }
    private void OnMagazineTakeAmmo(EntityUid uid, MagazineAmmoProviderComponent component, TakeAmmoEvent args)
    {
        var magEntity = GetMagazineEntity(uid);

        TryComp <AppearanceComponent>(uid, out var appearance);

        if (magEntity == null)
        {
            appearance?.SetData(AmmoVisuals.MagLoaded, false);
            return;
        }

        // Pass the event onwards.
        RaiseLocalEvent(magEntity.Value, args, false);
        // Should be Dirtied by what other ammoprovider is handling it.

        var ammoEv = new GetAmmoCountEvent();

        RaiseLocalEvent(magEntity.Value, ref ammoEv, false);
        FinaliseMagazineTakeAmmo(uid, component, args, ammoEv.Count, ammoEv.Capacity, appearance);
    }
 private void OnRevolverGetAmmoCount(EntityUid uid, RevolverAmmoProviderComponent component, ref GetAmmoCountEvent args)
 {
     args.Count    += GetRevolverCount(component);
     args.Capacity += component.Capacity;
 }
Ejemplo n.º 5
0
 private void OnBatteryAmmoCount(EntityUid uid, BatteryAmmoProviderComponent component, ref GetAmmoCountEvent args)
 {
     args.Count    = component.Shots;
     args.Capacity = component.Capacity;
 }
Ejemplo n.º 6
0
 private void OnBasicEntityAmmoCount(EntityUid uid, BasicEntityAmmoProviderComponent component, ref GetAmmoCountEvent args)
 {
     args.Capacity = component.Capacity ?? int.MaxValue;
     args.Count    = component.Count ?? int.MaxValue;
 }