Пример #1
0
 public void AuthorizedVend(EntityUid uid, EntityUid sender, string itemId, VendingMachineComponent component)
 {
     if (IsAuthorized(uid, sender, component))
     {
         TryEjectVendorItem(uid, itemId, component.CanShoot, component);
     }
     return;
 }
 private void OnVendingEnableChangeAttempt(EntityUid uid, VendingMachineComponent component, AdvertiseEnableChangeAttemptEvent args)
 {
     // TODO: Improve this...
     if (args.NewState && component.Broken)
     {
         args.Cancel();
     }
 }
Пример #3
0
        private void OnInventoryRequestMessage(EntityUid uid, VendingMachineComponent component, InventorySyncRequestMessage args)
        {
            if (!IsPowered(uid, component))
            {
                return;
            }

            component.UserInterface?.SendMessage(new VendingMachineInventoryMessage(component.Inventory));
        }
Пример #4
0
        private void OnComponentInit(EntityUid uid, VendingMachineComponent component, ComponentInit args)
        {
            base.Initialize();

            if (TryComp <ApcPowerReceiverComponent>(component.Owner, out var receiver))
            {
                TryUpdateVisualState(uid, null, component);
            }

            InitializeFromPrototype(uid, component);
        }
Пример #5
0
        private void OnInventoryEjectMessage(EntityUid uid, VendingMachineComponent component, VendingMachineEjectMessage args)
        {
            if (!IsPowered(uid, component))
            {
                return;
            }

            if (args.Session.AttachedEntity is not {
                Valid : true
            } entity || Deleted(entity))
            {
                return;
            }

            AuthorizedVend(uid, entity, args.ID, component);
        }
        private void HandleActivate(EntityUid uid, VendingMachineComponent component, ActivateInWorldEvent args)
        {
            if (!TryComp <ActorComponent>(args.User, out var actor))
            {
                return;
            }

            if (!IsPowered(uid, component))
            {
                return;
            }

            if (TryComp <WiresComponent>(uid, out var wires))
            {
                if (wires.IsPanelOpen)
                {
                    wires.OpenInterface(actor.PlayerSession);
                    return;
                }
            }

            component.UserInterface?.Toggle(actor.PlayerSession);
        }
Пример #7
0
 private void OnBreak(EntityUid uid, VendingMachineComponent vendComponent, BreakageEventArgs eventArgs)
 {
     vendComponent.Broken = true;
     TryUpdateVisualState(uid, VendingMachineVisualState.Broken, vendComponent);
 }
Пример #8
0
 private void OnPowerChanged(EntityUid uid, VendingMachineComponent component, PowerChangedEvent args)
 {
     TryUpdateVisualState(uid, null, component);
 }