Пример #1
0
    private void OnCellInsertAttempt(EntityUid uid, PowerCellSlotComponent component, ContainerIsInsertingAttemptEvent args)
    {
        if (!component.Initialized)
        {
            return;
        }

        if (args.Container.ID != component.CellSlot.ID)
        {
            return;
        }

        if (!HasComp <PowerCellComponent>(args.EntityUid))
        {
            args.Cancel();
        }
    }
    private void OnCellInsertAttempt(EntityUid uid, PowerCellSlotComponent component, ContainerIsInsertingAttemptEvent args)
    {
        if (!component.Initialized)
        {
            return;
        }

        if (args.Container.ID != component.CellSlot.ID)
        {
            return;
        }

        if (!TryComp(args.EntityUid, out PowerCellComponent? cell) || cell.CellSize != component.SlotSize)
        {
            args.Cancel();
        }
    }
Пример #3
0
    /// <summary>
    ///     Verify that the entity being inserted is actually rechargeable.
    /// </summary>
    private void OnInsertAttempt(EntityUid uid, ChargerComponent component, ContainerIsInsertingAttemptEvent args)
    {
        if (!component.Initialized)
        {
            return;
        }

        if (args.Container.ID != component.ChargerSlot.ID)
        {
            return;
        }

        if (!TryComp(args.EntityUid, out PowerCellSlotComponent? cellSlot))
        {
            return;
        }

        if (!cellSlot.FitsInCharger || !cellSlot.CellSlot.HasItem)
        {
            args.Cancel();
        }
    }