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(); } }
private void OnInventoryRequestMessage(EntityUid uid, VendingMachineComponent component, InventorySyncRequestMessage args) { if (!IsPowered(uid, component)) { return; } component.UserInterface?.SendMessage(new VendingMachineInventoryMessage(component.Inventory)); }
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); }
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); }
private void OnBreak(EntityUid uid, VendingMachineComponent vendComponent, BreakageEventArgs eventArgs) { vendComponent.Broken = true; TryUpdateVisualState(uid, VendingMachineVisualState.Broken, vendComponent); }
private void OnPowerChanged(EntityUid uid, VendingMachineComponent component, PowerChangedEvent args) { TryUpdateVisualState(uid, null, component); }