protected override void OnComponentInit(EntityUid uid, SharedVendingMachineComponent sharedComponent, ComponentInit args)
        {
            base.OnComponentInit(uid, sharedComponent, args);

            var component = (VendingMachineComponent)sharedComponent;

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

            if (component.Action != null)
            {
                var action = new InstantAction(_prototypeManager.Index <InstantActionPrototype>(component.Action));
                _action.AddAction(uid, action, uid);
            }
        }
Exemple #2
0
    protected virtual void OnComponentInit(EntityUid uid, SharedVendingMachineComponent component, ComponentInit args)
    {
        if (!_prototypeManager.TryIndex(component.PackPrototypeId, out VendingMachineInventoryPrototype? packPrototype))
        {
            return;
        }

        MetaData(uid).EntityName    = packPrototype.Name;
        component.AnimationDuration = TimeSpan.FromSeconds(packPrototype.AnimationDuration);

        if (TryComp(component.Owner, out AppearanceComponent? appearance))
        {
            appearance.SetData(VendingMachineVisuals.Inventory, component.PackPrototypeId);
        }

        AddInventoryFromPrototype(uid, packPrototype.StartingInventory, InventoryType.Regular, component);
        AddInventoryFromPrototype(uid, packPrototype.EmaggedInventory, InventoryType.Emagged, component);
        AddInventoryFromPrototype(uid, packPrototype.ContrabandInventory, InventoryType.Contraband, component);
    }
Exemple #3
0
        protected override void Open()
        {
            base.Open();

            if (!Owner.Owner.TryGetComponent(out SharedVendingMachineComponent vendingMachine))
            {
                return;
            }

            VendingMachine = vendingMachine;

            _menu = new VendingMachineMenu()
            {
                Owner = this, Title = Owner.Owner.Name
            };
            _menu.Populate(VendingMachine.Inventory);

            _menu.OnClose += Close;
            _menu.OpenCentered();
        }